diff --git a/src/llvm_backend.zig b/src/llvm_backend.zig index 20d821f1da..cd1d7029b4 100644 --- a/src/llvm_backend.zig +++ b/src/llvm_backend.zig @@ -139,9 +139,9 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { pub const LLVMIRModule = struct { module: *Module, - llvm_module: *const llvm.ModuleRef, - target_machine: *const llvm.TargetMachineRef, - builder: *const llvm.BuilderRef, + llvm_module: *const llvm.Module, + target_machine: *const llvm.TargetMachine, + builder: *const llvm.Builder, object_path: []const u8, @@ -150,10 +150,10 @@ pub const LLVMIRModule = struct { /// This stores the LLVM values used in a function, such that they can be /// referred to in other instructions. This table is cleared before every function is generated. - func_inst_table: std.AutoHashMapUnmanaged(*Inst, *const llvm.ValueRef) = .{}, + func_inst_table: std.AutoHashMapUnmanaged(*Inst, *const llvm.Value) = .{}, /// These fields are used to refer to the LLVM value of the function paramaters in an Arg instruction. - args: []*const llvm.ValueRef = &[_]*const llvm.ValueRef{}, + args: []*const llvm.Value = &[_]*const llvm.Value{}, arg_index: usize = 0, pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*LLVMIRModule { @@ -177,15 +177,15 @@ pub const LLVMIRModule = struct { const root_nameZ = try gpa.dupeZ(u8, options.root_name); defer gpa.free(root_nameZ); - const llvm_module = llvm.ModuleRef.createWithName(root_nameZ.ptr); + const llvm_module = llvm.Module.createWithName(root_nameZ.ptr); errdefer llvm_module.disposeModule(); const llvm_target_triple = try targetTriple(gpa, options.target); defer gpa.free(llvm_target_triple); var error_message: [*:0]const u8 = undefined; - var target_ref: *const llvm.TargetRef = undefined; - if (llvm.TargetRef.getTargetFromTriple(llvm_target_triple.ptr, &target_ref, &error_message)) { + var target: *const llvm.Target = undefined; + if (llvm.Target.getTargetFromTriple(llvm_target_triple.ptr, &target, &error_message)) { defer llvm.disposeMessage(error_message); const stderr = std.io.getStdErr().outStream(); @@ -205,8 +205,8 @@ pub const LLVMIRModule = struct { } const opt_level: llvm.CodeGenOptLevel = if (options.optimize_mode == .Debug) .None else .Aggressive; - const target_machine = llvm.TargetMachineRef.createTargetMachine( - target_ref, + const target_machine = llvm.TargetMachine.createTargetMachine( + target, llvm_target_triple.ptr, "", "", @@ -216,7 +216,7 @@ pub const LLVMIRModule = struct { ); errdefer target_machine.disposeTargetMachine(); - const builder = llvm.BuilderRef.createBuilder(); + const builder = llvm.Builder.createBuilder(); errdefer builder.disposeBuilder(); self.* = .{ @@ -313,7 +313,7 @@ pub const LLVMIRModule = struct { // This gets the LLVM values from the function and stores them in `self.args`. const fn_param_len = func.owner_decl.typed_value.most_recent.typed_value.ty.fnParamLen(); - var args = try self.gpa.alloc(*const llvm.ValueRef, fn_param_len); + var args = try self.gpa.alloc(*const llvm.Value, fn_param_len); defer self.gpa.free(args); for (args) |*arg, i| { @@ -337,7 +337,7 @@ pub const LLVMIRModule = struct { const instructions = func.body.instructions; for (instructions) |inst| { - const opt_llvm_val: ?*const llvm.ValueRef = switch (inst.tag) { + const opt_llvm_val: ?*const llvm.Value = switch (inst.tag) { .add => try self.genAdd(inst.castTag(.add).?), .alloc => try self.genAlloc(inst.castTag(.alloc).?), .arg => try self.genArg(inst.castTag(.arg).?), @@ -367,7 +367,7 @@ pub const LLVMIRModule = struct { } } - fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.ValueRef { + fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.Value { if (inst.func.value()) |func_value| { const fn_decl = if (func_value.castTag(.extern_fn)) |extern_fn| extern_fn.data @@ -381,7 +381,7 @@ pub const LLVMIRModule = struct { const num_args = inst.args.len; - const llvm_param_vals = try self.gpa.alloc(*const llvm.ValueRef, num_args); + const llvm_param_vals = try self.gpa.alloc(*const llvm.Value, num_args); defer self.gpa.free(llvm_param_vals); for (inst.args) |arg, i| { @@ -411,26 +411,26 @@ pub const LLVMIRModule = struct { } } - fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef { + fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value { _ = self.builder.buildRetVoid(); return null; } - fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { _ = self.builder.buildRet(try self.resolveInst(inst.operand)); return null; } - fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { return self.builder.buildNot(try self.resolveInst(inst.operand), ""); } - fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef { + fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value { _ = self.builder.buildUnreachable(); return null; } - fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { + fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { const lhs = try self.resolveInst(inst.lhs); const rhs = try self.resolveInst(inst.rhs); @@ -443,7 +443,7 @@ pub const LLVMIRModule = struct { self.builder.buildNUWAdd(lhs, rhs, ""); } - fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { + fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { const lhs = try self.resolveInst(inst.lhs); const rhs = try self.resolveInst(inst.rhs); @@ -456,7 +456,7 @@ pub const LLVMIRModule = struct { self.builder.buildNUWSub(lhs, rhs, ""); } - fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { const val = try self.resolveInst(inst.operand); const signed = inst.base.ty.isSignedInt(); @@ -465,14 +465,14 @@ pub const LLVMIRModule = struct { return self.builder.buildIntCast2(val, try self.getLLVMType(inst.base.ty, inst.base.src), signed, ""); } - fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { const val = try self.resolveInst(inst.operand); const dest_type = try self.getLLVMType(inst.base.ty, inst.base.src); return self.builder.buildBitCast(val, dest_type, ""); } - fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.ValueRef { + fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.Value { const arg_val = self.args[self.arg_index]; self.arg_index += 1; @@ -481,7 +481,7 @@ pub const LLVMIRModule = struct { return self.builder.buildLoad(ptr_val, ""); } - fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef { + fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value { // buildAlloca expects the pointee type, not the pointer type, so assert that // a Payload.PointerSimple is passed to the alloc instruction. const pointee_type = inst.base.ty.castPointer().?.data; @@ -491,25 +491,25 @@ pub const LLVMIRModule = struct { return self.builder.buildAlloca(try self.getLLVMType(pointee_type, inst.base.src), ""); } - fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { + fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { const val = try self.resolveInst(inst.rhs); const ptr = try self.resolveInst(inst.lhs); _ = self.builder.buildStore(val, ptr); return null; } - fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { const ptr_val = try self.resolveInst(inst.operand); return self.builder.buildLoad(ptr_val, ""); } - fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef { + fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value { const llvn_fn = self.getIntrinsic("llvm.debugtrap"); _ = self.builder.buildCall(llvn_fn, null, 0, ""); return null; } - fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.ValueRef { + fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.Value { const id = llvm.lookupIntrinsicID(name.ptr, name.len); assert(id != 0); // TODO: add support for overload intrinsics by passing the prefix of the intrinsic @@ -518,7 +518,7 @@ pub const LLVMIRModule = struct { return self.llvm_module.getIntrinsicDeclaration(id, null, 0); } - fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.ValueRef { + fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.Value { if (inst.value()) |val| { return self.genTypedValue(inst.src, .{ .ty = inst.ty, .val = val }); } @@ -527,7 +527,7 @@ pub const LLVMIRModule = struct { return self.fail(inst.src, "TODO implement global llvm values (or the value is not in the func_inst_table table)", .{}); } - fn genTypedValue(self: *LLVMIRModule, src: usize, tv: TypedValue) error{ OutOfMemory, CodegenFail }!*const llvm.ValueRef { + fn genTypedValue(self: *LLVMIRModule, src: usize, tv: TypedValue) error{ OutOfMemory, CodegenFail }!*const llvm.Value { const llvm_type = try self.getLLVMType(tv.ty, src); if (tv.val.isUndef()) @@ -558,7 +558,7 @@ pub const LLVMIRModule = struct { const usize_type = try self.getLLVMType(Type.initTag(.usize), src); // TODO: second index should be the index into the memory! - var indices: [2]*const llvm.ValueRef = .{ + var indices: [2]*const llvm.Value = .{ usize_type.constNull(), usize_type.constNull(), }; @@ -584,7 +584,7 @@ pub const LLVMIRModule = struct { } } - fn getLLVMType(self: *LLVMIRModule, t: Type, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.TypeRef { + fn getLLVMType(self: *LLVMIRModule, t: Type, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.Type { switch (t.zigTypeTag()) { .Void => return llvm.voidType(), .NoReturn => return llvm.voidType(), @@ -609,7 +609,7 @@ pub const LLVMIRModule = struct { } } - fn resolveGlobalDecl(self: *LLVMIRModule, decl: *Module.Decl, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.ValueRef { + fn resolveGlobalDecl(self: *LLVMIRModule, decl: *Module.Decl, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.Value { // TODO: do we want to store this in our own datastructure? if (self.llvm_module.getNamedGlobal(decl.name)) |val| return val; @@ -628,7 +628,7 @@ pub const LLVMIRModule = struct { } /// If the llvm function does not exist, create it - fn resolveLLVMFunction(self: *LLVMIRModule, func: *Module.Decl, src: usize) !*const llvm.ValueRef { + fn resolveLLVMFunction(self: *LLVMIRModule, func: *Module.Decl, src: usize) !*const llvm.Value { // TODO: do we want to store this in our own datastructure? if (self.llvm_module.getNamedFunction(func.name)) |llvm_fn| return llvm_fn; @@ -641,14 +641,14 @@ pub const LLVMIRModule = struct { defer self.gpa.free(fn_param_types); zig_fn_type.fnParamTypes(fn_param_types); - const llvm_param = try self.gpa.alloc(*const llvm.TypeRef, fn_param_len); + const llvm_param = try self.gpa.alloc(*const llvm.Type, fn_param_len); defer self.gpa.free(llvm_param); for (fn_param_types) |fn_param, i| { llvm_param[i] = try self.getLLVMType(fn_param, src); } - const fn_type = llvm.TypeRef.functionType( + const fn_type = llvm.Type.functionType( try self.getLLVMType(return_type, src), if (fn_param_len == 0) null else llvm_param.ptr, @intCast(c_uint, fn_param_len), diff --git a/src/llvm_bindings.zig b/src/llvm_bindings.zig index 369772d4c1..690c28e1a0 100644 --- a/src/llvm_bindings.zig +++ b/src/llvm_bindings.zig @@ -7,85 +7,85 @@ const assert = std.debug.assert; const LLVMBool = bool; pub const LLVMAttributeIndex = c_uint; -pub const ValueRef = opaque { +pub const Value = opaque { pub const addAttributeAtIndex = LLVMAddAttributeAtIndex; - extern fn LLVMAddAttributeAtIndex(*const ValueRef, Idx: LLVMAttributeIndex, A: *const AttributeRef) void; + extern fn LLVMAddAttributeAtIndex(*const Value, Idx: LLVMAttributeIndex, A: *const Attribute) void; pub const appendBasicBlock = LLVMAppendBasicBlock; - extern fn LLVMAppendBasicBlock(Fn: *const ValueRef, Name: [*:0]const u8) *const BasicBlockRef; + extern fn LLVMAppendBasicBlock(Fn: *const Value, Name: [*:0]const u8) *const BasicBlock; pub const getFirstBasicBlock = LLVMGetFirstBasicBlock; - extern fn LLVMGetFirstBasicBlock(Fn: *const ValueRef) ?*const BasicBlockRef; + extern fn LLVMGetFirstBasicBlock(Fn: *const Value) ?*const BasicBlock; // Helper functions // TODO: Do we want to put these functions here? It allows for convienient function calls - // on ValueRef: llvm_fn.addFnAttr("noreturn") - fn addAttr(val: *const ValueRef, index: LLVMAttributeIndex, name: []const u8) void { + // on Value: llvm_fn.addFnAttr("noreturn") + fn addAttr(val: *const Value, index: LLVMAttributeIndex, name: []const u8) void { const kind_id = getEnumAttributeKindForName(name.ptr, name.len); assert(kind_id != 0); - const llvm_attr = ContextRef.getGlobal().createEnumAttribute(kind_id, 0); + const llvm_attr = Context.getGlobal().createEnumAttribute(kind_id, 0); val.addAttributeAtIndex(index, llvm_attr); } - pub fn addFnAttr(val: *const ValueRef, attr_name: []const u8) void { + pub fn addFnAttr(val: *const Value, attr_name: []const u8) void { // TODO: improve this API, `addAttr(-1, attr_name)` val.addAttr(std.math.maxInt(LLVMAttributeIndex), attr_name); } }; -pub const TypeRef = opaque { +pub const Type = opaque { pub const functionType = LLVMFunctionType; - extern fn LLVMFunctionType(ReturnType: *const TypeRef, ParamTypes: ?[*]*const TypeRef, ParamCount: c_uint, IsVarArg: LLVMBool) *const TypeRef; + extern fn LLVMFunctionType(ReturnType: *const Type, ParamTypes: ?[*]*const Type, ParamCount: c_uint, IsVarArg: LLVMBool) *const Type; pub const constNull = LLVMConstNull; - extern fn LLVMConstNull(Ty: *const TypeRef) *const ValueRef; + extern fn LLVMConstNull(Ty: *const Type) *const Value; pub const constAllOnes = LLVMConstAllOnes; - extern fn LLVMConstAllOnes(Ty: *const TypeRef) *const ValueRef; + extern fn LLVMConstAllOnes(Ty: *const Type) *const Value; pub const constInt = LLVMConstInt; - extern fn LLVMConstInt(IntTy: *const TypeRef, N: c_ulonglong, SignExtend: LLVMBool) *const ValueRef; + extern fn LLVMConstInt(IntTy: *const Type, N: c_ulonglong, SignExtend: LLVMBool) *const Value; pub const constArray = LLVMConstArray; - extern fn LLVMConstArray(ElementTy: *const TypeRef, ConstantVals: ?[*]*const ValueRef, Length: c_uint) *const ValueRef; + extern fn LLVMConstArray(ElementTy: *const Type, ConstantVals: ?[*]*const Value, Length: c_uint) *const Value; pub const getUndef = LLVMGetUndef; - extern fn LLVMGetUndef(Ty: *const TypeRef) *const ValueRef; + extern fn LLVMGetUndef(Ty: *const Type) *const Value; pub const pointerType = LLVMPointerType; - extern fn LLVMPointerType(ElementType: *const TypeRef, AddressSpace: c_uint) *const TypeRef; + extern fn LLVMPointerType(ElementType: *const Type, AddressSpace: c_uint) *const Type; pub const arrayType = LLVMArrayType; - extern fn LLVMArrayType(ElementType: *const TypeRef, ElementCount: c_uint) *const TypeRef; + extern fn LLVMArrayType(ElementType: *const Type, ElementCount: c_uint) *const Type; }; -pub const ModuleRef = opaque { +pub const Module = opaque { pub const createWithName = LLVMModuleCreateWithName; - extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const ModuleRef; + extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const Module; pub const disposeModule = LLVMDisposeModule; - extern fn LLVMDisposeModule(*const ModuleRef) void; + extern fn LLVMDisposeModule(*const Module) void; pub const verifyModule = LLVMVerifyModule; - extern fn LLVMVerifyModule(*const ModuleRef, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) LLVMBool; + extern fn LLVMVerifyModule(*const Module, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) LLVMBool; pub const addFunction = LLVMAddFunction; - extern fn LLVMAddFunction(*const ModuleRef, Name: [*:0]const u8, FunctionTy: *const TypeRef) *const ValueRef; + extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value; pub const getNamedFunction = LLVMGetNamedFunction; - extern fn LLVMGetNamedFunction(*const ModuleRef, Name: [*:0]const u8) ?*const ValueRef; + extern fn LLVMGetNamedFunction(*const Module, Name: [*:0]const u8) ?*const Value; pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration; - extern fn LLVMGetIntrinsicDeclaration(Mod: *const ModuleRef, ID: c_uint, ParamTypes: ?[*]*const TypeRef, ParamCount: usize) *const ValueRef; + extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]*const Type, ParamCount: usize) *const Value; pub const printToString = LLVMPrintModuleToString; - extern fn LLVMPrintModuleToString(*const ModuleRef) [*:0]const u8; + extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8; pub const addGlobal = LLVMAddGlobal; - extern fn LLVMAddGlobal(M: *const ModuleRef, Ty: *const TypeRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMAddGlobal(M: *const Module, Ty: *const Type, Name: [*:0]const u8) *const Value; pub const getNamedGlobal = LLVMGetNamedGlobal; - extern fn LLVMGetNamedGlobal(M: *const ModuleRef, Name: [*:0]const u8) ?*const ValueRef; + extern fn LLVMGetNamedGlobal(M: *const Module, Name: [*:0]const u8) ?*const Value; }; pub const lookupIntrinsicID = LLVMLookupIntrinsicID; @@ -101,120 +101,120 @@ pub const VerifierFailureAction = extern enum { }; pub const constNeg = LLVMConstNeg; -extern fn LLVMConstNeg(ConstantVal: *const ValueRef) *const ValueRef; +extern fn LLVMConstNeg(ConstantVal: *const Value) *const Value; pub const constString = LLVMConstString; -extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const ValueRef; +extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const Value; pub const setInitializer = LLVMSetInitializer; -extern fn LLVMSetInitializer(GlobalVar: *const ValueRef, ConstantVal: *const ValueRef) void; +extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void; pub const voidType = LLVMVoidType; -extern fn LLVMVoidType() *const TypeRef; +extern fn LLVMVoidType() *const Type; pub const getParam = LLVMGetParam; -extern fn LLVMGetParam(Fn: *const ValueRef, Index: c_uint) *const ValueRef; +extern fn LLVMGetParam(Fn: *const Value, Index: c_uint) *const Value; pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName; extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint; -pub const AttributeRef = opaque {}; +pub const Attribute = opaque {}; -pub const ContextRef = opaque { +pub const Context = opaque { pub const createEnumAttribute = LLVMCreateEnumAttribute; - extern fn LLVMCreateEnumAttribute(*const ContextRef, KindID: c_uint, Val: u64) *const AttributeRef; + extern fn LLVMCreateEnumAttribute(*const Context, KindID: c_uint, Val: u64) *const Attribute; pub const getGlobal = LLVMGetGlobalContext; - extern fn LLVMGetGlobalContext() *const ContextRef; + extern fn LLVMGetGlobalContext() *const Context; }; pub const intType = LLVMIntType; -extern fn LLVMIntType(NumBits: c_uint) *const TypeRef; +extern fn LLVMIntType(NumBits: c_uint) *const Type; -pub const BuilderRef = opaque { +pub const Builder = opaque { pub const createBuilder = LLVMCreateBuilder; - extern fn LLVMCreateBuilder() *const BuilderRef; + extern fn LLVMCreateBuilder() *const Builder; pub const disposeBuilder = LLVMDisposeBuilder; - extern fn LLVMDisposeBuilder(Builder: *const BuilderRef) void; + extern fn LLVMDisposeBuilder(Builder: *const Builder) void; pub const positionBuilderAtEnd = LLVMPositionBuilderAtEnd; - extern fn LLVMPositionBuilderAtEnd(Builder: *const BuilderRef, Block: *const BasicBlockRef) void; + extern fn LLVMPositionBuilderAtEnd(Builder: *const Builder, Block: *const BasicBlock) void; pub const getInsertBlock = LLVMGetInsertBlock; - extern fn LLVMGetInsertBlock(Builder: *const BuilderRef) *const BasicBlockRef; + extern fn LLVMGetInsertBlock(Builder: *const Builder) *const BasicBlock; pub const buildCall = LLVMBuildCall; - extern fn LLVMBuildCall(*const BuilderRef, Fn: *const ValueRef, Args: ?[*]*const ValueRef, NumArgs: c_uint, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildCall(*const Builder, Fn: *const Value, Args: ?[*]*const Value, NumArgs: c_uint, Name: [*:0]const u8) *const Value; pub const buildCall2 = LLVMBuildCall2; - extern fn LLVMBuildCall2(*const BuilderRef, *const TypeRef, Fn: *const ValueRef, Args: [*]*const ValueRef, NumArgs: c_uint, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildCall2(*const Builder, *const Type, Fn: *const Value, Args: [*]*const Value, NumArgs: c_uint, Name: [*:0]const u8) *const Value; pub const buildRetVoid = LLVMBuildRetVoid; - extern fn LLVMBuildRetVoid(*const BuilderRef) *const ValueRef; + extern fn LLVMBuildRetVoid(*const Builder) *const Value; pub const buildRet = LLVMBuildRet; - extern fn LLVMBuildRet(*const BuilderRef, V: *const ValueRef) *const ValueRef; + extern fn LLVMBuildRet(*const Builder, V: *const Value) *const Value; pub const buildUnreachable = LLVMBuildUnreachable; - extern fn LLVMBuildUnreachable(*const BuilderRef) *const ValueRef; + extern fn LLVMBuildUnreachable(*const Builder) *const Value; pub const buildAlloca = LLVMBuildAlloca; - extern fn LLVMBuildAlloca(*const BuilderRef, Ty: *const TypeRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildAlloca(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value; pub const buildStore = LLVMBuildStore; - extern fn LLVMBuildStore(*const BuilderRef, Val: *const ValueRef, Ptr: *const ValueRef) *const ValueRef; + extern fn LLVMBuildStore(*const Builder, Val: *const Value, Ptr: *const Value) *const Value; pub const buildLoad = LLVMBuildLoad; - extern fn LLVMBuildLoad(*const BuilderRef, PointerVal: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildLoad(*const Builder, PointerVal: *const Value, Name: [*:0]const u8) *const Value; pub const buildNot = LLVMBuildNot; - extern fn LLVMBuildNot(*const BuilderRef, V: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildNot(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value; pub const buildNSWAdd = LLVMBuildNSWAdd; - extern fn LLVMBuildNSWAdd(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildNSWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value; pub const buildNUWAdd = LLVMBuildNUWAdd; - extern fn LLVMBuildNUWAdd(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildNUWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value; pub const buildNSWSub = LLVMBuildNSWSub; - extern fn LLVMBuildNSWSub(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildNSWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value; pub const buildNUWSub = LLVMBuildNUWSub; - extern fn LLVMBuildNUWSub(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildNUWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value; pub const buildIntCast2 = LLVMBuildIntCast2; - extern fn LLVMBuildIntCast2(*const BuilderRef, Val: *const ValueRef, DestTy: *const TypeRef, IsSigned: LLVMBool, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildIntCast2(*const Builder, Val: *const Value, DestTy: *const Type, IsSigned: LLVMBool, Name: [*:0]const u8) *const Value; pub const buildBitCast = LLVMBuildBitCast; - extern fn LLVMBuildBitCast(*const BuilderRef, Val: *const ValueRef, DestTy: *const TypeRef, Name: [*:0]const u8) *const ValueRef; + 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 BuilderRef, Pointer: *const ValueRef, Indices: [*]*const ValueRef, NumIndices: c_uint, Name: [*:0]const u8) *const ValueRef; + extern fn LLVMBuildInBoundsGEP(B: *const Builder, Pointer: *const Value, Indices: [*]*const Value, NumIndices: c_uint, Name: [*:0]const u8) *const Value; }; -pub const BasicBlockRef = opaque { +pub const BasicBlock = opaque { pub const deleteBasicBlock = LLVMDeleteBasicBlock; - extern fn LLVMDeleteBasicBlock(BB: *const BasicBlockRef) void; + extern fn LLVMDeleteBasicBlock(BB: *const BasicBlock) void; }; -pub const TargetMachineRef = opaque { +pub const TargetMachine = opaque { pub const createTargetMachine = LLVMCreateTargetMachine; extern fn LLVMCreateTargetMachine( - T: *const TargetRef, + T: *const Target, Triple: [*:0]const u8, CPU: [*:0]const u8, Features: [*:0]const u8, Level: CodeGenOptLevel, Reloc: RelocMode, CodeModel: CodeMode, - ) *const TargetMachineRef; + ) *const TargetMachine; pub const disposeTargetMachine = LLVMDisposeTargetMachine; - extern fn LLVMDisposeTargetMachine(T: *const TargetMachineRef) void; + extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void; pub const emitToFile = LLVMTargetMachineEmitToFile; - extern fn LLVMTargetMachineEmitToFile(*const TargetMachineRef, M: *const ModuleRef, Filename: [*:0]const u8, codegen: CodeGenFileType, ErrorMessage: *[*:0]const u8) LLVMBool; + extern fn LLVMTargetMachineEmitToFile(*const TargetMachine, M: *const Module, Filename: [*:0]const u8, codegen: CodeGenFileType, ErrorMessage: *[*:0]const u8) LLVMBool; }; pub const CodeMode = extern enum { @@ -249,9 +249,9 @@ pub const CodeGenFileType = extern enum { ObjectFile, }; -pub const TargetRef = opaque { +pub const Target = opaque { pub const getTargetFromTriple = LLVMGetTargetFromTriple; - extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const TargetRef, ErrorMessage: *[*:0]const u8) LLVMBool; + extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const Target, ErrorMessage: *[*:0]const u8) LLVMBool; }; extern fn LLVMInitializeAArch64TargetInfo() void;