SHARE
TWEET

Untitled

a guest Aug 12th, 2010 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    if(typeid(*v) == typeid(llvm::Function))
  2.    {
  3.       v->dump();
  4.       return;
  5.     }
  6.  
  7.     llvm::FunctionType* ft = llvm::FunctionType::get(llvm::Type::getDoubleTy(llvm::getGlobalContext()),
  8.         std::vector<const llvm::Type*>(0,llvm::Type::getDoubleTy(llvm::getGlobalContext())),false);
  9.     llvm::Function* f = llvm::Function::Create(ft,llvm::Function::ExternalLinkage,"",module);
  10.     llvm::BasicBlock* bb = llvm::BasicBlock::Create(llvm::getGlobalContext(),"entry",f);
  11.     builder.SetInsertPoint(bb);
  12.     builder.CreateRet(v);
  13.     std::cerr << "reg dump (before verify):\n";
  14.     v->dump();
  15.     std::cerr << "function dump (before verify):\n";
  16.     f->dump();
  17.     llvm::verifyFunction(*f);
  18.     std::cerr << "verified\n";
  19.  
  20.     void* fptr = executionEngine->getPointerToFunction(f);
  21.     double (*FP)() = (double (*)())(intptr_t)fptr;
  22.     std::cout << "evaluated to: " << FP() << "\n";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top