diff options
-rw-r--r-- | llvm.cpp | 21 | ||||
-rw-r--r-- | tuplr.hpp | 1 |
2 files changed, 12 insertions, 10 deletions
@@ -51,10 +51,20 @@ llType(const AType* t) } struct LLVMEngine { - LLVMEngine() : module(new Module("tuplr")), engine(ExecutionEngine::create(module)) {} + LLVMEngine() + : module(new Module("tuplr")), engine(ExecutionEngine::create(module)) + { + // Host provided allocation primitive prototype + std::vector<const Type*> argsT(1, Type::Int32Ty); // unsigned size + argsT.push_back(Type::Int8Ty); // char tag + FunctionType* funcT = FunctionType::get(PointerType::get(Type::Int8Ty, 0), argsT, false); + alloc = Function::Create(funcT, Function::ExternalLinkage, + "tuplr_gc_allocate", module); + } Module* module; ExecutionEngine* engine; IRBuilder<> builder; + CFunction alloc; }; static LLVMEngine* @@ -82,7 +92,7 @@ struct CEnv::PImpl { }; CEnv::CEnv(PEnv& p, TEnv& t, CEngine e, ostream& os, ostream& es) - : out(os), err(es), penv(p), tenv(t), symID(0), alloc(0), _pimpl(new PImpl((LLVMEngine*)e)) + : out(os), err(es), penv(p), tenv(t), symID(0), _pimpl(new PImpl((LLVMEngine*)e)) { } @@ -520,13 +530,6 @@ newCenv(PEnv& penv, TEnv& tenv) LLVMEngine* engine = new LLVMEngine(); CEnv* cenv = new CEnv(penv, tenv, engine); - // Host provided allocation primitive prototypes - std::vector<const Type*> argsT(1, Type::Int32Ty); // size - argsT.push_back(Type::Int8Ty); // tag - FunctionType* funcT = FunctionType::get(PointerType::get(Type::Int8Ty, 0), argsT, false); - cenv->alloc = Function::Create(funcT, Function::ExternalLinkage, - "tuplr_gc_allocate", engine->module); - return cenv; } @@ -599,7 +599,6 @@ struct CEnv { Vals vals; unsigned symID; - CFunction alloc; Subst tsubst; map<string,string> args; |