Calling convention setting/getting
This commit is contained in:
parent
a9ea1eb6d9
commit
8274ca7d8a
47
src/LLVM.zig
47
src/LLVM.zig
@ -675,6 +675,9 @@ pub const Function = opaque {
|
||||
pub fn to_string(function: *Function) []const u8 {
|
||||
return api.llvm_function_to_string(function).to_slice();
|
||||
}
|
||||
|
||||
pub const set_calling_convention = api.LLVMSetFunctionCallConv;
|
||||
pub const get_calling_convention = api.LLVMGetFunctionCallConv;
|
||||
};
|
||||
|
||||
pub const Constant = opaque {
|
||||
@ -1005,6 +1008,50 @@ pub const ThreadLocalMode = enum(c_uint) {
|
||||
none = 0,
|
||||
};
|
||||
|
||||
pub const CallingConvention = enum(c_uint) {
|
||||
c = 0,
|
||||
fast = 8,
|
||||
cold = 9,
|
||||
ghc = 10,
|
||||
hipe = 11,
|
||||
anyreg = 13,
|
||||
preserve_most = 14,
|
||||
preserve_all = 15,
|
||||
swift = 16,
|
||||
cxx_fast_tls = 17,
|
||||
x86_stdcall = 64,
|
||||
x86_fastcall = 65,
|
||||
arm_apcs = 66,
|
||||
arm_aapcs = 67,
|
||||
arm_aapcsvfp = 68,
|
||||
msp430_interrupt = 69,
|
||||
x86_thiscall = 70,
|
||||
ptx_kernel = 71,
|
||||
ptx_device = 72,
|
||||
spir_func = 75,
|
||||
spir_kernel = 76,
|
||||
intel_oclbi = 77,
|
||||
x86_64_system_v = 78,
|
||||
win64 = 79,
|
||||
x86_vector = 80,
|
||||
hhvm = 81,
|
||||
hhvmc = 82,
|
||||
x86_interrupt = 83,
|
||||
avr_interrupt = 84,
|
||||
avr_signal = 85,
|
||||
avr_builtin = 86,
|
||||
amdgpu_vs = 87,
|
||||
amdgpu_gs = 88,
|
||||
amdgpu_ps = 89,
|
||||
amdgpu_cs = 90,
|
||||
amdgpu_kernel = 91,
|
||||
x86_regcall = 92,
|
||||
amdgpu_hs = 93,
|
||||
msp430_builtin = 94,
|
||||
amgpu_ls = 95,
|
||||
amdgpu_es = 96,
|
||||
};
|
||||
|
||||
pub const lld = struct {
|
||||
pub const Result = extern struct {
|
||||
stdout: String,
|
||||
|
@ -61,6 +61,13 @@ const FunctionKeyword = enum {
|
||||
const CallingConvention = enum {
|
||||
unknown,
|
||||
c,
|
||||
|
||||
pub fn to_llvm(calling_convention: CallingConvention) llvm.CallingConvention {
|
||||
return switch (calling_convention) {
|
||||
.unknown => .fast,
|
||||
.c => .c,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const Variable = struct {
|
||||
@ -935,6 +942,7 @@ pub noinline fn convert(options: ConvertOptions) void {
|
||||
},
|
||||
.type = function_type,
|
||||
});
|
||||
handle.set_calling_convention(calling_convention.to_llvm());
|
||||
|
||||
const entry_block = thread.context.create_basic_block("entry", handle);
|
||||
thread.builder.position_at_end(entry_block);
|
||||
|
@ -14,6 +14,9 @@ pub extern fn llvm_context_create_basic_block(context: *llvm.Context, name: llvm
|
||||
|
||||
pub extern fn LLVMGetBasicBlockTerminator(basic_block: *llvm.BasicBlock) ?*llvm.Value;
|
||||
|
||||
pub extern fn LLVMSetFunctionCallConv(function: *llvm.Function, calling_convention: llvm.CallingConvention) void;
|
||||
pub extern fn LLVMGetFunctionCallConv(function: *llvm.Function) llvm.CallingConvention;
|
||||
|
||||
pub extern fn llvm_function_to_string(function: *llvm.Function) *llvm.String;
|
||||
pub extern fn llvm_function_verify(function: *llvm.Function, error_message: *llvm.String) bool;
|
||||
pub extern fn llvm_module_verify(module: *llvm.Module, error_message: *llvm.String) bool;
|
||||
|
Loading…
x
Reference in New Issue
Block a user