Compare commits
No commits in common. "5771877457d50ab2802f54221e612af2b2b74572" and "5713df2a8b4d97756d505ab76a354d79d073a91b" have entirely different histories.
5771877457
...
5713df2a8b
2 changed files with 5 additions and 8 deletions
|
@ -7,7 +7,7 @@ pub fn build(b: *Builder) void {
|
||||||
exe.install();
|
exe.install();
|
||||||
|
|
||||||
exe.linkSystemLibrary("c");
|
exe.linkSystemLibrary("c");
|
||||||
exe.linkSystemLibrary("LLVM-10");
|
exe.linkSystemLibrary("LLVM-9");
|
||||||
exe.linkSystemLibrary("stdc++");
|
exe.linkSystemLibrary("stdc++");
|
||||||
|
|
||||||
const run_cmd = exe.run();
|
const run_cmd = exe.run();
|
||||||
|
|
|
@ -176,14 +176,12 @@ pub const Codegen = struct {
|
||||||
.Call => |call| {
|
.Call => |call| {
|
||||||
const name = call.callee.*.Variable.lexeme;
|
const name = call.callee.*.Variable.lexeme;
|
||||||
|
|
||||||
var llvm_func_entry = self.llvm_table.getEntry(name);
|
var llvm_func = self.llvm_table.get(name);
|
||||||
if (llvm_func_entry == null) {
|
if (llvm_func == null) {
|
||||||
std.debug.warn("Function '{}' not found\n", .{name});
|
std.debug.warn("Function '{}' not found\n", .{name});
|
||||||
return CompileError.EmitError;
|
return CompileError.EmitError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const llvm_func = llvm_func_entry.?.value;
|
|
||||||
|
|
||||||
var args = LLVMValueList.init(self.allocator);
|
var args = LLVMValueList.init(self.allocator);
|
||||||
errdefer args.deinit();
|
errdefer args.deinit();
|
||||||
|
|
||||||
|
@ -196,7 +194,7 @@ pub const Codegen = struct {
|
||||||
|
|
||||||
return llvm.LLVMBuildCall(
|
return llvm.LLVMBuildCall(
|
||||||
builder,
|
builder,
|
||||||
llvm_func,
|
llvm_func.?,
|
||||||
args_slice.ptr,
|
args_slice.ptr,
|
||||||
@intCast(c_uint, args_slice.len),
|
@intCast(c_uint, args_slice.len),
|
||||||
"call",
|
"call",
|
||||||
|
@ -434,8 +432,7 @@ pub const Codegen = struct {
|
||||||
);
|
);
|
||||||
|
|
||||||
var func = llvm.LLVMAddFunction(mod, name_cstr.ptr, llvm_ret_type);
|
var func = llvm.LLVMAddFunction(mod, name_cstr.ptr, llvm_ret_type);
|
||||||
std.debug.warn("inserting function '{}' to llvm table\n", .{name});
|
_ = try self.llvm_table.put(name, func);
|
||||||
try self.llvm_table.put(name, func);
|
|
||||||
|
|
||||||
var buf = try self.allocator.alloc(u8, 512);
|
var buf = try self.allocator.alloc(u8, 512);
|
||||||
var entry_lbl = try std.fmt.bufPrint(buf, "fn_{}_entry", .{name});
|
var entry_lbl = try std.fmt.bufPrint(buf, "fn_{}_entry", .{name});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue