authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-09-21 13:26:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-09-21 13:27:23-07:00
log99b954b9ce1cf096490a1e4bb4d316420a13c297
tree1871cf856d4d1604200254d85780a0223af4f2a0
parent4961044ce8d06f43bf6f43c103433d70a1fbd79a

LLVM: remove purposeless const qualifiers

These const qualifiers on pointers to opaque types do not serve any purpose. If anything they are misleading since the underlying pointers very likely point to objects that are in fact mutated. This commit does not change any behavior.

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

src/codegen/llvm.zig+346-346
......@@ -316,7 +316,7 @@ pub fn supportsTailCall(target: std.Target) bool {
316316}
317317
318318/// TODO can this be done with simpler logic / different API binding?
319fn deleteLlvmGlobal(llvm_global: *const llvm.Value) void {
319fn deleteLlvmGlobal(llvm_global: *llvm.Value) void {
320320 if (llvm_global.globalGetValueType().getTypeKind() == .Function) {
321321 llvm_global.deleteFunction();
322322 return;
......@@ -327,7 +327,7 @@ fn deleteLlvmGlobal(llvm_global: *const llvm.Value) void {
327327pub const Object = struct {
328328 gpa: Allocator,
329329 module: *Module,
330 llvm_module: *const llvm.Module,
330 llvm_module: *llvm.Module,
331331 di_builder: ?*llvm.DIBuilder,
332332 /// One of these mappings:
333333 /// - *Module.File => *DIFile
......@@ -335,9 +335,9 @@ pub const Object = struct {
335335 /// - *Module.Decl (Non-Fn) => *DIGlobalVariable
336336 di_map: std.AutoHashMapUnmanaged(*const anyopaque, *llvm.DINode),
337337 di_compile_unit: ?*llvm.DICompileUnit,
338 context: *const llvm.Context,
339 target_machine: *const llvm.TargetMachine,
340 target_data: *const llvm.TargetData,
338 context: *llvm.Context,
339 target_machine: *llvm.TargetMachine,
340 target_data: *llvm.TargetData,
341341 target: std.Target,
342342 /// Ideally we would use `llvm_module.getNamedFunction` to go from *Decl to LLVM function,
343343 /// but that has some downsides:
......@@ -347,9 +347,9 @@ pub const Object = struct {
347347 /// version of the name and incorrectly get function not found in the llvm module.
348348 /// * it works for functions not all globals.
349349 /// Therefore, this table keeps track of the mapping.
350 decl_map: std.AutoHashMapUnmanaged(Module.Decl.Index, *const llvm.Value),
350 decl_map: std.AutoHashMapUnmanaged(Module.Decl.Index, *llvm.Value),
351351 /// Serves the same purpose as `decl_map` but only used for the `is_named_enum_value` instruction.
352 named_enum_map: std.AutoHashMapUnmanaged(Module.Decl.Index, *const llvm.Value),
352 named_enum_map: std.AutoHashMapUnmanaged(Module.Decl.Index, *llvm.Value),
353353 /// Maps Zig types to LLVM types. The table memory itself is backed by the GPA of
354354 /// the compiler, but the Type/Value memory here is backed by `type_map_arena`.
355355 /// TODO we need to remove entries from this map in response to incremental compilation
......@@ -363,7 +363,7 @@ pub const Object = struct {
363363 /// The LLVM global table which holds the names corresponding to Zig errors.
364364 /// Note that the values are not added until flushModule, when all errors in
365365 /// the compilation are known.
366 error_name_table: ?*const llvm.Value,
366 error_name_table: ?*llvm.Value,
367367 /// This map is usually very close to empty. It tracks only the cases when a
368368 /// second extern Decl could not be emitted with the correct name due to a
369369 /// name collision.
......@@ -371,7 +371,7 @@ pub const Object = struct {
371371
372372 pub const TypeMap = std.HashMapUnmanaged(
373373 Type,
374 *const llvm.Type,
374 *llvm.Type,
375375 Type.HashContext64,
376376 std.hash_map.default_max_load_percentage,
377377 );
......@@ -405,7 +405,7 @@ pub const Object = struct {
405405 defer gpa.free(llvm_target_triple);
406406
407407 var error_message: [*:0]const u8 = undefined;
408 var target: *const llvm.Target = undefined;
408 var target: *llvm.Target = undefined;
409409 if (llvm.Target.getFromTriple(llvm_target_triple.ptr, &target, &error_message).toBool()) {
410410 defer llvm.disposeMessage(error_message);
411411
......@@ -578,7 +578,7 @@ pub const Object = struct {
578578
579579 const llvm_ptr_ty = self.context.intType(8).pointerType(0); // TODO: Address space
580580 const llvm_usize_ty = self.context.intType(target.cpu.arch.ptrBitWidth());
581 const type_fields = [_]*const llvm.Type{
581 const type_fields = [_]*llvm.Type{
582582 llvm_ptr_ty,
583583 llvm_usize_ty,
584584 };
......@@ -587,7 +587,7 @@ pub const Object = struct {
587587 const slice_alignment = slice_ty.abiAlignment(target);
588588
589589 const error_name_list = mod.error_name_list.items;
590 const llvm_errors = try mod.gpa.alloc(*const llvm.Value, error_name_list.len);
590 const llvm_errors = try mod.gpa.alloc(*llvm.Value, error_name_list.len);
591591 defer mod.gpa.free(llvm_errors);
592592
593593 llvm_errors[0] = llvm_slice_ty.getUndef();
......@@ -601,7 +601,7 @@ pub const Object = struct {
601601 str_global.setUnnamedAddr(.True);
602602 str_global.setAlignment(1);
603603
604 const slice_fields = [_]*const llvm.Value{
604 const slice_fields = [_]*llvm.Value{
605605 str_global.constBitCast(llvm_ptr_ty),
606606 llvm_usize_ty.constInt(name.len, .False),
607607 };
......@@ -911,7 +911,7 @@ pub const Object = struct {
911911 // This is the list of args we will use that correspond directly to the AIR arg
912912 // instructions. Depending on the calling convention, this list is not necessarily
913913 // a bijection with the actual LLVM parameters of the function.
914 var args = std.ArrayList(*const llvm.Value).init(gpa);
914 var args = std.ArrayList(*llvm.Value).init(gpa);
915915 defer args.deinit();
916916
917917 {
......@@ -1028,7 +1028,7 @@ pub const Object = struct {
10281028 const param_alignment = param_ty.abiAlignment(target);
10291029 const arg_ptr = buildAllocaInner(builder, llvm_func, false, param_llvm_ty);
10301030 arg_ptr.setAlignment(param_alignment);
1031 var field_types_buf: [8]*const llvm.Type = undefined;
1031 var field_types_buf: [8]*llvm.Type = undefined;
10321032 const field_types = field_types_buf[0..llvm_ints.len];
10331033 for (llvm_ints) |int_bits, i| {
10341034 field_types[i] = dg.context.intType(int_bits);
......@@ -1059,7 +1059,7 @@ pub const Object = struct {
10591059 const param_alignment = param_ty.abiAlignment(target);
10601060 const arg_ptr = buildAllocaInner(builder, llvm_func, false, param_llvm_ty);
10611061 arg_ptr.setAlignment(param_alignment);
1062 var field_types_buf: [8]*const llvm.Type = undefined;
1062 var field_types_buf: [8]*llvm.Type = undefined;
10631063 const field_types = field_types_buf[0..llvm_floats.len];
10641064 for (llvm_floats) |float_bits, i| {
10651065 switch (float_bits) {
......@@ -1215,7 +1215,7 @@ pub const Object = struct {
12151215
12161216 /// TODO replace this with a call to `Module::getNamedValue`. This will require adding
12171217 /// a new wrapper in zig_llvm.h/zig_llvm.cpp.
1218 fn getLlvmGlobal(o: Object, name: [*:0]const u8) ?*const llvm.Value {
1218 fn getLlvmGlobal(o: Object, name: [*:0]const u8) ?*llvm.Value {
12191219 if (o.llvm_module.getNamedFunction(name)) |x| return x;
12201220 if (o.llvm_module.getNamedGlobal(name)) |x| return x;
12211221 return null;
......@@ -2338,7 +2338,7 @@ pub const Object = struct {
23382338};
23392339
23402340pub const DeclGen = struct {
2341 context: *const llvm.Context,
2341 context: *llvm.Context,
23422342 object: *Object,
23432343 module: *Module,
23442344 decl: *Module.Decl,
......@@ -2354,7 +2354,7 @@ pub const DeclGen = struct {
23542354 return error.CodegenFail;
23552355 }
23562356
2357 fn llvmModule(self: *DeclGen) *const llvm.Module {
2357 fn llvmModule(self: *DeclGen) *llvm.Module {
23582358 return self.object.llvm_module;
23592359 }
23602360
......@@ -2444,7 +2444,7 @@ pub const DeclGen = struct {
24442444 /// If the llvm function does not exist, create it.
24452445 /// Note that this can be called before the function's semantic analysis has
24462446 /// completed, so if any attributes rely on that, they must be done in updateFunc, not here.
2447 fn resolveLlvmFunction(dg: *DeclGen, decl_index: Module.Decl.Index) !*const llvm.Value {
2447 fn resolveLlvmFunction(dg: *DeclGen, decl_index: Module.Decl.Index) !*llvm.Value {
24482448 const decl = dg.module.declPtr(decl_index);
24492449 const zig_fn_type = decl.ty;
24502450 const gop = try dg.object.decl_map.getOrPut(dg.gpa, decl_index);
......@@ -2559,7 +2559,7 @@ pub const DeclGen = struct {
25592559 return llvm_fn;
25602560 }
25612561
2562 fn addCommonFnAttributes(dg: *DeclGen, llvm_fn: *const llvm.Value) void {
2562 fn addCommonFnAttributes(dg: *DeclGen, llvm_fn: *llvm.Value) void {
25632563 const comp = dg.module.comp;
25642564
25652565 if (!comp.bin_file.options.red_zone) {
......@@ -2599,7 +2599,7 @@ pub const DeclGen = struct {
25992599 }
26002600 }
26012601
2602 fn resolveGlobalDecl(dg: *DeclGen, decl_index: Module.Decl.Index) Error!*const llvm.Value {
2602 fn resolveGlobalDecl(dg: *DeclGen, decl_index: Module.Decl.Index) Error!*llvm.Value {
26032603 const gop = try dg.object.decl_map.getOrPut(dg.gpa, decl_index);
26042604 if (gop.found_existing) return gop.value_ptr.*;
26052605 errdefer assert(dg.object.decl_map.remove(decl_index));
......@@ -2661,7 +2661,7 @@ pub const DeclGen = struct {
26612661 };
26622662 }
26632663
2664 fn isUnnamedType(dg: *DeclGen, ty: Type, val: *const llvm.Value) bool {
2664 fn isUnnamedType(dg: *DeclGen, ty: Type, val: *llvm.Value) bool {
26652665 // Once `lowerType` succeeds, successive calls to it with the same Zig type
26662666 // are guaranteed to succeed. So if a call to `lowerType` fails here it means
26672667 // it is the first time lowering the type, which means the value can't possible
......@@ -2670,7 +2670,7 @@ pub const DeclGen = struct {
26702670 return val.typeOf() != llvm_ty;
26712671 }
26722672
2673 fn lowerType(dg: *DeclGen, t: Type) Allocator.Error!*const llvm.Type {
2673 fn lowerType(dg: *DeclGen, t: Type) Allocator.Error!*llvm.Type {
26742674 const llvm_ty = try lowerTypeInner(dg, t);
26752675 if (std.debug.runtime_safety and false) check: {
26762676 if (t.zigTypeTag() == .Opaque) break :check;
......@@ -2688,7 +2688,7 @@ pub const DeclGen = struct {
26882688 return llvm_ty;
26892689 }
26902690
2691 fn lowerTypeInner(dg: *DeclGen, t: Type) Allocator.Error!*const llvm.Type {
2691 fn lowerTypeInner(dg: *DeclGen, t: Type) Allocator.Error!*llvm.Type {
26922692 const gpa = dg.gpa;
26932693 const target = dg.module.getTarget();
26942694 switch (t.zigTypeTag()) {
......@@ -2719,7 +2719,7 @@ pub const DeclGen = struct {
27192719 var buf: Type.SlicePtrFieldTypeBuffer = undefined;
27202720 const ptr_type = t.slicePtrFieldType(&buf);
27212721
2722 const fields: [2]*const llvm.Type = .{
2722 const fields: [2]*llvm.Type = .{
27232723 try dg.lowerType(ptr_type),
27242724 try dg.lowerType(Type.usize),
27252725 };
......@@ -2776,7 +2776,7 @@ pub const DeclGen = struct {
27762776 }
27772777
27782778 comptime assert(optional_layout_version == 3);
2779 var fields_buf: [3]*const llvm.Type = .{
2779 var fields_buf: [3]*llvm.Type = .{
27802780 payload_llvm_ty, dg.context.intType(8), undefined,
27812781 };
27822782 const offset = child_ty.abiSize(target) + 1;
......@@ -2802,7 +2802,7 @@ pub const DeclGen = struct {
28022802 const payload_size = payload_ty.abiSize(target);
28032803 const error_size = Type.anyerror.abiSize(target);
28042804
2805 var fields_buf: [3]*const llvm.Type = undefined;
2805 var fields_buf: [3]*llvm.Type = undefined;
28062806 if (error_align > payload_align) {
28072807 fields_buf[0] = llvm_error_type;
28082808 fields_buf[1] = llvm_payload_type;
......@@ -2845,7 +2845,7 @@ pub const DeclGen = struct {
28452845 const llvm_struct_ty = dg.context.structCreateNamed("");
28462846 gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls
28472847
2848 var llvm_field_types: std.ArrayListUnmanaged(*const llvm.Type) = .{};
2848 var llvm_field_types: std.ArrayListUnmanaged(*llvm.Type) = .{};
28492849 defer llvm_field_types.deinit(gpa);
28502850
28512851 try llvm_field_types.ensureUnusedCapacity(gpa, tuple.types.len);
......@@ -2908,7 +2908,7 @@ pub const DeclGen = struct {
29082908
29092909 assert(struct_obj.haveFieldTypes());
29102910
2911 var llvm_field_types: std.ArrayListUnmanaged(*const llvm.Type) = .{};
2911 var llvm_field_types: std.ArrayListUnmanaged(*llvm.Type) = .{};
29122912 defer llvm_field_types.deinit(gpa);
29132913
29142914 try llvm_field_types.ensureUnusedCapacity(gpa, struct_obj.fields.count());
......@@ -2991,7 +2991,7 @@ pub const DeclGen = struct {
29912991 @intCast(c_uint, layout.abi_size - layout.most_aligned_field_size)
29922992 else
29932993 @intCast(c_uint, layout.payload_size - layout.most_aligned_field_size);
2994 const fields: [2]*const llvm.Type = .{
2994 const fields: [2]*llvm.Type = .{
29952995 llvm_aligned_field_ty,
29962996 dg.context.intType(8).arrayType(padding_len),
29972997 };
......@@ -2999,7 +2999,7 @@ pub const DeclGen = struct {
29992999 };
30003000
30013001 if (layout.tag_size == 0) {
3002 var llvm_fields: [1]*const llvm.Type = .{llvm_payload_ty};
3002 var llvm_fields: [1]*llvm.Type = .{llvm_payload_ty};
30033003 llvm_union_ty.structSetBody(&llvm_fields, llvm_fields.len, .False);
30043004 return llvm_union_ty;
30053005 }
......@@ -3007,7 +3007,7 @@ pub const DeclGen = struct {
30073007
30083008 // Put the tag before or after the payload depending on which one's
30093009 // alignment is greater.
3010 var llvm_fields: [3]*const llvm.Type = undefined;
3010 var llvm_fields: [3]*llvm.Type = undefined;
30113011 var llvm_fields_len: c_uint = 2;
30123012
30133013 if (layout.tag_align >= layout.payload_align) {
......@@ -3040,12 +3040,12 @@ pub const DeclGen = struct {
30403040 }
30413041 }
30423042
3043 fn lowerTypeFn(dg: *DeclGen, fn_ty: Type) Allocator.Error!*const llvm.Type {
3043 fn lowerTypeFn(dg: *DeclGen, fn_ty: Type) Allocator.Error!*llvm.Type {
30443044 const target = dg.module.getTarget();
30453045 const fn_info = fn_ty.fnInfo();
30463046 const llvm_ret_ty = try lowerFnRetTy(dg, fn_info);
30473047
3048 var llvm_params = std.ArrayList(*const llvm.Type).init(dg.gpa);
3048 var llvm_params = std.ArrayList(*llvm.Type).init(dg.gpa);
30493049 defer llvm_params.deinit();
30503050
30513051 if (firstParamSRet(fn_info, target)) {
......@@ -3135,7 +3135,7 @@ pub const DeclGen = struct {
31353135 /// Use this instead of lowerType when you want to handle correctly the case of elem_ty
31363136 /// being a zero bit type, but it should still be lowered as an i8 in such case.
31373137 /// There are other similar cases handled here as well.
3138 fn lowerPtrElemTy(dg: *DeclGen, elem_ty: Type) Allocator.Error!*const llvm.Type {
3138 fn lowerPtrElemTy(dg: *DeclGen, elem_ty: Type) Allocator.Error!*llvm.Type {
31393139 const lower_elem_ty = switch (elem_ty.zigTypeTag()) {
31403140 .Opaque, .Fn => true,
31413141 .Array => elem_ty.childType().hasRuntimeBitsIgnoreComptime(),
......@@ -3149,7 +3149,7 @@ pub const DeclGen = struct {
31493149 return llvm_elem_ty;
31503150 }
31513151
3152 fn lowerValue(dg: *DeclGen, tv: TypedValue) Error!*const llvm.Value {
3152 fn lowerValue(dg: *DeclGen, tv: TypedValue) Error!*llvm.Value {
31533153 if (tv.val.isUndef()) {
31543154 const llvm_type = try dg.lowerType(tv.ty);
31553155 return llvm_type.getUndef();
......@@ -3264,7 +3264,7 @@ pub const DeclGen = struct {
32643264 .slice => {
32653265 const slice = tv.val.castTag(.slice).?.data;
32663266 var buf: Type.SlicePtrFieldTypeBuffer = undefined;
3267 const fields: [2]*const llvm.Value = .{
3267 const fields: [2]*llvm.Value = .{
32683268 try dg.lowerValue(.{
32693269 .ty = tv.ty.slicePtrFieldType(&buf),
32703270 .val = slice.ptr,
......@@ -3336,7 +3336,7 @@ pub const DeclGen = struct {
33363336 const elem_ty = tv.ty.elemType();
33373337 const gpa = dg.gpa;
33383338 const len = @intCast(usize, tv.ty.arrayLenIncludingSentinel());
3339 const llvm_elems = try gpa.alloc(*const llvm.Value, len);
3339 const llvm_elems = try gpa.alloc(*llvm.Value, len);
33403340 defer gpa.free(llvm_elems);
33413341 var need_unnamed = false;
33423342 for (elem_vals[0..len]) |elem_val, i| {
......@@ -3364,7 +3364,7 @@ pub const DeclGen = struct {
33643364 const len = @intCast(usize, tv.ty.arrayLen());
33653365 const len_including_sent = len + @boolToInt(sentinel != null);
33663366 const gpa = dg.gpa;
3367 const llvm_elems = try gpa.alloc(*const llvm.Value, len_including_sent);
3367 const llvm_elems = try gpa.alloc(*llvm.Value, len_including_sent);
33683368 defer gpa.free(llvm_elems);
33693369
33703370 var need_unnamed = false;
......@@ -3398,7 +3398,7 @@ pub const DeclGen = struct {
33983398 const elem_ty = tv.ty.elemType();
33993399 const sent_val = tv.ty.sentinel().?;
34003400 const sentinel = try dg.lowerValue(.{ .ty = elem_ty, .val = sent_val });
3401 const llvm_elems: [1]*const llvm.Value = .{sentinel};
3401 const llvm_elems: [1]*llvm.Value = .{sentinel};
34023402 const need_unnamed = dg.isUnnamedType(elem_ty, llvm_elems[0]);
34033403 if (need_unnamed) {
34043404 return dg.context.constStruct(&llvm_elems, llvm_elems.len, .True);
......@@ -3433,7 +3433,7 @@ pub const DeclGen = struct {
34333433 assert(payload_ty.zigTypeTag() != .Fn);
34343434
34353435 const llvm_field_count = llvm_ty.countStructElementTypes();
3436 var fields_buf: [3]*const llvm.Value = undefined;
3436 var fields_buf: [3]*llvm.Value = undefined;
34373437 fields_buf[0] = try dg.lowerValue(.{
34383438 .ty = payload_ty,
34393439 .val = if (tv.val.castTag(.opt_payload)) |pl| pl.data else Value.initTag(.undef),
......@@ -3489,7 +3489,7 @@ pub const DeclGen = struct {
34893489 .ty = payload_type,
34903490 .val = if (tv.val.castTag(.eu_payload)) |pl| pl.data else Value.initTag(.undef),
34913491 });
3492 var fields_buf: [3]*const llvm.Value = undefined;
3492 var fields_buf: [3]*llvm.Value = undefined;
34933493
34943494 const llvm_ty = try dg.lowerType(tv.ty);
34953495 const llvm_field_count = llvm_ty.countStructElementTypes();
......@@ -3515,7 +3515,7 @@ pub const DeclGen = struct {
35153515
35163516 if (tv.ty.isTupleOrAnonStruct()) {
35173517 const tuple = tv.ty.tupleFields();
3518 var llvm_fields: std.ArrayListUnmanaged(*const llvm.Value) = .{};
3518 var llvm_fields: std.ArrayListUnmanaged(*llvm.Value) = .{};
35193519 defer llvm_fields.deinit(gpa);
35203520
35213521 try llvm_fields.ensureUnusedCapacity(gpa, tuple.types.len);
......@@ -3584,7 +3584,7 @@ pub const DeclGen = struct {
35843584 const int_llvm_ty = dg.context.intType(@intCast(c_uint, big_bits));
35853585 const fields = struct_obj.fields.values();
35863586 comptime assert(Type.packed_struct_layout_version == 2);
3587 var running_int: *const llvm.Value = int_llvm_ty.constNull();
3587 var running_int: *llvm.Value = int_llvm_ty.constNull();
35883588 var running_bits: u16 = 0;
35893589 for (field_vals) |field_val, i| {
35903590 const field = fields[i];
......@@ -3613,7 +3613,7 @@ pub const DeclGen = struct {
36133613 }
36143614
36153615 const llvm_field_count = llvm_struct_ty.countStructElementTypes();
3616 var llvm_fields = try std.ArrayListUnmanaged(*const llvm.Value).initCapacity(gpa, llvm_field_count);
3616 var llvm_fields = try std.ArrayListUnmanaged(*llvm.Value).initCapacity(gpa, llvm_field_count);
36173617 defer llvm_fields.deinit(gpa);
36183618
36193619 comptime assert(struct_layout_version == 2);
......@@ -3706,14 +3706,14 @@ pub const DeclGen = struct {
37063706 break :p field;
37073707 }
37083708 const padding_len = @intCast(c_uint, layout.payload_size - field_size);
3709 const fields: [2]*const llvm.Value = .{
3709 const fields: [2]*llvm.Value = .{
37103710 field, dg.context.intType(8).arrayType(padding_len).getUndef(),
37113711 };
37123712 break :p dg.context.constStruct(&fields, fields.len, .True);
37133713 };
37143714
37153715 if (layout.tag_size == 0) {
3716 const fields: [1]*const llvm.Value = .{payload};
3716 const fields: [1]*llvm.Value = .{payload};
37173717 if (need_unnamed) {
37183718 return dg.context.constStruct(&fields, fields.len, .False);
37193719 } else {
......@@ -3724,7 +3724,7 @@ pub const DeclGen = struct {
37243724 .ty = tv.ty.unionTagTypeSafety().?,
37253725 .val = tag_and_val.tag,
37263726 });
3727 var fields: [3]*const llvm.Value = undefined;
3727 var fields: [3]*llvm.Value = undefined;
37283728 var fields_len: c_uint = 2;
37293729 if (layout.tag_align >= layout.payload_align) {
37303730 fields = .{ llvm_tag_value, payload, undefined };
......@@ -3749,7 +3749,7 @@ pub const DeclGen = struct {
37493749 assert(vector_len == bytes.len or vector_len + 1 == bytes.len);
37503750
37513751 const elem_ty = tv.ty.elemType();
3752 const llvm_elems = try dg.gpa.alloc(*const llvm.Value, vector_len);
3752 const llvm_elems = try dg.gpa.alloc(*llvm.Value, vector_len);
37533753 defer dg.gpa.free(llvm_elems);
37543754 for (llvm_elems) |*elem, i| {
37553755 var byte_payload: Value.Payload.U64 = .{
......@@ -3774,7 +3774,7 @@ pub const DeclGen = struct {
37743774 const vector_len = @intCast(usize, tv.ty.arrayLen());
37753775 assert(vector_len == elem_vals.len or vector_len + 1 == elem_vals.len);
37763776 const elem_ty = tv.ty.elemType();
3777 const llvm_elems = try dg.gpa.alloc(*const llvm.Value, vector_len);
3777 const llvm_elems = try dg.gpa.alloc(*llvm.Value, vector_len);
37783778 defer dg.gpa.free(llvm_elems);
37793779 for (llvm_elems) |*elem, i| {
37803780 elem.* = try dg.lowerValue(.{ .ty = elem_ty, .val = elem_vals[i] });
......@@ -3789,7 +3789,7 @@ pub const DeclGen = struct {
37893789 const val = tv.val.castTag(.repeated).?.data;
37903790 const elem_ty = tv.ty.elemType();
37913791 const len = @intCast(usize, tv.ty.arrayLen());
3792 const llvm_elems = try dg.gpa.alloc(*const llvm.Value, len);
3792 const llvm_elems = try dg.gpa.alloc(*llvm.Value, len);
37933793 defer dg.gpa.free(llvm_elems);
37943794 for (llvm_elems) |*elem| {
37953795 elem.* = try dg.lowerValue(.{ .ty = elem_ty, .val = val });
......@@ -3821,7 +3821,7 @@ pub const DeclGen = struct {
38213821
38223822 const ParentPtr = struct {
38233823 ty: Type,
3824 llvm_ptr: *const llvm.Value,
3824 llvm_ptr: *llvm.Value,
38253825 };
38263826
38273827 fn lowerParentPtrDecl(
......@@ -3829,7 +3829,7 @@ pub const DeclGen = struct {
38293829 ptr_val: Value,
38303830 decl_index: Module.Decl.Index,
38313831 ptr_child_ty: Type,
3832 ) Error!*const llvm.Value {
3832 ) Error!*llvm.Value {
38333833 const decl = dg.module.declPtr(decl_index);
38343834 dg.module.markDeclAlive(decl);
38353835 var ptr_ty_payload: Type.Payload.ElemType = .{
......@@ -3846,7 +3846,7 @@ pub const DeclGen = struct {
38463846 }
38473847 }
38483848
3849 fn lowerParentPtr(dg: *DeclGen, ptr_val: Value, ptr_child_ty: Type) Error!*const llvm.Value {
3849 fn lowerParentPtr(dg: *DeclGen, ptr_val: Value, ptr_child_ty: Type) Error!*llvm.Value {
38503850 const target = dg.module.getTarget();
38513851 var bitcast_needed: bool = undefined;
38523852 const llvm_ptr = switch (ptr_val.tag()) {
......@@ -3895,7 +3895,7 @@ pub const DeclGen = struct {
38953895 0
38963896 else
38973897 @boolToInt(layout.tag_align >= layout.payload_align);
3898 const indices: [2]*const llvm.Value = .{
3898 const indices: [2]*llvm.Value = .{
38993899 llvm_u32.constInt(0, .False),
39003900 llvm_u32.constInt(llvm_pl_index, .False),
39013901 };
......@@ -3926,7 +3926,7 @@ pub const DeclGen = struct {
39263926
39273927 var ty_buf: Type.Payload.Pointer = undefined;
39283928 const llvm_field_index = llvmFieldIndex(parent_ty, field_index, target, &ty_buf).?;
3929 const indices: [2]*const llvm.Value = .{
3929 const indices: [2]*llvm.Value = .{
39303930 llvm_u32.constInt(0, .False),
39313931 llvm_u32.constInt(llvm_field_index, .False),
39323932 };
......@@ -3942,7 +3942,7 @@ pub const DeclGen = struct {
39423942 bitcast_needed = !elem_ptr.elem_ty.eql(ptr_child_ty, dg.module);
39433943
39443944 const llvm_usize = try dg.lowerType(Type.usize);
3945 const indices: [1]*const llvm.Value = .{
3945 const indices: [1]*llvm.Value = .{
39463946 llvm_usize.constInt(elem_ptr.index, .False),
39473947 };
39483948 const elem_llvm_ty = try dg.lowerType(elem_ptr.elem_ty);
......@@ -3965,7 +3965,7 @@ pub const DeclGen = struct {
39653965 }
39663966
39673967 const llvm_u32 = dg.context.intType(32);
3968 const indices: [2]*const llvm.Value = .{
3968 const indices: [2]*llvm.Value = .{
39693969 llvm_u32.constInt(0, .False),
39703970 llvm_u32.constInt(0, .False),
39713971 };
......@@ -3987,7 +3987,7 @@ pub const DeclGen = struct {
39873987
39883988 const payload_offset: u8 = if (payload_ty.abiAlignment(target) > Type.anyerror.abiSize(target)) 2 else 1;
39893989 const llvm_u32 = dg.context.intType(32);
3990 const indices: [2]*const llvm.Value = .{
3990 const indices: [2]*llvm.Value = .{
39913991 llvm_u32.constInt(0, .False),
39923992 llvm_u32.constInt(payload_offset, .False),
39933993 };
......@@ -4007,7 +4007,7 @@ pub const DeclGen = struct {
40074007 self: *DeclGen,
40084008 tv: TypedValue,
40094009 decl_index: Module.Decl.Index,
4010 ) Error!*const llvm.Value {
4010 ) Error!*llvm.Value {
40114011 if (tv.ty.isSlice()) {
40124012 var buf: Type.SlicePtrFieldTypeBuffer = undefined;
40134013 const ptr_ty = tv.ty.slicePtrFieldType(&buf);
......@@ -4015,7 +4015,7 @@ pub const DeclGen = struct {
40154015 .base = .{ .tag = .int_u64 },
40164016 .data = tv.val.sliceLen(self.module),
40174017 };
4018 const fields: [2]*const llvm.Value = .{
4018 const fields: [2]*llvm.Value = .{
40194019 try self.lowerValue(.{
40204020 .ty = ptr_ty,
40214021 .val = tv.val,
......@@ -4060,7 +4060,7 @@ pub const DeclGen = struct {
40604060 }
40614061 }
40624062
4063 fn lowerPtrToVoid(dg: *DeclGen, ptr_ty: Type) !*const llvm.Value {
4063 fn lowerPtrToVoid(dg: *DeclGen, ptr_ty: Type) !*llvm.Value {
40644064 const alignment = ptr_ty.ptrInfo().data.@"align";
40654065 // Even though we are pointing at something which has zero bits (e.g. `void`),
40664066 // Pointers are defined to have bits. So we must return something here.
......@@ -4086,19 +4086,19 @@ pub const DeclGen = struct {
40864086 return int.constIntToPtr(llvm_ptr_ty);
40874087 }
40884088
4089 fn addAttr(dg: DeclGen, val: *const llvm.Value, index: llvm.AttributeIndex, name: []const u8) void {
4089 fn addAttr(dg: DeclGen, val: *llvm.Value, index: llvm.AttributeIndex, name: []const u8) void {
40904090 return dg.addAttrInt(val, index, name, 0);
40914091 }
40924092
4093 fn addArgAttr(dg: DeclGen, fn_val: *const llvm.Value, param_index: u32, attr_name: []const u8) void {
4093 fn addArgAttr(dg: DeclGen, fn_val: *llvm.Value, param_index: u32, attr_name: []const u8) void {
40944094 return dg.addAttr(fn_val, param_index + 1, attr_name);
40954095 }
40964096
4097 fn addArgAttrInt(dg: DeclGen, fn_val: *const llvm.Value, param_index: u32, attr_name: []const u8, int: u64) void {
4097 fn addArgAttrInt(dg: DeclGen, fn_val: *llvm.Value, param_index: u32, attr_name: []const u8, int: u64) void {
40984098 return dg.addAttrInt(fn_val, param_index + 1, attr_name, int);
40994099 }
41004100
4101 fn removeAttr(val: *const llvm.Value, index: llvm.AttributeIndex, name: []const u8) void {
4101 fn removeAttr(val: *llvm.Value, index: llvm.AttributeIndex, name: []const u8) void {
41024102 const kind_id = llvm.getEnumAttributeKindForName(name.ptr, name.len);
41034103 assert(kind_id != 0);
41044104 val.removeEnumAttributeAtIndex(index, kind_id);
......@@ -4106,7 +4106,7 @@ pub const DeclGen = struct {
41064106
41074107 fn addAttrInt(
41084108 dg: DeclGen,
4109 val: *const llvm.Value,
4109 val: *llvm.Value,
41104110 index: llvm.AttributeIndex,
41114111 name: []const u8,
41124112 int: u64,
......@@ -4119,7 +4119,7 @@ pub const DeclGen = struct {
41194119
41204120 fn addAttrString(
41214121 dg: *DeclGen,
4122 val: *const llvm.Value,
4122 val: *llvm.Value,
41234123 index: llvm.AttributeIndex,
41244124 name: []const u8,
41254125 value: []const u8,
......@@ -4133,19 +4133,19 @@ pub const DeclGen = struct {
41334133 val.addAttributeAtIndex(index, llvm_attr);
41344134 }
41354135
4136 fn addFnAttr(dg: DeclGen, val: *const llvm.Value, name: []const u8) void {
4136 fn addFnAttr(dg: DeclGen, val: *llvm.Value, name: []const u8) void {
41374137 dg.addAttr(val, std.math.maxInt(llvm.AttributeIndex), name);
41384138 }
41394139
4140 fn addFnAttrString(dg: *DeclGen, val: *const llvm.Value, name: []const u8, value: []const u8) void {
4140 fn addFnAttrString(dg: *DeclGen, val: *llvm.Value, name: []const u8, value: []const u8) void {
41414141 dg.addAttrString(val, std.math.maxInt(llvm.AttributeIndex), name, value);
41424142 }
41434143
4144 fn removeFnAttr(fn_val: *const llvm.Value, name: []const u8) void {
4144 fn removeFnAttr(fn_val: *llvm.Value, name: []const u8) void {
41454145 removeAttr(fn_val, std.math.maxInt(llvm.AttributeIndex), name);
41464146 }
41474147
4148 fn addFnAttrInt(dg: DeclGen, fn_val: *const llvm.Value, name: []const u8, int: u64) void {
4148 fn addFnAttrInt(dg: DeclGen, fn_val: *llvm.Value, name: []const u8, int: u64) void {
41494149 return dg.addAttrInt(fn_val, std.math.maxInt(llvm.AttributeIndex), name, int);
41504150 }
41514151
......@@ -4153,7 +4153,7 @@ pub const DeclGen = struct {
41534153 /// widen it before using it and then truncate the result.
41544154 /// RMW exchange of floating-point values is bitcasted to same-sized integer
41554155 /// types to work around a LLVM deficiency when targeting ARM/AArch64.
4156 fn getAtomicAbiType(dg: *DeclGen, ty: Type, is_rmw_xchg: bool) ?*const llvm.Type {
4156 fn getAtomicAbiType(dg: *DeclGen, ty: Type, is_rmw_xchg: bool) ?*llvm.Type {
41574157 const target = dg.module.getTarget();
41584158 var buffer: Type.Payload.Bits = undefined;
41594159 const int_ty = switch (ty.zigTypeTag()) {
......@@ -4176,7 +4176,7 @@ pub const DeclGen = struct {
41764176
41774177 fn addByValParamAttrs(
41784178 dg: DeclGen,
4179 llvm_fn: *const llvm.Value,
4179 llvm_fn: *llvm.Value,
41804180 param_ty: Type,
41814181 param_index: u32,
41824182 fn_info: Type.Payload.Function.Data,
......@@ -4213,11 +4213,11 @@ pub const DeclGen = struct {
42134213
42144214 fn addByRefParamAttrs(
42154215 dg: DeclGen,
4216 llvm_fn: *const llvm.Value,
4216 llvm_fn: *llvm.Value,
42174217 llvm_arg_i: u32,
42184218 alignment: u32,
42194219 byval_attr: bool,
4220 param_llvm_ty: *const llvm.Type,
4220 param_llvm_ty: *llvm.Type,
42214221 ) void {
42224222 dg.addArgAttr(llvm_fn, llvm_arg_i, "nonnull");
42234223 dg.addArgAttr(llvm_fn, llvm_arg_i, "readonly");
......@@ -4233,8 +4233,8 @@ pub const FuncGen = struct {
42334233 dg: *DeclGen,
42344234 air: Air,
42354235 liveness: Liveness,
4236 context: *const llvm.Context,
4237 builder: *const llvm.Builder,
4236 context: *llvm.Context,
4237 builder: *llvm.Builder,
42384238 di_scope: ?*llvm.DIScope,
42394239 di_file: ?*llvm.DIFile,
42404240 base_line: u32,
......@@ -4250,30 +4250,30 @@ pub const FuncGen = struct {
42504250
42514251 /// This stores the LLVM values used in a function, such that they can be referred to
42524252 /// in other instructions. This table is cleared before every function is generated.
4253 func_inst_table: std.AutoHashMapUnmanaged(Air.Inst.Ref, *const llvm.Value),
4253 func_inst_table: std.AutoHashMapUnmanaged(Air.Inst.Ref, *llvm.Value),
42544254
42554255 /// If the return type is sret, this is the result pointer. Otherwise null.
42564256 /// Note that this can disagree with isByRef for the return type in the case
42574257 /// of C ABI functions.
4258 ret_ptr: ?*const llvm.Value,
4258 ret_ptr: ?*llvm.Value,
42594259 /// Any function that needs to perform Valgrind client requests needs an array alloca
42604260 /// instruction, however a maximum of one per function is needed.
4261 valgrind_client_request_array: ?*const llvm.Value = null,
4261 valgrind_client_request_array: ?*llvm.Value = null,
42624262 /// These fields are used to refer to the LLVM value of the function parameters
42634263 /// in an Arg instruction.
42644264 /// This list may be shorter than the list according to the zig type system;
42654265 /// it omits 0-bit types. If the function uses sret as the first parameter,
42664266 /// this slice does not include it.
4267 args: []const *const llvm.Value,
4267 args: []const *llvm.Value,
42684268 arg_index: c_uint,
42694269
4270 llvm_func: *const llvm.Value,
4270 llvm_func: *llvm.Value,
42714271
4272 err_ret_trace: ?*const llvm.Value = null,
4272 err_ret_trace: ?*llvm.Value = null,
42734273
42744274 /// This data structure is used to implement breaking to blocks.
42754275 blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, struct {
4276 parent_bb: *const llvm.BasicBlock,
4276 parent_bb: *llvm.BasicBlock,
42774277 breaks: *BreakList,
42784278 }),
42794279
......@@ -4281,8 +4281,8 @@ pub const FuncGen = struct {
42814281
42824282 const DbgState = struct { loc: *llvm.DILocation, scope: *llvm.DIScope, base_line: u32 };
42834283 const BreakList = std.MultiArrayList(struct {
4284 bb: *const llvm.BasicBlock,
4285 val: *const llvm.Value,
4284 bb: *llvm.BasicBlock,
4285 val: *llvm.Value,
42864286 });
42874287
42884288 fn deinit(self: *FuncGen) void {
......@@ -4298,11 +4298,11 @@ pub const FuncGen = struct {
42984298 return self.dg.todo(format, args);
42994299 }
43004300
4301 fn llvmModule(self: *FuncGen) *const llvm.Module {
4301 fn llvmModule(self: *FuncGen) *llvm.Module {
43024302 return self.dg.object.llvm_module;
43034303 }
43044304
4305 fn resolveInst(self: *FuncGen, inst: Air.Inst.Ref) !*const llvm.Value {
4305 fn resolveInst(self: *FuncGen, inst: Air.Inst.Ref) !*llvm.Value {
43064306 const gop = try self.func_inst_table.getOrPut(self.dg.gpa, inst);
43074307 if (gop.found_existing) return gop.value_ptr.*;
43084308
......@@ -4336,7 +4336,7 @@ pub const FuncGen = struct {
43364336 fn genBody(self: *FuncGen, body: []const Air.Inst.Index) Error!void {
43374337 const air_tags = self.air.instructions.items(.tag);
43384338 for (body) |inst, i| {
4339 const opt_value: ?*const llvm.Value = switch (air_tags[inst]) {
4339 const opt_value: ?*llvm.Value = switch (air_tags[inst]) {
43404340 // zig fmt: off
43414341 .add => try self.airAdd(inst, false),
43424342 .addwrap => try self.airAddWrap(inst, false),
......@@ -4563,7 +4563,7 @@ pub const FuncGen = struct {
45634563 }
45644564 }
45654565
4566 fn airCall(self: *FuncGen, inst: Air.Inst.Index, attr: llvm.CallAttr) !?*const llvm.Value {
4566 fn airCall(self: *FuncGen, inst: Air.Inst.Index, attr: llvm.CallAttr) !?*llvm.Value {
45674567 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
45684568 const extra = self.air.extraData(Air.Call, pl_op.payload);
45694569 const args = @ptrCast([]const Air.Inst.Ref, self.air.extra[extra.end..][0..extra.data.args_len]);
......@@ -4579,7 +4579,7 @@ pub const FuncGen = struct {
45794579 const target = self.dg.module.getTarget();
45804580 const sret = firstParamSRet(fn_info, target);
45814581
4582 var llvm_args = std.ArrayList(*const llvm.Value).init(self.gpa);
4582 var llvm_args = std.ArrayList(*llvm.Value).init(self.gpa);
45834583 defer llvm_args.deinit();
45844584
45854585 const ret_ptr = if (!sret) null else blk: {
......@@ -4693,7 +4693,7 @@ pub const FuncGen = struct {
46934693 break :p p;
46944694 };
46954695
4696 var field_types_buf: [8]*const llvm.Type = undefined;
4696 var field_types_buf: [8]*llvm.Type = undefined;
46974697 const field_types = field_types_buf[0..llvm_ints.len];
46984698 for (llvm_ints) |int_bits, i| {
46994699 field_types[i] = self.dg.context.intType(int_bits);
......@@ -4722,7 +4722,7 @@ pub const FuncGen = struct {
47224722 break :p p;
47234723 };
47244724
4725 var field_types_buf: [8]*const llvm.Type = undefined;
4725 var field_types_buf: [8]*llvm.Type = undefined;
47264726 const field_types = field_types_buf[0..llvm_floats.len];
47274727 for (llvm_floats) |float_bits, i| {
47284728 switch (float_bits) {
......@@ -4840,7 +4840,7 @@ pub const FuncGen = struct {
48404840 }
48414841 }
48424842
4843 fn airRet(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
4843 fn airRet(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
48444844 const un_op = self.air.instructions.items(.data)[inst].un_op;
48454845 const ret_ty = self.air.typeOf(un_op);
48464846 if (self.ret_ptr) |ret_ptr| {
......@@ -4901,7 +4901,7 @@ pub const FuncGen = struct {
49014901 return null;
49024902 }
49034903
4904 fn airRetLoad(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
4904 fn airRetLoad(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
49054905 const un_op = self.air.instructions.items(.data)[inst].un_op;
49064906 const ptr_ty = self.air.typeOf(un_op);
49074907 const ret_ty = ptr_ty.childType();
......@@ -4936,7 +4936,7 @@ pub const FuncGen = struct {
49364936 return null;
49374937 }
49384938
4939 fn airCmp(self: *FuncGen, inst: Air.Inst.Index, op: math.CompareOperator, want_fast_math: bool) !?*const llvm.Value {
4939 fn airCmp(self: *FuncGen, inst: Air.Inst.Index, op: math.CompareOperator, want_fast_math: bool) !?*llvm.Value {
49404940 if (self.liveness.isUnused(inst)) return null;
49414941 self.builder.setFastMath(want_fast_math);
49424942
......@@ -4948,7 +4948,7 @@ pub const FuncGen = struct {
49484948 return self.cmp(lhs, rhs, operand_ty, op);
49494949 }
49504950
4951 fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
4951 fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
49524952 if (self.liveness.isUnused(inst)) return null;
49534953 self.builder.setFastMath(want_fast_math);
49544954
......@@ -4963,23 +4963,23 @@ pub const FuncGen = struct {
49634963 return self.cmp(lhs, rhs, vec_ty, cmp_op);
49644964 }
49654965
4966 fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
4966 fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
49674967 if (self.liveness.isUnused(inst)) return null;
49684968
49694969 const un_op = self.air.instructions.items(.data)[inst].un_op;
49704970 const operand = try self.resolveInst(un_op);
49714971 const llvm_fn = try self.getCmpLtErrorsLenFunction();
4972 const args: [1]*const llvm.Value = .{operand};
4972 const args: [1]*llvm.Value = .{operand};
49734973 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
49744974 }
49754975
49764976 fn cmp(
49774977 self: *FuncGen,
4978 lhs: *const llvm.Value,
4979 rhs: *const llvm.Value,
4978 lhs: *llvm.Value,
4979 rhs: *llvm.Value,
49804980 operand_ty: Type,
49814981 op: math.CompareOperator,
4982 ) Allocator.Error!*const llvm.Value {
4982 ) Allocator.Error!*llvm.Value {
49834983 var int_buffer: Type.Payload.Bits = undefined;
49844984 var opt_buffer: Type.Payload.ElemType = undefined;
49854985
......@@ -5029,7 +5029,7 @@ pub const FuncGen = struct {
50295029 const both_pl_block_end = self.builder.getInsertBlock();
50305030
50315031 self.builder.positionBuilderAtEnd(end_block);
5032 const incoming_blocks: [3]*const llvm.BasicBlock = .{
5032 const incoming_blocks: [3]*llvm.BasicBlock = .{
50335033 both_null_block,
50345034 mixed_block,
50355035 both_pl_block_end,
......@@ -5037,7 +5037,7 @@ pub const FuncGen = struct {
50375037 const llvm_i1 = self.context.intType(1);
50385038 const llvm_i1_0 = llvm_i1.constInt(0, .False);
50395039 const llvm_i1_1 = llvm_i1.constInt(1, .False);
5040 const incoming_values: [3]*const llvm.Value = .{
5040 const incoming_values: [3]*llvm.Value = .{
50415041 switch (op) {
50425042 .eq => llvm_i1_1,
50435043 .neq => llvm_i1_0,
......@@ -5075,7 +5075,7 @@ pub const FuncGen = struct {
50755075 return self.builder.buildICmp(operation, lhs, rhs, "");
50765076 }
50775077
5078 fn airBlock(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5078 fn airBlock(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
50795079 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
50805080 const extra = self.air.extraData(Air.Block, ty_pl.payload);
50815081 const body = self.air.extra[extra.end..][0..extra.data.body_len];
......@@ -5127,7 +5127,7 @@ pub const FuncGen = struct {
51275127 return phi_node;
51285128 }
51295129
5130 fn airBr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5130 fn airBr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
51315131 const branch = self.air.instructions.items(.data)[inst].br;
51325132 const block = self.blocks.get(branch.block_inst).?;
51335133
......@@ -5147,7 +5147,7 @@ pub const FuncGen = struct {
51475147 return null;
51485148 }
51495149
5150 fn airCondBr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5150 fn airCondBr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
51515151 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
51525152 const cond = try self.resolveInst(pl_op.operand);
51535153 const extra = self.air.extraData(Air.CondBr, pl_op.payload);
......@@ -5168,7 +5168,7 @@ pub const FuncGen = struct {
51685168 return null;
51695169 }
51705170
5171 fn airTry(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5171 fn airTry(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
51725172 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
51735173 const err_union = try self.resolveInst(pl_op.operand);
51745174 const extra = self.air.extraData(Air.Try, pl_op.payload);
......@@ -5178,7 +5178,7 @@ pub const FuncGen = struct {
51785178 return lowerTry(self, err_union, body, err_union_ty, false, result_ty);
51795179 }
51805180
5181 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5181 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
51825182 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
51835183 const extra = self.air.extraData(Air.TryPtr, ty_pl.payload);
51845184 const err_union_ptr = try self.resolveInst(extra.data.ptr);
......@@ -5190,12 +5190,12 @@ pub const FuncGen = struct {
51905190
51915191 fn lowerTry(
51925192 fg: *FuncGen,
5193 err_union: *const llvm.Value,
5193 err_union: *llvm.Value,
51945194 body: []const Air.Inst.Index,
51955195 err_union_ty: Type,
51965196 operand_is_ptr: bool,
51975197 result_ty: Type,
5198 ) !?*const llvm.Value {
5198 ) !?*llvm.Value {
51995199 const payload_ty = err_union_ty.errorUnionPayload();
52005200 const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime();
52015201 const target = fg.dg.module.getTarget();
......@@ -5256,7 +5256,7 @@ pub const FuncGen = struct {
52565256 return fg.builder.buildExtractValue(err_union, offset, "");
52575257 }
52585258
5259 fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5259 fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
52605260 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
52615261 const cond = try self.resolveInst(pl_op.operand);
52625262 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
......@@ -5305,7 +5305,7 @@ pub const FuncGen = struct {
53055305 return null;
53065306 }
53075307
5308 fn airLoop(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5308 fn airLoop(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
53095309 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
53105310 const loop = self.air.extraData(Air.Block, ty_pl.payload);
53115311 const body = self.air.extra[loop.end..][0..loop.data.body_len];
......@@ -5327,7 +5327,7 @@ pub const FuncGen = struct {
53275327 return null;
53285328 }
53295329
5330 fn airArrayToSlice(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5330 fn airArrayToSlice(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
53315331 if (self.liveness.isUnused(inst))
53325332 return null;
53335333
......@@ -5341,7 +5341,7 @@ pub const FuncGen = struct {
53415341 return self.builder.buildInsertValue(slice_llvm_ty.getUndef(), len, 1, "");
53425342 }
53435343 const operand = try self.resolveInst(ty_op.operand);
5344 const indices: [2]*const llvm.Value = .{
5344 const indices: [2]*llvm.Value = .{
53455345 llvm_usize.constNull(), llvm_usize.constNull(),
53465346 };
53475347 const array_llvm_ty = try self.dg.lowerType(array_ty);
......@@ -5350,7 +5350,7 @@ pub const FuncGen = struct {
53505350 return self.builder.buildInsertValue(partial, len, 1, "");
53515351 }
53525352
5353 fn airIntToFloat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5353 fn airIntToFloat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
53545354 if (self.liveness.isUnused(inst))
53555355 return null;
53565356
......@@ -5394,22 +5394,22 @@ pub const FuncGen = struct {
53945394 compiler_rt_dest_abbrev,
53955395 }) catch unreachable;
53965396
5397 var param_types = [1]*const llvm.Type{rt_int_ty};
5397 var param_types = [1]*llvm.Type{rt_int_ty};
53985398 if (rt_int_bits == 128 and (target.os.tag == .windows and target.cpu.arch == .x86_64)) {
53995399 // On Windows x86-64, "ti" functions must use Vector(2, u64) instead of the standard
54005400 // i128 calling convention to adhere to the ABI that LLVM expects compiler-rt to have.
54015401 const v2i64 = self.context.intType(64).vectorType(2);
54025402 extended = self.builder.buildBitCast(extended, v2i64, "");
5403 param_types = [1]*const llvm.Type{v2i64};
5403 param_types = [1]*llvm.Type{v2i64};
54045404 }
54055405
54065406 const libc_fn = self.getLibcFunction(fn_name, &param_types, dest_llvm_ty);
5407 const params = [1]*const llvm.Value{extended};
5407 const params = [1]*llvm.Value{extended};
54085408
54095409 return self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
54105410 }
54115411
5412 fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
5412 fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
54135413 if (self.liveness.isUnused(inst))
54145414 return null;
54155415
......@@ -5457,9 +5457,9 @@ pub const FuncGen = struct {
54575457 }) catch unreachable;
54585458
54595459 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
5460 const param_types = [1]*const llvm.Type{operand_llvm_ty};
5460 const param_types = [1]*llvm.Type{operand_llvm_ty};
54615461 const libc_fn = self.getLibcFunction(fn_name, &param_types, libc_ret_ty);
5462 const params = [1]*const llvm.Value{operand};
5462 const params = [1]*llvm.Value{operand};
54635463
54645464 var result = self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
54655465
......@@ -5468,7 +5468,7 @@ pub const FuncGen = struct {
54685468 return result;
54695469 }
54705470
5471 fn airSliceField(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*const llvm.Value {
5471 fn airSliceField(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*llvm.Value {
54725472 if (self.liveness.isUnused(inst)) return null;
54735473
54745474 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -5476,7 +5476,7 @@ pub const FuncGen = struct {
54765476 return self.builder.buildExtractValue(operand, index, "");
54775477 }
54785478
5479 fn airPtrSliceFieldPtr(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*const llvm.Value {
5479 fn airPtrSliceFieldPtr(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*llvm.Value {
54805480 if (self.liveness.isUnused(inst)) return null;
54815481
54825482 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -5487,7 +5487,7 @@ pub const FuncGen = struct {
54875487 return self.builder.buildStructGEP(slice_llvm_ty, slice_ptr, index, "");
54885488 }
54895489
5490 fn airSliceElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5490 fn airSliceElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
54915491 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
54925492 const slice_ty = self.air.typeOf(bin_op.lhs);
54935493 if (!slice_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
......@@ -5496,12 +5496,12 @@ pub const FuncGen = struct {
54965496 const index = try self.resolveInst(bin_op.rhs);
54975497 const llvm_elem_ty = try self.dg.lowerPtrElemTy(slice_ty.childType());
54985498 const base_ptr = self.builder.buildExtractValue(slice, 0, "");
5499 const indices: [1]*const llvm.Value = .{index};
5499 const indices: [1]*llvm.Value = .{index};
55005500 const ptr = self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55015501 return self.load(ptr, slice_ty);
55025502 }
55035503
5504 fn airSliceElemPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5504 fn airSliceElemPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
55055505 if (self.liveness.isUnused(inst)) return null;
55065506 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
55075507 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
......@@ -5511,11 +5511,11 @@ pub const FuncGen = struct {
55115511 const index = try self.resolveInst(bin_op.rhs);
55125512 const llvm_elem_ty = try self.dg.lowerPtrElemTy(slice_ty.childType());
55135513 const base_ptr = self.builder.buildExtractValue(slice, 0, "");
5514 const indices: [1]*const llvm.Value = .{index};
5514 const indices: [1]*llvm.Value = .{index};
55155515 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55165516 }
55175517
5518 fn airArrayElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5518 fn airArrayElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
55195519 if (self.liveness.isUnused(inst)) return null;
55205520
55215521 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -5524,7 +5524,7 @@ pub const FuncGen = struct {
55245524 const rhs = try self.resolveInst(bin_op.rhs);
55255525 if (isByRef(array_ty)) {
55265526 const array_llvm_ty = try self.dg.lowerType(array_ty);
5527 const indices: [2]*const llvm.Value = .{ self.context.intType(32).constNull(), rhs };
5527 const indices: [2]*llvm.Value = .{ self.context.intType(32).constNull(), rhs };
55285528 const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, "");
55295529 const elem_ty = array_ty.childType();
55305530 if (isByRef(elem_ty)) {
......@@ -5539,7 +5539,7 @@ pub const FuncGen = struct {
55395539 return self.builder.buildExtractElement(array_llvm_val, rhs, "");
55405540 }
55415541
5542 fn airPtrElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5542 fn airPtrElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
55435543 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
55445544 const ptr_ty = self.air.typeOf(bin_op.lhs);
55455545 if (!ptr_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
......@@ -5550,16 +5550,16 @@ pub const FuncGen = struct {
55505550 // TODO: when we go fully opaque pointers in LLVM 16 we can remove this branch
55515551 const ptr = if (ptr_ty.isSinglePointer()) ptr: {
55525552 // If this is a single-item pointer to an array, we need another index in the GEP.
5553 const indices: [2]*const llvm.Value = .{ self.context.intType(32).constNull(), rhs };
5553 const indices: [2]*llvm.Value = .{ self.context.intType(32).constNull(), rhs };
55545554 break :ptr self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55555555 } else ptr: {
5556 const indices: [1]*const llvm.Value = .{rhs};
5556 const indices: [1]*llvm.Value = .{rhs};
55575557 break :ptr self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55585558 };
55595559 return self.load(ptr, ptr_ty);
55605560 }
55615561
5562 fn airPtrElemPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5562 fn airPtrElemPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
55635563 if (self.liveness.isUnused(inst)) return null;
55645564
55655565 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -5573,15 +5573,15 @@ pub const FuncGen = struct {
55735573 const llvm_elem_ty = try self.dg.lowerPtrElemTy(elem_ty);
55745574 if (ptr_ty.isSinglePointer()) {
55755575 // If this is a single-item pointer to an array, we need another index in the GEP.
5576 const indices: [2]*const llvm.Value = .{ self.context.intType(32).constNull(), rhs };
5576 const indices: [2]*llvm.Value = .{ self.context.intType(32).constNull(), rhs };
55775577 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55785578 } else {
5579 const indices: [1]*const llvm.Value = .{rhs};
5579 const indices: [1]*llvm.Value = .{rhs};
55805580 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
55815581 }
55825582 }
55835583
5584 fn airStructFieldPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5584 fn airStructFieldPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
55855585 if (self.liveness.isUnused(inst))
55865586 return null;
55875587
......@@ -5596,7 +5596,7 @@ pub const FuncGen = struct {
55965596 self: *FuncGen,
55975597 inst: Air.Inst.Index,
55985598 field_index: u32,
5599 ) !?*const llvm.Value {
5599 ) !?*llvm.Value {
56005600 if (self.liveness.isUnused(inst)) return null;
56015601
56025602 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -5605,7 +5605,7 @@ pub const FuncGen = struct {
56055605 return self.fieldPtr(inst, struct_ptr, struct_ptr_ty, field_index);
56065606 }
56075607
5608 fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5608 fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
56095609 if (self.liveness.isUnused(inst)) return null;
56105610
56115611 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -5683,7 +5683,7 @@ pub const FuncGen = struct {
56835683 }
56845684 }
56855685
5686 fn airFieldParentPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5686 fn airFieldParentPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
56875687 if (self.liveness.isUnused(inst)) return null;
56885688
56895689 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -5706,7 +5706,7 @@ pub const FuncGen = struct {
57065706 return self.builder.buildIntToPtr(base_ptr_int, res_ty, "");
57075707 }
57085708
5709 fn airNot(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5709 fn airNot(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
57105710 if (self.liveness.isUnused(inst))
57115711 return null;
57125712
......@@ -5716,13 +5716,13 @@ pub const FuncGen = struct {
57165716 return self.builder.buildNot(operand, "");
57175717 }
57185718
5719 fn airUnreach(self: *FuncGen, inst: Air.Inst.Index) ?*const llvm.Value {
5719 fn airUnreach(self: *FuncGen, inst: Air.Inst.Index) ?*llvm.Value {
57205720 _ = inst;
57215721 _ = self.builder.buildUnreachable();
57225722 return null;
57235723 }
57245724
5725 fn airDbgStmt(self: *FuncGen, inst: Air.Inst.Index) ?*const llvm.Value {
5725 fn airDbgStmt(self: *FuncGen, inst: Air.Inst.Index) ?*llvm.Value {
57265726 const di_scope = self.di_scope orelse return null;
57275727 const dbg_stmt = self.air.instructions.items(.data)[inst].dbg_stmt;
57285728 self.prev_dbg_line = @intCast(c_uint, self.base_line + dbg_stmt.line + 1);
......@@ -5735,7 +5735,7 @@ pub const FuncGen = struct {
57355735 return null;
57365736 }
57375737
5738 fn airDbgInlineBegin(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5738 fn airDbgInlineBegin(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
57395739 const dib = self.dg.object.di_builder orelse return null;
57405740 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
57415741
......@@ -5778,7 +5778,7 @@ pub const FuncGen = struct {
57785778 return null;
57795779 }
57805780
5781 fn airDbgInlineEnd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5781 fn airDbgInlineEnd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
57825782 if (self.dg.object.di_builder == null) return null;
57835783 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
57845784
......@@ -5793,7 +5793,7 @@ pub const FuncGen = struct {
57935793 return null;
57945794 }
57955795
5796 fn airDbgBlockBegin(self: *FuncGen) !?*const llvm.Value {
5796 fn airDbgBlockBegin(self: *FuncGen) !?*llvm.Value {
57975797 const dib = self.dg.object.di_builder orelse return null;
57985798 const old_scope = self.di_scope.?;
57995799 try self.dbg_block_stack.append(self.gpa, old_scope);
......@@ -5802,13 +5802,13 @@ pub const FuncGen = struct {
58025802 return null;
58035803 }
58045804
5805 fn airDbgBlockEnd(self: *FuncGen) !?*const llvm.Value {
5805 fn airDbgBlockEnd(self: *FuncGen) !?*llvm.Value {
58065806 if (self.dg.object.di_builder == null) return null;
58075807 self.di_scope = self.dbg_block_stack.pop();
58085808 return null;
58095809 }
58105810
5811 fn airDbgVarPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5811 fn airDbgVarPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
58125812 const dib = self.dg.object.di_builder orelse return null;
58135813 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
58145814 const operand = try self.resolveInst(pl_op.operand);
......@@ -5834,7 +5834,7 @@ pub const FuncGen = struct {
58345834 return null;
58355835 }
58365836
5837 fn airDbgVarVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5837 fn airDbgVarVal(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
58385838 const dib = self.dg.object.di_builder orelse return null;
58395839 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
58405840 const operand = try self.resolveInst(pl_op.operand);
......@@ -5868,7 +5868,7 @@ pub const FuncGen = struct {
58685868 return null;
58695869 }
58705870
5871 fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
5871 fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
58725872 // Eventually, the Zig compiler needs to be reworked to have inline assembly go
58735873 // through the same parsing code regardless of backend, and have LLVM-flavored
58745874 // inline assembly be *output* from that assembler.
......@@ -5899,15 +5899,15 @@ pub const FuncGen = struct {
58995899 // The exact number of return / parameter values depends on which output values
59005900 // are passed by reference as indirect outputs (determined below).
59015901 const max_return_count = outputs.len;
5902 const llvm_ret_types = try arena.alloc(*const llvm.Type, max_return_count);
5902 const llvm_ret_types = try arena.alloc(*llvm.Type, max_return_count);
59035903 const llvm_ret_indirect = try arena.alloc(bool, max_return_count);
59045904
59055905 const max_param_count = inputs.len + outputs.len;
5906 const llvm_param_types = try arena.alloc(*const llvm.Type, max_param_count);
5907 const llvm_param_values = try arena.alloc(*const llvm.Value, max_param_count);
5906 const llvm_param_types = try arena.alloc(*llvm.Type, max_param_count);
5907 const llvm_param_values = try arena.alloc(*llvm.Value, max_param_count);
59085908 // This stores whether we need to add an elementtype attribute and
59095909 // if so, the element type itself.
5910 const llvm_param_attrs = try arena.alloc(?*const llvm.Type, max_param_count);
5910 const llvm_param_attrs = try arena.alloc(?*llvm.Type, max_param_count);
59115911 const target = self.dg.module.getTarget();
59125912
59135913 var llvm_ret_i: usize = 0;
......@@ -5987,7 +5987,7 @@ pub const FuncGen = struct {
59875987
59885988 const arg_llvm_value = try self.resolveInst(input);
59895989 const arg_ty = self.air.typeOf(input);
5990 var llvm_elem_ty: ?*const llvm.Type = null;
5990 var llvm_elem_ty: ?*llvm.Type = null;
59915991 if (isByRef(arg_ty)) {
59925992 llvm_elem_ty = try self.dg.lowerPtrElemTy(arg_ty);
59935993 if (constraintAllowsMemory(constraint)) {
......@@ -6208,7 +6208,7 @@ pub const FuncGen = struct {
62086208 inst: Air.Inst.Index,
62096209 operand_is_ptr: bool,
62106210 pred: llvm.IntPredicate,
6211 ) !?*const llvm.Value {
6211 ) !?*llvm.Value {
62126212 if (self.liveness.isUnused(inst)) return null;
62136213
62146214 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -6251,7 +6251,7 @@ pub const FuncGen = struct {
62516251 inst: Air.Inst.Index,
62526252 op: llvm.IntPredicate,
62536253 operand_is_ptr: bool,
6254 ) !?*const llvm.Value {
6254 ) !?*llvm.Value {
62556255 if (self.liveness.isUnused(inst)) return null;
62566256
62576257 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -6293,7 +6293,7 @@ pub const FuncGen = struct {
62936293 return self.builder.buildICmp(op, loaded, zero, "");
62946294 }
62956295
6296 fn airOptionalPayloadPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6296 fn airOptionalPayloadPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
62976297 if (self.liveness.isUnused(inst)) return null;
62986298
62996299 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6318,7 +6318,7 @@ pub const FuncGen = struct {
63186318 return self.builder.buildStructGEP(optional_llvm_ty, operand, 0, "");
63196319 }
63206320
6321 fn airOptionalPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6321 fn airOptionalPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
63226322 comptime assert(optional_layout_version == 3);
63236323
63246324 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6355,7 +6355,7 @@ pub const FuncGen = struct {
63556355 return self.builder.buildStructGEP(optional_llvm_ty, operand, 0, "");
63566356 }
63576357
6358 fn airOptionalPayload(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6358 fn airOptionalPayload(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
63596359 if (self.liveness.isUnused(inst)) return null;
63606360
63616361 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6377,7 +6377,7 @@ pub const FuncGen = struct {
63776377 self: *FuncGen,
63786378 inst: Air.Inst.Index,
63796379 operand_is_ptr: bool,
6380 ) !?*const llvm.Value {
6380 ) !?*llvm.Value {
63816381 if (self.liveness.isUnused(inst)) return null;
63826382
63836383 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6415,7 +6415,7 @@ pub const FuncGen = struct {
64156415 self: *FuncGen,
64166416 inst: Air.Inst.Index,
64176417 operand_is_ptr: bool,
6418 ) !?*const llvm.Value {
6418 ) !?*llvm.Value {
64196419 if (self.liveness.isUnused(inst))
64206420 return null;
64216421
......@@ -6452,7 +6452,7 @@ pub const FuncGen = struct {
64526452 return self.builder.buildExtractValue(operand, offset, "");
64536453 }
64546454
6455 fn airErrUnionPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6455 fn airErrUnionPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
64566456 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
64576457 const operand = try self.resolveInst(ty_op.operand);
64586458 const err_union_ty = self.air.typeOf(ty_op.operand).childType();
......@@ -6480,18 +6480,18 @@ pub const FuncGen = struct {
64806480 return self.builder.buildStructGEP(err_union_llvm_ty, operand, payload_offset, "");
64816481 }
64826482
6483 fn airErrReturnTrace(self: *FuncGen, _: Air.Inst.Index) !?*const llvm.Value {
6483 fn airErrReturnTrace(self: *FuncGen, _: Air.Inst.Index) !?*llvm.Value {
64846484 return self.err_ret_trace.?;
64856485 }
64866486
6487 fn airSetErrReturnTrace(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6487 fn airSetErrReturnTrace(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
64886488 const un_op = self.air.instructions.items(.data)[inst].un_op;
64896489 const operand = try self.resolveInst(un_op);
64906490 self.err_ret_trace = operand;
64916491 return null;
64926492 }
64936493
6494 fn airWrapOptional(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6494 fn airWrapOptional(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
64956495 if (self.liveness.isUnused(inst)) return null;
64966496
64976497 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6524,7 +6524,7 @@ pub const FuncGen = struct {
65246524 return self.builder.buildInsertValue(partial, non_null_bit, 1, "");
65256525 }
65266526
6527 fn airWrapErrUnionPayload(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6527 fn airWrapErrUnionPayload(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
65286528 if (self.liveness.isUnused(inst)) return null;
65296529
65306530 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6560,7 +6560,7 @@ pub const FuncGen = struct {
65606560 return self.builder.buildInsertValue(partial, operand, payload_offset, "");
65616561 }
65626562
6563 fn airWrapErrUnionErr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6563 fn airWrapErrUnionErr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
65646564 if (self.liveness.isUnused(inst)) return null;
65656565
65666566 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -6598,31 +6598,31 @@ pub const FuncGen = struct {
65986598 return partial;
65996599 }
66006600
6601 fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6601 fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
66026602 if (self.liveness.isUnused(inst)) return null;
66036603
66046604 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
66056605 const index = pl_op.payload;
66066606 const llvm_u32 = self.context.intType(32);
66076607 const llvm_fn = self.getIntrinsic("llvm.wasm.memory.size", &.{llvm_u32});
6608 const args: [1]*const llvm.Value = .{llvm_u32.constInt(index, .False)};
6608 const args: [1]*llvm.Value = .{llvm_u32.constInt(index, .False)};
66096609 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
66106610 }
66116611
6612 fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6612 fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
66136613 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
66146614 const index = pl_op.payload;
66156615 const operand = try self.resolveInst(pl_op.operand);
66166616 const llvm_u32 = self.context.intType(32);
66176617 const llvm_fn = self.getIntrinsic("llvm.wasm.memory.grow", &.{llvm_u32});
6618 const args: [2]*const llvm.Value = .{
6618 const args: [2]*llvm.Value = .{
66196619 llvm_u32.constInt(index, .False),
66206620 operand,
66216621 };
66226622 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
66236623 }
66246624
6625 fn airMin(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6625 fn airMin(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
66266626 if (self.liveness.isUnused(inst)) return null;
66276627
66286628 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -6635,7 +6635,7 @@ pub const FuncGen = struct {
66356635 return self.builder.buildUMin(lhs, rhs, "");
66366636 }
66376637
6638 fn airMax(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6638 fn airMax(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
66396639 if (self.liveness.isUnused(inst)) return null;
66406640
66416641 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -6648,7 +6648,7 @@ pub const FuncGen = struct {
66486648 return self.builder.buildUMax(lhs, rhs, "");
66496649 }
66506650
6651 fn airSlice(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6651 fn airSlice(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
66526652 if (self.liveness.isUnused(inst)) return null;
66536653
66546654 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -6670,7 +6670,7 @@ pub const FuncGen = struct {
66706670 return self.builder.buildInsertValue(partial, len, 1, "");
66716671 }
66726672
6673 fn airAdd(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6673 fn airAdd(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
66746674 if (self.liveness.isUnused(inst)) return null;
66756675 self.builder.setFastMath(want_fast_math);
66766676
......@@ -6685,7 +6685,7 @@ pub const FuncGen = struct {
66856685 return self.builder.buildNUWAdd(lhs, rhs, "");
66866686 }
66876687
6688 fn airAddWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6688 fn airAddWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
66896689 if (self.liveness.isUnused(inst)) return null;
66906690 self.builder.setFastMath(want_fast_math);
66916691
......@@ -6696,7 +6696,7 @@ pub const FuncGen = struct {
66966696 return self.builder.buildAdd(lhs, rhs, "");
66976697 }
66986698
6699 fn airAddSat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6699 fn airAddSat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
67006700 if (self.liveness.isUnused(inst)) return null;
67016701
67026702 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -6711,7 +6711,7 @@ pub const FuncGen = struct {
67116711 return self.builder.buildUAddSat(lhs, rhs, "");
67126712 }
67136713
6714 fn airSub(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6714 fn airSub(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
67156715 if (self.liveness.isUnused(inst)) return null;
67166716 self.builder.setFastMath(want_fast_math);
67176717
......@@ -6726,7 +6726,7 @@ pub const FuncGen = struct {
67266726 return self.builder.buildNUWSub(lhs, rhs, "");
67276727 }
67286728
6729 fn airSubWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6729 fn airSubWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
67306730 if (self.liveness.isUnused(inst)) return null;
67316731 self.builder.setFastMath(want_fast_math);
67326732
......@@ -6737,7 +6737,7 @@ pub const FuncGen = struct {
67376737 return self.builder.buildSub(lhs, rhs, "");
67386738 }
67396739
6740 fn airSubSat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6740 fn airSubSat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
67416741 if (self.liveness.isUnused(inst)) return null;
67426742
67436743 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -6751,7 +6751,7 @@ pub const FuncGen = struct {
67516751 return self.builder.buildUSubSat(lhs, rhs, "");
67526752 }
67536753
6754 fn airMul(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6754 fn airMul(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
67556755 if (self.liveness.isUnused(inst)) return null;
67566756 self.builder.setFastMath(want_fast_math);
67576757
......@@ -6766,7 +6766,7 @@ pub const FuncGen = struct {
67666766 return self.builder.buildNUWMul(lhs, rhs, "");
67676767 }
67686768
6769 fn airMulWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6769 fn airMulWrap(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
67706770 if (self.liveness.isUnused(inst)) return null;
67716771 self.builder.setFastMath(want_fast_math);
67726772
......@@ -6777,7 +6777,7 @@ pub const FuncGen = struct {
67776777 return self.builder.buildMul(lhs, rhs, "");
67786778 }
67796779
6780 fn airMulSat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6780 fn airMulSat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
67816781 if (self.liveness.isUnused(inst)) return null;
67826782
67836783 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -6791,7 +6791,7 @@ pub const FuncGen = struct {
67916791 return self.builder.buildUMulFixSat(lhs, rhs, "");
67926792 }
67936793
6794 fn airDivFloat(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6794 fn airDivFloat(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
67956795 if (self.liveness.isUnused(inst)) return null;
67966796 self.builder.setFastMath(want_fast_math);
67976797
......@@ -6803,7 +6803,7 @@ pub const FuncGen = struct {
68036803 return self.buildFloatOp(.div, inst_ty, 2, .{ lhs, rhs });
68046804 }
68056805
6806 fn airDivTrunc(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6806 fn airDivTrunc(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
68076807 if (self.liveness.isUnused(inst)) return null;
68086808 self.builder.setFastMath(want_fast_math);
68096809
......@@ -6821,7 +6821,7 @@ pub const FuncGen = struct {
68216821 return self.builder.buildUDiv(lhs, rhs, "");
68226822 }
68236823
6824 fn airDivFloor(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6824 fn airDivFloor(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
68256825 if (self.liveness.isUnused(inst)) return null;
68266826 self.builder.setFastMath(want_fast_math);
68276827
......@@ -6854,7 +6854,7 @@ pub const FuncGen = struct {
68546854 return self.builder.buildUDiv(lhs, rhs, "");
68556855 }
68566856
6857 fn airDivExact(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6857 fn airDivExact(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
68586858 if (self.liveness.isUnused(inst)) return null;
68596859 self.builder.setFastMath(want_fast_math);
68606860
......@@ -6869,7 +6869,7 @@ pub const FuncGen = struct {
68696869 return self.builder.buildExactUDiv(lhs, rhs, "");
68706870 }
68716871
6872 fn airRem(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6872 fn airRem(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
68736873 if (self.liveness.isUnused(inst)) return null;
68746874 self.builder.setFastMath(want_fast_math);
68756875
......@@ -6884,7 +6884,7 @@ pub const FuncGen = struct {
68846884 return self.builder.buildURem(lhs, rhs, "");
68856885 }
68866886
6887 fn airMod(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
6887 fn airMod(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
68886888 if (self.liveness.isUnused(inst)) return null;
68896889 self.builder.setFastMath(want_fast_math);
68906890
......@@ -6914,7 +6914,7 @@ pub const FuncGen = struct {
69146914 return self.builder.buildURem(lhs, rhs, "");
69156915 }
69166916
6917 fn airPtrAdd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6917 fn airPtrAdd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
69186918 if (self.liveness.isUnused(inst)) return null;
69196919
69206920 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -6925,17 +6925,17 @@ pub const FuncGen = struct {
69256925 const llvm_elem_ty = try self.dg.lowerPtrElemTy(ptr_ty.childType());
69266926 if (ptr_ty.ptrSize() == .One) {
69276927 // It's a pointer to an array, so according to LLVM we need an extra GEP index.
6928 const indices: [2]*const llvm.Value = .{
6928 const indices: [2]*llvm.Value = .{
69296929 self.context.intType(32).constNull(), offset,
69306930 };
69316931 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
69326932 } else {
6933 const indices: [1]*const llvm.Value = .{offset};
6933 const indices: [1]*llvm.Value = .{offset};
69346934 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
69356935 }
69366936 }
69376937
6938 fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
6938 fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
69396939 if (self.liveness.isUnused(inst)) return null;
69406940
69416941 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -6947,12 +6947,12 @@ pub const FuncGen = struct {
69476947 const llvm_elem_ty = try self.dg.lowerPtrElemTy(ptr_ty.childType());
69486948 if (ptr_ty.ptrSize() == .One) {
69496949 // It's a pointer to an array, so according to LLVM we need an extra GEP index.
6950 const indices: [2]*const llvm.Value = .{
6950 const indices: [2]*llvm.Value = .{
69516951 self.context.intType(32).constNull(), negative_offset,
69526952 };
69536953 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
69546954 } else {
6955 const indices: [1]*const llvm.Value = .{negative_offset};
6955 const indices: [1]*llvm.Value = .{negative_offset};
69566956 return self.builder.buildInBoundsGEP(llvm_elem_ty, base_ptr, &indices, indices.len, "");
69576957 }
69586958 }
......@@ -6962,7 +6962,7 @@ pub const FuncGen = struct {
69626962 inst: Air.Inst.Index,
69636963 signed_intrinsic: []const u8,
69646964 unsigned_intrinsic: []const u8,
6965 ) !?*const llvm.Value {
6965 ) !?*llvm.Value {
69666966 if (self.liveness.isUnused(inst))
69676967 return null;
69686968
......@@ -6984,7 +6984,7 @@ pub const FuncGen = struct {
69846984 const tg = self.dg.module.getTarget();
69856985
69866986 const llvm_fn = self.getIntrinsic(intrinsic_name, &.{llvm_lhs_ty});
6987 const result_struct = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &[_]*const llvm.Value{ lhs, rhs }, 2, .Fast, .Auto, "");
6987 const result_struct = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &[_]*llvm.Value{ lhs, rhs }, 2, .Fast, .Auto, "");
69886988
69896989 const result = self.builder.buildExtractValue(result_struct, 0, "");
69906990 const overflow_bit = self.builder.buildExtractValue(result_struct, 1, "");
......@@ -7018,11 +7018,11 @@ pub const FuncGen = struct {
70187018
70197019 fn buildElementwiseCall(
70207020 self: *FuncGen,
7021 llvm_fn: *const llvm.Value,
7022 args_vectors: []const *const llvm.Value,
7023 result_vector: *const llvm.Value,
7021 llvm_fn: *llvm.Value,
7022 args_vectors: []const *llvm.Value,
7023 result_vector: *llvm.Value,
70247024 vector_len: usize,
7025 ) !*const llvm.Value {
7025 ) !*llvm.Value {
70267026 const args_len = @intCast(c_uint, args_vectors.len);
70277027 const llvm_i32 = self.context.intType(32);
70287028 assert(args_len <= 3);
......@@ -7032,7 +7032,7 @@ pub const FuncGen = struct {
70327032 while (i < vector_len) : (i += 1) {
70337033 const index_i32 = llvm_i32.constInt(i, .False);
70347034
7035 var args: [3]*const llvm.Value = undefined;
7035 var args: [3]*llvm.Value = undefined;
70367036 for (args_vectors) |arg_vector, k| {
70377037 args[k] = self.builder.buildExtractElement(arg_vector, index_i32, "");
70387038 }
......@@ -7045,9 +7045,9 @@ pub const FuncGen = struct {
70457045 fn getLibcFunction(
70467046 self: *FuncGen,
70477047 fn_name: [:0]const u8,
7048 param_types: []const *const llvm.Type,
7049 return_type: *const llvm.Type,
7050 ) *const llvm.Value {
7048 param_types: []const *llvm.Type,
7049 return_type: *llvm.Type,
7050 ) *llvm.Value {
70517051 return self.dg.object.llvm_module.getNamedFunction(fn_name.ptr) orelse b: {
70527052 const alias = self.dg.object.llvm_module.getNamedGlobalAlias(fn_name.ptr, fn_name.len);
70537053 break :b if (alias) |a| a.getAliasee() else null;
......@@ -7105,8 +7105,8 @@ pub const FuncGen = struct {
71057105 self: *FuncGen,
71067106 pred: math.CompareOperator,
71077107 ty: Type,
7108 params: [2]*const llvm.Value,
7109 ) !*const llvm.Value {
7108 params: [2]*llvm.Value,
7109 ) !*llvm.Value {
71107110 const target = self.dg.module.getTarget();
71117111 const scalar_ty = ty.scalarType();
71127112 const scalar_llvm_ty = try self.dg.lowerType(scalar_ty);
......@@ -7138,7 +7138,7 @@ pub const FuncGen = struct {
71387138 fn_base_name, compiler_rt_float_abbrev,
71397139 }) catch unreachable;
71407140
7141 const param_types = [2]*const llvm.Type{ scalar_llvm_ty, scalar_llvm_ty };
7141 const param_types = [2]*llvm.Type{ scalar_llvm_ty, scalar_llvm_ty };
71427142 const llvm_i32 = self.context.intType(32);
71437143 const libc_fn = self.getLibcFunction(fn_name, param_types[0..], llvm_i32);
71447144
......@@ -7206,8 +7206,8 @@ pub const FuncGen = struct {
72067206 comptime op: FloatOp,
72077207 ty: Type,
72087208 comptime params_len: usize,
7209 params: [params_len]*const llvm.Value,
7210 ) !*const llvm.Value {
7209 params: [params_len]*llvm.Value,
7210 ) !*llvm.Value {
72117211 const target = self.dg.module.getTarget();
72127212 const scalar_ty = ty.scalarType();
72137213 const llvm_ty = try self.dg.lowerType(ty);
......@@ -7278,10 +7278,10 @@ pub const FuncGen = struct {
72787278 };
72797279 };
72807280
7281 const llvm_fn: *const llvm.Value = switch (strat) {
7281 const llvm_fn: *llvm.Value = switch (strat) {
72827282 .intrinsic => |fn_name| self.getIntrinsic(fn_name, &.{llvm_ty}),
72837283 .libc => |fn_name| b: {
7284 const param_types = [3]*const llvm.Type{ scalar_llvm_ty, scalar_llvm_ty, scalar_llvm_ty };
7284 const param_types = [3]*llvm.Type{ scalar_llvm_ty, scalar_llvm_ty, scalar_llvm_ty };
72857285 const libc_fn = self.getLibcFunction(fn_name, param_types[0..params.len], scalar_llvm_ty);
72867286 if (ty.zigTypeTag() == .Vector) {
72877287 const result = llvm_ty.getUndef();
......@@ -7294,7 +7294,7 @@ pub const FuncGen = struct {
72947294 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params_len, .C, .Auto, "");
72957295 }
72967296
7297 fn airMulAdd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7297 fn airMulAdd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
72987298 if (self.liveness.isUnused(inst)) return null;
72997299
73007300 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
......@@ -7308,7 +7308,7 @@ pub const FuncGen = struct {
73087308 return self.buildFloatOp(.fma, ty, 3, .{ mulend1, mulend2, addend });
73097309 }
73107310
7311 fn airShlWithOverflow(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7311 fn airShlWithOverflow(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
73127312 if (self.liveness.isUnused(inst))
73137313 return null;
73147314
......@@ -7368,7 +7368,7 @@ pub const FuncGen = struct {
73687368 return self.builder.buildInsertValue(partial, overflow_bit, overflow_index, "");
73697369 }
73707370
7371 fn airAnd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7371 fn airAnd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
73727372 if (self.liveness.isUnused(inst))
73737373 return null;
73747374 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7377,7 +7377,7 @@ pub const FuncGen = struct {
73777377 return self.builder.buildAnd(lhs, rhs, "");
73787378 }
73797379
7380 fn airOr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7380 fn airOr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
73817381 if (self.liveness.isUnused(inst))
73827382 return null;
73837383 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7386,7 +7386,7 @@ pub const FuncGen = struct {
73867386 return self.builder.buildOr(lhs, rhs, "");
73877387 }
73887388
7389 fn airXor(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7389 fn airXor(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
73907390 if (self.liveness.isUnused(inst))
73917391 return null;
73927392 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7395,7 +7395,7 @@ pub const FuncGen = struct {
73957395 return self.builder.buildXor(lhs, rhs, "");
73967396 }
73977397
7398 fn airShlExact(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7398 fn airShlExact(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
73997399 if (self.liveness.isUnused(inst)) return null;
74007400
74017401 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7418,7 +7418,7 @@ pub const FuncGen = struct {
74187418 return self.builder.buildNUWShl(lhs, casted_rhs, "");
74197419 }
74207420
7421 fn airShl(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7421 fn airShl(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
74227422 if (self.liveness.isUnused(inst)) return null;
74237423
74247424 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7440,7 +7440,7 @@ pub const FuncGen = struct {
74407440 return self.builder.buildShl(lhs, casted_rhs, "");
74417441 }
74427442
7443 fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7443 fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
74447444 if (self.liveness.isUnused(inst)) return null;
74457445
74467446 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7485,7 +7485,7 @@ pub const FuncGen = struct {
74857485 }
74867486 }
74877487
7488 fn airShr(self: *FuncGen, inst: Air.Inst.Index, is_exact: bool) !?*const llvm.Value {
7488 fn airShr(self: *FuncGen, inst: Air.Inst.Index, is_exact: bool) !?*llvm.Value {
74897489 if (self.liveness.isUnused(inst)) return null;
74907490
74917491 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -7521,7 +7521,7 @@ pub const FuncGen = struct {
75217521 }
75227522 }
75237523
7524 fn airIntCast(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7524 fn airIntCast(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
75257525 if (self.liveness.isUnused(inst))
75267526 return null;
75277527
......@@ -7546,7 +7546,7 @@ pub const FuncGen = struct {
75467546 }
75477547 }
75487548
7549 fn airTrunc(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7549 fn airTrunc(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
75507550 if (self.liveness.isUnused(inst)) return null;
75517551
75527552 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -7555,7 +7555,7 @@ pub const FuncGen = struct {
75557555 return self.builder.buildTrunc(operand, dest_llvm_ty, "");
75567556 }
75577557
7558 fn airFptrunc(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7558 fn airFptrunc(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
75597559 if (self.liveness.isUnused(inst))
75607560 return null;
75617561
......@@ -7573,7 +7573,7 @@ pub const FuncGen = struct {
75737573 return self.builder.buildFPTrunc(operand, dest_llvm_ty, "");
75747574 }
75757575
7576 fn airFpext(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7576 fn airFpext(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
75777577 if (self.liveness.isUnused(inst))
75787578 return null;
75797579
......@@ -7591,7 +7591,7 @@ pub const FuncGen = struct {
75917591 return self.builder.buildFPExt(operand, dest_llvm_ty, "");
75927592 }
75937593
7594 fn airPtrToInt(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7594 fn airPtrToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
75957595 if (self.liveness.isUnused(inst))
75967596 return null;
75977597
......@@ -7601,7 +7601,7 @@ pub const FuncGen = struct {
76017601 return self.builder.buildPtrToInt(operand, dest_llvm_ty, "");
76027602 }
76037603
7604 fn airBitCast(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7604 fn airBitCast(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
76057605 if (self.liveness.isUnused(inst)) return null;
76067606
76077607 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -7645,7 +7645,7 @@ pub const FuncGen = struct {
76457645 while (i < vector_len) : (i += 1) {
76467646 const index_usize = llvm_usize.constInt(i, .False);
76477647 const index_u32 = llvm_u32.constInt(i, .False);
7648 const indexes: [2]*const llvm.Value = .{ zero, index_usize };
7648 const indexes: [2]*llvm.Value = .{ zero, index_usize };
76497649 const elem_ptr = self.builder.buildInBoundsGEP(llvm_dest_ty, array_ptr, &indexes, indexes.len, "");
76507650 const elem = self.builder.buildExtractElement(operand, index_u32, "");
76517651 _ = self.builder.buildStore(elem, elem_ptr);
......@@ -7682,7 +7682,7 @@ pub const FuncGen = struct {
76827682 while (i < vector_len) : (i += 1) {
76837683 const index_usize = llvm_usize.constInt(i, .False);
76847684 const index_u32 = llvm_u32.constInt(i, .False);
7685 const indexes: [2]*const llvm.Value = .{ zero, index_usize };
7685 const indexes: [2]*llvm.Value = .{ zero, index_usize };
76867686 const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, operand, &indexes, indexes.len, "");
76877687 const elem = self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
76887688 vector = self.builder.buildInsertElement(vector, elem, index_u32, "");
......@@ -7731,7 +7731,7 @@ pub const FuncGen = struct {
77317731 return self.builder.buildBitCast(operand, llvm_dest_ty, "");
77327732 }
77337733
7734 fn airBoolToInt(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7734 fn airBoolToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
77357735 if (self.liveness.isUnused(inst))
77367736 return null;
77377737
......@@ -7740,7 +7740,7 @@ pub const FuncGen = struct {
77407740 return operand;
77417741 }
77427742
7743 fn airArg(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7743 fn airArg(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
77447744 const arg_val = self.args[self.arg_index];
77457745 self.arg_index += 1;
77467746
......@@ -7787,7 +7787,7 @@ pub const FuncGen = struct {
77877787 } else unreachable;
77887788 }
77897789
7790 fn airAlloc(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7790 fn airAlloc(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
77917791 if (self.liveness.isUnused(inst)) return null;
77927792 const ptr_ty = self.air.typeOfIndex(inst);
77937793 const pointee_type = ptr_ty.childType();
......@@ -7801,7 +7801,7 @@ pub const FuncGen = struct {
78017801 return alloca_inst;
78027802 }
78037803
7804 fn airRetPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7804 fn airRetPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
78057805 if (self.liveness.isUnused(inst)) return null;
78067806 const ptr_ty = self.air.typeOfIndex(inst);
78077807 const ret_ty = ptr_ty.childType();
......@@ -7816,11 +7816,11 @@ pub const FuncGen = struct {
78167816
78177817 /// Use this instead of builder.buildAlloca, because this function makes sure to
78187818 /// put the alloca instruction at the top of the function!
7819 fn buildAlloca(self: *FuncGen, llvm_ty: *const llvm.Type) *const llvm.Value {
7819 fn buildAlloca(self: *FuncGen, llvm_ty: *llvm.Type) *llvm.Value {
78207820 return buildAllocaInner(self.builder, self.llvm_func, self.di_scope != null, llvm_ty);
78217821 }
78227822
7823 fn airStore(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7823 fn airStore(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
78247824 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
78257825 const dest_ptr = try self.resolveInst(bin_op.lhs);
78267826 const ptr_ty = self.air.typeOf(bin_op.lhs);
......@@ -7873,7 +7873,7 @@ pub const FuncGen = struct {
78737873 inst: Air.Inst.Index,
78747874 body: []const Air.Inst.Index,
78757875 body_i: usize,
7876 ) !?*const llvm.Value {
7876 ) !?*llvm.Value {
78777877 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
78787878 const ptr_ty = self.air.typeOf(ty_op.operand);
78797879 elide: {
......@@ -7899,14 +7899,14 @@ pub const FuncGen = struct {
78997899 return self.load(ptr, ptr_ty);
79007900 }
79017901
7902 fn airBreakpoint(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7902 fn airBreakpoint(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
79037903 _ = inst;
79047904 const llvm_fn = self.getIntrinsic("llvm.debugtrap", &.{});
79057905 _ = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, undefined, 0, .C, .Auto, "");
79067906 return null;
79077907 }
79087908
7909 fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7909 fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
79107910 if (self.liveness.isUnused(inst)) return null;
79117911
79127912 const llvm_usize = try self.dg.lowerType(Type.usize);
......@@ -7918,30 +7918,30 @@ pub const FuncGen = struct {
79187918
79197919 const llvm_i32 = self.context.intType(32);
79207920 const llvm_fn = self.getIntrinsic("llvm.returnaddress", &.{});
7921 const params = [_]*const llvm.Value{llvm_i32.constNull()};
7921 const params = [_]*llvm.Value{llvm_i32.constNull()};
79227922 const ptr_val = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
79237923 return self.builder.buildPtrToInt(ptr_val, llvm_usize, "");
79247924 }
79257925
7926 fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7926 fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
79277927 if (self.liveness.isUnused(inst)) return null;
79287928
79297929 const llvm_i32 = self.context.intType(32);
79307930 const llvm_fn_name = "llvm.frameaddress.p0";
79317931 const llvm_fn = self.dg.object.llvm_module.getNamedFunction(llvm_fn_name) orelse blk: {
79327932 const llvm_p0i8 = self.context.intType(8).pointerType(0);
7933 const param_types = [_]*const llvm.Type{llvm_i32};
7933 const param_types = [_]*llvm.Type{llvm_i32};
79347934 const fn_type = llvm.functionType(llvm_p0i8, &param_types, param_types.len, .False);
79357935 break :blk self.dg.object.llvm_module.addFunction(llvm_fn_name, fn_type);
79367936 };
79377937
7938 const params = [_]*const llvm.Value{llvm_i32.constNull()};
7938 const params = [_]*llvm.Value{llvm_i32.constNull()};
79397939 const ptr_val = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
79407940 const llvm_usize = try self.dg.lowerType(Type.usize);
79417941 return self.builder.buildPtrToInt(ptr_val, llvm_usize, "");
79427942 }
79437943
7944 fn airFence(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7944 fn airFence(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
79457945 const atomic_order = self.air.instructions.items(.data)[inst].fence;
79467946 const llvm_memory_order = toLlvmAtomicOrdering(atomic_order);
79477947 const single_threaded = llvm.Bool.fromBool(self.single_threaded);
......@@ -7949,7 +7949,7 @@ pub const FuncGen = struct {
79497949 return null;
79507950 }
79517951
7952 fn airCmpxchg(self: *FuncGen, inst: Air.Inst.Index, is_weak: bool) !?*const llvm.Value {
7952 fn airCmpxchg(self: *FuncGen, inst: Air.Inst.Index, is_weak: bool) !?*llvm.Value {
79537953 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
79547954 const extra = self.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
79557955 var ptr = try self.resolveInst(extra.ptr);
......@@ -7996,7 +7996,7 @@ pub const FuncGen = struct {
79967996 return buildOptional(self, optional_ty, payload, non_null_bit);
79977997 }
79987998
7999 fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
7999 fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
80008000 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
80018001 const extra = self.air.extraData(Air.AtomicRmw, pl_op.payload).data;
80028002 const ptr = try self.resolveInst(pl_op.operand);
......@@ -8053,7 +8053,7 @@ pub const FuncGen = struct {
80538053 return self.builder.buildIntToPtr(uncasted_result, operand_llvm_ty, "");
80548054 }
80558055
8056 fn airAtomicLoad(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8056 fn airAtomicLoad(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
80578057 const atomic_load = self.air.instructions.items(.data)[inst].atomic_load;
80588058 const ptr = try self.resolveInst(atomic_load.ptr);
80598059 const ptr_ty = self.air.typeOf(atomic_load.ptr);
......@@ -8090,7 +8090,7 @@ pub const FuncGen = struct {
80908090 self: *FuncGen,
80918091 inst: Air.Inst.Index,
80928092 ordering: llvm.AtomicOrdering,
8093 ) !?*const llvm.Value {
8093 ) !?*llvm.Value {
80948094 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
80958095 const ptr_ty = self.air.typeOf(bin_op.lhs);
80968096 const operand_ty = ptr_ty.childType();
......@@ -8112,7 +8112,7 @@ pub const FuncGen = struct {
81128112 return null;
81138113 }
81148114
8115 fn airMemset(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8115 fn airMemset(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
81168116 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
81178117 const extra = self.air.extraData(Air.Bin, pl_op.payload).data;
81188118 const dest_ptr = try self.resolveInst(pl_op.operand);
......@@ -8134,7 +8134,7 @@ pub const FuncGen = struct {
81348134 return null;
81358135 }
81368136
8137 fn airMemcpy(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8137 fn airMemcpy(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
81388138 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
81398139 const extra = self.air.extraData(Air.Bin, pl_op.payload).data;
81408140 const dest_ptr = try self.resolveInst(pl_op.operand);
......@@ -8158,7 +8158,7 @@ pub const FuncGen = struct {
81588158 return null;
81598159 }
81608160
8161 fn airSetUnionTag(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8161 fn airSetUnionTag(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
81628162 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
81638163 const un_ty = self.air.typeOf(bin_op.lhs).childType();
81648164 const target = self.dg.module.getTarget();
......@@ -8179,7 +8179,7 @@ pub const FuncGen = struct {
81798179 return null;
81808180 }
81818181
8182 fn airGetUnionTag(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8182 fn airGetUnionTag(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
81838183 if (self.liveness.isUnused(inst)) return null;
81848184
81858185 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -8205,7 +8205,7 @@ pub const FuncGen = struct {
82058205 }
82068206 }
82078207
8208 fn airUnaryOp(self: *FuncGen, inst: Air.Inst.Index, comptime op: FloatOp) !?*const llvm.Value {
8208 fn airUnaryOp(self: *FuncGen, inst: Air.Inst.Index, comptime op: FloatOp) !?*llvm.Value {
82098209 if (self.liveness.isUnused(inst)) return null;
82108210
82118211 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -8215,7 +8215,7 @@ pub const FuncGen = struct {
82158215 return self.buildFloatOp(op, operand_ty, 1, .{operand});
82168216 }
82178217
8218 fn airNeg(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
8218 fn airNeg(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
82198219 if (self.liveness.isUnused(inst)) return null;
82208220 self.builder.setFastMath(want_fast_math);
82218221
......@@ -8226,7 +8226,7 @@ pub const FuncGen = struct {
82268226 return self.buildFloatOp(.neg, operand_ty, 1, .{operand});
82278227 }
82288228
8229 fn airClzCtz(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*const llvm.Value {
8229 fn airClzCtz(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*llvm.Value {
82308230 if (self.liveness.isUnused(inst)) return null;
82318231
82328232 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -8237,7 +8237,7 @@ pub const FuncGen = struct {
82378237 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
82388238 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
82398239
8240 const params = [_]*const llvm.Value{ operand, llvm_i1.constNull() };
8240 const params = [_]*llvm.Value{ operand, llvm_i1.constNull() };
82418241 const wrong_size_result = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
82428242 const result_ty = self.air.typeOfIndex(inst);
82438243 const result_llvm_ty = try self.dg.lowerType(result_ty);
......@@ -8254,14 +8254,14 @@ pub const FuncGen = struct {
82548254 }
82558255 }
82568256
8257 fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*const llvm.Value {
8257 fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*llvm.Value {
82588258 if (self.liveness.isUnused(inst)) return null;
82598259
82608260 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
82618261 const operand_ty = self.air.typeOf(ty_op.operand);
82628262 const operand = try self.resolveInst(ty_op.operand);
82638263
8264 const params = [_]*const llvm.Value{operand};
8264 const params = [_]*llvm.Value{operand};
82658265 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
82668266 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
82678267
......@@ -8281,7 +8281,7 @@ pub const FuncGen = struct {
82818281 }
82828282 }
82838283
8284 fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*const llvm.Value {
8284 fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index, llvm_fn_name: []const u8) !?*llvm.Value {
82858285 if (self.liveness.isUnused(inst)) return null;
82868286
82878287 const target = self.dg.module.getTarget();
......@@ -8301,7 +8301,7 @@ pub const FuncGen = struct {
83018301 const vec_len = operand_ty.vectorLen();
83028302 operand_llvm_ty = scalar_llvm_ty.vectorType(vec_len);
83038303
8304 const shifts = try self.gpa.alloc(*const llvm.Value, vec_len);
8304 const shifts = try self.gpa.alloc(*llvm.Value, vec_len);
83058305 defer self.gpa.free(shifts);
83068306
83078307 for (shifts) |*elem| {
......@@ -8319,7 +8319,7 @@ pub const FuncGen = struct {
83198319 bits = bits + 8;
83208320 }
83218321
8322 const params = [_]*const llvm.Value{operand};
8322 const params = [_]*llvm.Value{operand};
83238323 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
83248324
83258325 const wrong_size_result = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
......@@ -8336,7 +8336,7 @@ pub const FuncGen = struct {
83368336 }
83378337 }
83388338
8339 fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8339 fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
83408340 if (self.liveness.isUnused(inst)) return null;
83418341
83428342 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -8372,10 +8372,10 @@ pub const FuncGen = struct {
83728372 self.builder.positionBuilderAtEnd(end_block);
83738373
83748374 const llvm_type = self.dg.context.intType(1);
8375 const incoming_values: [2]*const llvm.Value = .{
8375 const incoming_values: [2]*llvm.Value = .{
83768376 llvm_type.constInt(1, .False), llvm_type.constInt(0, .False),
83778377 };
8378 const incoming_blocks: [2]*const llvm.BasicBlock = .{
8378 const incoming_blocks: [2]*llvm.BasicBlock = .{
83798379 valid_block, invalid_block,
83808380 };
83818381 const phi_node = self.builder.buildPhi(llvm_type, "");
......@@ -8383,7 +8383,7 @@ pub const FuncGen = struct {
83838383 return phi_node;
83848384 }
83858385
8386 fn airIsNamedEnumValue(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8386 fn airIsNamedEnumValue(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
83878387 if (self.liveness.isUnused(inst)) return null;
83888388
83898389 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -8391,11 +8391,11 @@ pub const FuncGen = struct {
83918391 const enum_ty = self.air.typeOf(un_op);
83928392
83938393 const llvm_fn = try self.getIsNamedEnumValueFunction(enum_ty);
8394 const params = [_]*const llvm.Value{operand};
8394 const params = [_]*llvm.Value{operand};
83958395 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
83968396 }
83978397
8398 fn getIsNamedEnumValueFunction(self: *FuncGen, enum_ty: Type) !*const llvm.Value {
8398 fn getIsNamedEnumValueFunction(self: *FuncGen, enum_ty: Type) !*llvm.Value {
83998399 const enum_decl = enum_ty.getOwnerDecl();
84008400
84018401 // TODO: detect when the type changes and re-emit this function.
......@@ -8414,7 +8414,7 @@ pub const FuncGen = struct {
84148414
84158415 var int_tag_type_buffer: Type.Payload.Bits = undefined;
84168416 const int_tag_ty = enum_ty.intTagType(&int_tag_type_buffer);
8417 const param_types = [_]*const llvm.Type{try self.dg.lowerType(int_tag_ty)};
8417 const param_types = [_]*llvm.Type{try self.dg.lowerType(int_tag_ty)};
84188418
84198419 const llvm_ret_ty = try self.dg.lowerType(Type.bool);
84208420 const fn_type = llvm.functionType(llvm_ret_ty, &param_types, param_types.len, .False);
......@@ -8464,7 +8464,7 @@ pub const FuncGen = struct {
84648464 return fn_val;
84658465 }
84668466
8467 fn airTagName(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8467 fn airTagName(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
84688468 if (self.liveness.isUnused(inst)) return null;
84698469
84708470 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -8472,11 +8472,11 @@ pub const FuncGen = struct {
84728472 const enum_ty = self.air.typeOf(un_op);
84738473
84748474 const llvm_fn = try self.getEnumTagNameFunction(enum_ty);
8475 const params = [_]*const llvm.Value{operand};
8475 const params = [_]*llvm.Value{operand};
84768476 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
84778477 }
84788478
8479 fn getEnumTagNameFunction(self: *FuncGen, enum_ty: Type) !*const llvm.Value {
8479 fn getEnumTagNameFunction(self: *FuncGen, enum_ty: Type) !*llvm.Value {
84808480 const enum_decl = enum_ty.getOwnerDecl();
84818481
84828482 // TODO: detect when the type changes and re-emit this function.
......@@ -8501,7 +8501,7 @@ pub const FuncGen = struct {
85018501
85028502 var int_tag_type_buffer: Type.Payload.Bits = undefined;
85038503 const int_tag_ty = enum_ty.intTagType(&int_tag_type_buffer);
8504 const param_types = [_]*const llvm.Type{try self.dg.lowerType(int_tag_ty)};
8504 const param_types = [_]*llvm.Type{try self.dg.lowerType(int_tag_ty)};
85058505
85068506 const fn_type = llvm.functionType(llvm_ret_ty, &param_types, param_types.len, .False);
85078507 const fn_val = self.dg.object.llvm_module.addFunction(llvm_fn_name, fn_type);
......@@ -8528,7 +8528,7 @@ pub const FuncGen = struct {
85288528 const tag_int_value = fn_val.getParam(0);
85298529 const switch_instr = self.builder.buildSwitch(tag_int_value, bad_value_block, @intCast(c_uint, fields.count()));
85308530
8531 const array_ptr_indices = [_]*const llvm.Value{
8531 const array_ptr_indices = [_]*llvm.Value{
85328532 usize_llvm_ty.constNull(), usize_llvm_ty.constNull(),
85338533 };
85348534
......@@ -8542,7 +8542,7 @@ pub const FuncGen = struct {
85428542 str_global.setUnnamedAddr(.True);
85438543 str_global.setAlignment(1);
85448544
8545 const slice_fields = [_]*const llvm.Value{
8545 const slice_fields = [_]*llvm.Value{
85468546 str_init_llvm_ty.constInBoundsGEP(str_global, &array_ptr_indices, array_ptr_indices.len),
85478547 usize_llvm_ty.constInt(name.len, .False),
85488548 };
......@@ -8578,7 +8578,7 @@ pub const FuncGen = struct {
85788578 return fn_val;
85798579 }
85808580
8581 fn getCmpLtErrorsLenFunction(self: *FuncGen) !*const llvm.Value {
8581 fn getCmpLtErrorsLenFunction(self: *FuncGen) !*llvm.Value {
85828582 if (self.dg.object.llvm_module.getNamedFunction(lt_errors_fn_name)) |llvm_fn| {
85838583 return llvm_fn;
85848584 }
......@@ -8587,7 +8587,7 @@ pub const FuncGen = struct {
85878587
85888588 const ret_llvm_ty = try self.dg.lowerType(Type.bool);
85898589 const anyerror_llvm_ty = try self.dg.lowerType(Type.anyerror);
8590 const param_types = [_]*const llvm.Type{anyerror_llvm_ty};
8590 const param_types = [_]*llvm.Type{anyerror_llvm_ty};
85918591
85928592 const fn_type = llvm.functionType(ret_llvm_ty, &param_types, param_types.len, .False);
85938593 const llvm_fn = self.dg.object.llvm_module.addFunction(lt_errors_fn_name, fn_type);
......@@ -8597,7 +8597,7 @@ pub const FuncGen = struct {
85978597 return llvm_fn;
85988598 }
85998599
8600 fn airErrorName(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8600 fn airErrorName(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
86018601 if (self.liveness.isUnused(inst)) return null;
86028602
86038603 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -8608,12 +8608,12 @@ pub const FuncGen = struct {
86088608 const error_name_table_ptr = try self.getErrorNameTable();
86098609 const ptr_slice_llvm_ty = slice_llvm_ty.pointerType(0);
86108610 const error_name_table = self.builder.buildLoad(ptr_slice_llvm_ty, error_name_table_ptr, "");
8611 const indices = [_]*const llvm.Value{operand};
8611 const indices = [_]*llvm.Value{operand};
86128612 const error_name_ptr = self.builder.buildInBoundsGEP(slice_llvm_ty, error_name_table, &indices, indices.len, "");
86138613 return self.builder.buildLoad(slice_llvm_ty, error_name_ptr, "");
86148614 }
86158615
8616 fn airSplat(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8616 fn airSplat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
86178617 if (self.liveness.isUnused(inst)) return null;
86188618
86198619 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -8623,7 +8623,7 @@ pub const FuncGen = struct {
86238623 return self.builder.buildVectorSplat(len, scalar, "");
86248624 }
86258625
8626 fn airSelect(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8626 fn airSelect(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
86278627 if (self.liveness.isUnused(inst)) return null;
86288628
86298629 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
......@@ -8635,7 +8635,7 @@ pub const FuncGen = struct {
86358635 return self.builder.buildSelect(pred, a, b, "");
86368636 }
86378637
8638 fn airShuffle(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8638 fn airShuffle(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
86398639 if (self.liveness.isUnused(inst)) return null;
86408640
86418641 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -8651,7 +8651,7 @@ pub const FuncGen = struct {
86518651 // when changing code, so Zig uses negative numbers to index the
86528652 // second vector. These start at -1 and go down, and are easiest to use
86538653 // with the ~ operator. Here we convert between the two formats.
8654 const values = try self.gpa.alloc(*const llvm.Value, mask_len);
8654 const values = try self.gpa.alloc(*llvm.Value, mask_len);
86558655 defer self.gpa.free(values);
86568656
86578657 const llvm_i32 = self.context.intType(32);
......@@ -8672,7 +8672,7 @@ pub const FuncGen = struct {
86728672 return self.builder.buildShuffleVector(a, b, llvm_mask_value, "");
86738673 }
86748674
8675 fn airReduce(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
8675 fn airReduce(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
86768676 if (self.liveness.isUnused(inst)) return null;
86778677 self.builder.setFastMath(want_fast_math);
86788678
......@@ -8717,7 +8717,7 @@ pub const FuncGen = struct {
87178717 }
87188718 }
87198719
8720 fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8720 fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
87218721 if (self.liveness.isUnused(inst)) return null;
87228722
87238723 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -8746,7 +8746,7 @@ pub const FuncGen = struct {
87468746 const int_llvm_ty = self.dg.context.intType(@intCast(c_uint, big_bits));
87478747 const fields = struct_obj.fields.values();
87488748 comptime assert(Type.packed_struct_layout_version == 2);
8749 var running_int: *const llvm.Value = int_llvm_ty.constNull();
8749 var running_int: *llvm.Value = int_llvm_ty.constNull();
87508750 var running_bits: u16 = 0;
87518751 for (elements) |elem, i| {
87528752 const field = fields[i];
......@@ -8780,7 +8780,7 @@ pub const FuncGen = struct {
87808780 // even if we fully populate the fields.
87818781 alloca_inst.setAlignment(result_ty.abiAlignment(target));
87828782
8783 var indices: [2]*const llvm.Value = .{ llvm_u32.constNull(), undefined };
8783 var indices: [2]*llvm.Value = .{ llvm_u32.constNull(), undefined };
87848784 for (elements) |elem, i| {
87858785 if (result_ty.structFieldValueComptime(i) != null) continue;
87868786
......@@ -8829,7 +8829,7 @@ pub const FuncGen = struct {
88298829 const elem_ptr_ty = Type.initPayload(&elem_ptr_payload.base);
88308830
88318831 for (elements) |elem, i| {
8832 const indices: [2]*const llvm.Value = .{
8832 const indices: [2]*llvm.Value = .{
88338833 llvm_usize.constNull(),
88348834 llvm_usize.constInt(@intCast(c_uint, i), .False),
88358835 };
......@@ -8838,7 +8838,7 @@ pub const FuncGen = struct {
88388838 self.store(elem_ptr, elem_ptr_ty, llvm_elem, .NotAtomic);
88398839 }
88408840 if (array_info.sentinel) |sent_val| {
8841 const indices: [2]*const llvm.Value = .{
8841 const indices: [2]*llvm.Value = .{
88428842 llvm_usize.constNull(),
88438843 llvm_usize.constInt(@intCast(c_uint, array_info.len), .False),
88448844 };
......@@ -8857,7 +8857,7 @@ pub const FuncGen = struct {
88578857 }
88588858 }
88598859
8860 fn airUnionInit(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8860 fn airUnionInit(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
88618861 if (self.liveness.isUnused(inst)) return null;
88628862
88638863 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
......@@ -8910,17 +8910,17 @@ pub const FuncGen = struct {
89108910 break :p field_llvm_ty;
89118911 }
89128912 const padding_len = @intCast(c_uint, layout.payload_size - field_size);
8913 const fields: [2]*const llvm.Type = .{
8913 const fields: [2]*llvm.Type = .{
89148914 field_llvm_ty, self.context.intType(8).arrayType(padding_len),
89158915 };
89168916 break :p self.context.structType(&fields, fields.len, .False);
89178917 };
89188918 if (layout.tag_size == 0) {
8919 const fields: [1]*const llvm.Type = .{payload};
8919 const fields: [1]*llvm.Type = .{payload};
89208920 break :t self.context.structType(&fields, fields.len, .False);
89218921 }
89228922 const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty);
8923 var fields: [3]*const llvm.Type = undefined;
8923 var fields: [3]*llvm.Type = undefined;
89248924 var fields_len: c_uint = 2;
89258925 if (layout.tag_align >= layout.payload_align) {
89268926 fields = .{ tag_llvm_ty, payload, undefined };
......@@ -8949,7 +8949,7 @@ pub const FuncGen = struct {
89498949 };
89508950 const field_ptr_ty = Type.initPayload(&field_ptr_payload.base);
89518951 if (layout.tag_size == 0) {
8952 const indices: [3]*const llvm.Value = .{
8952 const indices: [3]*llvm.Value = .{
89538953 index_type.constNull(),
89548954 index_type.constNull(),
89558955 index_type.constNull(),
......@@ -8961,7 +8961,7 @@ pub const FuncGen = struct {
89618961 }
89628962
89638963 {
8964 const indices: [3]*const llvm.Value = .{
8964 const indices: [3]*llvm.Value = .{
89658965 index_type.constNull(),
89668966 index_type.constInt(@boolToInt(layout.tag_align >= layout.payload_align), .False),
89678967 index_type.constNull(),
......@@ -8971,7 +8971,7 @@ pub const FuncGen = struct {
89718971 self.store(field_ptr, field_ptr_ty, llvm_payload, .NotAtomic);
89728972 }
89738973 {
8974 const indices: [2]*const llvm.Value = .{
8974 const indices: [2]*llvm.Value = .{
89758975 index_type.constNull(),
89768976 index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False),
89778977 };
......@@ -8985,7 +8985,7 @@ pub const FuncGen = struct {
89858985 return result_ptr;
89868986 }
89878987
8988 fn airPrefetch(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
8988 fn airPrefetch(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
89898989 const prefetch = self.air.instructions.items(.data)[inst].prefetch;
89908990
89918991 comptime assert(@enumToInt(std.builtin.PrefetchOptions.Rw.read) == 0);
......@@ -9026,7 +9026,7 @@ pub const FuncGen = struct {
90269026 const fn_val = self.dg.object.llvm_module.getNamedFunction(llvm_fn_name) orelse blk: {
90279027 // declare void @llvm.prefetch(i8*, i32, i32, i32)
90289028 const llvm_void = self.context.voidType();
9029 const param_types = [_]*const llvm.Type{
9029 const param_types = [_]*llvm.Type{
90309030 llvm_ptr_u8, llvm_u32, llvm_u32, llvm_u32,
90319031 };
90329032 const fn_type = llvm.functionType(llvm_void, &param_types, param_types.len, .False);
......@@ -9036,7 +9036,7 @@ pub const FuncGen = struct {
90369036 const ptr = try self.resolveInst(prefetch.ptr);
90379037 const ptr_u8 = self.builder.buildBitCast(ptr, llvm_ptr_u8, "");
90389038
9039 const params = [_]*const llvm.Value{
9039 const params = [_]*llvm.Value{
90409040 ptr_u8,
90419041 llvm_u32.constInt(@enumToInt(prefetch.rw), .False),
90429042 llvm_u32.constInt(prefetch.locality, .False),
......@@ -9048,17 +9048,17 @@ pub const FuncGen = struct {
90489048
90499049 fn softF80TruncOrExt(
90509050 self: *FuncGen,
9051 operand: *const llvm.Value,
9051 operand: *llvm.Value,
90529052 src_bits: u16,
90539053 dest_bits: u16,
9054 ) !?*const llvm.Value {
9054 ) !?*llvm.Value {
90559055 const target = self.dg.module.getTarget();
90569056
9057 var param_llvm_ty: *const llvm.Type = self.context.intType(80);
9058 var ret_llvm_ty: *const llvm.Type = param_llvm_ty;
9057 var param_llvm_ty: *llvm.Type = self.context.intType(80);
9058 var ret_llvm_ty: *llvm.Type = param_llvm_ty;
90599059 var fn_name: [*:0]const u8 = undefined;
90609060 var arg = operand;
9061 var final_cast: ?*const llvm.Type = null;
9061 var final_cast: ?*llvm.Type = null;
90629062
90639063 assert(src_bits == 80 or dest_bits == 80);
90649064
......@@ -9116,18 +9116,18 @@ pub const FuncGen = struct {
91169116 }
91179117
91189118 const llvm_fn = self.dg.object.llvm_module.getNamedFunction(fn_name) orelse f: {
9119 const param_types = [_]*const llvm.Type{param_llvm_ty};
9119 const param_types = [_]*llvm.Type{param_llvm_ty};
91209120 const fn_type = llvm.functionType(ret_llvm_ty, &param_types, param_types.len, .False);
91219121 break :f self.dg.object.llvm_module.addFunction(fn_name, fn_type);
91229122 };
91239123
9124 var args: [1]*const llvm.Value = .{arg};
9124 var args: [1]*llvm.Value = .{arg};
91259125 const result = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .C, .Auto, "");
91269126 const final_cast_llvm_ty = final_cast orelse return result;
91279127 return self.builder.buildBitCast(result, final_cast_llvm_ty, "");
91289128 }
91299129
9130 fn getErrorNameTable(self: *FuncGen) !*const llvm.Value {
9130 fn getErrorNameTable(self: *FuncGen) !*llvm.Value {
91319131 if (self.dg.object.error_name_table) |table| {
91329132 return table;
91339133 }
......@@ -9151,10 +9151,10 @@ pub const FuncGen = struct {
91519151 /// Assumes the optional is not pointer-like and payload has bits.
91529152 fn optIsNonNull(
91539153 self: *FuncGen,
9154 opt_llvm_ty: *const llvm.Type,
9155 opt_handle: *const llvm.Value,
9154 opt_llvm_ty: *llvm.Type,
9155 opt_handle: *llvm.Value,
91569156 is_by_ref: bool,
9157 ) *const llvm.Value {
9157 ) *llvm.Value {
91589158 const non_null_llvm_ty = self.context.intType(8);
91599159 const field = b: {
91609160 if (is_by_ref) {
......@@ -9171,10 +9171,10 @@ pub const FuncGen = struct {
91719171 /// Assumes the optional is not pointer-like and payload has bits.
91729172 fn optPayloadHandle(
91739173 fg: *FuncGen,
9174 opt_llvm_ty: *const llvm.Type,
9175 opt_handle: *const llvm.Value,
9174 opt_llvm_ty: *llvm.Type,
9175 opt_handle: *llvm.Value,
91769176 opt_ty: Type,
9177 ) !*const llvm.Value {
9177 ) !*llvm.Value {
91789178 var buf: Type.Payload.ElemType = undefined;
91799179 const payload_ty = opt_ty.optionalChild(&buf);
91809180
......@@ -9200,9 +9200,9 @@ pub const FuncGen = struct {
92009200 fn buildOptional(
92019201 self: *FuncGen,
92029202 optional_ty: Type,
9203 payload: *const llvm.Value,
9204 non_null_bit: *const llvm.Value,
9205 ) !?*const llvm.Value {
9203 payload: *llvm.Value,
9204 non_null_bit: *llvm.Value,
9205 ) !?*llvm.Value {
92069206 const optional_llvm_ty = try self.dg.lowerType(optional_ty);
92079207 const non_null_field = self.builder.buildZExt(non_null_bit, self.dg.context.intType(8), "");
92089208
......@@ -9233,10 +9233,10 @@ pub const FuncGen = struct {
92339233 fn fieldPtr(
92349234 self: *FuncGen,
92359235 inst: Air.Inst.Index,
9236 struct_ptr: *const llvm.Value,
9236 struct_ptr: *llvm.Value,
92379237 struct_ptr_ty: Type,
92389238 field_index: u32,
9239 ) !?*const llvm.Value {
9239 ) !?*llvm.Value {
92409240 if (self.liveness.isUnused(inst)) return null;
92419241
92429242 const target = self.dg.object.target;
......@@ -9268,7 +9268,7 @@ pub const FuncGen = struct {
92689268 const ptr_as_bytes = self.builder.buildBitCast(struct_ptr, byte_llvm_ty.pointerType(0), "");
92699269 const llvm_usize = try self.dg.lowerType(Type.usize);
92709270 const llvm_index = llvm_usize.constInt(byte_offset, .False);
9271 const indices: [1]*const llvm.Value = .{llvm_index};
9271 const indices: [1]*llvm.Value = .{llvm_index};
92729272 const new_ptr = self.builder.buildInBoundsGEP(byte_llvm_ty, ptr_as_bytes, &indices, indices.len, "");
92739273 return self.builder.buildBitCast(new_ptr, result_llvm_ty, "");
92749274 },
......@@ -9285,7 +9285,7 @@ pub const FuncGen = struct {
92859285 // the struct.
92869286 const llvm_usize = try self.dg.lowerType(Type.usize);
92879287 const llvm_index = llvm_usize.constInt(1, .False);
9288 const indices: [1]*const llvm.Value = .{llvm_index};
9288 const indices: [1]*llvm.Value = .{llvm_index};
92899289 return self.builder.buildInBoundsGEP(struct_llvm_ty, struct_ptr, &indices, indices.len, "");
92909290 }
92919291 },
......@@ -9298,9 +9298,9 @@ pub const FuncGen = struct {
92989298 fn unionFieldPtr(
92999299 self: *FuncGen,
93009300 inst: Air.Inst.Index,
9301 union_ptr: *const llvm.Value,
9301 union_ptr: *llvm.Value,
93029302 union_ty: Type,
9303 ) !?*const llvm.Value {
9303 ) !?*llvm.Value {
93049304 const target = self.dg.module.getTarget();
93059305 const layout = union_ty.unionGetLayout(target);
93069306 const result_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst));
......@@ -9313,7 +9313,7 @@ pub const FuncGen = struct {
93139313 return self.builder.buildBitCast(union_field_ptr, result_llvm_ty, "");
93149314 }
93159315
9316 fn getIntrinsic(self: *FuncGen, name: []const u8, types: []const *const llvm.Type) *const llvm.Value {
9316 fn getIntrinsic(self: *FuncGen, name: []const u8, types: []const *llvm.Type) *llvm.Value {
93179317 const id = llvm.lookupIntrinsicID(name.ptr, name.len);
93189318 assert(id != 0);
93199319 return self.llvmModule().getIntrinsicDeclaration(id, types.ptr, types.len);
......@@ -9322,7 +9322,7 @@ pub const FuncGen = struct {
93229322 /// This function always performs a copy. For isByRef=true types, it creates a new
93239323 /// alloca and copies the value into it, then returns the alloca instruction.
93249324 /// For isByRef=false types, it creates a load instruction and returns it.
9325 fn load(self: *FuncGen, ptr: *const llvm.Value, ptr_ty: Type) !?*const llvm.Value {
9325 fn load(self: *FuncGen, ptr: *llvm.Value, ptr_ty: Type) !?*llvm.Value {
93269326 const info = ptr_ty.ptrInfo().data;
93279327 if (!info.pointee_type.hasRuntimeBitsIgnoreComptime()) return null;
93289328
......@@ -9396,9 +9396,9 @@ pub const FuncGen = struct {
93969396
93979397 fn store(
93989398 self: *FuncGen,
9399 ptr: *const llvm.Value,
9399 ptr: *llvm.Value,
94009400 ptr_ty: Type,
9401 elem: *const llvm.Value,
9401 elem: *llvm.Value,
94029402 ordering: llvm.AtomicOrdering,
94039403 ) void {
94049404 const info = ptr_ty.ptrInfo().data;
......@@ -9463,7 +9463,7 @@ pub const FuncGen = struct {
94639463 );
94649464 }
94659465
9466 fn valgrindMarkUndef(fg: *FuncGen, ptr: *const llvm.Value, len: *const llvm.Value) void {
9466 fn valgrindMarkUndef(fg: *FuncGen, ptr: *llvm.Value, len: *llvm.Value) void {
94679467 const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545;
94689468 const target = fg.dg.module.getTarget();
94699469 const usize_llvm_ty = fg.context.intType(target.cpu.arch.ptrBitWidth());
......@@ -9475,14 +9475,14 @@ pub const FuncGen = struct {
94759475
94769476 fn valgrindClientRequest(
94779477 fg: *FuncGen,
9478 default_value: *const llvm.Value,
9479 request: *const llvm.Value,
9480 a1: *const llvm.Value,
9481 a2: *const llvm.Value,
9482 a3: *const llvm.Value,
9483 a4: *const llvm.Value,
9484 a5: *const llvm.Value,
9485 ) *const llvm.Value {
9478 default_value: *llvm.Value,
9479 request: *llvm.Value,
9480 a1: *llvm.Value,
9481 a2: *llvm.Value,
9482 a3: *llvm.Value,
9483 a4: *llvm.Value,
9484 a5: *llvm.Value,
9485 ) *llvm.Value {
94869486 const target = fg.dg.module.getTarget();
94879487 if (!target_util.hasValgrindSupport(target)) return default_value;
94889488
......@@ -9498,10 +9498,10 @@ pub const FuncGen = struct {
94989498 fg.valgrind_client_request_array = array_ptr;
94999499 break :a array_ptr;
95009500 };
9501 const array_elements = [_]*const llvm.Value{ request, a1, a2, a3, a4, a5 };
9501 const array_elements = [_]*llvm.Value{ request, a1, a2, a3, a4, a5 };
95029502 const zero = usize_llvm_ty.constInt(0, .False);
95039503 for (array_elements) |elem, i| {
9504 const indexes = [_]*const llvm.Value{
9504 const indexes = [_]*llvm.Value{
95059505 zero, usize_llvm_ty.constInt(@intCast(c_uint, i), .False),
95069506 };
95079507 const elem_ptr = fg.builder.buildInBoundsGEP(array_llvm_ty, array_ptr, &indexes, indexes.len, "");
......@@ -9518,8 +9518,8 @@ pub const FuncGen = struct {
95189518 const asm_constraints = "={rdx},{rax},0,~{cc},~{memory}";
95199519
95209520 const array_ptr_as_usize = fg.builder.buildPtrToInt(array_ptr, usize_llvm_ty, "");
9521 const args = [_]*const llvm.Value{ array_ptr_as_usize, default_value };
9522 const param_types = [_]*const llvm.Type{ usize_llvm_ty, usize_llvm_ty };
9521 const args = [_]*llvm.Value{ array_ptr_as_usize, default_value };
9522 const param_types = [_]*llvm.Type{ usize_llvm_ty, usize_llvm_ty };
95239523 const fn_llvm_ty = llvm.functionType(usize_llvm_ty, &param_types, args.len, .False);
95249524 const asm_fn = llvm.getInlineAsm(
95259525 fn_llvm_ty,
......@@ -9898,7 +9898,7 @@ fn firstParamSRet(fn_info: Type.Payload.Function.Data, target: std.Target) bool
98989898/// In order to support the C calling convention, some return types need to be lowered
98999899/// completely differently in the function prototype to honor the C ABI, and then
99009900/// be effectively bitcasted to the actual return type.
9901fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*const llvm.Type {
9901fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*llvm.Type {
99029902 if (!fn_info.return_type.hasRuntimeBitsIgnoreComptime()) {
99039903 // If the return type is an error set or an error union, then we make this
99049904 // anyerror return type instead, so that it can be coerced into a function
......@@ -9945,7 +9945,7 @@ fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*const llvm.
99459945 if (classes[0] == .memory) {
99469946 return dg.context.voidType();
99479947 }
9948 var llvm_types_buffer: [8]*const llvm.Type = undefined;
9948 var llvm_types_buffer: [8]*llvm.Type = undefined;
99499949 var llvm_types_index: u32 = 0;
99509950 for (classes) |class| {
99519951 switch (class) {
......@@ -10488,11 +10488,11 @@ fn compilerRtIntBits(bits: u16) u16 {
1048810488}
1048910489
1049010490fn buildAllocaInner(
10491 builder: *const llvm.Builder,
10492 llvm_func: *const llvm.Value,
10491 builder: *llvm.Builder,
10492 llvm_func: *llvm.Value,
1049310493 di_scope_non_null: bool,
10494 llvm_ty: *const llvm.Type,
10495) *const llvm.Value {
10494 llvm_ty: *llvm.Type,
10495) *llvm.Value {
1049610496 const prev_block = builder.getInsertBlock();
1049710497 const prev_debug_location = builder.getCurrentDebugLocation2();
1049810498 defer {
src/codegen/llvm/bindings.zig+360-360
......@@ -20,405 +20,405 @@ pub const AttributeIndex = c_uint;
2020/// Make sure to use the *InContext functions instead of the global ones.
2121pub const Context = opaque {
2222 pub const create = LLVMContextCreate;
23 extern fn LLVMContextCreate() *const Context;
23 extern fn LLVMContextCreate() *Context;
2424
2525 pub const dispose = LLVMContextDispose;
26 extern fn LLVMContextDispose(C: *const Context) void;
26 extern fn LLVMContextDispose(C: *Context) void;
2727
2828 pub const createEnumAttribute = LLVMCreateEnumAttribute;
29 extern fn LLVMCreateEnumAttribute(*const Context, KindID: c_uint, Val: u64) *const Attribute;
29 extern fn LLVMCreateEnumAttribute(*Context, KindID: c_uint, Val: u64) *Attribute;
3030
3131 pub const createStringAttribute = LLVMCreateStringAttribute;
32 extern fn LLVMCreateStringAttribute(*const Context, Key: [*]const u8, Key_Len: c_uint, Value: [*]const u8, Value_Len: c_uint) *const Attribute;
32 extern fn LLVMCreateStringAttribute(*Context, Key: [*]const u8, Key_Len: c_uint, Value: [*]const u8, Value_Len: c_uint) *Attribute;
3333
3434 pub const pointerType = LLVMPointerTypeInContext;
35 extern fn LLVMPointerTypeInContext(C: *const Context, AddressSpace: c_uint) *const Type;
35 extern fn LLVMPointerTypeInContext(C: *Context, AddressSpace: c_uint) *Type;
3636
3737 pub const intType = LLVMIntTypeInContext;
38 extern fn LLVMIntTypeInContext(C: *const Context, NumBits: c_uint) *const Type;
38 extern fn LLVMIntTypeInContext(C: *Context, NumBits: c_uint) *Type;
3939
4040 pub const halfType = LLVMHalfTypeInContext;
41 extern fn LLVMHalfTypeInContext(C: *const Context) *const Type;
41 extern fn LLVMHalfTypeInContext(C: *Context) *Type;
4242
4343 pub const floatType = LLVMFloatTypeInContext;
44 extern fn LLVMFloatTypeInContext(C: *const Context) *const Type;
44 extern fn LLVMFloatTypeInContext(C: *Context) *Type;
4545
4646 pub const doubleType = LLVMDoubleTypeInContext;
47 extern fn LLVMDoubleTypeInContext(C: *const Context) *const Type;
47 extern fn LLVMDoubleTypeInContext(C: *Context) *Type;
4848
4949 pub const x86FP80Type = LLVMX86FP80TypeInContext;
50 extern fn LLVMX86FP80TypeInContext(C: *const Context) *const Type;
50 extern fn LLVMX86FP80TypeInContext(C: *Context) *Type;
5151
5252 pub const fp128Type = LLVMFP128TypeInContext;
53 extern fn LLVMFP128TypeInContext(C: *const Context) *const Type;
53 extern fn LLVMFP128TypeInContext(C: *Context) *Type;
5454
5555 pub const voidType = LLVMVoidTypeInContext;
56 extern fn LLVMVoidTypeInContext(C: *const Context) *const Type;
56 extern fn LLVMVoidTypeInContext(C: *Context) *Type;
5757
5858 pub const structType = LLVMStructTypeInContext;
5959 extern fn LLVMStructTypeInContext(
60 C: *const Context,
61 ElementTypes: [*]const *const Type,
60 C: *Context,
61 ElementTypes: [*]const *Type,
6262 ElementCount: c_uint,
6363 Packed: Bool,
64 ) *const Type;
64 ) *Type;
6565
6666 pub const structCreateNamed = LLVMStructCreateNamed;
67 extern fn LLVMStructCreateNamed(C: *const Context, Name: [*:0]const u8) *const Type;
67 extern fn LLVMStructCreateNamed(C: *Context, Name: [*:0]const u8) *Type;
6868
6969 pub const constString = LLVMConstStringInContext;
70 extern fn LLVMConstStringInContext(C: *const Context, Str: [*]const u8, Length: c_uint, DontNullTerminate: Bool) *const Value;
70 extern fn LLVMConstStringInContext(C: *Context, Str: [*]const u8, Length: c_uint, DontNullTerminate: Bool) *Value;
7171
7272 pub const constStruct = LLVMConstStructInContext;
7373 extern fn LLVMConstStructInContext(
74 C: *const Context,
75 ConstantVals: [*]const *const Value,
74 C: *Context,
75 ConstantVals: [*]const *Value,
7676 Count: c_uint,
7777 Packed: Bool,
78 ) *const Value;
78 ) *Value;
7979
8080 pub const createBasicBlock = LLVMCreateBasicBlockInContext;
81 extern fn LLVMCreateBasicBlockInContext(C: *const Context, Name: [*:0]const u8) *const BasicBlock;
81 extern fn LLVMCreateBasicBlockInContext(C: *Context, Name: [*:0]const u8) *BasicBlock;
8282
8383 pub const appendBasicBlock = LLVMAppendBasicBlockInContext;
84 extern fn LLVMAppendBasicBlockInContext(C: *const Context, Fn: *const Value, Name: [*:0]const u8) *const BasicBlock;
84 extern fn LLVMAppendBasicBlockInContext(C: *Context, Fn: *Value, Name: [*:0]const u8) *BasicBlock;
8585
8686 pub const createBuilder = LLVMCreateBuilderInContext;
87 extern fn LLVMCreateBuilderInContext(C: *const Context) *const Builder;
87 extern fn LLVMCreateBuilderInContext(C: *Context) *Builder;
8888};
8989
9090pub const Value = opaque {
9191 pub const addAttributeAtIndex = LLVMAddAttributeAtIndex;
92 extern fn LLVMAddAttributeAtIndex(*const Value, Idx: AttributeIndex, A: *const Attribute) void;
92 extern fn LLVMAddAttributeAtIndex(*Value, Idx: AttributeIndex, A: *Attribute) void;
9393
9494 pub const removeEnumAttributeAtIndex = LLVMRemoveEnumAttributeAtIndex;
95 extern fn LLVMRemoveEnumAttributeAtIndex(F: *const Value, Idx: AttributeIndex, KindID: c_uint) void;
95 extern fn LLVMRemoveEnumAttributeAtIndex(F: *Value, Idx: AttributeIndex, KindID: c_uint) void;
9696
9797 pub const getFirstBasicBlock = LLVMGetFirstBasicBlock;
98 extern fn LLVMGetFirstBasicBlock(Fn: *const Value) ?*const BasicBlock;
98 extern fn LLVMGetFirstBasicBlock(Fn: *Value) ?*BasicBlock;
9999
100100 pub const appendExistingBasicBlock = LLVMAppendExistingBasicBlock;
101 extern fn LLVMAppendExistingBasicBlock(Fn: *const Value, BB: *const BasicBlock) void;
101 extern fn LLVMAppendExistingBasicBlock(Fn: *Value, BB: *BasicBlock) void;
102102
103103 pub const addIncoming = LLVMAddIncoming;
104104 extern fn LLVMAddIncoming(
105 PhiNode: *const Value,
106 IncomingValues: [*]const *const Value,
107 IncomingBlocks: [*]const *const BasicBlock,
105 PhiNode: *Value,
106 IncomingValues: [*]const *Value,
107 IncomingBlocks: [*]const *BasicBlock,
108108 Count: c_uint,
109109 ) void;
110110
111111 pub const getNextInstruction = LLVMGetNextInstruction;
112 extern fn LLVMGetNextInstruction(Inst: *const Value) ?*const Value;
112 extern fn LLVMGetNextInstruction(Inst: *Value) ?*Value;
113113
114114 pub const typeOf = LLVMTypeOf;
115 extern fn LLVMTypeOf(Val: *const Value) *const Type;
115 extern fn LLVMTypeOf(Val: *Value) *Type;
116116
117117 pub const setGlobalConstant = LLVMSetGlobalConstant;
118 extern fn LLVMSetGlobalConstant(GlobalVar: *const Value, IsConstant: Bool) void;
118 extern fn LLVMSetGlobalConstant(GlobalVar: *Value, IsConstant: Bool) void;
119119
120120 pub const setLinkage = LLVMSetLinkage;
121 extern fn LLVMSetLinkage(Global: *const Value, Linkage: Linkage) void;
121 extern fn LLVMSetLinkage(Global: *Value, Linkage: Linkage) void;
122122
123123 pub const setVisibility = LLVMSetVisibility;
124 extern fn LLVMSetVisibility(Global: *const Value, Linkage: Visibility) void;
124 extern fn LLVMSetVisibility(Global: *Value, Linkage: Visibility) void;
125125
126126 pub const setUnnamedAddr = LLVMSetUnnamedAddr;
127 extern fn LLVMSetUnnamedAddr(Global: *const Value, HasUnnamedAddr: Bool) void;
127 extern fn LLVMSetUnnamedAddr(Global: *Value, HasUnnamedAddr: Bool) void;
128128
129129 pub const setThreadLocalMode = LLVMSetThreadLocalMode;
130 extern fn LLVMSetThreadLocalMode(Global: *const Value, Mode: ThreadLocalMode) void;
130 extern fn LLVMSetThreadLocalMode(Global: *Value, Mode: ThreadLocalMode) void;
131131
132132 pub const setSection = LLVMSetSection;
133 extern fn LLVMSetSection(Global: *const Value, Section: [*:0]const u8) void;
133 extern fn LLVMSetSection(Global: *Value, Section: [*:0]const u8) void;
134134
135135 pub const deleteGlobal = LLVMDeleteGlobal;
136 extern fn LLVMDeleteGlobal(GlobalVar: *const Value) void;
136 extern fn LLVMDeleteGlobal(GlobalVar: *Value) void;
137137
138138 pub const getNextGlobalAlias = LLVMGetNextGlobalAlias;
139 extern fn LLVMGetNextGlobalAlias(GA: *const Value) *const Value;
139 extern fn LLVMGetNextGlobalAlias(GA: *Value) *Value;
140140
141141 pub const getAliasee = LLVMAliasGetAliasee;
142 extern fn LLVMAliasGetAliasee(Alias: *const Value) *const Value;
142 extern fn LLVMAliasGetAliasee(Alias: *Value) *Value;
143143
144144 pub const setAliasee = LLVMAliasSetAliasee;
145 extern fn LLVMAliasSetAliasee(Alias: *const Value, Aliasee: *const Value) void;
145 extern fn LLVMAliasSetAliasee(Alias: *Value, Aliasee: *Value) void;
146146
147147 pub const constBitCast = LLVMConstBitCast;
148 extern fn LLVMConstBitCast(ConstantVal: *const Value, ToType: *const Type) *const Value;
148 extern fn LLVMConstBitCast(ConstantVal: *Value, ToType: *Type) *Value;
149149
150150 pub const constIntToPtr = LLVMConstIntToPtr;
151 extern fn LLVMConstIntToPtr(ConstantVal: *const Value, ToType: *const Type) *const Value;
151 extern fn LLVMConstIntToPtr(ConstantVal: *Value, ToType: *Type) *Value;
152152
153153 pub const constPtrToInt = LLVMConstPtrToInt;
154 extern fn LLVMConstPtrToInt(ConstantVal: *const Value, ToType: *const Type) *const Value;
154 extern fn LLVMConstPtrToInt(ConstantVal: *Value, ToType: *Type) *Value;
155155
156156 pub const constShl = LLVMConstShl;
157 extern fn LLVMConstShl(LHSConstant: *const Value, RHSConstant: *const Value) *const Value;
157 extern fn LLVMConstShl(LHSConstant: *Value, RHSConstant: *Value) *Value;
158158
159159 pub const constOr = LLVMConstOr;
160 extern fn LLVMConstOr(LHSConstant: *const Value, RHSConstant: *const Value) *const Value;
160 extern fn LLVMConstOr(LHSConstant: *Value, RHSConstant: *Value) *Value;
161161
162162 pub const constZExt = LLVMConstZExt;
163 extern fn LLVMConstZExt(ConstantVal: *const Value, ToType: *const Type) *const Value;
163 extern fn LLVMConstZExt(ConstantVal: *Value, ToType: *Type) *Value;
164164
165165 pub const constZExtOrBitCast = LLVMConstZExtOrBitCast;
166 extern fn LLVMConstZExtOrBitCast(ConstantVal: *const Value, ToType: *const Type) *const Value;
166 extern fn LLVMConstZExtOrBitCast(ConstantVal: *Value, ToType: *Type) *Value;
167167
168168 pub const constNot = LLVMConstNot;
169 extern fn LLVMConstNot(ConstantVal: *const Value) *const Value;
169 extern fn LLVMConstNot(ConstantVal: *Value) *Value;
170170
171171 pub const constAdd = LLVMConstAdd;
172 extern fn LLVMConstAdd(LHSConstant: *const Value, RHSConstant: *const Value) *const Value;
172 extern fn LLVMConstAdd(LHSConstant: *Value, RHSConstant: *Value) *Value;
173173
174174 pub const setWeak = LLVMSetWeak;
175 extern fn LLVMSetWeak(CmpXchgInst: *const Value, IsWeak: Bool) void;
175 extern fn LLVMSetWeak(CmpXchgInst: *Value, IsWeak: Bool) void;
176176
177177 pub const setOrdering = LLVMSetOrdering;
178 extern fn LLVMSetOrdering(MemoryAccessInst: *const Value, Ordering: AtomicOrdering) void;
178 extern fn LLVMSetOrdering(MemoryAccessInst: *Value, Ordering: AtomicOrdering) void;
179179
180180 pub const setVolatile = LLVMSetVolatile;
181 extern fn LLVMSetVolatile(MemoryAccessInst: *const Value, IsVolatile: Bool) void;
181 extern fn LLVMSetVolatile(MemoryAccessInst: *Value, IsVolatile: Bool) void;
182182
183183 pub const setAlignment = LLVMSetAlignment;
184 extern fn LLVMSetAlignment(V: *const Value, Bytes: c_uint) void;
184 extern fn LLVMSetAlignment(V: *Value, Bytes: c_uint) void;
185185
186186 pub const getFunctionCallConv = LLVMGetFunctionCallConv;
187 extern fn LLVMGetFunctionCallConv(Fn: *const Value) CallConv;
187 extern fn LLVMGetFunctionCallConv(Fn: *Value) CallConv;
188188
189189 pub const setFunctionCallConv = LLVMSetFunctionCallConv;
190 extern fn LLVMSetFunctionCallConv(Fn: *const Value, CC: CallConv) void;
190 extern fn LLVMSetFunctionCallConv(Fn: *Value, CC: CallConv) void;
191191
192192 pub const fnSetSubprogram = ZigLLVMFnSetSubprogram;
193 extern fn ZigLLVMFnSetSubprogram(f: *const Value, subprogram: *DISubprogram) void;
193 extern fn ZigLLVMFnSetSubprogram(f: *Value, subprogram: *DISubprogram) void;
194194
195195 pub const setValueName = LLVMSetValueName;
196 extern fn LLVMSetValueName(Val: *const Value, Name: [*:0]const u8) void;
196 extern fn LLVMSetValueName(Val: *Value, Name: [*:0]const u8) void;
197197
198198 pub const setValueName2 = LLVMSetValueName2;
199 extern fn LLVMSetValueName2(Val: *const Value, Name: [*]const u8, NameLen: usize) void;
199 extern fn LLVMSetValueName2(Val: *Value, Name: [*]const u8, NameLen: usize) void;
200200
201201 pub const getValueName = LLVMGetValueName;
202 extern fn LLVMGetValueName(Val: *const Value) [*:0]const u8;
202 extern fn LLVMGetValueName(Val: *Value) [*:0]const u8;
203203
204204 pub const takeName = ZigLLVMTakeName;
205 extern fn ZigLLVMTakeName(new_owner: *const Value, victim: *const Value) void;
205 extern fn ZigLLVMTakeName(new_owner: *Value, victim: *Value) void;
206206
207207 pub const deleteFunction = LLVMDeleteFunction;
208 extern fn LLVMDeleteFunction(Fn: *const Value) void;
208 extern fn LLVMDeleteFunction(Fn: *Value) void;
209209
210210 pub const addSretAttr = ZigLLVMAddSretAttr;
211 extern fn ZigLLVMAddSretAttr(fn_ref: *const Value, type_val: *const Type) void;
211 extern fn ZigLLVMAddSretAttr(fn_ref: *Value, type_val: *Type) void;
212212
213213 pub const setCallSret = ZigLLVMSetCallSret;
214 extern fn ZigLLVMSetCallSret(Call: *const Value, return_type: *const Type) void;
214 extern fn ZigLLVMSetCallSret(Call: *Value, return_type: *Type) void;
215215
216216 pub const getParam = LLVMGetParam;
217 extern fn LLVMGetParam(Fn: *const Value, Index: c_uint) *const Value;
217 extern fn LLVMGetParam(Fn: *Value, Index: c_uint) *Value;
218218
219219 pub const setInitializer = LLVMSetInitializer;
220 extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void;
220 extern fn LLVMSetInitializer(GlobalVar: *Value, ConstantVal: *Value) void;
221221
222222 pub const setDLLStorageClass = LLVMSetDLLStorageClass;
223 extern fn LLVMSetDLLStorageClass(Global: *const Value, Class: DLLStorageClass) void;
223 extern fn LLVMSetDLLStorageClass(Global: *Value, Class: DLLStorageClass) void;
224224
225225 pub const addCase = LLVMAddCase;
226 extern fn LLVMAddCase(Switch: *const Value, OnVal: *const Value, Dest: *const BasicBlock) void;
226 extern fn LLVMAddCase(Switch: *Value, OnVal: *Value, Dest: *BasicBlock) void;
227227
228 pub inline fn isPoison(Val: *const Value) bool {
228 pub inline fn isPoison(Val: *Value) bool {
229229 return LLVMIsPoison(Val).toBool();
230230 }
231 extern fn LLVMIsPoison(Val: *const Value) Bool;
231 extern fn LLVMIsPoison(Val: *Value) Bool;
232232
233233 pub const replaceAllUsesWith = LLVMReplaceAllUsesWith;
234 extern fn LLVMReplaceAllUsesWith(OldVal: *const Value, NewVal: *const Value) void;
234 extern fn LLVMReplaceAllUsesWith(OldVal: *Value, NewVal: *Value) void;
235235
236236 pub const globalGetValueType = LLVMGlobalGetValueType;
237 extern fn LLVMGlobalGetValueType(Global: *const Value) *const Type;
237 extern fn LLVMGlobalGetValueType(Global: *Value) *Type;
238238
239239 pub const getLinkage = LLVMGetLinkage;
240 extern fn LLVMGetLinkage(Global: *const Value) Linkage;
240 extern fn LLVMGetLinkage(Global: *Value) Linkage;
241241
242242 pub const getUnnamedAddress = LLVMGetUnnamedAddress;
243 extern fn LLVMGetUnnamedAddress(Global: *const Value) Bool;
243 extern fn LLVMGetUnnamedAddress(Global: *Value) Bool;
244244
245245 pub const getAlignment = LLVMGetAlignment;
246 extern fn LLVMGetAlignment(V: *const Value) c_uint;
246 extern fn LLVMGetAlignment(V: *Value) c_uint;
247247
248248 pub const addFunctionAttr = ZigLLVMAddFunctionAttr;
249 extern fn ZigLLVMAddFunctionAttr(Fn: *const Value, attr_name: [*:0]const u8, attr_value: [*:0]const u8) void;
249 extern fn ZigLLVMAddFunctionAttr(Fn: *Value, attr_name: [*:0]const u8, attr_value: [*:0]const u8) void;
250250
251251 pub const getGEPResultElementType = ZigLLVMGetGEPResultElementType;
252 extern fn ZigLLVMGetGEPResultElementType(GEP: *const Value) *const Type;
252 extern fn ZigLLVMGetGEPResultElementType(GEP: *Value) *Type;
253253
254254 pub const addByValAttr = ZigLLVMAddByValAttr;
255 extern fn ZigLLVMAddByValAttr(Fn: *const Value, ArgNo: c_uint, type: *const Type) void;
255 extern fn ZigLLVMAddByValAttr(Fn: *Value, ArgNo: c_uint, type: *Type) void;
256256};
257257
258258pub const Type = opaque {
259259 pub const constNull = LLVMConstNull;
260 extern fn LLVMConstNull(Ty: *const Type) *const Value;
260 extern fn LLVMConstNull(Ty: *Type) *Value;
261261
262262 pub const constAllOnes = LLVMConstAllOnes;
263 extern fn LLVMConstAllOnes(Ty: *const Type) *const Value;
263 extern fn LLVMConstAllOnes(Ty: *Type) *Value;
264264
265265 pub const constInt = LLVMConstInt;
266 extern fn LLVMConstInt(IntTy: *const Type, N: c_ulonglong, SignExtend: Bool) *const Value;
266 extern fn LLVMConstInt(IntTy: *Type, N: c_ulonglong, SignExtend: Bool) *Value;
267267
268268 pub const constIntOfArbitraryPrecision = LLVMConstIntOfArbitraryPrecision;
269 extern fn LLVMConstIntOfArbitraryPrecision(IntTy: *const Type, NumWords: c_uint, Words: [*]const u64) *const Value;
269 extern fn LLVMConstIntOfArbitraryPrecision(IntTy: *Type, NumWords: c_uint, Words: [*]const u64) *Value;
270270
271271 pub const constReal = LLVMConstReal;
272 extern fn LLVMConstReal(RealTy: *const Type, N: f64) *const Value;
272 extern fn LLVMConstReal(RealTy: *Type, N: f64) *Value;
273273
274274 pub const constArray = LLVMConstArray;
275 extern fn LLVMConstArray(ElementTy: *const Type, ConstantVals: [*]const *const Value, Length: c_uint) *const Value;
275 extern fn LLVMConstArray(ElementTy: *Type, ConstantVals: [*]const *Value, Length: c_uint) *Value;
276276
277277 pub const constNamedStruct = LLVMConstNamedStruct;
278278 extern fn LLVMConstNamedStruct(
279 StructTy: *const Type,
280 ConstantVals: [*]const *const Value,
279 StructTy: *Type,
280 ConstantVals: [*]const *Value,
281281 Count: c_uint,
282 ) *const Value;
282 ) *Value;
283283
284284 pub const getUndef = LLVMGetUndef;
285 extern fn LLVMGetUndef(Ty: *const Type) *const Value;
285 extern fn LLVMGetUndef(Ty: *Type) *Value;
286286
287287 pub const pointerType = LLVMPointerType;
288 extern fn LLVMPointerType(ElementType: *const Type, AddressSpace: c_uint) *const Type;
288 extern fn LLVMPointerType(ElementType: *Type, AddressSpace: c_uint) *Type;
289289
290290 pub const arrayType = LLVMArrayType;
291 extern fn LLVMArrayType(ElementType: *const Type, ElementCount: c_uint) *const Type;
291 extern fn LLVMArrayType(ElementType: *Type, ElementCount: c_uint) *Type;
292292
293293 pub const vectorType = LLVMVectorType;
294 extern fn LLVMVectorType(ElementType: *const Type, ElementCount: c_uint) *const Type;
294 extern fn LLVMVectorType(ElementType: *Type, ElementCount: c_uint) *Type;
295295
296296 pub const structSetBody = LLVMStructSetBody;
297297 extern fn LLVMStructSetBody(
298 StructTy: *const Type,
299 ElementTypes: [*]*const Type,
298 StructTy: *Type,
299 ElementTypes: [*]*Type,
300300 ElementCount: c_uint,
301301 Packed: Bool,
302302 ) void;
303303
304304 pub const structGetTypeAtIndex = LLVMStructGetTypeAtIndex;
305 extern fn LLVMStructGetTypeAtIndex(StructTy: *const Type, i: c_uint) *const Type;
305 extern fn LLVMStructGetTypeAtIndex(StructTy: *Type, i: c_uint) *Type;
306306
307307 pub const getTypeKind = LLVMGetTypeKind;
308 extern fn LLVMGetTypeKind(Ty: *const Type) TypeKind;
308 extern fn LLVMGetTypeKind(Ty: *Type) TypeKind;
309309
310310 pub const getElementType = LLVMGetElementType;
311 extern fn LLVMGetElementType(Ty: *const Type) *const Type;
311 extern fn LLVMGetElementType(Ty: *Type) *Type;
312312
313313 pub const countStructElementTypes = LLVMCountStructElementTypes;
314 extern fn LLVMCountStructElementTypes(StructTy: *const Type) c_uint;
314 extern fn LLVMCountStructElementTypes(StructTy: *Type) c_uint;
315315
316316 pub const isOpaqueStruct = LLVMIsOpaqueStruct;
317 extern fn LLVMIsOpaqueStruct(StructTy: *const Type) Bool;
317 extern fn LLVMIsOpaqueStruct(StructTy: *Type) Bool;
318318
319319 pub const isSized = LLVMTypeIsSized;
320 extern fn LLVMTypeIsSized(Ty: *const Type) Bool;
320 extern fn LLVMTypeIsSized(Ty: *Type) Bool;
321321
322322 pub const constInBoundsGEP = LLVMConstInBoundsGEP2;
323323 extern fn LLVMConstInBoundsGEP2(
324 Ty: *const Type,
325 ConstantVal: *const Value,
326 ConstantIndices: [*]const *const Value,
324 Ty: *Type,
325 ConstantVal: *Value,
326 ConstantIndices: [*]const *Value,
327327 NumIndices: c_uint,
328 ) *const Value;
328 ) *Value;
329329};
330330
331331pub const Module = opaque {
332332 pub const createWithName = LLVMModuleCreateWithNameInContext;
333 extern fn LLVMModuleCreateWithNameInContext(ModuleID: [*:0]const u8, C: *const Context) *const Module;
333 extern fn LLVMModuleCreateWithNameInContext(ModuleID: [*:0]const u8, C: *Context) *Module;
334334
335335 pub const dispose = LLVMDisposeModule;
336 extern fn LLVMDisposeModule(*const Module) void;
336 extern fn LLVMDisposeModule(*Module) void;
337337
338338 pub const verify = LLVMVerifyModule;
339 extern fn LLVMVerifyModule(*const Module, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) Bool;
339 extern fn LLVMVerifyModule(*Module, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) Bool;
340340
341341 pub const setModuleDataLayout = LLVMSetModuleDataLayout;
342 extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;
342 extern fn LLVMSetModuleDataLayout(*Module, *TargetData) void;
343343
344344 pub const setModulePICLevel = ZigLLVMSetModulePICLevel;
345 extern fn ZigLLVMSetModulePICLevel(module: *const Module) void;
345 extern fn ZigLLVMSetModulePICLevel(module: *Module) void;
346346
347347 pub const setModulePIELevel = ZigLLVMSetModulePIELevel;
348 extern fn ZigLLVMSetModulePIELevel(module: *const Module) void;
348 extern fn ZigLLVMSetModulePIELevel(module: *Module) void;
349349
350350 pub const setModuleCodeModel = ZigLLVMSetModuleCodeModel;
351 extern fn ZigLLVMSetModuleCodeModel(module: *const Module, code_model: CodeModel) void;
351 extern fn ZigLLVMSetModuleCodeModel(module: *Module, code_model: CodeModel) void;
352352
353353 pub const addFunction = LLVMAddFunction;
354 extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;
354 extern fn LLVMAddFunction(*Module, Name: [*:0]const u8, FunctionTy: *Type) *Value;
355355
356356 pub const addFunctionInAddressSpace = ZigLLVMAddFunctionInAddressSpace;
357 extern fn ZigLLVMAddFunctionInAddressSpace(*const Module, Name: [*:0]const u8, FunctionTy: *const Type, AddressSpace: c_uint) *const Value;
357 extern fn ZigLLVMAddFunctionInAddressSpace(*Module, Name: [*:0]const u8, FunctionTy: *Type, AddressSpace: c_uint) *Value;
358358
359359 pub const getNamedFunction = LLVMGetNamedFunction;
360 extern fn LLVMGetNamedFunction(*const Module, Name: [*:0]const u8) ?*const Value;
360 extern fn LLVMGetNamedFunction(*Module, Name: [*:0]const u8) ?*Value;
361361
362362 pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration;
363 extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]const *const Type, ParamCount: usize) *const Value;
363 extern fn LLVMGetIntrinsicDeclaration(Mod: *Module, ID: c_uint, ParamTypes: ?[*]const *Type, ParamCount: usize) *Value;
364364
365365 pub const printToString = LLVMPrintModuleToString;
366 extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8;
366 extern fn LLVMPrintModuleToString(*Module) [*:0]const u8;
367367
368368 pub const addGlobal = LLVMAddGlobal;
369 extern fn LLVMAddGlobal(M: *const Module, Ty: *const Type, Name: [*:0]const u8) *const Value;
369 extern fn LLVMAddGlobal(M: *Module, Ty: *Type, Name: [*:0]const u8) *Value;
370370
371371 pub const addGlobalInAddressSpace = LLVMAddGlobalInAddressSpace;
372 extern fn LLVMAddGlobalInAddressSpace(M: *const Module, Ty: *const Type, Name: [*:0]const u8, AddressSpace: c_uint) *const Value;
372 extern fn LLVMAddGlobalInAddressSpace(M: *Module, Ty: *Type, Name: [*:0]const u8, AddressSpace: c_uint) *Value;
373373
374374 pub const getNamedGlobal = LLVMGetNamedGlobal;
375 extern fn LLVMGetNamedGlobal(M: *const Module, Name: [*:0]const u8) ?*const Value;
375 extern fn LLVMGetNamedGlobal(M: *Module, Name: [*:0]const u8) ?*Value;
376376
377377 pub const dump = LLVMDumpModule;
378 extern fn LLVMDumpModule(M: *const Module) void;
378 extern fn LLVMDumpModule(M: *Module) void;
379379
380380 pub const getFirstGlobalAlias = LLVMGetFirstGlobalAlias;
381 extern fn LLVMGetFirstGlobalAlias(M: *const Module) *const Value;
381 extern fn LLVMGetFirstGlobalAlias(M: *Module) *Value;
382382
383383 pub const getLastGlobalAlias = LLVMGetLastGlobalAlias;
384 extern fn LLVMGetLastGlobalAlias(M: *const Module) *const Value;
384 extern fn LLVMGetLastGlobalAlias(M: *Module) *Value;
385385
386386 pub const addAlias = LLVMAddAlias2;
387387 extern fn LLVMAddAlias2(
388 M: *const Module,
389 Ty: *const Type,
388 M: *Module,
389 Ty: *Type,
390390 AddrSpace: c_uint,
391 Aliasee: *const Value,
391 Aliasee: *Value,
392392 Name: [*:0]const u8,
393 ) *const Value;
393 ) *Value;
394394
395395 pub const getNamedGlobalAlias = LLVMGetNamedGlobalAlias;
396396 extern fn LLVMGetNamedGlobalAlias(
397 M: *const Module,
397 M: *Module,
398398 /// Empirically, LLVM will call strlen() on `Name` and so it
399399 /// must be both null terminated and also have `NameLen` set
400400 /// to the size.
401401 Name: [*:0]const u8,
402402 NameLen: usize,
403 ) ?*const Value;
403 ) ?*Value;
404404
405405 pub const setTarget = LLVMSetTarget;
406 extern fn LLVMSetTarget(M: *const Module, Triple: [*:0]const u8) void;
406 extern fn LLVMSetTarget(M: *Module, Triple: [*:0]const u8) void;
407407
408408 pub const addModuleDebugInfoFlag = ZigLLVMAddModuleDebugInfoFlag;
409 extern fn ZigLLVMAddModuleDebugInfoFlag(module: *const Module) void;
409 extern fn ZigLLVMAddModuleDebugInfoFlag(module: *Module) void;
410410
411411 pub const addModuleCodeViewFlag = ZigLLVMAddModuleCodeViewFlag;
412 extern fn ZigLLVMAddModuleCodeViewFlag(module: *const Module) void;
412 extern fn ZigLLVMAddModuleCodeViewFlag(module: *Module) void;
413413
414414 pub const createDIBuilder = ZigLLVMCreateDIBuilder;
415 extern fn ZigLLVMCreateDIBuilder(module: *const Module, allow_unresolved: bool) *DIBuilder;
415 extern fn ZigLLVMCreateDIBuilder(module: *Module, allow_unresolved: bool) *DIBuilder;
416416
417417 pub const setModuleInlineAsm2 = LLVMSetModuleInlineAsm2;
418 extern fn LLVMSetModuleInlineAsm2(M: *const Module, Asm: [*]const u8, Len: usize) void;
418 extern fn LLVMSetModuleInlineAsm2(M: *Module, Asm: [*]const u8, Len: usize) void;
419419
420420 pub const printModuleToFile = LLVMPrintModuleToFile;
421 extern fn LLVMPrintModuleToFile(M: *const Module, Filename: [*:0]const u8, ErrorMessage: *[*:0]const u8) Bool;
421 extern fn LLVMPrintModuleToFile(M: *Module, Filename: [*:0]const u8, ErrorMessage: *[*:0]const u8) Bool;
422422};
423423
424424pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
......@@ -434,20 +434,20 @@ pub const VerifierFailureAction = enum(c_int) {
434434};
435435
436436pub const constNeg = LLVMConstNeg;
437extern fn LLVMConstNeg(ConstantVal: *const Value) *const Value;
437extern fn LLVMConstNeg(ConstantVal: *Value) *Value;
438438
439439pub const constVector = LLVMConstVector;
440440extern fn LLVMConstVector(
441 ScalarConstantVals: [*]*const Value,
441 ScalarConstantVals: [*]*Value,
442442 Size: c_uint,
443) *const Value;
443) *Value;
444444
445445pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName;
446446extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint;
447447
448448pub const getInlineAsm = LLVMGetInlineAsm;
449449extern fn LLVMGetInlineAsm(
450 Ty: *const Type,
450 Ty: *Type,
451451 AsmString: [*]const u8,
452452 AsmStringSize: usize,
453453 Constraints: [*]const u8,
......@@ -456,15 +456,15 @@ extern fn LLVMGetInlineAsm(
456456 IsAlignStack: Bool,
457457 Dialect: InlineAsmDialect,
458458 CanThrow: Bool,
459) *const Value;
459) *Value;
460460
461461pub const functionType = LLVMFunctionType;
462462extern fn LLVMFunctionType(
463 ReturnType: *const Type,
464 ParamTypes: [*]const *const Type,
463 ReturnType: *Type,
464 ParamTypes: [*]const *Type,
465465 ParamCount: c_uint,
466466 IsVarArg: Bool,
467) *const Type;
467) *Type;
468468
469469pub const InlineAsmDialect = enum(c_uint) { ATT, Intel };
470470
......@@ -472,495 +472,495 @@ pub const Attribute = opaque {};
472472
473473pub const Builder = opaque {
474474 pub const dispose = LLVMDisposeBuilder;
475 extern fn LLVMDisposeBuilder(Builder: *const Builder) void;
475 extern fn LLVMDisposeBuilder(Builder: *Builder) void;
476476
477477 pub const positionBuilder = LLVMPositionBuilder;
478478 extern fn LLVMPositionBuilder(
479 Builder: *const Builder,
480 Block: *const BasicBlock,
481 Instr: *const Value,
479 Builder: *Builder,
480 Block: *BasicBlock,
481 Instr: *Value,
482482 ) void;
483483
484484 pub const positionBuilderAtEnd = LLVMPositionBuilderAtEnd;
485 extern fn LLVMPositionBuilderAtEnd(Builder: *const Builder, Block: *const BasicBlock) void;
485 extern fn LLVMPositionBuilderAtEnd(Builder: *Builder, Block: *BasicBlock) void;
486486
487487 pub const getInsertBlock = LLVMGetInsertBlock;
488 extern fn LLVMGetInsertBlock(Builder: *const Builder) *const BasicBlock;
488 extern fn LLVMGetInsertBlock(Builder: *Builder) *BasicBlock;
489489
490490 pub const buildZExt = LLVMBuildZExt;
491491 extern fn LLVMBuildZExt(
492 *const Builder,
493 Value: *const Value,
494 DestTy: *const Type,
492 *Builder,
493 Value: *Value,
494 DestTy: *Type,
495495 Name: [*:0]const u8,
496 ) *const Value;
496 ) *Value;
497497
498498 pub const buildZExtOrBitCast = LLVMBuildZExtOrBitCast;
499499 extern fn LLVMBuildZExtOrBitCast(
500 *const Builder,
501 Val: *const Value,
502 DestTy: *const Type,
500 *Builder,
501 Val: *Value,
502 DestTy: *Type,
503503 Name: [*:0]const u8,
504 ) *const Value;
504 ) *Value;
505505
506506 pub const buildSExt = LLVMBuildSExt;
507507 extern fn LLVMBuildSExt(
508 *const Builder,
509 Val: *const Value,
510 DestTy: *const Type,
508 *Builder,
509 Val: *Value,
510 DestTy: *Type,
511511 Name: [*:0]const u8,
512 ) *const Value;
512 ) *Value;
513513
514514 pub const buildSExtOrBitCast = LLVMBuildSExtOrBitCast;
515515 extern fn LLVMBuildSExtOrBitCast(
516 *const Builder,
517 Val: *const Value,
518 DestTy: *const Type,
516 *Builder,
517 Val: *Value,
518 DestTy: *Type,
519519 Name: [*:0]const u8,
520 ) *const Value;
520 ) *Value;
521521
522522 pub const buildCall = ZigLLVMBuildCall;
523523 extern fn ZigLLVMBuildCall(
524 *const Builder,
525 *const Type,
526 Fn: *const Value,
527 Args: [*]const *const Value,
524 *Builder,
525 *Type,
526 Fn: *Value,
527 Args: [*]const *Value,
528528 NumArgs: c_uint,
529529 CC: CallConv,
530530 attr: CallAttr,
531531 Name: [*:0]const u8,
532 ) *const Value;
532 ) *Value;
533533
534534 pub const buildRetVoid = LLVMBuildRetVoid;
535 extern fn LLVMBuildRetVoid(*const Builder) *const Value;
535 extern fn LLVMBuildRetVoid(*Builder) *Value;
536536
537537 pub const buildRet = LLVMBuildRet;
538 extern fn LLVMBuildRet(*const Builder, V: *const Value) *const Value;
538 extern fn LLVMBuildRet(*Builder, V: *Value) *Value;
539539
540540 pub const buildUnreachable = LLVMBuildUnreachable;
541 extern fn LLVMBuildUnreachable(*const Builder) *const Value;
541 extern fn LLVMBuildUnreachable(*Builder) *Value;
542542
543543 pub const buildAlloca = LLVMBuildAlloca;
544 extern fn LLVMBuildAlloca(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value;
544 extern fn LLVMBuildAlloca(*Builder, Ty: *Type, Name: [*:0]const u8) *Value;
545545
546546 pub const buildStore = LLVMBuildStore;
547 extern fn LLVMBuildStore(*const Builder, Val: *const Value, Ptr: *const Value) *const Value;
547 extern fn LLVMBuildStore(*Builder, Val: *Value, Ptr: *Value) *Value;
548548
549549 pub const buildLoad = LLVMBuildLoad2;
550 extern fn LLVMBuildLoad2(*const Builder, Ty: *const Type, PointerVal: *const Value, Name: [*:0]const u8) *const Value;
550 extern fn LLVMBuildLoad2(*Builder, Ty: *Type, PointerVal: *Value, Name: [*:0]const u8) *Value;
551551
552552 pub const buildNeg = LLVMBuildNeg;
553 extern fn LLVMBuildNeg(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
553 extern fn LLVMBuildNeg(*Builder, V: *Value, Name: [*:0]const u8) *Value;
554554
555555 pub const buildNot = LLVMBuildNot;
556 extern fn LLVMBuildNot(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
556 extern fn LLVMBuildNot(*Builder, V: *Value, Name: [*:0]const u8) *Value;
557557
558558 pub const buildFAdd = LLVMBuildFAdd;
559 extern fn LLVMBuildFAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
559 extern fn LLVMBuildFAdd(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
560560
561561 pub const buildAdd = LLVMBuildAdd;
562 extern fn LLVMBuildAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
562 extern fn LLVMBuildAdd(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
563563
564564 pub const buildNSWAdd = LLVMBuildNSWAdd;
565 extern fn LLVMBuildNSWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
565 extern fn LLVMBuildNSWAdd(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
566566
567567 pub const buildNUWAdd = LLVMBuildNUWAdd;
568 extern fn LLVMBuildNUWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
568 extern fn LLVMBuildNUWAdd(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
569569
570570 pub const buildSAddSat = ZigLLVMBuildSAddSat;
571 extern fn ZigLLVMBuildSAddSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
571 extern fn ZigLLVMBuildSAddSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
572572
573573 pub const buildUAddSat = ZigLLVMBuildUAddSat;
574 extern fn ZigLLVMBuildUAddSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
574 extern fn ZigLLVMBuildUAddSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
575575
576576 pub const buildFSub = LLVMBuildFSub;
577 extern fn LLVMBuildFSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
577 extern fn LLVMBuildFSub(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
578578
579579 pub const buildFNeg = LLVMBuildFNeg;
580 extern fn LLVMBuildFNeg(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
580 extern fn LLVMBuildFNeg(*Builder, V: *Value, Name: [*:0]const u8) *Value;
581581
582582 pub const buildSub = LLVMBuildSub;
583 extern fn LLVMBuildSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
583 extern fn LLVMBuildSub(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
584584
585585 pub const buildNSWSub = LLVMBuildNSWSub;
586 extern fn LLVMBuildNSWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
586 extern fn LLVMBuildNSWSub(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
587587
588588 pub const buildNUWSub = LLVMBuildNUWSub;
589 extern fn LLVMBuildNUWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
589 extern fn LLVMBuildNUWSub(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
590590
591591 pub const buildSSubSat = ZigLLVMBuildSSubSat;
592 extern fn ZigLLVMBuildSSubSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
592 extern fn ZigLLVMBuildSSubSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
593593
594594 pub const buildUSubSat = ZigLLVMBuildUSubSat;
595 extern fn ZigLLVMBuildUSubSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
595 extern fn ZigLLVMBuildUSubSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
596596
597597 pub const buildFMul = LLVMBuildFMul;
598 extern fn LLVMBuildFMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
598 extern fn LLVMBuildFMul(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
599599
600600 pub const buildMul = LLVMBuildMul;
601 extern fn LLVMBuildMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
601 extern fn LLVMBuildMul(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
602602
603603 pub const buildNSWMul = LLVMBuildNSWMul;
604 extern fn LLVMBuildNSWMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
604 extern fn LLVMBuildNSWMul(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
605605
606606 pub const buildNUWMul = LLVMBuildNUWMul;
607 extern fn LLVMBuildNUWMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
607 extern fn LLVMBuildNUWMul(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
608608
609609 pub const buildSMulFixSat = ZigLLVMBuildSMulFixSat;
610 extern fn ZigLLVMBuildSMulFixSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
610 extern fn ZigLLVMBuildSMulFixSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
611611
612612 pub const buildUMulFixSat = ZigLLVMBuildUMulFixSat;
613 extern fn ZigLLVMBuildUMulFixSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
613 extern fn ZigLLVMBuildUMulFixSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
614614
615615 pub const buildUDiv = LLVMBuildUDiv;
616 extern fn LLVMBuildUDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
616 extern fn LLVMBuildUDiv(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
617617
618618 pub const buildSDiv = LLVMBuildSDiv;
619 extern fn LLVMBuildSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
619 extern fn LLVMBuildSDiv(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
620620
621621 pub const buildFDiv = LLVMBuildFDiv;
622 extern fn LLVMBuildFDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
622 extern fn LLVMBuildFDiv(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
623623
624624 pub const buildURem = LLVMBuildURem;
625 extern fn LLVMBuildURem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
625 extern fn LLVMBuildURem(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
626626
627627 pub const buildSRem = LLVMBuildSRem;
628 extern fn LLVMBuildSRem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
628 extern fn LLVMBuildSRem(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
629629
630630 pub const buildFRem = LLVMBuildFRem;
631 extern fn LLVMBuildFRem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
631 extern fn LLVMBuildFRem(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
632632
633633 pub const buildAnd = LLVMBuildAnd;
634 extern fn LLVMBuildAnd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
634 extern fn LLVMBuildAnd(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
635635
636636 pub const buildLShr = LLVMBuildLShr;
637 extern fn LLVMBuildLShr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
637 extern fn LLVMBuildLShr(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
638638
639639 pub const buildAShr = LLVMBuildAShr;
640 extern fn LLVMBuildAShr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
640 extern fn LLVMBuildAShr(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
641641
642642 pub const buildLShrExact = ZigLLVMBuildLShrExact;
643 extern fn ZigLLVMBuildLShrExact(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
643 extern fn ZigLLVMBuildLShrExact(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
644644
645645 pub const buildAShrExact = ZigLLVMBuildAShrExact;
646 extern fn ZigLLVMBuildAShrExact(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
646 extern fn ZigLLVMBuildAShrExact(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
647647
648648 pub const buildShl = LLVMBuildShl;
649 extern fn LLVMBuildShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
649 extern fn LLVMBuildShl(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
650650
651651 pub const buildNUWShl = ZigLLVMBuildNUWShl;
652 extern fn ZigLLVMBuildNUWShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
652 extern fn ZigLLVMBuildNUWShl(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
653653
654654 pub const buildNSWShl = ZigLLVMBuildNSWShl;
655 extern fn ZigLLVMBuildNSWShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
655 extern fn ZigLLVMBuildNSWShl(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
656656
657657 pub const buildSShlSat = ZigLLVMBuildSShlSat;
658 extern fn ZigLLVMBuildSShlSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
658 extern fn ZigLLVMBuildSShlSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
659659
660660 pub const buildUShlSat = ZigLLVMBuildUShlSat;
661 extern fn ZigLLVMBuildUShlSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
661 extern fn ZigLLVMBuildUShlSat(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
662662
663663 pub const buildOr = LLVMBuildOr;
664 extern fn LLVMBuildOr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
664 extern fn LLVMBuildOr(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
665665
666666 pub const buildXor = LLVMBuildXor;
667 extern fn LLVMBuildXor(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
667 extern fn LLVMBuildXor(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
668668
669669 pub const buildIntCast2 = LLVMBuildIntCast2;
670 extern fn LLVMBuildIntCast2(*const Builder, Val: *const Value, DestTy: *const Type, IsSigned: Bool, Name: [*:0]const u8) *const Value;
670 extern fn LLVMBuildIntCast2(*Builder, Val: *Value, DestTy: *Type, IsSigned: Bool, Name: [*:0]const u8) *Value;
671671
672672 pub const buildBitCast = LLVMBuildBitCast;
673 extern fn LLVMBuildBitCast(*const Builder, Val: *const Value, DestTy: *const Type, Name: [*:0]const u8) *const Value;
673 extern fn LLVMBuildBitCast(*Builder, Val: *Value, DestTy: *Type, Name: [*:0]const u8) *Value;
674674
675675 pub const buildInBoundsGEP = LLVMBuildInBoundsGEP2;
676676 extern fn LLVMBuildInBoundsGEP2(
677 B: *const Builder,
678 Ty: *const Type,
679 Pointer: *const Value,
680 Indices: [*]const *const Value,
677 B: *Builder,
678 Ty: *Type,
679 Pointer: *Value,
680 Indices: [*]const *Value,
681681 NumIndices: c_uint,
682682 Name: [*:0]const u8,
683 ) *const Value;
683 ) *Value;
684684
685685 pub const buildICmp = LLVMBuildICmp;
686 extern fn LLVMBuildICmp(*const Builder, Op: IntPredicate, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
686 extern fn LLVMBuildICmp(*Builder, Op: IntPredicate, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
687687
688688 pub const buildFCmp = LLVMBuildFCmp;
689 extern fn LLVMBuildFCmp(*const Builder, Op: RealPredicate, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
689 extern fn LLVMBuildFCmp(*Builder, Op: RealPredicate, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
690690
691691 pub const buildBr = LLVMBuildBr;
692 extern fn LLVMBuildBr(*const Builder, Dest: *const BasicBlock) *const Value;
692 extern fn LLVMBuildBr(*Builder, Dest: *BasicBlock) *Value;
693693
694694 pub const buildCondBr = LLVMBuildCondBr;
695 extern fn LLVMBuildCondBr(*const Builder, If: *const Value, Then: *const BasicBlock, Else: *const BasicBlock) *const Value;
695 extern fn LLVMBuildCondBr(*Builder, If: *Value, Then: *BasicBlock, Else: *BasicBlock) *Value;
696696
697697 pub const buildSwitch = LLVMBuildSwitch;
698 extern fn LLVMBuildSwitch(*const Builder, V: *const Value, Else: *const BasicBlock, NumCases: c_uint) *const Value;
698 extern fn LLVMBuildSwitch(*Builder, V: *Value, Else: *BasicBlock, NumCases: c_uint) *Value;
699699
700700 pub const buildPhi = LLVMBuildPhi;
701 extern fn LLVMBuildPhi(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value;
701 extern fn LLVMBuildPhi(*Builder, Ty: *Type, Name: [*:0]const u8) *Value;
702702
703703 pub const buildExtractValue = LLVMBuildExtractValue;
704704 extern fn LLVMBuildExtractValue(
705 *const Builder,
706 AggVal: *const Value,
705 *Builder,
706 AggVal: *Value,
707707 Index: c_uint,
708708 Name: [*:0]const u8,
709 ) *const Value;
709 ) *Value;
710710
711711 pub const buildExtractElement = LLVMBuildExtractElement;
712712 extern fn LLVMBuildExtractElement(
713 *const Builder,
714 VecVal: *const Value,
715 Index: *const Value,
713 *Builder,
714 VecVal: *Value,
715 Index: *Value,
716716 Name: [*:0]const u8,
717 ) *const Value;
717 ) *Value;
718718
719719 pub const buildInsertElement = LLVMBuildInsertElement;
720720 extern fn LLVMBuildInsertElement(
721 *const Builder,
722 VecVal: *const Value,
723 EltVal: *const Value,
724 Index: *const Value,
721 *Builder,
722 VecVal: *Value,
723 EltVal: *Value,
724 Index: *Value,
725725 Name: [*:0]const u8,
726 ) *const Value;
726 ) *Value;
727727
728728 pub const buildVectorSplat = LLVMBuildVectorSplat;
729729 extern fn LLVMBuildVectorSplat(
730 *const Builder,
730 *Builder,
731731 ElementCount: c_uint,
732 EltVal: *const Value,
732 EltVal: *Value,
733733 Name: [*:0]const u8,
734 ) *const Value;
734 ) *Value;
735735
736736 pub const buildPtrToInt = LLVMBuildPtrToInt;
737737 extern fn LLVMBuildPtrToInt(
738 *const Builder,
739 Val: *const Value,
740 DestTy: *const Type,
738 *Builder,
739 Val: *Value,
740 DestTy: *Type,
741741 Name: [*:0]const u8,
742 ) *const Value;
742 ) *Value;
743743
744744 pub const buildIntToPtr = LLVMBuildIntToPtr;
745745 extern fn LLVMBuildIntToPtr(
746 *const Builder,
747 Val: *const Value,
748 DestTy: *const Type,
746 *Builder,
747 Val: *Value,
748 DestTy: *Type,
749749 Name: [*:0]const u8,
750 ) *const Value;
750 ) *Value;
751751
752752 pub const buildStructGEP = LLVMBuildStructGEP2;
753753 extern fn LLVMBuildStructGEP2(
754 B: *const Builder,
755 Ty: *const Type,
756 Pointer: *const Value,
754 B: *Builder,
755 Ty: *Type,
756 Pointer: *Value,
757757 Idx: c_uint,
758758 Name: [*:0]const u8,
759 ) *const Value;
759 ) *Value;
760760
761761 pub const buildTrunc = LLVMBuildTrunc;
762762 extern fn LLVMBuildTrunc(
763 *const Builder,
764 Val: *const Value,
765 DestTy: *const Type,
763 *Builder,
764 Val: *Value,
765 DestTy: *Type,
766766 Name: [*:0]const u8,
767 ) *const Value;
767 ) *Value;
768768
769769 pub const buildInsertValue = LLVMBuildInsertValue;
770770 extern fn LLVMBuildInsertValue(
771 *const Builder,
772 AggVal: *const Value,
773 EltVal: *const Value,
771 *Builder,
772 AggVal: *Value,
773 EltVal: *Value,
774774 Index: c_uint,
775775 Name: [*:0]const u8,
776 ) *const Value;
776 ) *Value;
777777
778778 pub const buildAtomicCmpXchg = LLVMBuildAtomicCmpXchg;
779779 extern fn LLVMBuildAtomicCmpXchg(
780 builder: *const Builder,
781 ptr: *const Value,
782 cmp: *const Value,
783 new_val: *const Value,
780 builder: *Builder,
781 ptr: *Value,
782 cmp: *Value,
783 new_val: *Value,
784784 success_ordering: AtomicOrdering,
785785 failure_ordering: AtomicOrdering,
786786 is_single_threaded: Bool,
787 ) *const Value;
787 ) *Value;
788788
789789 pub const buildSelect = LLVMBuildSelect;
790790 extern fn LLVMBuildSelect(
791 *const Builder,
792 If: *const Value,
793 Then: *const Value,
794 Else: *const Value,
791 *Builder,
792 If: *Value,
793 Then: *Value,
794 Else: *Value,
795795 Name: [*:0]const u8,
796 ) *const Value;
796 ) *Value;
797797
798798 pub const buildFence = LLVMBuildFence;
799799 extern fn LLVMBuildFence(
800 B: *const Builder,
800 B: *Builder,
801801 ordering: AtomicOrdering,
802802 singleThread: Bool,
803803 Name: [*:0]const u8,
804 ) *const Value;
804 ) *Value;
805805
806806 pub const buildAtomicRmw = LLVMBuildAtomicRMW;
807807 extern fn LLVMBuildAtomicRMW(
808 B: *const Builder,
808 B: *Builder,
809809 op: AtomicRMWBinOp,
810 PTR: *const Value,
811 Val: *const Value,
810 PTR: *Value,
811 Val: *Value,
812812 ordering: AtomicOrdering,
813813 singleThread: Bool,
814 ) *const Value;
814 ) *Value;
815815
816816 pub const buildFPToUI = LLVMBuildFPToUI;
817817 extern fn LLVMBuildFPToUI(
818 *const Builder,
819 Val: *const Value,
820 DestTy: *const Type,
818 *Builder,
819 Val: *Value,
820 DestTy: *Type,
821821 Name: [*:0]const u8,
822 ) *const Value;
822 ) *Value;
823823
824824 pub const buildFPToSI = LLVMBuildFPToSI;
825825 extern fn LLVMBuildFPToSI(
826 *const Builder,
827 Val: *const Value,
828 DestTy: *const Type,
826 *Builder,
827 Val: *Value,
828 DestTy: *Type,
829829 Name: [*:0]const u8,
830 ) *const Value;
830 ) *Value;
831831
832832 pub const buildUIToFP = LLVMBuildUIToFP;
833833 extern fn LLVMBuildUIToFP(
834 *const Builder,
835 Val: *const Value,
836 DestTy: *const Type,
834 *Builder,
835 Val: *Value,
836 DestTy: *Type,
837837 Name: [*:0]const u8,
838 ) *const Value;
838 ) *Value;
839839
840840 pub const buildSIToFP = LLVMBuildSIToFP;
841841 extern fn LLVMBuildSIToFP(
842 *const Builder,
843 Val: *const Value,
844 DestTy: *const Type,
842 *Builder,
843 Val: *Value,
844 DestTy: *Type,
845845 Name: [*:0]const u8,
846 ) *const Value;
846 ) *Value;
847847
848848 pub const buildFPTrunc = LLVMBuildFPTrunc;
849849 extern fn LLVMBuildFPTrunc(
850 *const Builder,
851 Val: *const Value,
852 DestTy: *const Type,
850 *Builder,
851 Val: *Value,
852 DestTy: *Type,
853853 Name: [*:0]const u8,
854 ) *const Value;
854 ) *Value;
855855
856856 pub const buildFPExt = LLVMBuildFPExt;
857857 extern fn LLVMBuildFPExt(
858 *const Builder,
859 Val: *const Value,
860 DestTy: *const Type,
858 *Builder,
859 Val: *Value,
860 DestTy: *Type,
861861 Name: [*:0]const u8,
862 ) *const Value;
862 ) *Value;
863863
864864 pub const buildMemSet = ZigLLVMBuildMemSet;
865865 extern fn ZigLLVMBuildMemSet(
866 B: *const Builder,
867 Ptr: *const Value,
868 Val: *const Value,
869 Len: *const Value,
866 B: *Builder,
867 Ptr: *Value,
868 Val: *Value,
869 Len: *Value,
870870 Align: c_uint,
871871 is_volatile: bool,
872 ) *const Value;
872 ) *Value;
873873
874874 pub const buildMemCpy = ZigLLVMBuildMemCpy;
875875 extern fn ZigLLVMBuildMemCpy(
876 B: *const Builder,
877 Dst: *const Value,
876 B: *Builder,
877 Dst: *Value,
878878 DstAlign: c_uint,
879 Src: *const Value,
879 Src: *Value,
880880 SrcAlign: c_uint,
881 Size: *const Value,
881 Size: *Value,
882882 is_volatile: bool,
883 ) *const Value;
883 ) *Value;
884884
885885 pub const buildMaxNum = ZigLLVMBuildMaxNum;
886 extern fn ZigLLVMBuildMaxNum(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
886 extern fn ZigLLVMBuildMaxNum(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
887887
888888 pub const buildMinNum = ZigLLVMBuildMinNum;
889 extern fn ZigLLVMBuildMinNum(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
889 extern fn ZigLLVMBuildMinNum(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
890890
891891 pub const buildUMax = ZigLLVMBuildUMax;
892 extern fn ZigLLVMBuildUMax(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
892 extern fn ZigLLVMBuildUMax(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
893893
894894 pub const buildUMin = ZigLLVMBuildUMin;
895 extern fn ZigLLVMBuildUMin(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
895 extern fn ZigLLVMBuildUMin(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
896896
897897 pub const buildSMax = ZigLLVMBuildSMax;
898 extern fn ZigLLVMBuildSMax(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
898 extern fn ZigLLVMBuildSMax(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
899899
900900 pub const buildSMin = ZigLLVMBuildSMin;
901 extern fn ZigLLVMBuildSMin(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
901 extern fn ZigLLVMBuildSMin(builder: *Builder, LHS: *Value, RHS: *Value, name: [*:0]const u8) *Value;
902902
903903 pub const buildExactUDiv = LLVMBuildExactUDiv;
904 extern fn LLVMBuildExactUDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
904 extern fn LLVMBuildExactUDiv(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
905905
906906 pub const buildExactSDiv = LLVMBuildExactSDiv;
907 extern fn LLVMBuildExactSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
907 extern fn LLVMBuildExactSDiv(*Builder, LHS: *Value, RHS: *Value, Name: [*:0]const u8) *Value;
908908
909909 pub const setCurrentDebugLocation = ZigLLVMSetCurrentDebugLocation2;
910 extern fn ZigLLVMSetCurrentDebugLocation2(builder: *const Builder, line: c_uint, column: c_uint, scope: *DIScope, inlined_at: ?*DILocation) void;
910 extern fn ZigLLVMSetCurrentDebugLocation2(builder: *Builder, line: c_uint, column: c_uint, scope: *DIScope, inlined_at: ?*DILocation) void;
911911
912912 pub const clearCurrentDebugLocation = ZigLLVMClearCurrentDebugLocation;
913 extern fn ZigLLVMClearCurrentDebugLocation(builder: *const Builder) void;
913 extern fn ZigLLVMClearCurrentDebugLocation(builder: *Builder) void;
914914
915915 pub const getCurrentDebugLocation2 = LLVMGetCurrentDebugLocation2;
916 extern fn LLVMGetCurrentDebugLocation2(Builder: *const Builder) *Metadata;
916 extern fn LLVMGetCurrentDebugLocation2(Builder: *Builder) *Metadata;
917917
918918 pub const setCurrentDebugLocation2 = LLVMSetCurrentDebugLocation2;
919 extern fn LLVMSetCurrentDebugLocation2(Builder: *const Builder, Loc: *Metadata) void;
919 extern fn LLVMSetCurrentDebugLocation2(Builder: *Builder, Loc: *Metadata) void;
920920
921921 pub const buildShuffleVector = LLVMBuildShuffleVector;
922 extern fn LLVMBuildShuffleVector(*const Builder, V1: *const Value, V2: *const Value, Mask: *const Value, Name: [*:0]const u8) *const Value;
922 extern fn LLVMBuildShuffleVector(*Builder, V1: *Value, V2: *Value, Mask: *Value, Name: [*:0]const u8) *Value;
923923
924924 pub const buildAndReduce = ZigLLVMBuildAndReduce;
925 extern fn ZigLLVMBuildAndReduce(B: *const Builder, Val: *const Value) *const Value;
925 extern fn ZigLLVMBuildAndReduce(B: *Builder, Val: *Value) *Value;
926926
927927 pub const buildOrReduce = ZigLLVMBuildOrReduce;
928 extern fn ZigLLVMBuildOrReduce(B: *const Builder, Val: *const Value) *const Value;
928 extern fn ZigLLVMBuildOrReduce(B: *Builder, Val: *Value) *Value;
929929
930930 pub const buildXorReduce = ZigLLVMBuildXorReduce;
931 extern fn ZigLLVMBuildXorReduce(B: *const Builder, Val: *const Value) *const Value;
931 extern fn ZigLLVMBuildXorReduce(B: *Builder, Val: *Value) *Value;
932932
933933 pub const buildIntMaxReduce = ZigLLVMBuildIntMaxReduce;
934 extern fn ZigLLVMBuildIntMaxReduce(B: *const Builder, Val: *const Value, is_signed: bool) *const Value;
934 extern fn ZigLLVMBuildIntMaxReduce(B: *Builder, Val: *Value, is_signed: bool) *Value;
935935
936936 pub const buildIntMinReduce = ZigLLVMBuildIntMinReduce;
937 extern fn ZigLLVMBuildIntMinReduce(B: *const Builder, Val: *const Value, is_signed: bool) *const Value;
937 extern fn ZigLLVMBuildIntMinReduce(B: *Builder, Val: *Value, is_signed: bool) *Value;
938938
939939 pub const buildFPMaxReduce = ZigLLVMBuildFPMaxReduce;
940 extern fn ZigLLVMBuildFPMaxReduce(B: *const Builder, Val: *const Value) *const Value;
940 extern fn ZigLLVMBuildFPMaxReduce(B: *Builder, Val: *Value) *Value;
941941
942942 pub const buildFPMinReduce = ZigLLVMBuildFPMinReduce;
943 extern fn ZigLLVMBuildFPMinReduce(B: *const Builder, Val: *const Value) *const Value;
943 extern fn ZigLLVMBuildFPMinReduce(B: *Builder, Val: *Value) *Value;
944944
945945 pub const buildAddReduce = ZigLLVMBuildAddReduce;
946 extern fn ZigLLVMBuildAddReduce(B: *const Builder, Val: *const Value) *const Value;
946 extern fn ZigLLVMBuildAddReduce(B: *Builder, Val: *Value) *Value;
947947
948948 pub const buildMulReduce = ZigLLVMBuildMulReduce;
949 extern fn ZigLLVMBuildMulReduce(B: *const Builder, Val: *const Value) *const Value;
949 extern fn ZigLLVMBuildMulReduce(B: *Builder, Val: *Value) *Value;
950950
951951 pub const buildFPAddReduce = ZigLLVMBuildFPAddReduce;
952 extern fn ZigLLVMBuildFPAddReduce(B: *const Builder, Acc: *const Value, Val: *const Value) *const Value;
952 extern fn ZigLLVMBuildFPAddReduce(B: *Builder, Acc: *Value, Val: *Value) *Value;
953953
954954 pub const buildFPMulReduce = ZigLLVMBuildFPMulReduce;
955 extern fn ZigLLVMBuildFPMulReduce(B: *const Builder, Acc: *const Value, Val: *const Value) *const Value;
955 extern fn ZigLLVMBuildFPMulReduce(B: *Builder, Acc: *Value, Val: *Value) *Value;
956956
957957 pub const setFastMath = ZigLLVMSetFastMath;
958 extern fn ZigLLVMSetFastMath(B: *const Builder, on_state: bool) void;
958 extern fn ZigLLVMSetFastMath(B: *Builder, on_state: bool) void;
959959};
960960
961961pub const MDString = opaque {
962962 pub const get = LLVMMDStringInContext2;
963 extern fn LLVMMDStringInContext2(C: *const Context, Str: [*]const u8, SLen: usize) *MDString;
963 extern fn LLVMMDStringInContext2(C: *Context, Str: [*]const u8, SLen: usize) *MDString;
964964};
965965
966966pub const DIScope = opaque {
......@@ -1003,16 +1003,16 @@ pub const RealPredicate = enum(c_uint) {
10031003
10041004pub const BasicBlock = opaque {
10051005 pub const deleteBasicBlock = LLVMDeleteBasicBlock;
1006 extern fn LLVMDeleteBasicBlock(BB: *const BasicBlock) void;
1006 extern fn LLVMDeleteBasicBlock(BB: *BasicBlock) void;
10071007
10081008 pub const getFirstInstruction = LLVMGetFirstInstruction;
1009 extern fn LLVMGetFirstInstruction(BB: *const BasicBlock) ?*const Value;
1009 extern fn LLVMGetFirstInstruction(BB: *BasicBlock) ?*Value;
10101010};
10111011
10121012pub const TargetMachine = opaque {
10131013 pub const create = ZigLLVMCreateTargetMachine;
10141014 extern fn ZigLLVMCreateTargetMachine(
1015 T: *const Target,
1015 T: *Target,
10161016 Triple: [*:0]const u8,
10171017 CPU: ?[*:0]const u8,
10181018 Features: ?[*:0]const u8,
......@@ -1022,15 +1022,15 @@ pub const TargetMachine = opaque {
10221022 function_sections: bool,
10231023 float_abi: ABIType,
10241024 abi_name: ?[*:0]const u8,
1025 ) *const TargetMachine;
1025 ) *TargetMachine;
10261026
10271027 pub const dispose = LLVMDisposeTargetMachine;
1028 extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void;
1028 extern fn LLVMDisposeTargetMachine(T: *TargetMachine) void;
10291029
10301030 pub const emitToFile = ZigLLVMTargetMachineEmitToFile;
10311031 extern fn ZigLLVMTargetMachineEmitToFile(
1032 T: *const TargetMachine,
1033 M: *const Module,
1032 T: *TargetMachine,
1033 M: *Module,
10341034 ErrorMessage: *[*:0]const u8,
10351035 is_debug: bool,
10361036 is_small: bool,
......@@ -1044,18 +1044,18 @@ pub const TargetMachine = opaque {
10441044 ) bool;
10451045
10461046 pub const createTargetDataLayout = LLVMCreateTargetDataLayout;
1047 extern fn LLVMCreateTargetDataLayout(*const TargetMachine) *const TargetData;
1047 extern fn LLVMCreateTargetDataLayout(*TargetMachine) *TargetData;
10481048};
10491049
10501050pub const TargetData = opaque {
10511051 pub const dispose = LLVMDisposeTargetData;
1052 extern fn LLVMDisposeTargetData(*const TargetData) void;
1052 extern fn LLVMDisposeTargetData(*TargetData) void;
10531053
10541054 pub const abiAlignmentOfType = LLVMABIAlignmentOfType;
1055 extern fn LLVMABIAlignmentOfType(TD: *const TargetData, Ty: *const Type) c_uint;
1055 extern fn LLVMABIAlignmentOfType(TD: *TargetData, Ty: *Type) c_uint;
10561056
10571057 pub const abiSizeOfType = LLVMABISizeOfType;
1058 extern fn LLVMABISizeOfType(TD: *const TargetData, Ty: *const Type) c_ulonglong;
1058 extern fn LLVMABISizeOfType(TD: *TargetData, Ty: *Type) c_ulonglong;
10591059};
10601060
10611061pub const CodeModel = enum(c_int) {
......@@ -1101,7 +1101,7 @@ pub const ABIType = enum(c_int) {
11011101
11021102pub const Target = opaque {
11031103 pub const getFromTriple = LLVMGetTargetFromTriple;
1104 extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const Target, ErrorMessage: *[*:0]const u8) Bool;
1104 extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **Target, ErrorMessage: *[*:0]const u8) Bool;
11051105};
11061106
11071107pub extern fn LLVMInitializeAArch64TargetInfo() void;
......@@ -1355,7 +1355,7 @@ extern fn ZigLLVMWriteImportLibrary(
13551355) bool;
13561356
13571357pub const setCallElemTypeAttr = ZigLLVMSetCallElemTypeAttr;
1358extern fn ZigLLVMSetCallElemTypeAttr(Call: *const Value, arg_index: usize, return_type: *const Type) void;
1358extern fn ZigLLVMSetCallElemTypeAttr(Call: *Value, arg_index: usize, return_type: *Type) void;
13591359
13601360pub const Linkage = enum(c_uint) {
13611361 External,
......@@ -1854,29 +1854,29 @@ pub const DIBuilder = opaque {
18541854 pub const insertDeclareAtEnd = ZigLLVMInsertDeclareAtEnd;
18551855 extern fn ZigLLVMInsertDeclareAtEnd(
18561856 dib: *DIBuilder,
1857 storage: *const Value,
1857 storage: *Value,
18581858 var_info: *DILocalVariable,
18591859 debug_loc: *DILocation,
1860 basic_block_ref: *const BasicBlock,
1861 ) *const Value;
1860 basic_block_ref: *BasicBlock,
1861 ) *Value;
18621862
18631863 pub const insertDeclare = ZigLLVMInsertDeclare;
18641864 extern fn ZigLLVMInsertDeclare(
18651865 dib: *DIBuilder,
1866 storage: *const Value,
1866 storage: *Value,
18671867 var_info: *DILocalVariable,
18681868 debug_loc: *DILocation,
1869 insert_before_instr: *const Value,
1870 ) *const Value;
1869 insert_before_instr: *Value,
1870 ) *Value;
18711871
18721872 pub const insertDbgValueIntrinsicAtEnd = ZigLLVMInsertDbgValueIntrinsicAtEnd;
18731873 extern fn ZigLLVMInsertDbgValueIntrinsicAtEnd(
18741874 dib: *DIBuilder,
1875 val: *const Value,
1875 val: *Value,
18761876 var_info: *DILocalVariable,
18771877 debug_loc: *DILocation,
1878 basic_block_ref: *const BasicBlock,
1879 ) *const Value;
1878 basic_block_ref: *BasicBlock,
1879 ) *Value;
18801880};
18811881
18821882pub const DIFlags = opaque {