From 14d8a1c10da7e98ccfdbfd50473582043e48ca10 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 25 Jul 2021 22:38:50 -0700 Subject: stage2 llvm backend improvements working towards `zig test` * properly set global variables to const if they are not a global variable. * implement global variable initializations. * initial implementation of llvmType() for structs and functions. * implement genTypedValue for variable tags * implement more AIR instructions: varptr, slice_ptr, slice_len, slice_elem_val, ptr_slice_elem_val, unwrap_errunion_payload, unwrap_errunion_payload_ptr, unwrap_errunion_err, unwrap_errunion_err_ptr. --- src/codegen/llvm/bindings.zig | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/codegen/llvm/bindings.zig') diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index 3d17172cfd..3b76361030 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -42,6 +42,9 @@ pub const Context = opaque { Packed: Bool, ) *const Type; + const structCreateNamed = LLVMStructCreateNamed; + extern fn LLVMStructCreateNamed(C: *const Context, Name: [*:0]const u8) *const Type; + pub const constString = LLVMConstStringInContext; extern fn LLVMConstStringInContext(C: *const Context, Str: [*]const u8, Length: c_uint, DontNullTerminate: Bool) *const Value; @@ -76,6 +79,9 @@ pub const Value = opaque { pub const typeOf = LLVMTypeOf; extern fn LLVMTypeOf(Val: *const Value) *const Type; + + pub const setGlobalConstant = LLVMSetGlobalConstant; + extern fn LLVMSetGlobalConstant(GlobalVar: *const Value, IsConstant: Bool) void; }; pub const Type = opaque { @@ -99,6 +105,14 @@ pub const Type = opaque { pub const arrayType = LLVMArrayType; extern fn LLVMArrayType(ElementType: *const Type, ElementCount: c_uint) *const Type; + + pub const structSetBody = LLVMStructSetBody; + extern fn LLVMStructSetBody( + StructTy: *const Type, + ElementTypes: [*]*const Type, + ElementCount: c_uint, + Packed: Bool, + ) void; }; pub const Module = opaque { @@ -257,7 +271,13 @@ pub const Builder = opaque { extern fn LLVMBuildBitCast(*const Builder, Val: *const Value, DestTy: *const Type, Name: [*:0]const u8) *const Value; pub const buildInBoundsGEP = LLVMBuildInBoundsGEP; - extern fn LLVMBuildInBoundsGEP(B: *const Builder, Pointer: *const Value, Indices: [*]*const Value, NumIndices: c_uint, Name: [*:0]const u8) *const Value; + extern fn LLVMBuildInBoundsGEP( + B: *const Builder, + Pointer: *const Value, + Indices: [*]const *const Value, + NumIndices: c_uint, + Name: [*:0]const u8, + ) *const Value; pub const buildICmp = LLVMBuildICmp; extern fn LLVMBuildICmp(*const Builder, Op: IntPredicate, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value; -- cgit v1.2.3