| author | |
| committer | |
| log | 1149cd593e82b338058037c29bcd0e2caaab0dcb |
| tree | ecdb74c93fe068f665b355b5daf2137c3de88be3 |
| parent | 70f6d16ae2d2d9bf8690742c7eba2798b5395174 |
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 { | ... | @@ -139,9 +139,9 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { |
| 139 | 139 | ||
| 140 | pub const LLVMIRModule = struct { | 140 | pub const LLVMIRModule = struct { |
| 141 | module: *Module, | 141 | module: *Module, |
| 142 | llvm_module: *const llvm.ModuleRef, | 142 | llvm_module: *const llvm.Module, |
| 143 | target_machine: *const llvm.TargetMachineRef, | 143 | target_machine: *const llvm.TargetMachine, |
| 144 | builder: *const llvm.BuilderRef, | 144 | builder: *const llvm.Builder, |
| 145 | 145 | ||
| 146 | object_path: []const u8, | 146 | object_path: []const u8, |
| 147 | 147 | ||
| ... | @@ -150,10 +150,10 @@ pub const LLVMIRModule = struct { | ... | @@ -150,10 +150,10 @@ pub const LLVMIRModule = struct { |
| 150 | 150 | ||
| 151 | /// This stores the LLVM values used in a function, such that they can be | 151 | /// This stores the LLVM values used in a function, such that they can be |
| 152 | /// referred to in other instructions. This table is cleared before every function is generated. | 152 | /// 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) = .{}, |
| 154 | 154 | ||
| 155 | /// These fields are used to refer to the LLVM value of the function paramaters in an Arg instruction. | 155 | /// 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{}, |
| 157 | arg_index: usize = 0, | 157 | arg_index: usize = 0, |
| 158 | 158 | ||
| 159 | pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*LLVMIRModule { | 159 | pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*LLVMIRModule { |
| ... | @@ -177,15 +177,15 @@ pub const LLVMIRModule = struct { | ... | @@ -177,15 +177,15 @@ pub const LLVMIRModule = struct { |
| 177 | 177 | ||
| 178 | const root_nameZ = try gpa.dupeZ(u8, options.root_name); | 178 | const root_nameZ = try gpa.dupeZ(u8, options.root_name); |
| 179 | defer gpa.free(root_nameZ); | 179 | 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); |
| 181 | errdefer llvm_module.disposeModule(); | 181 | errdefer llvm_module.disposeModule(); |
| 182 | 182 | ||
| 183 | const llvm_target_triple = try targetTriple(gpa, options.target); | 183 | const llvm_target_triple = try targetTriple(gpa, options.target); |
| 184 | defer gpa.free(llvm_target_triple); | 184 | defer gpa.free(llvm_target_triple); |
| 185 | 185 | ||
| 186 | var error_message: [*:0]const u8 = undefined; | 186 | var error_message: [*:0]const u8 = undefined; |
| 187 | var target_ref: *const llvm.TargetRef = undefined; | 187 | var target: *const llvm.Target = undefined; |
| 188 | if (llvm.TargetRef.getTargetFromTriple(llvm_target_triple.ptr, &target_ref, &error_message)) { | 188 | if (llvm.Target.getTargetFromTriple(llvm_target_triple.ptr, &target, &error_message)) { |
| 189 | defer llvm.disposeMessage(error_message); | 189 | defer llvm.disposeMessage(error_message); |
| 190 | 190 | ||
| 191 | const stderr = std.io.getStdErr().outStream(); | 191 | const stderr = std.io.getStdErr().outStream(); |
| ... | @@ -205,8 +205,8 @@ pub const LLVMIRModule = struct { | ... | @@ -205,8 +205,8 @@ pub const LLVMIRModule = struct { |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | const opt_level: llvm.CodeGenOptLevel = if (options.optimize_mode == .Debug) .None else .Aggressive; | 207 | const opt_level: llvm.CodeGenOptLevel = if (options.optimize_mode == .Debug) .None else .Aggressive; |
| 208 | const target_machine = llvm.TargetMachineRef.createTargetMachine( | 208 | const target_machine = llvm.TargetMachine.createTargetMachine( |
| 209 | target_ref, | 209 | target, |
| 210 | llvm_target_triple.ptr, | 210 | llvm_target_triple.ptr, |
| 211 | "", | 211 | "", |
| 212 | "", | 212 | "", |
| ... | @@ -216,7 +216,7 @@ pub const LLVMIRModule = struct { | ... | @@ -216,7 +216,7 @@ pub const LLVMIRModule = struct { |
| 216 | ); | 216 | ); |
| 217 | errdefer target_machine.disposeTargetMachine(); | 217 | errdefer target_machine.disposeTargetMachine(); |
| 218 | 218 | ||
| 219 | const builder = llvm.BuilderRef.createBuilder(); | 219 | const builder = llvm.Builder.createBuilder(); |
| 220 | errdefer builder.disposeBuilder(); | 220 | errdefer builder.disposeBuilder(); |
| 221 | 221 | ||
| 222 | self.* = .{ | 222 | self.* = .{ |
| ... | @@ -313,7 +313,7 @@ pub const LLVMIRModule = struct { | ... | @@ -313,7 +313,7 @@ pub const LLVMIRModule = struct { |
| 313 | 313 | ||
| 314 | // This gets the LLVM values from the function and stores them in `self.args`. | 314 | // This gets the LLVM values from the function and stores them in `self.args`. |
| 315 | const fn_param_len = func.owner_decl.typed_value.most_recent.typed_value.ty.fnParamLen(); | 315 | 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); |
| 317 | defer self.gpa.free(args); | 317 | defer self.gpa.free(args); |
| 318 | 318 | ||
| 319 | for (args) |*arg, i| { | 319 | for (args) |*arg, i| { |
| ... | @@ -337,7 +337,7 @@ pub const LLVMIRModule = struct { | ... | @@ -337,7 +337,7 @@ pub const LLVMIRModule = struct { |
| 337 | 337 | ||
| 338 | const instructions = func.body.instructions; | 338 | const instructions = func.body.instructions; |
| 339 | for (instructions) |inst| { | 339 | 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) { |
| 341 | .add => try self.genAdd(inst.castTag(.add).?), | 341 | .add => try self.genAdd(inst.castTag(.add).?), |
| 342 | .alloc => try self.genAlloc(inst.castTag(.alloc).?), | 342 | .alloc => try self.genAlloc(inst.castTag(.alloc).?), |
| 343 | .arg => try self.genArg(inst.castTag(.arg).?), | 343 | .arg => try self.genArg(inst.castTag(.arg).?), |
| ... | @@ -367,7 +367,7 @@ pub const LLVMIRModule = struct { | ... | @@ -367,7 +367,7 @@ pub const LLVMIRModule = struct { |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.ValueRef { | 370 | fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !?*const llvm.Value { |
| 371 | if (inst.func.value()) |func_value| { | 371 | if (inst.func.value()) |func_value| { |
| 372 | const fn_decl = if (func_value.castTag(.extern_fn)) |extern_fn| | 372 | const fn_decl = if (func_value.castTag(.extern_fn)) |extern_fn| |
| 373 | extern_fn.data | 373 | extern_fn.data |
| ... | @@ -381,7 +381,7 @@ pub const LLVMIRModule = struct { | ... | @@ -381,7 +381,7 @@ pub const LLVMIRModule = struct { |
| 381 | 381 | ||
| 382 | const num_args = inst.args.len; | 382 | const num_args = inst.args.len; |
| 383 | 383 | ||
| 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); |
| 385 | defer self.gpa.free(llvm_param_vals); | 385 | defer self.gpa.free(llvm_param_vals); |
| 386 | 386 | ||
| 387 | for (inst.args) |arg, i| { | 387 | for (inst.args) |arg, i| { |
| ... | @@ -411,26 +411,26 @@ pub const LLVMIRModule = struct { | ... | @@ -411,26 +411,26 @@ pub const LLVMIRModule = struct { |
| 411 | } | 411 | } |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef { | 414 | fn genRetVoid(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value { |
| 415 | _ = self.builder.buildRetVoid(); | 415 | _ = self.builder.buildRetVoid(); |
| 416 | return null; | 416 | return null; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { | 419 | fn genRet(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { |
| 420 | _ = self.builder.buildRet(try self.resolveInst(inst.operand)); | 420 | _ = self.builder.buildRet(try self.resolveInst(inst.operand)); |
| 421 | return null; | 421 | return null; |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { | 424 | fn genNot(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { |
| 425 | return self.builder.buildNot(try self.resolveInst(inst.operand), ""); | 425 | return self.builder.buildNot(try self.resolveInst(inst.operand), ""); |
| 426 | } | 426 | } |
| 427 | 427 | ||
| 428 | fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.ValueRef { | 428 | fn genUnreach(self: *LLVMIRModule, inst: *Inst.NoOp) ?*const llvm.Value { |
| 429 | _ = self.builder.buildUnreachable(); | 429 | _ = self.builder.buildUnreachable(); |
| 430 | return null; | 430 | return null; |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { | 433 | fn genAdd(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { |
| 434 | const lhs = try self.resolveInst(inst.lhs); | 434 | const lhs = try self.resolveInst(inst.lhs); |
| 435 | const rhs = try self.resolveInst(inst.rhs); | 435 | const rhs = try self.resolveInst(inst.rhs); |
| 436 | 436 | ||
| ... | @@ -443,7 +443,7 @@ pub const LLVMIRModule = struct { | ... | @@ -443,7 +443,7 @@ pub const LLVMIRModule = struct { |
| 443 | self.builder.buildNUWAdd(lhs, rhs, ""); | 443 | self.builder.buildNUWAdd(lhs, rhs, ""); |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { | 446 | fn genSub(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { |
| 447 | const lhs = try self.resolveInst(inst.lhs); | 447 | const lhs = try self.resolveInst(inst.lhs); |
| 448 | const rhs = try self.resolveInst(inst.rhs); | 448 | const rhs = try self.resolveInst(inst.rhs); |
| 449 | 449 | ||
| ... | @@ -456,7 +456,7 @@ pub const LLVMIRModule = struct { | ... | @@ -456,7 +456,7 @@ pub const LLVMIRModule = struct { |
| 456 | self.builder.buildNUWSub(lhs, rhs, ""); | 456 | self.builder.buildNUWSub(lhs, rhs, ""); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { | 459 | fn genIntCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { |
| 460 | const val = try self.resolveInst(inst.operand); | 460 | const val = try self.resolveInst(inst.operand); |
| 461 | 461 | ||
| 462 | const signed = inst.base.ty.isSignedInt(); | 462 | const signed = inst.base.ty.isSignedInt(); |
| ... | @@ -465,14 +465,14 @@ pub const LLVMIRModule = struct { | ... | @@ -465,14 +465,14 @@ pub const LLVMIRModule = struct { |
| 465 | return self.builder.buildIntCast2(val, try self.getLLVMType(inst.base.ty, inst.base.src), signed, ""); | 465 | return self.builder.buildIntCast2(val, try self.getLLVMType(inst.base.ty, inst.base.src), signed, ""); |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { | 468 | fn genBitCast(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { |
| 469 | const val = try self.resolveInst(inst.operand); | 469 | const val = try self.resolveInst(inst.operand); |
| 470 | const dest_type = try self.getLLVMType(inst.base.ty, inst.base.src); | 470 | const dest_type = try self.getLLVMType(inst.base.ty, inst.base.src); |
| 471 | 471 | ||
| 472 | return self.builder.buildBitCast(val, dest_type, ""); | 472 | return self.builder.buildBitCast(val, dest_type, ""); |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.ValueRef { | 475 | fn genArg(self: *LLVMIRModule, inst: *Inst.Arg) !?*const llvm.Value { |
| 476 | const arg_val = self.args[self.arg_index]; | 476 | const arg_val = self.args[self.arg_index]; |
| 477 | self.arg_index += 1; | 477 | self.arg_index += 1; |
| 478 | 478 | ||
| ... | @@ -481,7 +481,7 @@ pub const LLVMIRModule = struct { | ... | @@ -481,7 +481,7 @@ pub const LLVMIRModule = struct { |
| 481 | return self.builder.buildLoad(ptr_val, ""); | 481 | return self.builder.buildLoad(ptr_val, ""); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef { | 484 | fn genAlloc(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value { |
| 485 | // buildAlloca expects the pointee type, not the pointer type, so assert that | 485 | // buildAlloca expects the pointee type, not the pointer type, so assert that |
| 486 | // a Payload.PointerSimple is passed to the alloc instruction. | 486 | // a Payload.PointerSimple is passed to the alloc instruction. |
| 487 | const pointee_type = inst.base.ty.castPointer().?.data; | 487 | const pointee_type = inst.base.ty.castPointer().?.data; |
| ... | @@ -491,25 +491,25 @@ pub const LLVMIRModule = struct { | ... | @@ -491,25 +491,25 @@ pub const LLVMIRModule = struct { |
| 491 | return self.builder.buildAlloca(try self.getLLVMType(pointee_type, inst.base.src), ""); | 491 | return self.builder.buildAlloca(try self.getLLVMType(pointee_type, inst.base.src), ""); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.ValueRef { | 494 | fn genStore(self: *LLVMIRModule, inst: *Inst.BinOp) !?*const llvm.Value { |
| 495 | const val = try self.resolveInst(inst.rhs); | 495 | const val = try self.resolveInst(inst.rhs); |
| 496 | const ptr = try self.resolveInst(inst.lhs); | 496 | const ptr = try self.resolveInst(inst.lhs); |
| 497 | _ = self.builder.buildStore(val, ptr); | 497 | _ = self.builder.buildStore(val, ptr); |
| 498 | return null; | 498 | return null; |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { | 501 | fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.Value { |
| 502 | const ptr_val = try self.resolveInst(inst.operand); | 502 | const ptr_val = try self.resolveInst(inst.operand); |
| 503 | return self.builder.buildLoad(ptr_val, ""); | 503 | return self.builder.buildLoad(ptr_val, ""); |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef { | 506 | fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.Value { |
| 507 | const llvn_fn = self.getIntrinsic("llvm.debugtrap"); | 507 | const llvn_fn = self.getIntrinsic("llvm.debugtrap"); |
| 508 | _ = self.builder.buildCall(llvn_fn, null, 0, ""); | 508 | _ = self.builder.buildCall(llvn_fn, null, 0, ""); |
| 509 | return null; | 509 | return null; |
| 510 | } | 510 | } |
| 511 | 511 | ||
| 512 | fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.ValueRef { | 512 | fn getIntrinsic(self: *LLVMIRModule, name: []const u8) *const llvm.Value { |
| 513 | const id = llvm.lookupIntrinsicID(name.ptr, name.len); | 513 | const id = llvm.lookupIntrinsicID(name.ptr, name.len); |
| 514 | assert(id != 0); | 514 | assert(id != 0); |
| 515 | // TODO: add support for overload intrinsics by passing the prefix of the intrinsic | 515 | // TODO: add support for overload intrinsics by passing the prefix of the intrinsic |
| ... | @@ -518,7 +518,7 @@ pub const LLVMIRModule = struct { | ... | @@ -518,7 +518,7 @@ pub const LLVMIRModule = struct { |
| 518 | return self.llvm_module.getIntrinsicDeclaration(id, null, 0); | 518 | return self.llvm_module.getIntrinsicDeclaration(id, null, 0); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.ValueRef { | 521 | fn resolveInst(self: *LLVMIRModule, inst: *ir.Inst) !*const llvm.Value { |
| 522 | if (inst.value()) |val| { | 522 | if (inst.value()) |val| { |
| 523 | return self.genTypedValue(inst.src, .{ .ty = inst.ty, .val = val }); | 523 | return self.genTypedValue(inst.src, .{ .ty = inst.ty, .val = val }); |
| 524 | } | 524 | } |
| ... | @@ -527,7 +527,7 @@ pub const LLVMIRModule = struct { | ... | @@ -527,7 +527,7 @@ pub const LLVMIRModule = struct { |
| 527 | return self.fail(inst.src, "TODO implement global llvm values (or the value is not in the func_inst_table table)", .{}); | 527 | return self.fail(inst.src, "TODO implement global llvm values (or the value is not in the func_inst_table table)", .{}); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 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 { |
| 531 | const llvm_type = try self.getLLVMType(tv.ty, src); | 531 | const llvm_type = try self.getLLVMType(tv.ty, src); |
| 532 | 532 | ||
| 533 | if (tv.val.isUndef()) | 533 | if (tv.val.isUndef()) |
| ... | @@ -558,7 +558,7 @@ pub const LLVMIRModule = struct { | ... | @@ -558,7 +558,7 @@ pub const LLVMIRModule = struct { |
| 558 | const usize_type = try self.getLLVMType(Type.initTag(.usize), src); | 558 | const usize_type = try self.getLLVMType(Type.initTag(.usize), src); |
| 559 | 559 | ||
| 560 | // TODO: second index should be the index into the memory! | 560 | // TODO: second index should be the index into the memory! |
| 561 | var indices: [2]*const llvm.ValueRef = .{ | 561 | var indices: [2]*const llvm.Value = .{ |
| 562 | usize_type.constNull(), | 562 | usize_type.constNull(), |
| 563 | usize_type.constNull(), | 563 | usize_type.constNull(), |
| 564 | }; | 564 | }; |
| ... | @@ -584,7 +584,7 @@ pub const LLVMIRModule = struct { | ... | @@ -584,7 +584,7 @@ pub const LLVMIRModule = struct { |
| 584 | } | 584 | } |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 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 { |
| 588 | switch (t.zigTypeTag()) { | 588 | switch (t.zigTypeTag()) { |
| 589 | .Void => return llvm.voidType(), | 589 | .Void => return llvm.voidType(), |
| 590 | .NoReturn => return llvm.voidType(), | 590 | .NoReturn => return llvm.voidType(), |
| ... | @@ -609,7 +609,7 @@ pub const LLVMIRModule = struct { | ... | @@ -609,7 +609,7 @@ pub const LLVMIRModule = struct { |
| 609 | } | 609 | } |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 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 { |
| 613 | // TODO: do we want to store this in our own datastructure? | 613 | // TODO: do we want to store this in our own datastructure? |
| 614 | if (self.llvm_module.getNamedGlobal(decl.name)) |val| return val; | 614 | if (self.llvm_module.getNamedGlobal(decl.name)) |val| return val; |
| 615 | 615 | ||
| ... | @@ -628,7 +628,7 @@ pub const LLVMIRModule = struct { | ... | @@ -628,7 +628,7 @@ pub const LLVMIRModule = struct { |
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | /// If the llvm function does not exist, create it | 630 | /// 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 { |
| 632 | // TODO: do we want to store this in our own datastructure? | 632 | // TODO: do we want to store this in our own datastructure? |
| 633 | if (self.llvm_module.getNamedFunction(func.name)) |llvm_fn| return llvm_fn; | 633 | if (self.llvm_module.getNamedFunction(func.name)) |llvm_fn| return llvm_fn; |
| 634 | 634 | ||
| ... | @@ -641,14 +641,14 @@ pub const LLVMIRModule = struct { | ... | @@ -641,14 +641,14 @@ pub const LLVMIRModule = struct { |
| 641 | defer self.gpa.free(fn_param_types); | 641 | defer self.gpa.free(fn_param_types); |
| 642 | zig_fn_type.fnParamTypes(fn_param_types); | 642 | zig_fn_type.fnParamTypes(fn_param_types); |
| 643 | 643 | ||
| 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); |
| 645 | defer self.gpa.free(llvm_param); | 645 | defer self.gpa.free(llvm_param); |
| 646 | 646 | ||
| 647 | for (fn_param_types) |fn_param, i| { | 647 | for (fn_param_types) |fn_param, i| { |
| 648 | llvm_param[i] = try self.getLLVMType(fn_param, src); | 648 | llvm_param[i] = try self.getLLVMType(fn_param, src); |
| 649 | } | 649 | } |
| 650 | 650 | ||
| 651 | const fn_type = llvm.TypeRef.functionType( | 651 | const fn_type = llvm.Type.functionType( |
| 652 | try self.getLLVMType(return_type, src), | 652 | try self.getLLVMType(return_type, src), |
| 653 | if (fn_param_len == 0) null else llvm_param.ptr, | 653 | if (fn_param_len == 0) null else llvm_param.ptr, |
| 654 | @intCast(c_uint, fn_param_len), | 654 | @intCast(c_uint, fn_param_len), |
src/llvm_bindings.zig+67-67| ... | @@ -7,85 +7,85 @@ const assert = std.debug.assert; | ... | @@ -7,85 +7,85 @@ const assert = std.debug.assert; |
| 7 | const LLVMBool = bool; | 7 | const LLVMBool = bool; |
| 8 | pub const LLVMAttributeIndex = c_uint; | 8 | pub const LLVMAttributeIndex = c_uint; |
| 9 | 9 | ||
| 10 | pub const ValueRef = opaque { | 10 | pub const Value = opaque { |
| 11 | pub const addAttributeAtIndex = LLVMAddAttributeAtIndex; | 11 | 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; |
| 13 | 13 | ||
| 14 | pub const appendBasicBlock = LLVMAppendBasicBlock; | 14 | 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; |
| 16 | 16 | ||
| 17 | pub const getFirstBasicBlock = LLVMGetFirstBasicBlock; | 17 | pub const getFirstBasicBlock = LLVMGetFirstBasicBlock; |
| 18 | extern fn LLVMGetFirstBasicBlock(Fn: *const ValueRef) ?*const BasicBlockRef; | 18 | extern fn LLVMGetFirstBasicBlock(Fn: *const Value) ?*const BasicBlock; |
| 19 | 19 | ||
| 20 | // Helper functions | 20 | // Helper functions |
| 21 | // TODO: Do we want to put these functions here? It allows for convienient function calls | 21 | // TODO: Do we want to put these functions here? It allows for convienient function calls |
| 22 | // on ValueRef: llvm_fn.addFnAttr("noreturn") | 22 | // on Value: llvm_fn.addFnAttr("noreturn") |
| 23 | fn addAttr(val: *const ValueRef, index: LLVMAttributeIndex, name: []const u8) void { | 23 | fn addAttr(val: *const Value, index: LLVMAttributeIndex, name: []const u8) void { |
| 24 | const kind_id = getEnumAttributeKindForName(name.ptr, name.len); | 24 | const kind_id = getEnumAttributeKindForName(name.ptr, name.len); |
| 25 | assert(kind_id != 0); | 25 | assert(kind_id != 0); |
| 26 | const llvm_attr = ContextRef.getGlobal().createEnumAttribute(kind_id, 0); | 26 | const llvm_attr = Context.getGlobal().createEnumAttribute(kind_id, 0); |
| 27 | val.addAttributeAtIndex(index, llvm_attr); | 27 | val.addAttributeAtIndex(index, llvm_attr); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn addFnAttr(val: *const ValueRef, attr_name: []const u8) void { | 30 | pub fn addFnAttr(val: *const Value, attr_name: []const u8) void { |
| 31 | // TODO: improve this API, `addAttr(-1, attr_name)` | 31 | // TODO: improve this API, `addAttr(-1, attr_name)` |
| 32 | val.addAttr(std.math.maxInt(LLVMAttributeIndex), attr_name); | 32 | val.addAttr(std.math.maxInt(LLVMAttributeIndex), attr_name); |
| 33 | } | 33 | } |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | pub const TypeRef = opaque { | 36 | pub const Type = opaque { |
| 37 | pub const functionType = LLVMFunctionType; | 37 | 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; |
| 39 | 39 | ||
| 40 | pub const constNull = LLVMConstNull; | 40 | pub const constNull = LLVMConstNull; |
| 41 | extern fn LLVMConstNull(Ty: *const TypeRef) *const ValueRef; | 41 | extern fn LLVMConstNull(Ty: *const Type) *const Value; |
| 42 | 42 | ||
| 43 | pub const constAllOnes = LLVMConstAllOnes; | 43 | pub const constAllOnes = LLVMConstAllOnes; |
| 44 | extern fn LLVMConstAllOnes(Ty: *const TypeRef) *const ValueRef; | 44 | extern fn LLVMConstAllOnes(Ty: *const Type) *const Value; |
| 45 | 45 | ||
| 46 | pub const constInt = LLVMConstInt; | 46 | 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; |
| 48 | 48 | ||
| 49 | pub const constArray = LLVMConstArray; | 49 | 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; |
| 51 | 51 | ||
| 52 | pub const getUndef = LLVMGetUndef; | 52 | pub const getUndef = LLVMGetUndef; |
| 53 | extern fn LLVMGetUndef(Ty: *const TypeRef) *const ValueRef; | 53 | extern fn LLVMGetUndef(Ty: *const Type) *const Value; |
| 54 | 54 | ||
| 55 | pub const pointerType = LLVMPointerType; | 55 | 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; |
| 57 | 57 | ||
| 58 | pub const arrayType = LLVMArrayType; | 58 | 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; |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | pub const ModuleRef = opaque { | 62 | pub const Module = opaque { |
| 63 | pub const createWithName = LLVMModuleCreateWithName; | 63 | pub const createWithName = LLVMModuleCreateWithName; |
| 64 | extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const ModuleRef; | 64 | extern fn LLVMModuleCreateWithName(ModuleID: [*:0]const u8) *const Module; |
| 65 | 65 | ||
| 66 | pub const disposeModule = LLVMDisposeModule; | 66 | pub const disposeModule = LLVMDisposeModule; |
| 67 | extern fn LLVMDisposeModule(*const ModuleRef) void; | 67 | extern fn LLVMDisposeModule(*const Module) void; |
| 68 | 68 | ||
| 69 | pub const verifyModule = LLVMVerifyModule; | 69 | 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; |
| 71 | 71 | ||
| 72 | pub const addFunction = LLVMAddFunction; | 72 | 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; |
| 74 | 74 | ||
| 75 | pub const getNamedFunction = LLVMGetNamedFunction; | 75 | 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; |
| 77 | 77 | ||
| 78 | pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration; | 78 | 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; |
| 80 | 80 | ||
| 81 | pub const printToString = LLVMPrintModuleToString; | 81 | pub const printToString = LLVMPrintModuleToString; |
| 82 | extern fn LLVMPrintModuleToString(*const ModuleRef) [*:0]const u8; | 82 | extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8; |
| 83 | 83 | ||
| 84 | pub const addGlobal = LLVMAddGlobal; | 84 | 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; |
| 86 | 86 | ||
| 87 | pub const getNamedGlobal = LLVMGetNamedGlobal; | 87 | 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; |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| 91 | pub const lookupIntrinsicID = LLVMLookupIntrinsicID; | 91 | pub const lookupIntrinsicID = LLVMLookupIntrinsicID; |
| ... | @@ -101,120 +101,120 @@ pub const VerifierFailureAction = extern enum { | ... | @@ -101,120 +101,120 @@ pub const VerifierFailureAction = extern enum { |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | pub const constNeg = LLVMConstNeg; | 103 | pub const constNeg = LLVMConstNeg; |
| 104 | extern fn LLVMConstNeg(ConstantVal: *const ValueRef) *const ValueRef; | 104 | extern fn LLVMConstNeg(ConstantVal: *const Value) *const Value; |
| 105 | 105 | ||
| 106 | pub const constString = LLVMConstString; | 106 | pub const constString = LLVMConstString; |
| 107 | extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const ValueRef; | 107 | extern fn LLVMConstString(Str: [*]const u8, Length: c_uint, DontNullTerminate: LLVMBool) *const Value; |
| 108 | 108 | ||
| 109 | pub const setInitializer = LLVMSetInitializer; | 109 | pub const setInitializer = LLVMSetInitializer; |
| 110 | extern fn LLVMSetInitializer(GlobalVar: *const ValueRef, ConstantVal: *const ValueRef) void; | 110 | extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void; |
| 111 | 111 | ||
| 112 | pub const voidType = LLVMVoidType; | 112 | pub const voidType = LLVMVoidType; |
| 113 | extern fn LLVMVoidType() *const TypeRef; | 113 | extern fn LLVMVoidType() *const Type; |
| 114 | 114 | ||
| 115 | pub const getParam = LLVMGetParam; | 115 | pub const getParam = LLVMGetParam; |
| 116 | extern fn LLVMGetParam(Fn: *const ValueRef, Index: c_uint) *const ValueRef; | 116 | extern fn LLVMGetParam(Fn: *const Value, Index: c_uint) *const Value; |
| 117 | 117 | ||
| 118 | pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName; | 118 | pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName; |
| 119 | extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint; | 119 | extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint; |
| 120 | 120 | ||
| 121 | pub const AttributeRef = opaque {}; | 121 | pub const Attribute = opaque {}; |
| 122 | 122 | ||
| 123 | pub const ContextRef = opaque { | 123 | pub const Context = opaque { |
| 124 | pub const createEnumAttribute = LLVMCreateEnumAttribute; | 124 | 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; |
| 126 | 126 | ||
| 127 | pub const getGlobal = LLVMGetGlobalContext; | 127 | pub const getGlobal = LLVMGetGlobalContext; |
| 128 | extern fn LLVMGetGlobalContext() *const ContextRef; | 128 | extern fn LLVMGetGlobalContext() *const Context; |
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | pub const intType = LLVMIntType; | 131 | pub const intType = LLVMIntType; |
| 132 | extern fn LLVMIntType(NumBits: c_uint) *const TypeRef; | 132 | extern fn LLVMIntType(NumBits: c_uint) *const Type; |
| 133 | 133 | ||
| 134 | pub const BuilderRef = opaque { | 134 | pub const Builder = opaque { |
| 135 | pub const createBuilder = LLVMCreateBuilder; | 135 | pub const createBuilder = LLVMCreateBuilder; |
| 136 | extern fn LLVMCreateBuilder() *const BuilderRef; | 136 | extern fn LLVMCreateBuilder() *const Builder; |
| 137 | 137 | ||
| 138 | pub const disposeBuilder = LLVMDisposeBuilder; | 138 | pub const disposeBuilder = LLVMDisposeBuilder; |
| 139 | extern fn LLVMDisposeBuilder(Builder: *const BuilderRef) void; | 139 | extern fn LLVMDisposeBuilder(Builder: *const Builder) void; |
| 140 | 140 | ||
| 141 | pub const positionBuilderAtEnd = LLVMPositionBuilderAtEnd; | 141 | 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; |
| 143 | 143 | ||
| 144 | pub const getInsertBlock = LLVMGetInsertBlock; | 144 | pub const getInsertBlock = LLVMGetInsertBlock; |
| 145 | extern fn LLVMGetInsertBlock(Builder: *const BuilderRef) *const BasicBlockRef; | 145 | extern fn LLVMGetInsertBlock(Builder: *const Builder) *const BasicBlock; |
| 146 | 146 | ||
| 147 | pub const buildCall = LLVMBuildCall; | 147 | 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; |
| 149 | 149 | ||
| 150 | pub const buildCall2 = LLVMBuildCall2; | 150 | 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; |
| 152 | 152 | ||
| 153 | pub const buildRetVoid = LLVMBuildRetVoid; | 153 | pub const buildRetVoid = LLVMBuildRetVoid; |
| 154 | extern fn LLVMBuildRetVoid(*const BuilderRef) *const ValueRef; | 154 | extern fn LLVMBuildRetVoid(*const Builder) *const Value; |
| 155 | 155 | ||
| 156 | pub const buildRet = LLVMBuildRet; | 156 | 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; |
| 158 | 158 | ||
| 159 | pub const buildUnreachable = LLVMBuildUnreachable; | 159 | pub const buildUnreachable = LLVMBuildUnreachable; |
| 160 | extern fn LLVMBuildUnreachable(*const BuilderRef) *const ValueRef; | 160 | extern fn LLVMBuildUnreachable(*const Builder) *const Value; |
| 161 | 161 | ||
| 162 | pub const buildAlloca = LLVMBuildAlloca; | 162 | 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; |
| 164 | 164 | ||
| 165 | pub const buildStore = LLVMBuildStore; | 165 | 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; |
| 167 | 167 | ||
| 168 | pub const buildLoad = LLVMBuildLoad; | 168 | 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; |
| 170 | 170 | ||
| 171 | pub const buildNot = LLVMBuildNot; | 171 | 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; |
| 173 | 173 | ||
| 174 | pub const buildNSWAdd = LLVMBuildNSWAdd; | 174 | 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; |
| 176 | 176 | ||
| 177 | pub const buildNUWAdd = LLVMBuildNUWAdd; | 177 | 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; |
| 179 | 179 | ||
| 180 | pub const buildNSWSub = LLVMBuildNSWSub; | 180 | 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; |
| 182 | 182 | ||
| 183 | pub const buildNUWSub = LLVMBuildNUWSub; | 183 | 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; |
| 185 | 185 | ||
| 186 | pub const buildIntCast2 = LLVMBuildIntCast2; | 186 | 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; |
| 188 | 188 | ||
| 189 | pub const buildBitCast = LLVMBuildBitCast; | 189 | 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; |
| 191 | 191 | ||
| 192 | pub const buildInBoundsGEP = LLVMBuildInBoundsGEP; | 192 | 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; |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| 196 | pub const BasicBlockRef = opaque { | 196 | pub const BasicBlock = opaque { |
| 197 | pub const deleteBasicBlock = LLVMDeleteBasicBlock; | 197 | pub const deleteBasicBlock = LLVMDeleteBasicBlock; |
| 198 | extern fn LLVMDeleteBasicBlock(BB: *const BasicBlockRef) void; | 198 | extern fn LLVMDeleteBasicBlock(BB: *const BasicBlock) void; |
| 199 | }; | 199 | }; |
| 200 | 200 | ||
| 201 | pub const TargetMachineRef = opaque { | 201 | pub const TargetMachine = opaque { |
| 202 | pub const createTargetMachine = LLVMCreateTargetMachine; | 202 | pub const createTargetMachine = LLVMCreateTargetMachine; |
| 203 | extern fn LLVMCreateTargetMachine( | 203 | extern fn LLVMCreateTargetMachine( |
| 204 | T: *const TargetRef, | 204 | T: *const Target, |
| 205 | Triple: [*:0]const u8, | 205 | Triple: [*:0]const u8, |
| 206 | CPU: [*:0]const u8, | 206 | CPU: [*:0]const u8, |
| 207 | Features: [*:0]const u8, | 207 | Features: [*:0]const u8, |
| 208 | Level: CodeGenOptLevel, | 208 | Level: CodeGenOptLevel, |
| 209 | Reloc: RelocMode, | 209 | Reloc: RelocMode, |
| 210 | CodeModel: CodeMode, | 210 | CodeModel: CodeMode, |
| 211 | ) *const TargetMachineRef; | 211 | ) *const TargetMachine; |
| 212 | 212 | ||
| 213 | pub const disposeTargetMachine = LLVMDisposeTargetMachine; | 213 | pub const disposeTargetMachine = LLVMDisposeTargetMachine; |
| 214 | extern fn LLVMDisposeTargetMachine(T: *const TargetMachineRef) void; | 214 | extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void; |
| 215 | 215 | ||
| 216 | pub const emitToFile = LLVMTargetMachineEmitToFile; | 216 | 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; |
| 218 | }; | 218 | }; |
| 219 | 219 | ||
| 220 | pub const CodeMode = extern enum { | 220 | pub const CodeMode = extern enum { |
| ... | @@ -249,9 +249,9 @@ pub const CodeGenFileType = extern enum { | ... | @@ -249,9 +249,9 @@ pub const CodeGenFileType = extern enum { |
| 249 | ObjectFile, | 249 | ObjectFile, |
| 250 | }; | 250 | }; |
| 251 | 251 | ||
| 252 | pub const TargetRef = opaque { | 252 | pub const Target = opaque { |
| 253 | pub const getTargetFromTriple = LLVMGetTargetFromTriple; | 253 | 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; |
| 255 | }; | 255 | }; |
| 256 | 256 | ||
| 257 | extern fn LLVMInitializeAArch64TargetInfo() void; | 257 | extern fn LLVMInitializeAArch64TargetInfo() void; |