aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2024-06-20 18:01:48 -0400
committerClyne Sullivan <clyne@bitgloo.com>2024-06-20 18:01:48 -0400
commit95901f3a5fa0ec18128030c915d1d94bade5de94 (patch)
tree53c66d5230fa398688c1a5fefcd2e266ba577db6 /main.cpp
parentc546646cd46e9b523c3457fa6e867951ac37daba (diff)
global env; alloca locals
kinda messy
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/main.cpp b/main.cpp
index 19b76fe..5ae41bc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -48,7 +48,17 @@ int main()
}
}
+ auto func = llvmState.createFunction("main");
+ auto entry = llvmState.createEntry(func);
+ auto envtype = llvm::VectorType::get(llvmState.inttype, ThunkAST::envidx, false);
+ auto [t0, _] = Var::lookup("__t0");
+ llvmState.builder.SetInsertPoint(entry);
+ auto env = llvmState.builder.CreateAlloca(envtype, nullptr);
+ llvmState.builder.CreateCall(llvmState.ftype, t0, llvm::ArrayRef<llvm::Value *> {env});
+ llvmState.builder.CreateRetVoid();
+
llvmState.output();
+ std::cerr << "envidx: " << ThunkAST::envidx << std::endl;
std::cout << std::endl;
}
@@ -65,10 +75,7 @@ bool parseString(std::string_view sv)
switch (tok) {
case Token::ThunkOpen:
- if (scope.empty())
- scope.emplace_back(llvmState, "main");
- else
- scope.emplace_back(llvmState);
+ scope.emplace_back(llvmState);
Var::pushScope();
break;
case Token::ThunkClose: