aboutsummaryrefslogtreecommitdiffstats
path: root/src/llvm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r--src/llvm.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp
index bf00778..26b4bf2 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -169,6 +169,7 @@ struct LLVMEngine : public Engine {
CFunc compileFunction(CEnv& cenv, AFn* fn, const AType& argsT);
CVal compileTup(CEnv& cenv, const AType* type, const vector<CVal>& fields);
+ CVal compileDot(CEnv& cenv, CVal tup, int32_t index);
CVal compileLiteral(CEnv& cenv, AST* lit);
CVal compilePrimitive(CEnv& cenv, APrimitive* prim);
CVal compileIf(CEnv& cenv, AIf* aif);
@@ -231,8 +232,8 @@ LLVMEngine::compileTup(CEnv& cenv, const AType* type, const vector<CVal>& fields
// Allocate struct
Value* structSize = ConstantInt::get(Type::Int32Ty, bitsToBytes(s));
- Value* mem = builder.CreateCall(alloc, structSize, "tup");
- Value* structPtr = builder.CreateBitCast(mem, llType(type), "tupPtr");
+ Value* mem = builder.CreateCall(alloc, structSize, "tupMem");
+ Value* structPtr = builder.CreateBitCast(mem, llType(type), "tup");
// Set struct fields
size_t i = 0;
@@ -245,6 +246,13 @@ LLVMEngine::compileTup(CEnv& cenv, const AType* type, const vector<CVal>& fields
}
CVal
+LLVMEngine::compileDot(CEnv& cenv, CVal tup, int32_t index)
+{
+ Value* ptr = builder.CreateStructGEP(llVal(tup), index, "dotPtr");
+ return builder.CreateLoad(ptr, 0, "dotVal");
+}
+
+CVal
LLVMEngine::compileLiteral(CEnv& cenv, AST* lit)
{
ALiteral<int32_t>* ilit = dynamic_cast<ALiteral<int32_t>*>(lit);