authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2021-01-05 11:43:58+01:00
committergravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2021-01-06 10:52:19+01:00
log1149cd593e82b338058037c29bcd0e2caaab0dcb
treeecdb74c93fe068f665b355b5daf2137c3de88be3
parent70f6d16ae2d2d9bf8690742c7eba2798b5395174

stage2: rename `*const llvm.ValueRef` to `*const llvm.Value` in LLVM backend

The same has been done for all the other LLVM types.

2 files changed, 104 insertions(+), 104 deletions(-)

src/llvm_backend.zig+37-37
......@@ -139,9 +139,9 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 {
139139
140140pub const LLVMIRModule = struct {
141141 module: *Module,
142 llvm_module: *const llvm.ModuleRef,
143 target_machine: *const llvm.TargetMachineRef,
144 builder: *const llvm.BuilderRef,
142 llvm_module: *const llvm.Module,
143 target_machine: *const llvm.TargetMachine,
144 builder: *const llvm.Builder,
145145
146146 object_path: []const u8,
147147
......@@ -150,10 +150,10 @@ pub const LLVMIRModule = struct {
150150
151151 /// This stores the LLVM values used in a function, such that they can be
152152 /// referred to in other instructions. This table is cleared before every function is generated.
153 func_inst_table: std.AutoHashMapUnmanaged(*Inst, *const llvm.ValueRef) = .{},
153 func_inst_table: std.AutoHashMapUnmanaged(*Inst, *const llvm.Value) = .{},
154154
155155 /// These fields are used to refer to the LLVM value of the function paramaters in an Arg instruction.
156 args: []*const llvm.ValueRef = &[_]*const llvm.ValueRef{},
156 args: []*const llvm.Value = &[_]*const llvm.Value{},
157157 arg_index: usize = 0,
158158
159159 pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*LLVMIRModule {
......@@ -177,15 +177,15 @@ pub const LLVMIRModule = struct {
177177
178178 const root_nameZ = try gpa.dupeZ(u8, options.root_name);
179179 defer gpa.free(root_nameZ);
180 const llvm_module = llvm.ModuleRef.createWithName(root_nameZ.ptr);
180 const llvm_module = llvm.Module.createWithName(root_nameZ.ptr);
181181 errdefer llvm_module.disposeModule();
182182
183183 const llvm_target_triple = try targetTriple(gpa, options.target);
184184 defer gpa.free(llvm_target_triple);
185185
186186 var error_message: [*:0]const u8 = undefined;
187 var target_ref: *const llvm.TargetRef = undefined;
188 if (llvm.TargetRef.getTargetFromTriple(llvm_target_triple.ptr, &target_ref, &error_message)) {
187 var target: *const llvm.Target = undefined;
188 if (llvm.Target.getTargetFromTriple(llvm_target_triple.ptr, &target, &error_message)) {
189189 defer llvm.disposeMessage(error_message);
190190
191191 const stderr = std.io.getStdErr().outStream();
......@@ -205,8 +205,8 @@ pub const LLVMIRModule = struct {
205205 }
206206
207207 const opt_level: llvm.CodeGenOptLevel = if (options.optimize_mode == .Debug) .None else .Aggressive;
208 const target_machine = llvm.TargetMachineRef.createTargetMachine(
209 target_ref,
208 const target_machine = llvm.TargetMachine.createTargetMachine(
209 target,
210210 llvm_target_triple.ptr,
211211 "",
212212 "",
......@@ -216,7 +216,7 @@ pub const LLVMIRModule = struct {
216216 );
217217 errdefer target_machine.disposeTargetMachine();
218218
219 const builder = llvm.BuilderRef.createBuilder();
219 const builder = llvm.Builder.createBuilder();
220220 errdefer builder.disposeBuilder();
221221
222222 self.* = .{
......@@ -313,7 +313,7 @@ pub const LLVMIRModule = struct {
313313
314314 // This gets the LLVM values from the function and stores them in `self.args`.
315315 const fn_param_len = func.owner_decl.typed_value.most_recent.typed_value.ty.fnParamLen();
316 var args = try self.gpa.alloc(*const llvm.ValueRef, fn_param_len);
316 var args = try self.gpa.alloc(*const llvm.Value, fn_param_len);
317317 defer self.gpa.free(args);
318318
319319 for (args) |*arg, i| {
......@@ -337,7 +337,7 @@ pub const LLVMIRModule = struct {
337337
338338 const instructions = func.body.instructions;
339339 for (instructions) |inst| {
340 const opt_llvm_val: ?*const llvm.ValueRef = switch (inst.tag) {
340 const opt_llvm_val: ?*const llvm.Value = switch (inst.tag) {
341341 .add => try self.genAdd(inst.castTag(.add).?),
342342 .alloc => try self.genAlloc(inst.castTag(.alloc).?),
343343 .arg => try self.genArg(inst.castTag(.arg).?),
......@@ -367,7 +367,7 @@ pub const LLVMIRModule = struct {
367367 }
368368 }
369369
370 fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.ValueRef {
370 fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.Value {
371371 if (inst.func.value()) |func_value| {
372372 const fn_decl = if (func_value.castTag(.extern_fn)) |extern_fn|
373373 extern_fn.data
......@@ -381,7 +381,7 @@ pub const LLVMIRModule = struct {
381381
382382 const num_args = inst.args.len;
383383
384 const llvm_param_vals = try self.gpa.alloc(*const llvm.ValueRef, num_args);
384 const llvm_param_vals = try self.gpa.alloc(*const llvm.Value, num_args);
385385 defer self.gpa.free(llvm_param_vals);
386386
387387 for (inst.args) |arg, i| {
......@@ -411,26 +411,26 @@ pub const LLVMIRModule = struct {
411411 }
412412 }
413413
414 fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef {
414 fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value {
415415 _ = self.builder.buildRetVoid();
416416 return null;
417417 }
418418
419 fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef {
419 fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value {
420420 _ = self.builder.buildRet(try self.resolveInst(inst.operand));
421421 return null;
422422 }
423423
424 fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef {
424 fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value {
425425 return self.builder.buildNot(try self.resolveInst(inst.operand), "");
426426 }
427427
428 fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef {
428 fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value {
429429 _ = self.builder.buildUnreachable();
430430 return null;
431431 }
432432
433 fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef {
433 fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value {
434434 const lhs = try self.resolveInst(inst.lhs);
435435 const rhs = try self.resolveInst(inst.rhs);
436436
......@@ -443,7 +443,7 @@ pub const LLVMIRModule = struct {
443443 self.builder.buildNUWAdd(lhs, rhs, "");
444444 }
445445
446 fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef {
446 fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value {
447447 const lhs = try self.resolveInst(inst.lhs);
448448 const rhs = try self.resolveInst(inst.rhs);
449449
......@@ -456,7 +456,7 @@ pub const LLVMIRModule = struct {
456456 self.builder.buildNUWSub(lhs, rhs, "");
457457 }
458458
459 fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef {
459 fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value {
460460 const val = try self.resolveInst(inst.operand);
461461
462462 const signed = inst.base.ty.isSignedInt();
......@@ -465,14 +465,14 @@ pub const LLVMIRModule = struct {
465465 return self.builder.buildIntCast2(val, try self.getLLVMType(inst.base.ty, inst.base.src), signed, "");
466466 }
467467
468 fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef {
468 fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value {
469469 const val = try self.resolveInst(inst.operand);
470470 const dest_type = try self.getLLVMType(inst.base.ty, inst.base.src);
471471
472472 return self.builder.buildBitCast(val, dest_type, "");
473473 }
474474
475 fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.ValueRef {
475 fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.Value {
476476 const arg_val = self.args[self.arg_index];
477477 self.arg_index += 1;
478478
......@@ -481,7 +481,7 @@ pub const LLVMIRModule = struct {
481481 return self.builder.buildLoad(ptr_val, "");
482482 }
483483
484 fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef {
484 fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value {
485485 // buildAlloca expects the pointee type, not the pointer type, so assert that
486486 // a Payload.PointerSimple is passed to the alloc instruction.
487487 const pointee_type = inst.base.ty.castPointer().?.data;
......@@ -491,25 +491,25 @@ pub const LLVMIRModule = struct {
491491 return self.builder.buildAlloca(try self.getLLVMType(pointee_type, inst.base.src), "");
492492 }
493493
494 fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef {
494 fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value {
495495 const val = try self.resolveInst(inst.rhs);
496496 const ptr = try self.resolveInst(inst.lhs);
497497 _ = self.builder.buildStore(val, ptr);
498498 return null;
499499 }
500500
501 fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef {
501 fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value {
502502 const ptr_val = try self.resolveInst(inst.operand);
503503 return self.builder.buildLoad(ptr_val, "");
504504 }
505505
506 fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef {
506 fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value {
507507 const llvn_fn = self.getIntrinsic("llvm.debugtrap");
508508 _ = self.builder.buildCall(llvn_fn, null, 0, "");
509509 return null;
510510 }
511511
512 fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.ValueRef {
512 fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.Value {
513513 const id = llvm.lookupIntrinsicID(name.ptr, name.len);
514514 assert(id != 0);
515515 // TODO: add support for overload intrinsics by passing the prefix of the intrinsic
......@@ -518,7 +518,7 @@ pub const LLVMIRModule = struct {
518518 return self.llvm_module.getIntrinsicDeclaration(id, null, 0);
519519 }
520520
521 fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.ValueRef {
521 fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.Value {
522522 if (inst.value()) |val| {
523523 return self.genTypedValue(inst.src, .{ .ty = inst.ty, .val = val });
524524 }
......@@ -527,7 +527,7 @@ pub const LLVMIRModule = struct {
527527 return self.fail(inst.src, "TODO implement global llvm values (or the value is not in the func_inst_table table)", .{});
528528 }
529529
530 fn genTypedValue(self: *LLVMIRModule, src: usize, tv: TypedValue) error{ OutOfMemory, CodegenFail }!*const llvm.ValueRef {
530 fn genTypedValue(self: *LLVMIRModule, src: usize, tv: TypedValue) error{ OutOfMemory, CodegenFail }!*const llvm.Value {
531531 const llvm_type = try self.getLLVMType(tv.ty, src);
532532
533533 if (tv.val.isUndef())
......@@ -558,7 +558,7 @@ pub const LLVMIRModule = struct {
558558 const usize_type = try self.getLLVMType(Type.initTag(.usize), src);
559559
560560 // TODO: second index should be the index into the memory!
561 var indices: [2]*const llvm.ValueRef = .{
561 var indices: [2]*const llvm.Value = .{
562562 usize_type.constNull(),
563563 usize_type.constNull(),
564564 };
......@@ -584,7 +584,7 @@ pub const LLVMIRModule = struct {
584584 }
585585 }
586586
587 fn getLLVMType(self: *LLVMIRModule, t: Type, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.TypeRef {
587 fn getLLVMType(self: *LLVMIRModule, t: Type, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.Type {
588588 switch (t.zigTypeTag()) {
589589 .Void => return llvm.voidType(),
590590 .NoReturn => return llvm.voidType(),
......@@ -609,7 +609,7 @@ pub const LLVMIRModule = struct {
609609 }
610610 }
611611
612 fn resolveGlobalDecl(self: *LLVMIRModule, decl: *Module.Decl, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.ValueRef {
612 fn resolveGlobalDecl(self: *LLVMIRModule, decl: *Module.Decl, src: usize) error{ OutOfMemory, CodegenFail }!*const llvm.Value {
613613 // TODO: do we want to store this in our own datastructure?
614614 if (self.llvm_module.getNamedGlobal(decl.name)) |val| return val;
615615
......@@ -628,7 +628,7 @@ pub const LLVMIRModule = struct {
628628 }
629629
630630 /// If the llvm function does not exist, create it
631 fn resolveLLVMFunction(self: *LLVMIRModule, func: *Module.Decl, src: usize) !*const llvm.ValueRef {
631 fn resolveLLVMFunction(self: *LLVMIRModule, func: *Module.Decl, src: usize) !*const llvm.Value {
632632 // TODO: do we want to store this in our own datastructure?
633633 if (self.llvm_module.getNamedFunction(func.name)) |llvm_fn| return llvm_fn;
634634
......@@ -641,14 +641,14 @@ pub const LLVMIRModule = struct {
641641 defer self.gpa.free(fn_param_types);
642642 zig_fn_type.fnParamTypes(fn_param_types);
643643
644 const llvm_param = try self.gpa.alloc(*const llvm.TypeRef, fn_param_len);
644 const llvm_param = try self.gpa.alloc(*const llvm.Type, fn_param_len);
645645 defer self.gpa.free(llvm_param);
646646
647647 for (fn_param_types) |fn_param, i| {
648648 llvm_param[i] = try self.getLLVMType(fn_param, src);
649649 }
650650
651 const fn_type = llvm.TypeRef.functionType(
651 const fn_type = llvm.Type.functionType(
652652 try self.getLLVMType(return_type, src),
653653 if (fn_param_len == 0) null else llvm_param.ptr,
654654 @intCast(c_uint, fn_param_len),
src/llvm_bindings.zig+67-67
......@@ -7,85 +7,85 @@ const assert = std.debug.assert;
77const LLVMBool = bool;
88pub const LLVMAttributeIndex = c_uint;
99
10pub const ValueRef = opaque {
10pub const Value = opaque {
1111 pub const addAttributeAtIndex = LLVMAddAttributeAtIndex;
12 extern fn LLVMAddAttributeAtIndex(*const ValueRef, Idx: LLVMAttributeIndex, A: *const AttributeRef) void;
12 extern fn LLVMAddAttributeAtIndex(*const Value, Idx: LLVMAttributeIndex, A: *const Attribute) void;
1313
1414 pub const appendBasicBlock = LLVMAppendBasicBlock;
15 extern fn LLVMAppendBasicBlock(Fn: *const ValueRef, Name: [*:0]const u8) *const BasicBlockRef;
15 extern fn LLVMAppendBasicBlock(Fn: *const Value, Name: [*:0]const u8) *const BasicBlock;
1616
1717 pub const getFirstBasicBlock = LLVMGetFirstBasicBlock;
18 extern fn LLVMGetFirstBasicBlock(Fn: *const ValueRef) ?*const BasicBlockRef;
18 extern fn LLVMGetFirstBasicBlock(Fn: *const Value) ?*const BasicBlock;
1919
2020 // Helper functions
2121 // TODO: Do we want to put these functions here? It allows for convienient function calls
22 // on ValueRef: llvm_fn.addFnAttr("noreturn")
23 fn addAttr(val: *const ValueRef, index: LLVMAttributeIndex, name: []const u8) void {
22 // on Value: llvm_fn.addFnAttr("noreturn")
23 fn addAttr(val: *const Value, index: LLVMAttributeIndex, name: []const u8) void {
2424 const kind_id = getEnumAttributeKindForName(name.ptr, name.len);
2525 assert(kind_id != 0);
26 const llvm_attr = ContextRef.getGlobal().createEnumAttribute(kind_id, 0);
26 const llvm_attr = Context.getGlobal().createEnumAttribute(kind_id, 0);
2727 val.addAttributeAtIndex(index, llvm_attr);
2828 }
2929
30 pub fn addFnAttr(val: *const ValueRef, attr_name: []const u8) void {
30 pub fn addFnAttr(val: *const Value, attr_name: []const u8) void {
3131 // TODO: improve this API, `addAttr(-1, attr_name)`
3232 val.addAttr(std.math.maxInt(LLVMAttributeIndex), attr_name);
3333 }
3434};
3535
36pub const TypeRef = opaque {
36pub const Type = opaque {
3737 pub const functionType = LLVMFunctionType;
38 extern fn LLVMFunctionType(ReturnType: *const TypeRef, ParamTypes: ?[*]*const TypeRef, ParamCount: c_uint, IsVarArg: LLVMBool) *const TypeRef;
38 extern fn LLVMFunctionType(ReturnType: *const Type, ParamTypes: ?[*]*const Type, ParamCount: c_uint, IsVarArg: LLVMBool) *const Type;
3939
4040 pub const constNull = LLVMConstNull;
41 extern fn LLVMConstNull(Ty: *const TypeRef) *const ValueRef;
41 extern fn LLVMConstNull(Ty: *const Type) *const Value;
4242
4343 pub const constAllOnes = LLVMConstAllOnes;
44 extern fn LLVMConstAllOnes(Ty: *const TypeRef) *const ValueRef;
44 extern fn LLVMConstAllOnes(Ty: *const Type) *const Value;
4545
4646 pub const constInt = LLVMConstInt;
47 extern fn LLVMConstInt(IntTy: *const TypeRef, N: c_ulonglong, SignExtend: LLVMBool) *const ValueRef;
47 extern fn LLVMConstInt(IntTy: *const Type, N: c_ulonglong, SignExtend: LLVMBool) *const Value;
4848
4949 pub const constArray = LLVMConstArray;
50 extern fn LLVMConstArray(ElementTy: *const TypeRef, ConstantVals: ?[*]*const ValueRef, Length: c_uint) *const ValueRef;
50 extern fn LLVMConstArray(ElementTy: *const Type, ConstantVals: ?[*]*const Value, Length: c_uint) *const Value;
5151
5252 pub const getUndef = LLVMGetUndef;
53 extern fn LLVMGetUndef(Ty: *const TypeRef) *const ValueRef;
53 extern fn LLVMGetUndef(Ty: *const Type) *const Value;
5454
5555 pub const pointerType = LLVMPointerType;
56 extern fn LLVMPointerType(ElementType: *const TypeRef, AddressSpace: c_uint) *const TypeRef;
56 extern fn LLVMPointerType(ElementType: *const Type, AddressSpace: c_uint) *const Type;
5757
5858 pub const arrayType = LLVMArrayType;
59 extern fn LLVMArrayType(ElementType: *const TypeRef, ElementCount: c_uint) *const TypeRef;
59 extern fn LLVMArrayType(ElementType: *const Type, ElementCount: c_uint) *const Type;
6060};
6161
62pub const ModuleRef = opaque {
62pub const Module = opaque {
6363 pub const createWithName = LLVMModuleCreateWithName;
64 extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const ModuleRef;
64 extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const Module;
6565
6666 pub const disposeModule = LLVMDisposeModule;
67 extern fn LLVMDisposeModule(*const ModuleRef) void;
67 extern fn LLVMDisposeModule(*const Module) void;
6868
6969 pub const verifyModule = LLVMVerifyModule;
70 extern fn LLVMVerifyModule(*const ModuleRef, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) LLVMBool;
70 extern fn LLVMVerifyModule(*const Module, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) LLVMBool;
7171
7272 pub const addFunction = LLVMAddFunction;
73 extern fn LLVMAddFunction(*const ModuleRef, Name: [*:0]const u8, FunctionTy: *const TypeRef) *const ValueRef;
73 extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;
7474
7575 pub const getNamedFunction = LLVMGetNamedFunction;
76 extern fn LLVMGetNamedFunction(*const ModuleRef, Name: [*:0]const u8) ?*const ValueRef;
76 extern fn LLVMGetNamedFunction(*const Module, Name: [*:0]const u8) ?*const Value;
7777
7878 pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration;
79 extern fn LLVMGetIntrinsicDeclaration(Mod: *const ModuleRef, ID: c_uint, ParamTypes: ?[*]*const TypeRef, ParamCount: usize) *const ValueRef;
79 extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]*const Type, ParamCount: usize) *const Value;
8080
8181 pub const printToString = LLVMPrintModuleToString;
82 extern fn LLVMPrintModuleToString(*const ModuleRef) [*:0]const u8;
82 extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8;
8383
8484 pub const addGlobal = LLVMAddGlobal;
85 extern fn LLVMAddGlobal(M: *const ModuleRef, Ty: *const TypeRef, Name: [*:0]const u8) *const ValueRef;
85 extern fn LLVMAddGlobal(M: *const Module, Ty: *const Type, Name: [*:0]const u8) *const Value;
8686
8787 pub const getNamedGlobal = LLVMGetNamedGlobal;
88 extern fn LLVMGetNamedGlobal(M: *const ModuleRef, Name: [*:0]const u8) ?*const ValueRef;
88 extern fn LLVMGetNamedGlobal(M: *const Module, Name: [*:0]const u8) ?*const Value;
8989};
9090
9191pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
......@@ -101,120 +101,120 @@ pub const VerifierFailureAction = extern enum {
101101};
102102
103103pub const constNeg = LLVMConstNeg;
104extern fn LLVMConstNeg(ConstantVal: *const ValueRef) *const ValueRef;
104extern fn LLVMConstNeg(ConstantVal: *const Value) *const Value;
105105
106106pub const constString = LLVMConstString;
107extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const ValueRef;
107extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const Value;
108108
109109pub const setInitializer = LLVMSetInitializer;
110extern fn LLVMSetInitializer(GlobalVar: *const ValueRef, ConstantVal: *const ValueRef) void;
110extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void;
111111
112112pub const voidType = LLVMVoidType;
113extern fn LLVMVoidType() *const TypeRef;
113extern fn LLVMVoidType() *const Type;
114114
115115pub const getParam = LLVMGetParam;
116extern fn LLVMGetParam(Fn: *const ValueRef, Index: c_uint) *const ValueRef;
116extern fn LLVMGetParam(Fn: *const Value, Index: c_uint) *const Value;
117117
118118pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName;
119119extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint;
120120
121pub const AttributeRef = opaque {};
121pub const Attribute = opaque {};
122122
123pub const ContextRef = opaque {
123pub const Context = opaque {
124124 pub const createEnumAttribute = LLVMCreateEnumAttribute;
125 extern fn LLVMCreateEnumAttribute(*const ContextRef, KindID: c_uint, Val: u64) *const AttributeRef;
125 extern fn LLVMCreateEnumAttribute(*const Context, KindID: c_uint, Val: u64) *const Attribute;
126126
127127 pub const getGlobal = LLVMGetGlobalContext;
128 extern fn LLVMGetGlobalContext() *const ContextRef;
128 extern fn LLVMGetGlobalContext() *const Context;
129129};
130130
131131pub const intType = LLVMIntType;
132extern fn LLVMIntType(NumBits: c_uint) *const TypeRef;
132extern fn LLVMIntType(NumBits: c_uint) *const Type;
133133
134pub const BuilderRef = opaque {
134pub const Builder = opaque {
135135 pub const createBuilder = LLVMCreateBuilder;
136 extern fn LLVMCreateBuilder() *const BuilderRef;
136 extern fn LLVMCreateBuilder() *const Builder;
137137
138138 pub const disposeBuilder = LLVMDisposeBuilder;
139 extern fn LLVMDisposeBuilder(Builder: *const BuilderRef) void;
139 extern fn LLVMDisposeBuilder(Builder: *const Builder) void;
140140
141141 pub const positionBuilderAtEnd = LLVMPositionBuilderAtEnd;
142 extern fn LLVMPositionBuilderAtEnd(Builder: *const BuilderRef, Block: *const BasicBlockRef) void;
142 extern fn LLVMPositionBuilderAtEnd(Builder: *const Builder, Block: *const BasicBlock) void;
143143
144144 pub const getInsertBlock = LLVMGetInsertBlock;
145 extern fn LLVMGetInsertBlock(Builder: *const BuilderRef) *const BasicBlockRef;
145 extern fn LLVMGetInsertBlock(Builder: *const Builder) *const BasicBlock;
146146
147147 pub const buildCall = LLVMBuildCall;
148 extern fn LLVMBuildCall(*const BuilderRef, Fn: *const ValueRef, Args: ?[*]*const ValueRef, NumArgs: c_uint, Name: [*:0]const u8) *const ValueRef;
148 extern fn LLVMBuildCall(*const Builder, Fn: *const Value, Args: ?[*]*const Value, NumArgs: c_uint, Name: [*:0]const u8) *const Value;
149149
150150 pub const buildCall2 = LLVMBuildCall2;
151 extern fn LLVMBuildCall2(*const BuilderRef, *const TypeRef, Fn: *const ValueRef, Args: [*]*const ValueRef, NumArgs: c_uint, Name: [*:0]const u8) *const ValueRef;
151 extern fn LLVMBuildCall2(*const Builder, *const Type, Fn: *const Value, Args: [*]*const Value, NumArgs: c_uint, Name: [*:0]const u8) *const Value;
152152
153153 pub const buildRetVoid = LLVMBuildRetVoid;
154 extern fn LLVMBuildRetVoid(*const BuilderRef) *const ValueRef;
154 extern fn LLVMBuildRetVoid(*const Builder) *const Value;
155155
156156 pub const buildRet = LLVMBuildRet;
157 extern fn LLVMBuildRet(*const BuilderRef, V: *const ValueRef) *const ValueRef;
157 extern fn LLVMBuildRet(*const Builder, V: *const Value) *const Value;
158158
159159 pub const buildUnreachable = LLVMBuildUnreachable;
160 extern fn LLVMBuildUnreachable(*const BuilderRef) *const ValueRef;
160 extern fn LLVMBuildUnreachable(*const Builder) *const Value;
161161
162162 pub const buildAlloca = LLVMBuildAlloca;
163 extern fn LLVMBuildAlloca(*const BuilderRef, Ty: *const TypeRef, Name: [*:0]const u8) *const ValueRef;
163 extern fn LLVMBuildAlloca(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value;
164164
165165 pub const buildStore = LLVMBuildStore;
166 extern fn LLVMBuildStore(*const BuilderRef, Val: *const ValueRef, Ptr: *const ValueRef) *const ValueRef;
166 extern fn LLVMBuildStore(*const Builder, Val: *const Value, Ptr: *const Value) *const Value;
167167
168168 pub const buildLoad = LLVMBuildLoad;
169 extern fn LLVMBuildLoad(*const BuilderRef, PointerVal: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
169 extern fn LLVMBuildLoad(*const Builder, PointerVal: *const Value, Name: [*:0]const u8) *const Value;
170170
171171 pub const buildNot = LLVMBuildNot;
172 extern fn LLVMBuildNot(*const BuilderRef, V: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
172 extern fn LLVMBuildNot(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
173173
174174 pub const buildNSWAdd = LLVMBuildNSWAdd;
175 extern fn LLVMBuildNSWAdd(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
175 extern fn LLVMBuildNSWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
176176
177177 pub const buildNUWAdd = LLVMBuildNUWAdd;
178 extern fn LLVMBuildNUWAdd(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
178 extern fn LLVMBuildNUWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
179179
180180 pub const buildNSWSub = LLVMBuildNSWSub;
181 extern fn LLVMBuildNSWSub(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
181 extern fn LLVMBuildNSWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
182182
183183 pub const buildNUWSub = LLVMBuildNUWSub;
184 extern fn LLVMBuildNUWSub(*const BuilderRef, LHS: *const ValueRef, RHS: *const ValueRef, Name: [*:0]const u8) *const ValueRef;
184 extern fn LLVMBuildNUWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
185185
186186 pub const buildIntCast2 = LLVMBuildIntCast2;
187 extern fn LLVMBuildIntCast2(*const BuilderRef, Val: *const ValueRef, DestTy: *const TypeRef, IsSigned: LLVMBool, Name: [*:0]const u8) *const ValueRef;
187 extern fn LLVMBuildIntCast2(*const Builder, Val: *const Value, DestTy: *const Type, IsSigned: LLVMBool, Name: [*:0]const u8) *const Value;
188188
189189 pub const buildBitCast = LLVMBuildBitCast;
190 extern fn LLVMBuildBitCast(*const BuilderRef, Val: *const ValueRef, DestTy: *const TypeRef, Name: [*:0]const u8) *const ValueRef;
190 extern fn LLVMBuildBitCast(*const Builder, Val: *const Value, DestTy: *const Type, Name: [*:0]const u8) *const Value;
191191
192192 pub const buildInBoundsGEP = LLVMBuildInBoundsGEP;
193 extern fn LLVMBuildInBoundsGEP(B: *const BuilderRef, Pointer: *const ValueRef, Indices: [*]*const ValueRef, NumIndices: c_uint, Name: [*:0]const u8) *const ValueRef;
193 extern fn LLVMBuildInBoundsGEP(B: *const Builder, Pointer: *const Value, Indices: [*]*const Value, NumIndices: c_uint, Name: [*:0]const u8) *const Value;
194194};
195195
196pub const BasicBlockRef = opaque {
196pub const BasicBlock = opaque {
197197 pub const deleteBasicBlock = LLVMDeleteBasicBlock;
198 extern fn LLVMDeleteBasicBlock(BB: *const BasicBlockRef) void;
198 extern fn LLVMDeleteBasicBlock(BB: *const BasicBlock) void;
199199};
200200
201pub const TargetMachineRef = opaque {
201pub const TargetMachine = opaque {
202202 pub const createTargetMachine = LLVMCreateTargetMachine;
203203 extern fn LLVMCreateTargetMachine(
204 T: *const TargetRef,
204 T: *const Target,
205205 Triple: [*:0]const u8,
206206 CPU: [*:0]const u8,
207207 Features: [*:0]const u8,
208208 Level: CodeGenOptLevel,
209209 Reloc: RelocMode,
210210 CodeModel: CodeMode,
211 ) *const TargetMachineRef;
211 ) *const TargetMachine;
212212
213213 pub const disposeTargetMachine = LLVMDisposeTargetMachine;
214 extern fn LLVMDisposeTargetMachine(T: *const TargetMachineRef) void;
214 extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void;
215215
216216 pub const emitToFile = LLVMTargetMachineEmitToFile;
217 extern fn LLVMTargetMachineEmitToFile(*const TargetMachineRef, M: *const ModuleRef, Filename: [*:0]const u8, codegen: CodeGenFileType, ErrorMessage: *[*:0]const u8) LLVMBool;
217 extern fn LLVMTargetMachineEmitToFile(*const TargetMachine, M: *const Module, Filename: [*:0]const u8, codegen: CodeGenFileType, ErrorMessage: *[*:0]const u8) LLVMBool;
218218};
219219
220220pub const CodeMode = extern enum {
......@@ -249,9 +249,9 @@ pub const CodeGenFileType = extern enum {
249249 ObjectFile,
250250};
251251
252pub const TargetRef = opaque {
252pub const Target = opaque {
253253 pub const getTargetFromTriple = LLVMGetTargetFromTriple;
254 extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const TargetRef, ErrorMessage: *[*:0]const u8) LLVMBool;
254 extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const Target, ErrorMessage: *[*:0]const u8) LLVMBool;
255255};
256256
257257extern fn LLVMInitializeAArch64TargetInfo() void;