aboutsummaryrefslogtreecommitdiffstats
path: root/src/llvm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r--src/llvm.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp
index 6243919..e606062 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -192,8 +192,8 @@ struct LLVMEngine : public Engine {
CVal compileLiteral(CEnv& cenv, AST* lit);
CVal compilePrimitive(CEnv& cenv, APrimitive* prim);
CVal compileIf(CEnv& cenv, AIf* aif);
- CVal compileGlobal(CEnv& cenv, const AType* type, const string& name, CVal val);
- CVal getGlobal(CEnv& cenv, CVal val);
+ CVal compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal val);
+ CVal getGlobal(CEnv& cenv, const string& sym, CVal val);
void writeModule(CEnv& cenv, std::ostream& os) {
AssemblyAnnotationWriter writer;
@@ -300,9 +300,8 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type)
{
assert(type->concrete());
- LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine());
- const AType* argsT = type->prot()->as<const AType*>();
- const AType* retT = type->last()->as<const AType*>();
+ const AType* argsT = type->prot()->as<const AType*>();
+ const AType* retT = type->last()->as<const AType*>();
vector<string> argNames;
for (ATuple::const_iterator i = fn->prot()->begin(); i != fn->prot()->end(); ++i)
@@ -449,7 +448,6 @@ CVal
LLVMEngine::compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal val)
{
LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine());
- Constant* init = Constant::getNullValue(llType(type));
GlobalVariable* global = new GlobalVariable(*module, llType(type), false,
GlobalValue::ExternalLinkage, Constant::getNullValue(llType(type)), sym);
@@ -458,8 +456,8 @@ LLVMEngine::compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal
}
CVal
-LLVMEngine::getGlobal(CEnv& cenv, CVal val)
+LLVMEngine::getGlobal(CEnv& cenv, const string& sym, CVal val)
{
LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine());
- return engine->builder.CreateLoad(llVal(val), "globalPtr");
+ return engine->builder.CreateLoad(llVal(val), sym + "Ptr");
}