aboutsummaryrefslogtreecommitdiffstats
path: root/llvm.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-20 18:57:15 +0000
committerDavid Robillard <d@drobilla.net>2009-06-20 18:57:15 +0000
commitf1e547a50a132afedbcd31700abb4ff79405e665 (patch)
treed4fdacdd70048514e0e754355d75c692f5ffea39 /llvm.cpp
parent5423a36aee3156332183bc59c097a907e4d8c503 (diff)
downloadresp-f1e547a50a132afedbcd31700abb4ff79405e665.tar.gz
resp-f1e547a50a132afedbcd31700abb4ff79405e665.tar.bz2
resp-f1e547a50a132afedbcd31700abb4ff79405e665.zip
Move alloc function to backend.
git-svn-id: http://svn.drobilla.net/resp/tuplr@137 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'llvm.cpp')
-rw-r--r--llvm.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm.cpp b/llvm.cpp
index c7d9224..b40f953 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -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;
}