diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-20 18:01:48 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-20 18:01:48 -0400 |
commit | 95901f3a5fa0ec18128030c915d1d94bade5de94 (patch) | |
tree | 53c66d5230fa398688c1a5fefcd2e266ba577db6 /main.cpp | |
parent | c546646cd46e9b523c3457fa6e867951ac37daba (diff) |
global env; alloca locals
kinda messy
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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: |