Make llvm_context a class.

This commit is contained in:
2020-09-15 19:08:00 -07:00
parent 55486d511f
commit 0e3f16139d
5 changed files with 109 additions and 84 deletions

View File

@@ -163,6 +163,18 @@ void llvm_context::create_functions() {
);
}
IRBuilder<>& llvm_context::get_builder() {
return builder;
}
Module& llvm_context::get_module() {
return module;
}
BasicBlock* llvm_context::create_basic_block(const std::string& name, llvm::Function* f) {
return BasicBlock::Create(ctx, name, f);
}
ConstantInt* llvm_context::create_i8(int8_t i) {
return ConstantInt::get(ctx, APInt(8, i));
}
@@ -254,7 +266,7 @@ Value* llvm_context::create_app(Function* f, Value* l, Value* r) {
return create_track(f, alloc_app_call);
}
llvm::Function* llvm_context::create_custom_function(std::string name, int32_t arity) {
llvm::Function* llvm_context::create_custom_function(const std::string& name, int32_t arity) {
auto void_type = llvm::Type::getVoidTy(ctx);
auto new_function = llvm::Function::Create(
function_type,
@@ -271,3 +283,7 @@ llvm::Function* llvm_context::create_custom_function(std::string name, int32_t a
return new_function;
}
llvm_context::custom_function& llvm_context::get_custom_function(const std::string& name) {
return *custom_functions.at("f_" + name);
}