liberty/lib/LAMP/LAMPProfiling.cpp
/**
 * Create the LAMP Declarations, should only be run one time
 */
Create the LAMP Declarations, should only be run one time
Create the LAMP Declarations should only be run one time
void LAMPProfiler::createLampDeclarations(Module* M)
{
  std::string f[] = {"LAMP_load1", "LAMP_load2", "LAMP_load4", "LAMP_load8",
    "LAMP_store1", "LAMP_store2",  "LAMP_store4", "LAMP_store8"};
  std::string FnName = "LAMP_register";
  std::string AllocName = "LAMP_allocate";
  std::string DeallocName = "LAMP_deallocate";
  LLVMContext &ctx = M->getContext();
  Type *i8 = Type::getInt8Ty(ctx),
        *i32 = Type::getInt32Ty(ctx),
        *i64 = Type::getInt64Ty(ctx),
        *vty = Type::getVoidTy(ctx),
        *pi8 = PointerType::getUnqual(i8);
  for (int i=0; i < 4; i++)
  {
    FunctionCallee wrapperi = M->getOrInsertFunction(f[i], vty, i32, i64);
    FunctionCallee wrapperi4 = M->getOrInsertFunction(f[i+4], vty, i32, i64, i64);
    lampFuncs[i] = cast<Constant>(wrapperi.getCallee());
    lampFuncs[i+4] = cast<Constant>(wrapperi4.getCallee());
  }
  FunctionCallee wrapper = M->getOrInsertFunction(FnName, vty, i32);
  CallFn = cast<Constant>(wrapper.getCallee());
  wrapper = M->getOrInsertFunction(AllocName, vty, i32, i8, i32);
  AllocFn = cast<Constant>(wrapper.getCallee());
  wrapper = M->getOrInsertFunction(DeallocName, vty, i32, i8);
  DeallocFn = cast<Constant>(wrapper.getCallee());
  M->getOrInsertFunction("LAMP_llvm_memcpy_p0i8_p0i8_i32", vty, i32, pi8, pi8, i32);
  M->getOrInsertFunction("LAMP_llvm_memcpy_p0i8_p0i8_i64", vty, i32, pi8, pi8, i64);
  M->getOrInsertFunction("LAMP_llvm_memmove_p0i8_p0i8_i32", vty, i32, pi8, pi8, i32);
  M->getOrInsertFunction("LAMP_llvm_memmove_p0i8_p0i8_i64", vty, i32, pi8, pi8, i64);
  M->getOrInsertFunction("LAMP_llvm_memset_p0i8_i32", vty, i32, pi8, i8, i32);
  M->getOrInsertFunction("LAMP_llvm_memset_p0i8_i64", vty, i32, pi8, i8, i64);
}
void LAMPProfiler :: createLampDeclarations ( Module * M ) { std :: string f [ ] = { " " , " " , " " , " " , " " , " " , " " , " " } ; std :: string FnName = " " ; std :: string AllocName = " " ; std :: string DeallocName = " " ; LLVMContext & ctx = M -> getContext ( ) ; Type * i8 = Type :: getInt8Ty ( ctx ) , * i32 = Type :: getInt32Ty ( ctx ) , * i64 = Type :: getInt64Ty ( ctx ) , * vty = Type :: getVoidTy ( ctx ) , * pi8 = PointerType :: getUnqual ( i8 ) ; for ( int i = 0 ; i < 4 ; i ++ ) { FunctionCallee wrapperi = M -> getOrInsertFunction ( f [ i ] , vty , i32 , i64 ) ; FunctionCallee wrapperi4 = M -> getOrInsertFunction ( f [ i + 4 ] , vty , i32 , i64 , i64 ) ; lampFuncs [ i ] = cast < Constant > ( wrapperi . getCallee ( ) ) ; lampFuncs [ i + 4 ] = cast < Constant > ( wrapperi4 . getCallee ( ) ) ; } FunctionCallee wrapper = M -> getOrInsertFunction ( FnName , vty , i32 ) ; CallFn = cast < Constant > ( wrapper . getCallee ( ) ) ; wrapper = M -> getOrInsertFunction ( AllocName , vty , i32 , i8 , i32 ) ; AllocFn = cast < Constant > ( wrapper . getCallee ( ) ) ; wrapper = M -> getOrInsertFunction ( DeallocName , vty , i32 , i8 ) ; DeallocFn = cast < Constant > ( wrapper . getCallee ( ) ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , pi8 , i32 ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , pi8 , i64 ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , pi8 , i32 ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , pi8 , i64 ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , i8 , i32 ) ; M -> getOrInsertFunction ( " " , vty , i32 , pi8 , i8 , i64 ) ; }
Create the LAMP Declarations, should only be run one time
Create the LAMP Declarations should only be run one time
//sot // signature of LAMP_load1 is void LAMP_load1(const uint32_t instr, const uint64_t addr) // there seems no need for the last arg //lampFuncs[i] = M->getOrInsertFunction(f[i], vty, i32, i64, (Type*)0); //lampFuncs[i+4] = M->getOrInsertFunction(f[i+4], vty, i32, i64, i64, (Type*)0); //CallFn = M->getOrInsertFunction(FnName, vty, i32, (Type*)0); // args are unsigned32, void*, size_t ... seems to translate as these  TRM 7/25/08 // should be 32, 8?, 32 -- currently defined as 32 64 64 //sot //AllocFn = M->getOrInsertFunction(AllocName, vty, i32, pi8, i32, (Type*)0); //DeallocFn = M->getOrInsertFunction(DeallocName, vty, i32, i8, i32, (Type*)0); //sot //DeallocFn = M->getOrInsertFunction(DeallocName, vty, i32, pi8, (Type*)0); //sot /*
  M->getOrInsertFunction("LAMP_llvm_memcpy_p0i8_p0i8_i32", vty, i32, pi8, pi8, i32, (Type*)0);
  M->getOrInsertFunction("LAMP_llvm_memcpy_p0i8_p0i8_i64", vty, i32, pi8, pi8, i64, (Type*)0);

  M->getOrInsertFunction("LAMP_llvm_memmove_p0i8_p0i8_i32", vty, i32, pi8, pi8, i32, (Type*)0);
  M->getOrInsertFunction("LAMP_llvm_memmove_p0i8_p0i8_i64", vty, i32, pi8, pi8, i64, (Type*)0);

  M->getOrInsertFunction("LAMP_llvm_memset_p0i8_i32", vty, i32, pi8, i8, i32, (Type*)0);
  M->getOrInsertFunction("LAMP_llvm_memset_p0i8_i64", vty, i32, pi8, i8, i64, (Type*)0);
  */