Extern functions and basic C ABI support
This commit is contained in:
parent
6135ade3a7
commit
f67fdaa5f7
@ -677,6 +677,8 @@ pub const Builder = opaque {
|
|||||||
pub fn create_sign_extend(builder: *Builder, value: *Value, destination_type: *Type) *Value {
|
pub fn create_sign_extend(builder: *Builder, value: *Value, destination_type: *Type) *Value {
|
||||||
return api.LLVMBuildSExt(builder, value, destination_type, "");
|
return api.LLVMBuildSExt(builder, value, destination_type, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const create_unreachable = api.LLVMBuildUnreachable;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GlobalValue = opaque {
|
pub const GlobalValue = opaque {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -58,6 +58,7 @@ fn unit_test(allocator: std.mem.Allocator, options: InvokeWrapper) !void {
|
|||||||
.build_mode = options.build_mode,
|
.build_mode = options.build_mode,
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.has_debug_info = options.has_debug_info,
|
.has_debug_info = options.has_debug_info,
|
||||||
|
.target = converter.Target.get_native(),
|
||||||
});
|
});
|
||||||
const run_result = std.process.Child.run(.{
|
const run_result = std.process.Child.run(.{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
@ -172,3 +173,7 @@ test "bits" {
|
|||||||
test "basic_array" {
|
test "basic_array" {
|
||||||
try invsrc(@src());
|
try invsrc(@src());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "extern" {
|
||||||
|
try invsrc(@src());
|
||||||
|
}
|
||||||
|
@ -57,6 +57,7 @@ pub extern fn LLVMBuildInBoundsGEP2(builder: *llvm.Builder, ty: *llvm.Type, aggr
|
|||||||
pub extern fn LLVMBuildInsertValue(builder: *llvm.Builder, aggregate: *llvm.Value, element: *llvm.Value, index: c_uint, name: [*:0]const u8) *llvm.Value;
|
pub extern fn LLVMBuildInsertValue(builder: *llvm.Builder, aggregate: *llvm.Value, element: *llvm.Value, index: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||||
pub extern fn LLVMBuildZExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
pub extern fn LLVMBuildZExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||||
pub extern fn LLVMBuildSExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
pub extern fn LLVMBuildSExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||||
|
pub extern fn LLVMBuildUnreachable(builder: *llvm.Builder) *llvm.Value;
|
||||||
|
|
||||||
pub extern fn LLVMSetCurrentDebugLocation2(builder: *llvm.Builder, location: ?*llvm.DI.Location) void;
|
pub extern fn LLVMSetCurrentDebugLocation2(builder: *llvm.Builder, location: ?*llvm.DI.Location) void;
|
||||||
|
|
||||||
|
@ -182,6 +182,7 @@ pub fn main(argc: c_int, argv: [*:null]const ?[*:0]const u8) callconv(.C) c_int
|
|||||||
.content = file_content,
|
.content = file_content,
|
||||||
.path = file_path,
|
.path = file_path,
|
||||||
.has_debug_info = true,
|
.has_debug_info = true,
|
||||||
|
.target = converter.Target.get_native(),
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
5
tests/extern.bbb
Normal file
5
tests/extern.bbb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[extern] exit = fn [cc(c)] (exit_code: s32) noreturn;
|
||||||
|
[export] main = fn [cc(c)] () s32
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user