authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-06-26 01:52:10-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-07-27 14:35:12-04:00
logc6ab46cc3effecd18db8b8469de965eafd02e1fd
tree6f33a1b85d6e30eb8db45e0aed72f79ab8f17e6e
parent9e7f40db3a83242e12db853431cea0701446f5fb

llvm: `TypeRepr.by_value` -> `TypeRepr.as_value`

Otherwise, I constantly get it confused with `by_val` and `byval`.

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

src/codegen/llvm.zig+20-20
...@@ -2848,7 +2848,7 @@ pub const Object = struct {...@@ -2848,7 +2848,7 @@ pub const Object = struct {
2848 pub const TypeRepr = enum {2848 pub const TypeRepr = enum {
2849 /// The representation of the type when it is being manipulated as a value in a function.2849 /// The representation of the type when it is being manipulated as a value in a function.
2850 /// e.g. Zig `u5` -> LLVM `i5`2850 /// e.g. Zig `u5` -> LLVM `i5`
2851 by_value,2851 as_value,
2852 /// The representation of the type when it is stored in memory.2852 /// The representation of the type when it is stored in memory.
2853 /// e.g. Zig `u5` -> LLVM `i8`2853 /// e.g. Zig `u5` -> LLVM `i8`
2854 in_memory,2854 in_memory,
...@@ -2856,7 +2856,7 @@ pub const Object = struct {...@@ -2856,7 +2856,7 @@ pub const Object = struct {
28562856
2857 pub fn errorIntType(o: *Object, repr: TypeRepr) Allocator.Error!Builder.Type {2857 pub fn errorIntType(o: *Object, repr: TypeRepr) Allocator.Error!Builder.Type {
2858 return o.builder.intType(switch (repr) {2858 return o.builder.intType(switch (repr) {
2859 .by_value => o.zcu.errorSetBits(),2859 .as_value => o.zcu.errorSetBits(),
2860 .in_memory => @intCast(Type.anyerror.abiSize(o.zcu) * 8),2860 .in_memory => @intCast(Type.anyerror.abiSize(o.zcu) * 8),
2861 });2861 });
2862 }2862 }
...@@ -2866,7 +2866,7 @@ pub const Object = struct {...@@ -2866,7 +2866,7 @@ pub const Object = struct {
2866 const target = zcu.getTarget();2866 const target = zcu.getTarget();
2867 const ip = &zcu.intern_pool;2867 const ip = &zcu.intern_pool;
28682868
2869 if (repr == .by_value) {2869 if (repr == .as_value) {
2870 assert(!isByRef(t, zcu)); // by-ref types must only be manipulated in memory2870 assert(!isByRef(t, zcu)); // by-ref types must only be manipulated in memory
2871 }2871 }
28722872
...@@ -2886,7 +2886,7 @@ pub const Object = struct {...@@ -2886,7 +2886,7 @@ pub const Object = struct {
2886 .u128_type,2886 .u128_type,
2887 .i128_type,2887 .i128_type,
2888 => |tag| switch (repr) {2888 => |tag| switch (repr) {
2889 .by_value => @field(Builder.Type, "i" ++ @tagName(tag)[1 .. @tagName(tag).len - "_type".len]),2889 .as_value => @field(Builder.Type, "i" ++ @tagName(tag)[1 .. @tagName(tag).len - "_type".len]),
2890 .in_memory => try o.builder.intType(@intCast(t.abiSize(zcu) * 8)),2890 .in_memory => try o.builder.intType(@intCast(t.abiSize(zcu) * 8)),
2891 },2891 },
2892 .usize_type, .isize_type => try o.builder.intType(target.ptrBitWidth()),2892 .usize_type, .isize_type => try o.builder.intType(target.ptrBitWidth()),
...@@ -2973,7 +2973,7 @@ pub const Object = struct {...@@ -2973,7 +2973,7 @@ pub const Object = struct {
2973 => unreachable,2973 => unreachable,
2974 else => switch (ip.indexToKey(t.toIntern())) {2974 else => switch (ip.indexToKey(t.toIntern())) {
2975 .int_type => |int_type| switch (repr) {2975 .int_type => |int_type| switch (repr) {
2976 .by_value => try o.builder.intType(int_type.bits),2976 .as_value => try o.builder.intType(int_type.bits),
2977 .in_memory => try o.builder.intType(@intCast(t.abiSize(zcu) * 8)),2977 .in_memory => try o.builder.intType(@intCast(t.abiSize(zcu) * 8)),
2978 },2978 },
2979 .ptr_type => |ptr_type| type: {2979 .ptr_type => |ptr_type| type: {
...@@ -2995,7 +2995,7 @@ pub const Object = struct {...@@ -2995,7 +2995,7 @@ pub const Object = struct {
2995 .vector_type => |vector_type| o.builder.vectorType(2995 .vector_type => |vector_type| o.builder.vectorType(
2996 .normal,2996 .normal,
2997 vector_type.len,2997 vector_type.len,
2998 try o.lowerType(.fromInterned(vector_type.child), .by_value),2998 try o.lowerType(.fromInterned(vector_type.child), .as_value),
2999 ),2999 ),
3000 .opt_type => |child_ty| {3000 .opt_type => |child_ty| {
3001 // Must stay in sync with `opt_payload` logic in `lowerPtr`.3001 // Must stay in sync with `opt_payload` logic in `lowerPtr`.
...@@ -3310,7 +3310,7 @@ pub const Object = struct {...@@ -3310,7 +3310,7 @@ pub const Object = struct {
3310 .no_bits => continue,3310 .no_bits => continue,
3311 .byval => {3311 .byval => {
3312 const param_ty = Type.fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]);3312 const param_ty = Type.fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]);
3313 try llvm_params.append(o.gpa, try o.lowerType(param_ty, if (isByRef(param_ty, zcu)) .in_memory else .by_value));3313 try llvm_params.append(o.gpa, try o.lowerType(param_ty, if (isByRef(param_ty, zcu)) .in_memory else .as_value));
3314 },3314 },
3315 .byref, .byref_mut => {3315 .byref, .byref_mut => {
3316 try llvm_params.append(o.gpa, .ptr);3316 try llvm_params.append(o.gpa, .ptr);
...@@ -3325,7 +3325,7 @@ pub const Object = struct {...@@ -3325,7 +3325,7 @@ pub const Object = struct {
3325 const param_ty = Type.fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]);3325 const param_ty = Type.fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]);
3326 try llvm_params.appendSlice(o.gpa, &.{3326 try llvm_params.appendSlice(o.gpa, &.{
3327 try o.builder.ptrType(toLlvmAddressSpace(param_ty.ptrAddressSpace(zcu), target)),3327 try o.builder.ptrType(toLlvmAddressSpace(param_ty.ptrAddressSpace(zcu), target)),
3328 try o.lowerType(.usize, .by_value),3328 try o.lowerType(.usize, .as_value),
3329 });3329 });
3330 },3330 },
3331 .multiple_llvm_types => {3331 .multiple_llvm_types => {
...@@ -3347,7 +3347,7 @@ pub const Object = struct {...@@ -3347,7 +3347,7 @@ pub const Object = struct {
33473347
3348 const llvm_ret_ty: Builder.Type = switch (ret_strat) {3348 const llvm_ret_ty: Builder.Type = switch (ret_strat) {
3349 .void, .sret => .void,3349 .void, .sret => .void,
3350 .by_val => try o.lowerType(.fromInterned(fn_info.return_type), .by_value),3350 .by_val => try o.lowerType(.fromInterned(fn_info.return_type), .as_value),
3351 .mem_cast => |llvm_ret_ty| llvm_ret_ty,3351 .mem_cast => |llvm_ret_ty| llvm_ret_ty,
3352 };3352 };
3353 const llvm_fn_kind: Builder.Type.Function.Kind = switch (fn_info.is_var_args) {3353 const llvm_fn_kind: Builder.Type.Function.Kind = switch (fn_info.is_var_args) {
...@@ -3604,7 +3604,7 @@ pub const Object = struct {...@@ -3604,7 +3604,7 @@ pub const Object = struct {
3604 result_val.* = try o.builder.intConst(.i8, byte);3604 result_val.* = try o.builder.intConst(.i8, byte);
3605 },3605 },
3606 .elems => |elems| for (vals, elems) |*result_val, elem| {3606 .elems => |elems| for (vals, elems) |*result_val, elem| {
3607 result_val.* = try o.lowerValue(elem, .by_value);3607 result_val.* = try o.lowerValue(elem, .as_value);
3608 },3608 },
3609 .repeated_elem => unreachable,3609 .repeated_elem => unreachable,
3610 }3610 }
...@@ -3612,7 +3612,7 @@ pub const Object = struct {...@@ -3612,7 +3612,7 @@ pub const Object = struct {
3612 },3612 },
3613 .repeated_elem => |elem| return o.builder.splatConst(3613 .repeated_elem => |elem| return o.builder.splatConst(
3614 vector_ty,3614 vector_ty,
3615 try o.lowerValue(elem, .by_value),3615 try o.lowerValue(elem, .as_value),
3616 ),3616 ),
3617 }3617 }
3618 },3618 },
...@@ -3869,8 +3869,8 @@ pub const Object = struct {...@@ -3869,8 +3869,8 @@ pub const Object = struct {
3869 },3869 },
3870 .int => try o.builder.castConst(3870 .int => try o.builder.castConst(
3871 .inttoptr,3871 .inttoptr,
3872 try o.builder.intConst(try o.lowerType(.usize, .by_value), offset),3872 try o.builder.intConst(try o.lowerType(.usize, .as_value), offset),
3873 try o.lowerType(.fromInterned(ptr.ty), .by_value),3873 try o.lowerType(.fromInterned(ptr.ty), .as_value),
3874 ),3874 ),
3875 .eu_payload => |eu_ptr| try o.lowerPtr(3875 .eu_payload => |eu_ptr| try o.lowerPtr(
3876 eu_ptr,3876 eu_ptr,
...@@ -3917,7 +3917,7 @@ pub const Object = struct {...@@ -3917,7 +3917,7 @@ pub const Object = struct {
3917 @"addrspace": std.lang.AddressSpace,3917 @"addrspace": std.lang.AddressSpace,
3918 ) Allocator.Error!Builder.Constant {3918 ) Allocator.Error!Builder.Constant {
3919 const addr: u64 = @"align".toByteUnits().?;3919 const addr: u64 = @"align".toByteUnits().?;
3920 const llvm_usize = try o.lowerType(.usize, .by_value);3920 const llvm_usize = try o.lowerType(.usize, .as_value);
3921 const llvm_addr = try o.builder.intConst(llvm_usize, addr);3921 const llvm_addr = try o.builder.intConst(llvm_usize, addr);
3922 const llvm_ptr_ty = try o.builder.ptrType(toLlvmAddressSpace(@"addrspace", o.zcu.getTarget()));3922 const llvm_ptr_ty = try o.builder.ptrType(toLlvmAddressSpace(@"addrspace", o.zcu.getTarget()));
3923 return o.builder.castConst(.inttoptr, llvm_addr, llvm_ptr_ty);3923 return o.builder.castConst(.inttoptr, llvm_addr, llvm_ptr_ty);
...@@ -4132,9 +4132,9 @@ pub const Object = struct {...@@ -4132,9 +4132,9 @@ pub const Object = struct {
4132 const ip = &zcu.intern_pool;4132 const ip = &zcu.intern_pool;
4133 const loaded_enum = ip.loadEnumType(enum_ty.toIntern());4133 const loaded_enum = ip.loadEnumType(enum_ty.toIntern());
41344134
4135 const llvm_usize_ty = try o.lowerType(.usize, .by_value);4135 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
4136 const llvm_ret_ty = try o.lowerType(.slice_const_u8_sentinel_0, .by_value);4136 const llvm_ret_ty = try o.lowerType(.slice_const_u8_sentinel_0, .as_value);
4137 const llvm_int_ty = try o.lowerType(.fromInterned(loaded_enum.int_tag_type), .by_value);4137 const llvm_int_ty = try o.lowerType(.fromInterned(loaded_enum.int_tag_type), .as_value);
41384138
4139 function_index.ptrConst(&o.builder).global.ptr(&o.builder).type =4139 function_index.ptrConst(&o.builder).global.ptr(&o.builder).type =
4140 try o.builder.fnType(llvm_ret_ty, &.{llvm_int_ty}, .normal);4140 try o.builder.fnType(llvm_ret_ty, &.{llvm_int_ty}, .normal);
...@@ -4183,7 +4183,7 @@ pub const Object = struct {...@@ -4183,7 +4183,7 @@ pub const Object = struct {
4183 const return_block = try wip.block(1, "Name");4183 const return_block = try wip.block(1, "Name");
4184 const llvm_tag_val = switch (loaded_enum.field_values.getOrNone(ip, field_index)) {4184 const llvm_tag_val = switch (loaded_enum.field_values.getOrNone(ip, field_index)) {
4185 .none => try o.builder.intConst(llvm_int_ty, field_index), // auto-numbered4185 .none => try o.builder.intConst(llvm_int_ty, field_index), // auto-numbered
4186 else => |tag_val_ip| try o.lowerValue(tag_val_ip, .by_value),4186 else => |tag_val_ip| try o.lowerValue(tag_val_ip, .as_value),
4187 };4187 };
4188 try wip_switch.addCase(llvm_tag_val, return_block, &wip);4188 try wip_switch.addCase(llvm_tag_val, return_block, &wip);
41894189
...@@ -4229,7 +4229,7 @@ pub const Object = struct {...@@ -4229,7 +4229,7 @@ pub const Object = struct {
4229 const ip = &zcu.intern_pool;4229 const ip = &zcu.intern_pool;
4230 const loaded_enum = ip.loadEnumType(enum_ty.toIntern());4230 const loaded_enum = ip.loadEnumType(enum_ty.toIntern());
42314231
4232 const llvm_int_ty = try o.lowerType(.fromInterned(loaded_enum.int_tag_type), .by_value);4232 const llvm_int_ty = try o.lowerType(.fromInterned(loaded_enum.int_tag_type), .as_value);
4233 function_index.ptrConst(&o.builder).global.ptr(&o.builder).type =4233 function_index.ptrConst(&o.builder).global.ptr(&o.builder).type =
4234 try o.builder.fnType(.i1, &.{llvm_int_ty}, .normal);4234 try o.builder.fnType(.i1, &.{llvm_int_ty}, .normal);
42354235
...@@ -4256,7 +4256,7 @@ pub const Object = struct {...@@ -4256,7 +4256,7 @@ pub const Object = struct {
42564256
4257 if (loaded_enum.field_values.len > 0) {4257 if (loaded_enum.field_values.len > 0) {
4258 for (loaded_enum.field_values.get(ip)) |tag_val_ip| {4258 for (loaded_enum.field_values.get(ip)) |tag_val_ip| {
4259 const llvm_tag_val = try o.lowerValue(tag_val_ip, .by_value);4259 const llvm_tag_val = try o.lowerValue(tag_val_ip, .as_value);
4260 try wip_switch.addCase(llvm_tag_val, named_block, &wip);4260 try wip_switch.addCase(llvm_tag_val, named_block, &wip);
4261 }4261 }
4262 } else {4262 } else {
src/codegen/llvm/FuncGen.zig+117-117
...@@ -164,7 +164,7 @@ fn resolveValue(self: *FuncGen, val: Value) Allocator.Error!Builder.Constant {...@@ -164,7 +164,7 @@ fn resolveValue(self: *FuncGen, val: Value) Allocator.Error!Builder.Constant {
164 const zcu = o.zcu;164 const zcu = o.zcu;
165 const ty = val.typeOf(zcu);165 const ty = val.typeOf(zcu);
166 if (!isByRef(ty, zcu)) {166 if (!isByRef(ty, zcu)) {
167 return o.lowerValue(val.toIntern(), .by_value);167 return o.lowerValue(val.toIntern(), .as_value);
168 } else {168 } else {
169 // We need a pointer to a global constant, i.e. a UAV.169 // We need a pointer to a global constant, i.e. a UAV.
170 return o.lowerUavRef(170 return o.lowerUavRef(
...@@ -264,7 +264,7 @@ pub fn genMainBody(fg: *FuncGen) TodoError!void {...@@ -264,7 +264,7 @@ pub fn genMainBody(fg: *FuncGen) TodoError!void {
264 const param_ty: Type = .fromInterned(param_types[it.zig_index - 1]);264 const param_ty: Type = .fromInterned(param_types[it.zig_index - 1]);
265 assert(!isByRef(param_ty, zcu));265 assert(!isByRef(param_ty, zcu));
266 const slice_val = try fg.wip.buildAggregate(266 const slice_val = try fg.wip.buildAggregate(
267 try o.lowerType(param_ty, .by_value),267 try o.lowerType(param_ty, .as_value),
268 &.{ fg.wip.arg(it.llvm_index - 2), fg.wip.arg(it.llvm_index - 1) },268 &.{ fg.wip.arg(it.llvm_index - 2), fg.wip.arg(it.llvm_index - 1) },
269 "",269 "",
270 );270 );
...@@ -998,7 +998,7 @@ fn airCall(self: *FuncGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier...@@ -998,7 +998,7 @@ fn airCall(self: *FuncGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier
998 },998 },
999 cc_info.llvm_cc,999 cc_info.llvm_cc,
1000 try attributes.finish(&o.builder),1000 try attributes.finish(&o.builder),
1001 try o.lowerType(zig_fn_ty, .by_value),1001 try o.lowerType(zig_fn_ty, .as_value),
1002 llvm_fn,1002 llvm_fn,
1003 llvm_args.items,1003 llvm_args.items,
1004 "",1004 "",
...@@ -1038,7 +1038,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v...@@ -1038,7 +1038,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v
1038 const target = zcu.getTarget();1038 const target = zcu.getTarget();
1039 const panic_func = zcu.funcInfo(zcu.std_lang_decl_values.get(panic_id.toStdLangDecl()));1039 const panic_func = zcu.funcInfo(zcu.std_lang_decl_values.get(panic_id.toStdLangDecl()));
1040 const fn_info = zcu.typeToFunc(.fromInterned(panic_func.ty)).?;1040 const fn_info = zcu.typeToFunc(.fromInterned(panic_func.ty)).?;
1041 const llvm_panic_fn_ty = try o.lowerType(.fromInterned(panic_func.ty), .by_value);1041 const llvm_panic_fn_ty = try o.lowerType(.fromInterned(panic_func.ty), .as_value);
10421042
1043 const llvm_panic_fn_ref = try o.lowerNavRef(panic_func.owner_nav);1043 const llvm_panic_fn_ref = try o.lowerNavRef(panic_func.owner_nav);
10441044
...@@ -1076,7 +1076,7 @@ fn airRet(self: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!vo...@@ -1076,7 +1076,7 @@ fn airRet(self: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!vo
1076 .none => try self.buildZigAlloca(ret_ty, .none),1076 .none => try self.buildZigAlloca(ret_ty, .none),
1077 else => |rp| rp,1077 else => |rp| rp,
1078 };1078 };
1079 const len = try o.builder.intValue(try o.lowerType(.usize, .by_value), ret_ty.abiSize(zcu));1079 const len = try o.builder.intValue(try o.lowerType(.usize, .as_value), ret_ty.abiSize(zcu));
1080 _ = try self.wip.callMemSet(1080 _ = try self.wip.callMemSet(
1081 rp,1081 rp,
1082 ret_ty_align.toLlvm(),1082 ret_ty_align.toLlvm(),
...@@ -1165,7 +1165,7 @@ fn airCVaArg(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -1165,7 +1165,7 @@ fn airCVaArg(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
1165 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;1165 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;
1166 const list = try self.resolveInst(ty_op.operand);1166 const list = try self.resolveInst(ty_op.operand);
1167 const arg_ty = ty_op.ty.toType();1167 const arg_ty = ty_op.ty.toType();
1168 const llvm_arg_ty = try self.object.lowerType(arg_ty, .by_value);1168 const llvm_arg_ty = try self.object.lowerType(arg_ty, .as_value);
11691169
1170 return self.wip.vaArg(list, llvm_arg_ty, "");1170 return self.wip.vaArg(list, llvm_arg_ty, "");
1171}1171}
...@@ -1378,7 +1378,7 @@ fn lowerBlock(...@@ -1378,7 +1378,7 @@ fn lowerBlock(
1378 if (have_block_result) {1378 if (have_block_result) {
1379 const llvm_ty: Builder.Type = switch (isByRef(inst_ty, zcu)) {1379 const llvm_ty: Builder.Type = switch (isByRef(inst_ty, zcu)) {
1380 true => .ptr,1380 true => .ptr,
1381 false => try o.lowerType(inst_ty, .by_value),1381 false => try o.lowerType(inst_ty, .as_value),
1382 };1382 };
1383 parent_bb.ptr(&self.wip).incoming = @intCast(breaks.list.len);1383 parent_bb.ptr(&self.wip).incoming = @intCast(breaks.list.len);
1384 const phi = try self.wip.phi(llvm_ty, "");1384 const phi = try self.wip.phi(llvm_ty, "");
...@@ -1485,7 +1485,7 @@ fn lowerSwitchDispatch(...@@ -1485,7 +1485,7 @@ fn lowerSwitchDispatch(
1485 const table_index = try self.wip.conv(1485 const table_index = try self.wip.conv(
1486 .unsigned,1486 .unsigned,
1487 try self.wip.bin(.@"sub nuw", cond, jmp_table.min.toValue(), ""),1487 try self.wip.bin(.@"sub nuw", cond, jmp_table.min.toValue(), ""),
1488 try o.lowerType(.usize, .by_value),1488 try o.lowerType(.usize, .as_value),
1489 "",1489 "",
1490 );1490 );
1491 const target_ptr_ptr = try self.ptraddScaled(1491 const target_ptr_ptr = try self.ptraddScaled(
...@@ -1510,7 +1510,7 @@ fn lowerSwitchDispatch(...@@ -1510,7 +1510,7 @@ fn lowerSwitchDispatch(
1510 // The switch prongs will correspond to our scalar cases. Ranges will1510 // The switch prongs will correspond to our scalar cases. Ranges will
1511 // be handled by conditional branches in the `else` prong.1511 // be handled by conditional branches in the `else` prong.
15121512
1513 const llvm_usize = try o.lowerType(.usize, .by_value);1513 const llvm_usize = try o.lowerType(.usize, .as_value);
1514 const cond_int = if (cond_ty.zigTypeTag(zcu) == .pointer)1514 const cond_int = if (cond_ty.zigTypeTag(zcu) == .pointer)
1515 try self.wip.cast(.ptrtoint, cond, llvm_usize, "")1515 try self.wip.cast(.ptrtoint, cond, llvm_usize, "")
1516 else1516 else
...@@ -1725,7 +1725,7 @@ fn lowerTry(...@@ -1725,7 +1725,7 @@ fn lowerTry(
1725 if (err_union_ty.isVolatilePtr(zcu)) .@"volatile" else .normal,1725 if (err_union_ty.isVolatilePtr(zcu)) .@"volatile" else .normal,
1726 );1726 );
1727 };1727 };
1728 const zero = try o.builder.intValue(try o.errorIntType(.by_value), 0);1728 const zero = try o.builder.intValue(try o.errorIntType(.as_value), 0);
1729 const is_err = try fg.wip.icmp(.ne, loaded, zero, "");1729 const is_err = try fg.wip.icmp(.ne, loaded, zero, "");
17301730
1731 const return_block = try fg.wip.block(1, "TryRet");1731 const return_block = try fg.wip.block(1, "TryRet");
...@@ -1862,8 +1862,8 @@ fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index, is_dispatch_loop: bool) Tod...@@ -1862,8 +1862,8 @@ fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index, is_dispatch_loop: bool) Tod
1862 const table_includes_else = item_count != table_len;1862 const table_includes_else = item_count != table_len;
18631863
1864 break :jmp_table .{1864 break :jmp_table .{
1865 .min = try o.lowerValue(min.toIntern(), .by_value),1865 .min = try o.lowerValue(min.toIntern(), .as_value),
1866 .max = try o.lowerValue(max.toIntern(), .by_value),1866 .max = try o.lowerValue(max.toIntern(), .as_value),
1867 .in_bounds_hint = if (table_includes_else) .none else switch (switch_br.getElseHint()) {1867 .in_bounds_hint = if (table_includes_else) .none else switch (switch_br.getElseHint()) {
1868 .none, .cold => .none,1868 .none, .cold => .none,
1869 .unpredictable => .unpredictable,1869 .unpredictable => .unpredictable,
...@@ -2021,9 +2021,9 @@ fn airArrayToSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder...@@ -2021,9 +2021,9 @@ fn airArrayToSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder
2021 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;2021 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;
2022 const operand_ty = self.typeOf(ty_op.operand);2022 const operand_ty = self.typeOf(ty_op.operand);
2023 const array_ty = operand_ty.childType(zcu);2023 const array_ty = operand_ty.childType(zcu);
2024 const llvm_usize = try o.lowerType(.usize, .by_value);2024 const llvm_usize = try o.lowerType(.usize, .as_value);
2025 const len = try o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu));2025 const len = try o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu));
2026 const slice_llvm_ty = try o.lowerType(self.typeOfIndex(inst), .by_value);2026 const slice_llvm_ty = try o.lowerType(self.typeOfIndex(inst), .as_value);
2027 const operand = try self.resolveInst(ty_op.operand);2027 const operand = try self.resolveInst(ty_op.operand);
2028 return self.wip.buildAggregate(slice_llvm_ty, &.{ operand, len }, "");2028 return self.wip.buildAggregate(slice_llvm_ty, &.{ operand, len }, "");
2029}2029}
...@@ -2040,7 +2040,7 @@ fn airFloatFromInt(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value...@@ -2040,7 +2040,7 @@ fn airFloatFromInt(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value
20402040
2041 const dest_ty = self.typeOfIndex(inst);2041 const dest_ty = self.typeOfIndex(inst);
2042 const dest_scalar_ty = dest_ty.scalarType(zcu);2042 const dest_scalar_ty = dest_ty.scalarType(zcu);
2043 const dest_llvm_ty = try o.lowerType(dest_ty, .by_value);2043 const dest_llvm_ty = try o.lowerType(dest_ty, .as_value);
2044 const target = zcu.getTarget();2044 const target = zcu.getTarget();
20452045
2046 if (intrinsicsAllowed(dest_scalar_ty, target)) return self.wip.conv(2046 if (intrinsicsAllowed(dest_scalar_ty, target)) return self.wip.conv(
...@@ -2108,7 +2108,7 @@ fn airIntFromFloat(...@@ -2108,7 +2108,7 @@ fn airIntFromFloat(
21082108
2109 const dest_ty = self.typeOfIndex(inst);2109 const dest_ty = self.typeOfIndex(inst);
2110 const dest_scalar_ty = dest_ty.scalarType(zcu);2110 const dest_scalar_ty = dest_ty.scalarType(zcu);
2111 const dest_llvm_ty = try o.lowerType(dest_ty, .by_value);2111 const dest_llvm_ty = try o.lowerType(dest_ty, .as_value);
21122112
2113 if (intrinsicsAllowed(operand_scalar_ty, target)) {2113 if (intrinsicsAllowed(operand_scalar_ty, target)) {
2114 // TODO set fast math flag2114 // TODO set fast math flag
...@@ -2142,7 +2142,7 @@ fn airIntFromFloat(...@@ -2142,7 +2142,7 @@ fn airIntFromFloat(
2142 compiler_rt_dest_abbrev,2142 compiler_rt_dest_abbrev,
2143 });2143 });
21442144
2145 const operand_llvm_ty = try o.lowerType(operand_ty, .by_value);2145 const operand_llvm_ty = try o.lowerType(operand_ty, .as_value);
2146 const libc_fn = try o.getLibcFunction(fn_name, &.{operand_llvm_ty}, libc_ret_ty);2146 const libc_fn = try o.getLibcFunction(fn_name, &.{operand_llvm_ty}, libc_ret_ty);
2147 var result = try self.wip.call(2147 var result = try self.wip.call(
2148 .normal,2148 .normal,
...@@ -2167,7 +2167,7 @@ fn sliceOrArrayPtr(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!B...@@ -2167,7 +2167,7 @@ fn sliceOrArrayPtr(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!B
2167fn sliceOrArrayLenInBytes(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!Builder.Value {2167fn sliceOrArrayLenInBytes(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!Builder.Value {
2168 const o = fg.object;2168 const o = fg.object;
2169 const zcu = o.zcu;2169 const zcu = o.zcu;
2170 const llvm_usize = try o.lowerType(.usize, .by_value);2170 const llvm_usize = try o.lowerType(.usize, .as_value);
2171 switch (ty.ptrSize(zcu)) {2171 switch (ty.ptrSize(zcu)) {
2172 .slice => {2172 .slice => {
2173 const len = try fg.wip.extractValue(ptr, &.{1}, "");2173 const len = try fg.wip.extractValue(ptr, &.{1}, "");
...@@ -2365,7 +2365,7 @@ fn airAggFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder....@@ -2365,7 +2365,7 @@ fn airAggFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.
2365 },2365 },
2366 .float => {2366 .float => {
2367 // bitcast int->float2367 // bitcast int->float
2368 return self.wip.cast(.bitcast, field_int_val, try o.lowerType(field_ty, .by_value), "");2368 return self.wip.cast(.bitcast, field_int_val, try o.lowerType(field_ty, .as_value), "");
2369 },2369 },
2370 }2370 }
2371 }2371 }
...@@ -2395,8 +2395,8 @@ fn airFieldParentPtr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build...@@ -2395,8 +2395,8 @@ fn airFieldParentPtr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build
2395 const field_offset = parent_ty.structFieldOffset(extra.field_index, zcu);2395 const field_offset = parent_ty.structFieldOffset(extra.field_index, zcu);
2396 if (field_offset == 0) return field_ptr;2396 if (field_offset == 0) return field_ptr;
23972397
2398 const res_ty = try o.lowerType(ty_pl.ty.toType(), .by_value);2398 const res_ty = try o.lowerType(ty_pl.ty.toType(), .as_value);
2399 const llvm_usize = try o.lowerType(.usize, .by_value);2399 const llvm_usize = try o.lowerType(.usize, .as_value);
24002400
2401 const field_ptr_int = try self.wip.cast(.ptrtoint, field_ptr, llvm_usize, "");2401 const field_ptr_int = try self.wip.cast(.ptrtoint, field_ptr, llvm_usize, "");
2402 const base_ptr_int = try self.wip.bin(2402 const base_ptr_int = try self.wip.bin(
...@@ -2612,7 +2612,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {...@@ -2612,7 +2612,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {
2612 const output_inst = try self.resolveInst(output.operand);2612 const output_inst = try self.resolveInst(output.operand);
2613 const output_ty = self.typeOf(output.operand);2613 const output_ty = self.typeOf(output.operand);
2614 assert(output_ty.zigTypeTag(zcu) == .pointer);2614 assert(output_ty.zigTypeTag(zcu) == .pointer);
2615 const elem_llvm_ty = try o.lowerType(output_ty.childType(zcu), .by_value);2615 const elem_llvm_ty = try o.lowerType(output_ty.childType(zcu), .as_value);
26162616
2617 switch (constraint[0]) {2617 switch (constraint[0]) {
2618 '=' => {},2618 '=' => {},
...@@ -2650,7 +2650,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {...@@ -2650,7 +2650,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {
2650 llvm_ret_indirect[output.index] = false;2650 llvm_ret_indirect[output.index] = false;
26512651
2652 const ret_ty = self.typeOfIndex(inst);2652 const ret_ty = self.typeOfIndex(inst);
2653 llvm_ret_types[llvm_ret_i] = try o.lowerType(ret_ty, .by_value);2653 llvm_ret_types[llvm_ret_i] = try o.lowerType(ret_ty, .as_value);
2654 llvm_ret_i += 1;2654 llvm_ret_i += 1;
2655 }2655 }
26562656
...@@ -2689,7 +2689,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {...@@ -2689,7 +2689,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {
2689 llvm_param_types[llvm_param_i] = arg_llvm_value.typeOfWip(&self.wip);2689 llvm_param_types[llvm_param_i] = arg_llvm_value.typeOfWip(&self.wip);
2690 } else {2690 } else {
2691 const alignment = arg_ty.abiAlignment(zcu).toLlvm();2691 const alignment = arg_ty.abiAlignment(zcu).toLlvm();
2692 const arg_llvm_ty = try o.lowerType(arg_ty, .by_value);2692 const arg_llvm_ty = try o.lowerType(arg_ty, .as_value);
2693 const load_inst = try self.wip.load(.normal, arg_llvm_ty, arg_llvm_value, alignment, "");2693 const load_inst = try self.wip.load(.normal, arg_llvm_ty, arg_llvm_value, alignment, "");
2694 llvm_param_values[llvm_param_i] = load_inst;2694 llvm_param_values[llvm_param_i] = load_inst;
2695 llvm_param_types[llvm_param_i] = arg_llvm_ty;2695 llvm_param_types[llvm_param_i] = arg_llvm_ty;
...@@ -2729,7 +2729,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {...@@ -2729,7 +2729,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {
2729 llvm_param_attrs[llvm_param_i] = if (constraint[0] == '*') blk: {2729 llvm_param_attrs[llvm_param_i] = if (constraint[0] == '*') blk: {
2730 if (!is_by_ref) self.maybeMarkAllowZeroAccess(arg_ty.ptrInfo(zcu));2730 if (!is_by_ref) self.maybeMarkAllowZeroAccess(arg_ty.ptrInfo(zcu));
27312731
2732 break :blk try o.lowerType(if (is_by_ref) arg_ty else arg_ty.childType(zcu), .by_value);2732 break :blk try o.lowerType(if (is_by_ref) arg_ty else arg_ty.childType(zcu), .as_value);
2733 } else .none;2733 } else .none;
27342734
2735 llvm_param_i += 1;2735 llvm_param_i += 1;
...@@ -2743,7 +2743,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {...@@ -2743,7 +2743,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value {
2743 if (constraint[0] != '+') continue;2743 if (constraint[0] != '+') continue;
27442744
2745 const rw_ty = self.typeOf(output.operand);2745 const rw_ty = self.typeOf(output.operand);
2746 const llvm_elem_ty = try o.lowerType(rw_ty.childType(zcu), .by_value);2746 const llvm_elem_ty = try o.lowerType(rw_ty.childType(zcu), .as_value);
2747 if (llvm_ret_indirect[output.index]) {2747 if (llvm_ret_indirect[output.index]) {
2748 llvm_param_values[llvm_param_i] = llvm_rw_vals[output.index];2748 llvm_param_values[llvm_param_i] = llvm_rw_vals[output.index];
2749 llvm_param_types[llvm_param_i] = llvm_rw_vals[output.index].typeOfWip(&self.wip);2749 llvm_param_types[llvm_param_i] = llvm_rw_vals[output.index].typeOfWip(&self.wip);
...@@ -2957,7 +2957,7 @@ fn airIsNonNull(...@@ -2957,7 +2957,7 @@ fn airIsNonNull(
2957 ));2957 ));
2958 return self.wip.icmp(cond, slice_ptr, try o.builder.nullValue(ptr_ty), "");2958 return self.wip.icmp(cond, slice_ptr, try o.builder.nullValue(ptr_ty), "");
2959 }2959 }
2960 return self.wip.icmp(cond, loaded, try o.builder.zeroInitValue(try o.lowerType(optional_ty, .by_value)), "");2960 return self.wip.icmp(cond, loaded, try o.builder.zeroInitValue(try o.lowerType(optional_ty, .as_value)), "");
2961 }2961 }
29622962
2963 comptime assert(optional_layout_version == 3);2963 comptime assert(optional_layout_version == 3);
...@@ -2986,7 +2986,7 @@ fn airIsErr(...@@ -2986,7 +2986,7 @@ fn airIsErr(
2986 const operand_ty = self.typeOf(un_op);2986 const operand_ty = self.typeOf(un_op);
2987 const err_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty;2987 const err_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty;
2988 const payload_ty = err_union_ty.errorUnionPayload(zcu);2988 const payload_ty = err_union_ty.errorUnionPayload(zcu);
2989 const zero_err = try o.builder.intValue(try o.errorIntType(.by_value), 0);2989 const zero_err = try o.builder.intValue(try o.errorIntType(.as_value), 0);
29902990
2991 const access_kind: Builder.MemoryAccessKind =2991 const access_kind: Builder.MemoryAccessKind =
2992 if (operand_is_ptr and operand_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;2992 if (operand_is_ptr and operand_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;
...@@ -3156,7 +3156,7 @@ fn airErrUnionPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) Allocator.Erro...@@ -3156,7 +3156,7 @@ fn airErrUnionPayloadPtrSet(self: *FuncGen, inst: Air.Inst.Index) Allocator.Erro
3156 const err_union_ptr_align = err_union_ptr_ty.ptrAlignment(zcu);3156 const err_union_ptr_align = err_union_ptr_ty.ptrAlignment(zcu);
31573157
3158 const payload_ty = err_union_ty.errorUnionPayload(zcu);3158 const payload_ty = err_union_ty.errorUnionPayload(zcu);
3159 const non_error_val = try o.builder.intValue(try o.errorIntType(.by_value), 0);3159 const non_error_val = try o.builder.intValue(try o.errorIntType(.as_value), 0);
31603160
3161 const access_kind: Builder.MemoryAccessKind =3161 const access_kind: Builder.MemoryAccessKind =
3162 if (err_union_ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;3162 if (err_union_ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;
...@@ -3234,7 +3234,7 @@ fn airWrapErrUnionPayload(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!...@@ -3234,7 +3234,7 @@ fn airWrapErrUnionPayload(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!
3234 const payload_ty = self.typeOf(ty_op.operand);3234 const payload_ty = self.typeOf(ty_op.operand);
3235 assert(payload_ty.hasRuntimeBits(zcu));3235 assert(payload_ty.hasRuntimeBits(zcu));
3236 assert(isByRef(err_un_ty, zcu)); // error unions with runtime bits are always by-ref3236 assert(isByRef(err_un_ty, zcu)); // error unions with runtime bits are always by-ref
3237 const ok_err_code = try o.builder.intValue(try o.errorIntType(.by_value), 0);3237 const ok_err_code = try o.builder.intValue(try o.errorIntType(.as_value), 0);
32383238
3239 const result_ptr = try self.buildZigAlloca(err_un_ty, .none);3239 const result_ptr = try self.buildZigAlloca(err_un_ty, .none);
32403240
...@@ -3273,7 +3273,7 @@ fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build...@@ -3273,7 +3273,7 @@ fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build
3273 const o = self.object;3273 const o = self.object;
3274 const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op;3274 const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op;
3275 const index = pl_op.payload;3275 const index = pl_op.payload;
3276 const llvm_usize = try o.lowerType(.usize, .by_value);3276 const llvm_usize = try o.lowerType(.usize, .as_value);
3277 return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{llvm_usize}, &.{3277 return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{llvm_usize}, &.{
3278 try o.builder.intValue(.i32, index),3278 try o.builder.intValue(.i32, index),
3279 }, "");3279 }, "");
...@@ -3283,7 +3283,7 @@ fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build...@@ -3283,7 +3283,7 @@ fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build
3283 const o = self.object;3283 const o = self.object;
3284 const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op;3284 const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op;
3285 const index = pl_op.payload;3285 const index = pl_op.payload;
3286 const llvm_isize = try o.lowerType(.isize, .by_value);3286 const llvm_isize = try o.lowerType(.isize, .as_value);
3287 return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{llvm_isize}, &.{3287 return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{llvm_isize}, &.{
3288 try o.builder.intValue(.i32, index), try self.resolveInst(pl_op.operand),3288 try o.builder.intValue(.i32, index), try self.resolveInst(pl_op.operand),
3289 }, "");3289 }, "");
...@@ -3310,7 +3310,7 @@ fn airMin(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {...@@ -3310,7 +3310,7 @@ fn airMin(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
3310 .normal,3310 .normal,
3311 .none,3311 .none,
3312 if (scalar_ty.isSignedInt(zcu)) .smin else .umin,3312 if (scalar_ty.isSignedInt(zcu)) .smin else .umin,
3313 &.{try o.lowerType(inst_ty, .by_value)},3313 &.{try o.lowerType(inst_ty, .as_value)},
3314 &.{ lhs, rhs },3314 &.{ lhs, rhs },
3315 "",3315 "",
3316 );3316 );
...@@ -3330,7 +3330,7 @@ fn airMax(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {...@@ -3330,7 +3330,7 @@ fn airMax(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
3330 .normal,3330 .normal,
3331 .none,3331 .none,
3332 if (scalar_ty.isSignedInt(zcu)) .smax else .umax,3332 if (scalar_ty.isSignedInt(zcu)) .smax else .umax,
3333 &.{try o.lowerType(inst_ty, .by_value)},3333 &.{try o.lowerType(inst_ty, .as_value)},
3334 &.{ lhs, rhs },3334 &.{ lhs, rhs },
3335 "",3335 "",
3336 );3336 );
...@@ -3342,7 +3342,7 @@ fn airSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -3342,7 +3342,7 @@ fn airSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
3342 const ptr = try self.resolveInst(bin_op.lhs);3342 const ptr = try self.resolveInst(bin_op.lhs);
3343 const len = try self.resolveInst(bin_op.rhs);3343 const len = try self.resolveInst(bin_op.rhs);
3344 const inst_ty = self.typeOfIndex(inst);3344 const inst_ty = self.typeOfIndex(inst);
3345 return self.wip.buildAggregate(try self.object.lowerType(inst_ty, .by_value), &.{ ptr, len }, "");3345 return self.wip.buildAggregate(try self.object.lowerType(inst_ty, .as_value), &.{ ptr, len }, "");
3346}3346}
33473347
3348fn airAdd(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allocator.Error!Builder.Value {3348fn airAdd(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allocator.Error!Builder.Value {
...@@ -3373,7 +3373,7 @@ fn airSafeArithmetic(...@@ -3373,7 +3373,7 @@ fn airSafeArithmetic(
3373 const scalar_ty = inst_ty.scalarType(zcu);3373 const scalar_ty = inst_ty.scalarType(zcu);
33743374
3375 const intrinsic = if (scalar_ty.isSignedInt(zcu)) signed_intrinsic else unsigned_intrinsic;3375 const intrinsic = if (scalar_ty.isSignedInt(zcu)) signed_intrinsic else unsigned_intrinsic;
3376 const llvm_inst_ty = try o.lowerType(inst_ty, .by_value);3376 const llvm_inst_ty = try o.lowerType(inst_ty, .as_value);
3377 const results =3377 const results =
3378 try fg.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, "");3378 try fg.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, "");
33793379
...@@ -3423,7 +3423,7 @@ fn airAddSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -3423,7 +3423,7 @@ fn airAddSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
3423 .normal,3423 .normal,
3424 .none,3424 .none,
3425 if (scalar_ty.isSignedInt(zcu)) .@"sadd.sat" else .@"uadd.sat",3425 if (scalar_ty.isSignedInt(zcu)) .@"sadd.sat" else .@"uadd.sat",
3426 &.{try o.lowerType(inst_ty, .by_value)},3426 &.{try o.lowerType(inst_ty, .as_value)},
3427 &.{ lhs, rhs },3427 &.{ lhs, rhs },
3428 "",3428 "",
3429 );3429 );
...@@ -3462,7 +3462,7 @@ fn airSubSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -3462,7 +3462,7 @@ fn airSubSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
3462 .normal,3462 .normal,
3463 .none,3463 .none,
3464 if (scalar_ty.isSignedInt(zcu)) .@"ssub.sat" else .@"usub.sat",3464 if (scalar_ty.isSignedInt(zcu)) .@"ssub.sat" else .@"usub.sat",
3465 &.{try o.lowerType(inst_ty, .by_value)},3465 &.{try o.lowerType(inst_ty, .as_value)},
3466 &.{ lhs, rhs },3466 &.{ lhs, rhs },
3467 "",3467 "",
3468 );3468 );
...@@ -3501,7 +3501,7 @@ fn airMulSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -3501,7 +3501,7 @@ fn airMulSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
3501 .normal,3501 .normal,
3502 .none,3502 .none,
3503 if (scalar_ty.isSignedInt(zcu)) .@"smul.fix.sat" else .@"umul.fix.sat",3503 if (scalar_ty.isSignedInt(zcu)) .@"smul.fix.sat" else .@"umul.fix.sat",
3504 &.{try o.lowerType(inst_ty, .by_value)},3504 &.{try o.lowerType(inst_ty, .as_value)},
3505 &.{ lhs, rhs, .@"0" },3505 &.{ lhs, rhs, .@"0" },
3506 "",3506 "",
3507 );3507 );
...@@ -3545,8 +3545,8 @@ fn airDivFloor(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)...@@ -3545,8 +3545,8 @@ fn airDivFloor(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)
3545 return self.buildFloatOp(.floor, fast, inst_ty, 1, .{result});3545 return self.buildFloatOp(.floor, fast, inst_ty, 1, .{result});
3546 }3546 }
3547 if (scalar_ty.isSignedInt(zcu)) {3547 if (scalar_ty.isSignedInt(zcu)) {
3548 const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value);3548 const scalar_llvm_ty = try o.lowerType(scalar_ty, .as_value);
3549 const inst_llvm_ty = try o.lowerType(inst_ty, .by_value);3549 const inst_llvm_ty = try o.lowerType(inst_ty, .as_value);
35503550
3551 const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb;3551 const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb;
3552 var bfa_buf: ExpectedContents = undefined;3552 var bfa_buf: ExpectedContents = undefined;
...@@ -3594,8 +3594,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)...@@ -3594,8 +3594,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)
3594 return self.buildFloatOp(.ceil, fast, inst_ty, 1, .{result});3594 return self.buildFloatOp(.ceil, fast, inst_ty, 1, .{result});
3595 }3595 }
3596 if (scalar_ty.isSignedInt(zcu)) {3596 if (scalar_ty.isSignedInt(zcu)) {
3597 const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value);3597 const scalar_llvm_ty = try o.lowerType(scalar_ty, .as_value);
3598 const inst_llvm_ty = try o.lowerType(inst_ty, .by_value);3598 const inst_llvm_ty = try o.lowerType(inst_ty, .as_value);
35993599
3600 const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb;3600 const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb;
3601 var bfa_buf: ExpectedContents = undefined;3601 var bfa_buf: ExpectedContents = undefined;
...@@ -3634,8 +3634,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)...@@ -3634,8 +3634,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind)
3634 const correction = try self.wip.cast(.zext, need_correction, inst_llvm_ty, "divCeil.correction");3634 const correction = try self.wip.cast(.zext, need_correction, inst_llvm_ty, "divCeil.correction");
3635 return self.wip.bin(.@"add nsw", div, correction, "divCeil");3635 return self.wip.bin(.@"add nsw", div, correction, "divCeil");
3636 } else {3636 } else {
3637 const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value);3637 const scalar_llvm_ty = try o.lowerType(scalar_ty, .as_value);
3638 const inst_llvm_ty = try o.lowerType(inst_ty, .by_value);3638 const inst_llvm_ty = try o.lowerType(inst_ty, .as_value);
36393639
3640 const zero = try o.builder.splatValue(3640 const zero = try o.builder.splatValue(
3641 inst_llvm_ty,3641 inst_llvm_ty,
...@@ -3692,7 +3692,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo...@@ -3692,7 +3692,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo
3692 const lhs = try self.resolveInst(bin_op.lhs);3692 const lhs = try self.resolveInst(bin_op.lhs);
3693 const rhs = try self.resolveInst(bin_op.rhs);3693 const rhs = try self.resolveInst(bin_op.rhs);
3694 const inst_ty = self.typeOfIndex(inst);3694 const inst_ty = self.typeOfIndex(inst);
3695 const inst_llvm_ty = try o.lowerType(inst_ty, .by_value);3695 const inst_llvm_ty = try o.lowerType(inst_ty, .as_value);
3696 const scalar_ty = inst_ty.scalarType(zcu);3696 const scalar_ty = inst_ty.scalarType(zcu);
36973697
3698 if (scalar_ty.isRuntimeFloat()) {3698 if (scalar_ty.isRuntimeFloat()) {
...@@ -3721,7 +3721,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo...@@ -3721,7 +3721,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo
3721 defer allocator.free(smin_big_int.limbs);3721 defer allocator.free(smin_big_int.limbs);
3722 smin_big_int.setTwosCompIntLimit(.min, .signed, scalar_bits);3722 smin_big_int.setTwosCompIntLimit(.min, .signed, scalar_bits);
3723 const smin = try o.builder.splatValue(inst_llvm_ty, try o.builder.bigIntConst(3723 const smin = try o.builder.splatValue(inst_llvm_ty, try o.builder.bigIntConst(
3724 try o.lowerType(scalar_ty, .by_value),3724 try o.lowerType(scalar_ty, .as_value),
3725 smin_big_int.toConst(),3725 smin_big_int.toConst(),
3726 ));3726 ));
37273727
...@@ -3757,7 +3757,7 @@ fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -3757,7 +3757,7 @@ fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
3757 const ty_pl = self.air.instructions.items(.data)[@backingInt(inst)].ty_pl;3757 const ty_pl = self.air.instructions.items(.data)[@backingInt(inst)].ty_pl;
3758 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3758 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
3759 const ptr_or_slice = try self.resolveInst(bin_op.lhs);3759 const ptr_or_slice = try self.resolveInst(bin_op.lhs);
3760 const llvm_usize_ty = try o.lowerType(.usize, .by_value);3760 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
3761 const ptr_ty = self.typeOf(bin_op.lhs);3761 const ptr_ty = self.typeOf(bin_op.lhs);
3762 const elem_ty = ptr_ty.indexableElem(zcu);3762 const elem_ty = ptr_ty.indexableElem(zcu);
3763 const ptr = switch (ptr_ty.ptrSize(zcu)) {3763 const ptr = switch (ptr_ty.ptrSize(zcu)) {
...@@ -3790,7 +3790,7 @@ fn airOverflow(...@@ -3790,7 +3790,7 @@ fn airOverflow(
3790 assert(isByRef(inst_ty, zcu)); // auto structs are by-ref3790 assert(isByRef(inst_ty, zcu)); // auto structs are by-ref
37913791
3792 const intrinsic = if (scalar_ty.isSignedInt(zcu)) signed_intrinsic else unsigned_intrinsic;3792 const intrinsic = if (scalar_ty.isSignedInt(zcu)) signed_intrinsic else unsigned_intrinsic;
3793 const llvm_lhs_ty = try o.lowerType(lhs_ty, .by_value);3793 const llvm_lhs_ty = try o.lowerType(lhs_ty, .as_value);
3794 const results =3794 const results =
3795 try self.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_lhs_ty}, &.{ lhs, rhs }, "");3795 try self.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_lhs_ty}, &.{ lhs, rhs }, "");
37963796
...@@ -3863,7 +3863,7 @@ fn buildFloatCmp(...@@ -3863,7 +3863,7 @@ fn buildFloatCmp(
3863 const zcu = o.zcu;3863 const zcu = o.zcu;
3864 const target = zcu.getTarget();3864 const target = zcu.getTarget();
3865 const scalar_ty = ty.scalarType(zcu);3865 const scalar_ty = ty.scalarType(zcu);
3866 const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value);3866 const scalar_llvm_ty = try o.lowerType(scalar_ty, .as_value);
38673867
3868 if (intrinsicsAllowed(scalar_ty, target)) {3868 if (intrinsicsAllowed(scalar_ty, target)) {
3869 const cond: Builder.FloatCondition = switch (pred) {3869 const cond: Builder.FloatCondition = switch (pred) {
...@@ -3969,7 +3969,7 @@ fn buildFloatOp(...@@ -3969,7 +3969,7 @@ fn buildFloatOp(
3969 const zcu = o.zcu;3969 const zcu = o.zcu;
3970 const target = zcu.getTarget();3970 const target = zcu.getTarget();
3971 const scalar_ty = ty.scalarType(zcu);3971 const scalar_ty = ty.scalarType(zcu);
3972 const llvm_ty = try o.lowerType(ty, .by_value);3972 const llvm_ty = try o.lowerType(ty, .as_value);
39733973
3974 if (op != .tan and intrinsicsAllowed(scalar_ty, target)) switch (op) {3974 if (op != .tan and intrinsicsAllowed(scalar_ty, target)) switch (op) {
3975 // Some operations are dedicated LLVM instructions, not available as intrinsics3975 // Some operations are dedicated LLVM instructions, not available as intrinsics
...@@ -4074,7 +4074,7 @@ fn buildFloatOp(...@@ -4074,7 +4074,7 @@ fn buildFloatOp(
4074 }),4074 }),
4075 };4075 };
40764076
4077 const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value);4077 const scalar_llvm_ty = try o.lowerType(scalar_ty, .as_value);
4078 const libc_fn = try o.getLibcFunction(4078 const libc_fn = try o.getLibcFunction(
4079 fn_name,4079 fn_name,
4080 @as([3]Builder.Type, @splat(scalar_llvm_ty))[0..params.len],4080 @as([3]Builder.Type, @splat(scalar_llvm_ty))[0..params.len],
...@@ -4129,7 +4129,7 @@ fn airShlWithOverflow(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Buil...@@ -4129,7 +4129,7 @@ fn airShlWithOverflow(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Buil
4129 const dest_ty = self.typeOfIndex(inst);4129 const dest_ty = self.typeOfIndex(inst);
4130 assert(isByRef(dest_ty, zcu)); // auto structs are by-ref4130 assert(isByRef(dest_ty, zcu)); // auto structs are by-ref
41314131
4132 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .by_value), "");4132 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .as_value), "");
41334133
4134 const result = try self.wip.bin(.shl, lhs, casted_rhs, "");4134 const result = try self.wip.bin(.shl, lhs, casted_rhs, "");
4135 const reconstructed = try self.wip.bin(if (lhs_scalar_ty.isSignedInt(zcu))4135 const reconstructed = try self.wip.bin(if (lhs_scalar_ty.isSignedInt(zcu))
...@@ -4196,7 +4196,7 @@ fn airShlExact(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -4196,7 +4196,7 @@ fn airShlExact(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
4196 }4196 }
4197 const lhs_scalar_ty = lhs_ty.scalarType(zcu);4197 const lhs_scalar_ty = lhs_ty.scalarType(zcu);
41984198
4199 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .by_value), "");4199 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .as_value), "");
4200 return self.wip.bin(if (lhs_scalar_ty.isSignedInt(zcu))4200 return self.wip.bin(if (lhs_scalar_ty.isSignedInt(zcu))
4201 .@"shl nsw"4201 .@"shl nsw"
4202 else4202 else
...@@ -4217,7 +4217,7 @@ fn airShl(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {...@@ -4217,7 +4217,7 @@ fn airShl(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
4217 // features which we do not use. Therefore this branch is currently impossible.4217 // features which we do not use. Therefore this branch is currently impossible.
4218 unreachable;4218 unreachable;
4219 }4219 }
4220 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .by_value), "");4220 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .as_value), "");
4221 return self.wip.bin(.shl, lhs, casted_rhs, "");4221 return self.wip.bin(.shl, lhs, casted_rhs, "");
4222}4222}
42234223
...@@ -4231,8 +4231,8 @@ fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -4231,8 +4231,8 @@ fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
42314231
4232 const lhs_ty = self.typeOf(bin_op.lhs);4232 const lhs_ty = self.typeOf(bin_op.lhs);
4233 const lhs_info = lhs_ty.intInfo(zcu);4233 const lhs_info = lhs_ty.intInfo(zcu);
4234 const llvm_lhs_ty = try o.lowerType(lhs_ty, .by_value);4234 const llvm_lhs_ty = try o.lowerType(lhs_ty, .as_value);
4235 const llvm_lhs_scalar_ty = try o.lowerType(lhs_ty.scalarType(zcu), .by_value);4235 const llvm_lhs_scalar_ty = try o.lowerType(lhs_ty.scalarType(zcu), .as_value);
42364236
4237 const rhs_ty = self.typeOf(bin_op.rhs);4237 const rhs_ty = self.typeOf(bin_op.rhs);
4238 if (lhs_ty.isVector(zcu) and !rhs_ty.isVector(zcu)) {4238 if (lhs_ty.isVector(zcu) and !rhs_ty.isVector(zcu)) {
...@@ -4242,8 +4242,8 @@ fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -4242,8 +4242,8 @@ fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
4242 }4242 }
4243 const rhs_info = rhs_ty.intInfo(zcu);4243 const rhs_info = rhs_ty.intInfo(zcu);
4244 assert(rhs_info.signedness == .unsigned);4244 assert(rhs_info.signedness == .unsigned);
4245 const llvm_rhs_ty = try o.lowerType(rhs_ty, .by_value);4245 const llvm_rhs_ty = try o.lowerType(rhs_ty, .as_value);
4246 const llvm_rhs_scalar_ty = try o.lowerType(rhs_ty.scalarType(zcu), .by_value);4246 const llvm_rhs_scalar_ty = try o.lowerType(rhs_ty.scalarType(zcu), .as_value);
42474247
4248 const result = try self.wip.callIntrinsic(4248 const result = try self.wip.callIntrinsic(
4249 .normal,4249 .normal,
...@@ -4319,7 +4319,7 @@ fn airShr(self: *FuncGen, inst: Air.Inst.Index, is_exact: bool) Allocator.Error!...@@ -4319,7 +4319,7 @@ fn airShr(self: *FuncGen, inst: Air.Inst.Index, is_exact: bool) Allocator.Error!
4319 }4319 }
4320 const lhs_scalar_ty = lhs_ty.scalarType(zcu);4320 const lhs_scalar_ty = lhs_ty.scalarType(zcu);
43214321
4322 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .by_value), "");4322 const casted_rhs = try self.wip.conv(.unsigned, rhs, try o.lowerType(lhs_ty, .as_value), "");
4323 const is_signed_int = lhs_scalar_ty.isSignedInt(zcu);4323 const is_signed_int = lhs_scalar_ty.isSignedInt(zcu);
43244324
4325 return self.wip.bin(if (is_exact)4325 return self.wip.bin(if (is_exact)
...@@ -4340,7 +4340,7 @@ fn airAbs(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {...@@ -4340,7 +4340,7 @@ fn airAbs(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
4340 .normal,4340 .normal,
4341 .none,4341 .none,
4342 .abs,4342 .abs,
4343 &.{try o.lowerType(operand_ty, .by_value)},4343 &.{try o.lowerType(operand_ty, .as_value)},
4344 &.{ operand, .false },4344 &.{ operand, .false },
4345 "",4345 "",
4346 ),4346 ),
...@@ -4354,7 +4354,7 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!...@@ -4354,7 +4354,7 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!
4354 const zcu = o.zcu;4354 const zcu = o.zcu;
4355 const ty_op = fg.air.instructions.items(.data)[@backingInt(inst)].ty_op;4355 const ty_op = fg.air.instructions.items(.data)[@backingInt(inst)].ty_op;
4356 const dest_ty = fg.typeOfIndex(inst);4356 const dest_ty = fg.typeOfIndex(inst);
4357 const dest_llvm_ty = try o.lowerType(dest_ty, .by_value);4357 const dest_llvm_ty = try o.lowerType(dest_ty, .as_value);
4358 const operand = try fg.resolveInst(ty_op.operand);4358 const operand = try fg.resolveInst(ty_op.operand);
4359 const operand_ty = fg.typeOf(ty_op.operand);4359 const operand_ty = fg.typeOf(ty_op.operand);
4360 const operand_info = operand_ty.intInfo(zcu);4360 const operand_info = operand_ty.intInfo(zcu);
...@@ -4382,8 +4382,8 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!...@@ -4382,8 +4382,8 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!
43824382
4383 if (!have_min_check and !have_max_check) break :bounds_check;4383 if (!have_min_check and !have_max_check) break :bounds_check;
43844384
4385 const operand_llvm_ty = try o.lowerType(operand_ty, .by_value);4385 const operand_llvm_ty = try o.lowerType(operand_ty, .as_value);
4386 const operand_scalar_llvm_ty = try o.lowerType(operand_scalar, .by_value);4386 const operand_scalar_llvm_ty = try o.lowerType(operand_scalar, .as_value);
43874387
4388 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;4388 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
4389 assert(is_vector == (dest_ty.zigTypeTag(zcu) == .vector));4389 assert(is_vector == (dest_ty.zigTypeTag(zcu) == .vector));
...@@ -4461,7 +4461,7 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!...@@ -4461,7 +4461,7 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!
4461fn airTrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {4461fn airTrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
4462 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;4462 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;
4463 const operand = try self.resolveInst(ty_op.operand);4463 const operand = try self.resolveInst(ty_op.operand);
4464 const dest_llvm_ty = try self.object.lowerType(self.typeOfIndex(inst), .by_value);4464 const dest_llvm_ty = try self.object.lowerType(self.typeOfIndex(inst), .as_value);
4465 return self.wip.cast(.trunc, operand, dest_llvm_ty, "");4465 return self.wip.cast(.trunc, operand, dest_llvm_ty, "");
4466}4466}
44674467
...@@ -4475,10 +4475,10 @@ fn airFptrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu...@@ -4475,10 +4475,10 @@ fn airFptrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu
4475 const target = zcu.getTarget();4475 const target = zcu.getTarget();
44764476
4477 if (intrinsicsAllowed(dest_ty, target) and intrinsicsAllowed(operand_ty, target)) {4477 if (intrinsicsAllowed(dest_ty, target) and intrinsicsAllowed(operand_ty, target)) {
4478 return self.wip.cast(.fptrunc, operand, try o.lowerType(dest_ty, .by_value), "");4478 return self.wip.cast(.fptrunc, operand, try o.lowerType(dest_ty, .as_value), "");
4479 } else {4479 } else {
4480 const operand_llvm_ty = try o.lowerType(operand_ty, .by_value);4480 const operand_llvm_ty = try o.lowerType(operand_ty, .as_value);
4481 const dest_llvm_ty = try o.lowerType(dest_ty, .by_value);4481 const dest_llvm_ty = try o.lowerType(dest_ty, .as_value);
44824482
4483 const dest_bits = dest_ty.floatBits(target);4483 const dest_bits = dest_ty.floatBits(target);
4484 const src_bits = operand_ty.floatBits(target);4484 const src_bits = operand_ty.floatBits(target);
...@@ -4509,10 +4509,10 @@ fn airFpext(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -4509,10 +4509,10 @@ fn airFpext(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
4509 const target = zcu.getTarget();4509 const target = zcu.getTarget();
45104510
4511 if (intrinsicsAllowed(dest_ty, target) and intrinsicsAllowed(operand_ty, target)) {4511 if (intrinsicsAllowed(dest_ty, target) and intrinsicsAllowed(operand_ty, target)) {
4512 return self.wip.cast(.fpext, operand, try o.lowerType(dest_ty, .by_value), "");4512 return self.wip.cast(.fpext, operand, try o.lowerType(dest_ty, .as_value), "");
4513 } else {4513 } else {
4514 const operand_llvm_ty = try o.lowerType(operand_ty, .by_value);4514 const operand_llvm_ty = try o.lowerType(operand_ty, .as_value);
4515 const dest_llvm_ty = try o.lowerType(dest_ty, .by_value);4515 const dest_llvm_ty = try o.lowerType(dest_ty, .as_value);
45164516
4517 const dest_bits = dest_ty.scalarType(zcu).floatBits(target);4517 const dest_bits = dest_ty.scalarType(zcu).floatBits(target);
4518 const src_bits = operand_ty.scalarType(zcu).floatBits(target);4518 const src_bits = operand_ty.scalarType(zcu).floatBits(target);
...@@ -4563,7 +4563,7 @@ fn airBitCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!...@@ -4563,7 +4563,7 @@ fn airBitCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!
4563 assert(!isByRef(operand_ty, zcu));4563 assert(!isByRef(operand_ty, zcu));
4564 assert(!isByRef(dest_ty, zcu));4564 assert(!isByRef(dest_ty, zcu));
45654565
4566 const llvm_dest_ty = try o.lowerType(dest_ty, .by_value);4566 const llvm_dest_ty = try o.lowerType(dest_ty, .as_value);
4567 const result = try fg.wip.cast(.bitcast, operand, llvm_dest_ty, "");4567 const result = try fg.wip.cast(.bitcast, operand, llvm_dest_ty, "");
4568 if (safety and dest_ty.zigTypeTag(zcu) == .@"enum" and !dest_ty.isNonexhaustiveEnum(zcu)) {4568 if (safety and dest_ty.zigTypeTag(zcu) == .@"enum" and !dest_ty.isNonexhaustiveEnum(zcu)) {
4569 const llvm_fn = try o.getIsNamedEnumValueFunction(dest_ty);4569 const llvm_fn = try o.getIsNamedEnumValueFunction(dest_ty);
...@@ -4606,7 +4606,7 @@ fn airPtrFromInt(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -4606,7 +4606,7 @@ fn airPtrFromInt(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
4606 assert(dest_ty.scalarType(zcu).isPtrAtRuntime(zcu));4606 assert(dest_ty.scalarType(zcu).isPtrAtRuntime(zcu));
46074607
4608 const operand = try fg.resolveInst(ty_op.operand);4608 const operand = try fg.resolveInst(ty_op.operand);
4609 const llvm_dest_ty = try o.lowerType(dest_ty, .by_value);4609 const llvm_dest_ty = try o.lowerType(dest_ty, .as_value);
4610 return fg.wip.cast(.inttoptr, operand, llvm_dest_ty, "");4610 return fg.wip.cast(.inttoptr, operand, llvm_dest_ty, "");
4611}4611}
46124612
...@@ -4620,7 +4620,7 @@ fn airIntFromPtr(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -4620,7 +4620,7 @@ fn airIntFromPtr(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
4620 assert(dest_ty.scalarType(zcu).toIntern() == .usize_type);4620 assert(dest_ty.scalarType(zcu).toIntern() == .usize_type);
46214621
4622 const operand = try fg.resolveInst(ty_op.operand);4622 const operand = try fg.resolveInst(ty_op.operand);
4623 const llvm_dest_ty = try o.lowerType(dest_ty, .by_value);4623 const llvm_dest_ty = try o.lowerType(dest_ty, .as_value);
4624 return fg.wip.cast(.ptrtoint, operand, llvm_dest_ty, "");4624 return fg.wip.cast(.ptrtoint, operand, llvm_dest_ty, "");
4625}4625}
46264626
...@@ -4832,7 +4832,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu...@@ -4832,7 +4832,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu
4832 return .none;4832 return .none;
4833 }4833 }
48344834
4835 const len = try o.builder.intValue(try o.lowerType(.usize, .by_value), elem_ty.abiSize(zcu));4835 const len = try o.builder.intValue(try o.lowerType(.usize, .as_value), elem_ty.abiSize(zcu));
4836 _ = try fg.wip.callMemSet(4836 _ = try fg.wip.callMemSet(
4837 ptr,4837 ptr,
4838 ptr_alignment.toLlvm(),4838 ptr_alignment.toLlvm(),
...@@ -4867,7 +4867,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu...@@ -4867,7 +4867,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu
4867 if (ptr_info.packed_offset.host_size != 0) {4867 if (ptr_info.packed_offset.host_size != 0) {
4868 // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`.4868 // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`.
4869 const backing_int_ty = try fg.pt.intType(.unsigned, @intCast(ptr_info.packed_offset.host_size * 8));4869 const backing_int_ty = try fg.pt.intType(.unsigned, @intCast(ptr_info.packed_offset.host_size * 8));
4870 const llvm_backing_int_ty = try o.lowerType(backing_int_ty, .by_value);4870 const llvm_backing_int_ty = try o.lowerType(backing_int_ty, .as_value);
48714871
4872 const backing_int_val = try fg.load(ptr, ptr_alignment, backing_int_ty, access_kind);4872 const backing_int_val = try fg.load(ptr, ptr_alignment, backing_int_ty, access_kind);
48734873
...@@ -4945,14 +4945,14 @@ fn airLoad(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {...@@ -4945,14 +4945,14 @@ fn airLoad(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
49454945
4946 // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`.4946 // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`.
4947 const backing_int_ty = try fg.pt.intType(.unsigned, @intCast(ptr_info.packed_offset.host_size * 8));4947 const backing_int_ty = try fg.pt.intType(.unsigned, @intCast(ptr_info.packed_offset.host_size * 8));
4948 const llvm_backing_int_ty = try o.lowerType(backing_int_ty, .by_value);4948 const llvm_backing_int_ty = try o.lowerType(backing_int_ty, .as_value);
49494949
4950 const backing_int_val = try fg.load(ptr, ptr_align, backing_int_ty, .normal);4950 const backing_int_val = try fg.load(ptr, ptr_align, backing_int_ty, .normal);
49514951
4952 const elem_bits = ptr_ty.childType(zcu).bitSize(zcu);4952 const elem_bits = ptr_ty.childType(zcu).bitSize(zcu);
4953 const shift_amt = try o.builder.intValue(llvm_backing_int_ty, ptr_info.packed_offset.bit_offset);4953 const shift_amt = try o.builder.intValue(llvm_backing_int_ty, ptr_info.packed_offset.bit_offset);
4954 const shifted_value = try fg.wip.bin(.lshr, backing_int_val, shift_amt, "");4954 const shifted_value = try fg.wip.bin(.lshr, backing_int_val, shift_amt, "");
4955 const elem_llvm_ty = try o.lowerType(elem_ty, .by_value);4955 const elem_llvm_ty = try o.lowerType(elem_ty, .as_value);
49564956
4957 if (elem_ty.zigTypeTag(zcu) == .float or elem_ty.zigTypeTag(zcu) == .vector) {4957 if (elem_ty.zigTypeTag(zcu) == .float or elem_ty.zigTypeTag(zcu) == .vector) {
4958 const same_size_int = try o.builder.intType(@intCast(elem_bits));4958 const same_size_int = try o.builder.intType(@intCast(elem_bits));
...@@ -5002,7 +5002,7 @@ fn airBreakpoint(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.V...@@ -5002,7 +5002,7 @@ fn airBreakpoint(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.V
5002fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {5002fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
5003 _ = inst;5003 _ = inst;
5004 const o = self.object;5004 const o = self.object;
5005 const llvm_usize = try o.lowerType(.usize, .by_value);5005 const llvm_usize = try o.lowerType(.usize, .as_value);
5006 if (!target_util.supportsReturnAddress(self.object.zcu.getTarget(), self.ownerModule().optimize_mode)) {5006 if (!target_util.supportsReturnAddress(self.object.zcu.getTarget(), self.ownerModule().optimize_mode)) {
5007 // https://github.com/ziglang/zig/issues/119465007 // https://github.com/ziglang/zig/issues/11946
5008 return o.builder.intValue(llvm_usize, 0);5008 return o.builder.intValue(llvm_usize, 0);
...@@ -5014,7 +5014,7 @@ fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu...@@ -5014,7 +5014,7 @@ fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu
5014fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {5014fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
5015 _ = inst;5015 _ = inst;
5016 const result = try self.wip.callIntrinsic(.normal, .none, .frameaddress, &.{.ptr}, &.{.@"0"}, "");5016 const result = try self.wip.callIntrinsic(.normal, .none, .frameaddress, &.{.ptr}, &.{.@"0"}, "");
5017 return self.wip.cast(.ptrtoint, result, try self.object.lowerType(.usize, .by_value), "");5017 return self.wip.cast(.ptrtoint, result, try self.object.lowerType(.usize, .as_value), "");
5018}5018}
50195019
5020fn airCmpxchg(5020fn airCmpxchg(
...@@ -5031,7 +5031,7 @@ fn airCmpxchg(...@@ -5031,7 +5031,7 @@ fn airCmpxchg(
5031 var expected_value = try self.resolveInst(extra.expected_value);5031 var expected_value = try self.resolveInst(extra.expected_value);
5032 var new_value = try self.resolveInst(extra.new_value);5032 var new_value = try self.resolveInst(extra.new_value);
5033 const operand_ty = ptr_ty.childType(zcu);5033 const operand_ty = ptr_ty.childType(zcu);
5034 const llvm_operand_ty = try o.lowerType(operand_ty, .by_value);5034 const llvm_operand_ty = try o.lowerType(operand_ty, .as_value);
5035 const llvm_abi_ty = try self.getAtomicAbiType(operand_ty, false);5035 const llvm_abi_ty = try self.getAtomicAbiType(operand_ty, false);
5036 if (llvm_abi_ty != .none) {5036 if (llvm_abi_ty != .none) {
5037 // operand needs widening and truncating5037 // operand needs widening and truncating
...@@ -5101,7 +5101,7 @@ fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va...@@ -5101,7 +5101,7 @@ fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va
5101 const op = toLlvmAtomicRmwBinOp(extra.op(), is_signed_int, is_float);5101 const op = toLlvmAtomicRmwBinOp(extra.op(), is_signed_int, is_float);
5102 const ordering = toLlvmAtomicOrdering(extra.ordering());5102 const ordering = toLlvmAtomicOrdering(extra.ordering());
5103 const llvm_abi_ty = try self.getAtomicAbiType(operand_ty, op == .xchg);5103 const llvm_abi_ty = try self.getAtomicAbiType(operand_ty, op == .xchg);
5104 const llvm_operand_ty = try o.lowerType(operand_ty, .by_value);5104 const llvm_operand_ty = try o.lowerType(operand_ty, .as_value);
51055105
5106 const access_kind: Builder.MemoryAccessKind =5106 const access_kind: Builder.MemoryAccessKind =
5107 if (ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;5107 if (ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal;
...@@ -5130,7 +5130,7 @@ fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va...@@ -5130,7 +5130,7 @@ fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va
51305130
5131 // If we are storing a pointer we need to convert to and from a plain old integer.5131 // If we are storing a pointer we need to convert to and from a plain old integer.
5132 const non_ptr_operand = switch (operand_ty.zigTypeTag(zcu)) {5132 const non_ptr_operand = switch (operand_ty.zigTypeTag(zcu)) {
5133 .pointer => try self.wip.cast(.ptrtoint, operand, try o.lowerType(.usize, .by_value), ""),5133 .pointer => try self.wip.cast(.ptrtoint, operand, try o.lowerType(.usize, .as_value), ""),
5134 else => operand,5134 else => operand,
5135 };5135 };
51365136
...@@ -5169,7 +5169,7 @@ fn airAtomicLoad(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.V...@@ -5169,7 +5169,7 @@ fn airAtomicLoad(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.V
5169 Type.fromInterned(info.child).abiAlignment(zcu)).toLlvm();5169 Type.fromInterned(info.child).abiAlignment(zcu)).toLlvm();
5170 const access_kind: Builder.MemoryAccessKind =5170 const access_kind: Builder.MemoryAccessKind =
5171 if (info.flags.is_volatile) .@"volatile" else .normal;5171 if (info.flags.is_volatile) .@"volatile" else .normal;
5172 const elem_llvm_ty = try o.lowerType(elem_ty, .by_value);5172 const elem_llvm_ty = try o.lowerType(elem_ty, .as_value);
51735173
5174 self.maybeMarkAllowZeroAccess(info);5174 self.maybeMarkAllowZeroAccess(info);
51755175
...@@ -5503,11 +5503,11 @@ fn airClzCtz(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic)...@@ -5503,11 +5503,11 @@ fn airClzCtz(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic)
5503 .normal,5503 .normal,
5504 .none,5504 .none,
5505 intrinsic,5505 intrinsic,
5506 &.{try o.lowerType(operand_ty, .by_value)},5506 &.{try o.lowerType(operand_ty, .as_value)},
5507 &.{ operand, .false },5507 &.{ operand, .false },
5508 "",5508 "",
5509 );5509 );
5510 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .by_value), "");5510 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .as_value), "");
5511}5511}
55125512
5513fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic) Allocator.Error!Builder.Value {5513fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic) Allocator.Error!Builder.Value {
...@@ -5521,11 +5521,11 @@ fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic)...@@ -5521,11 +5521,11 @@ fn airBitOp(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic)
5521 .normal,5521 .normal,
5522 .none,5522 .none,
5523 intrinsic,5523 intrinsic,
5524 &.{try o.lowerType(operand_ty, .by_value)},5524 &.{try o.lowerType(operand_ty, .as_value)},
5525 &.{operand},5525 &.{operand},
5526 "",5526 "",
5527 );5527 );
5528 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .by_value), "");5528 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .as_value), "");
5529}5529}
55305530
5531fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {5531fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
...@@ -5538,7 +5538,7 @@ fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -5538,7 +5538,7 @@ fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
55385538
5539 const inst_ty = self.typeOfIndex(inst);5539 const inst_ty = self.typeOfIndex(inst);
5540 var operand = try self.resolveInst(ty_op.operand);5540 var operand = try self.resolveInst(ty_op.operand);
5541 var llvm_operand_ty = try o.lowerType(operand_ty, .by_value);5541 var llvm_operand_ty = try o.lowerType(operand_ty, .as_value);
55425542
5543 if (bits % 16 == 8) {5543 if (bits % 16 == 8) {
5544 // If not an even byte-multiple, we need zero-extend + shift-left 1 byte5544 // If not an even byte-multiple, we need zero-extend + shift-left 1 byte
...@@ -5559,7 +5559,7 @@ fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -5559,7 +5559,7 @@ fn airByteSwap(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
55595559
5560 const result =5560 const result =
5561 try self.wip.callIntrinsic(.normal, .none, .bswap, &.{llvm_operand_ty}, &.{operand}, "");5561 try self.wip.callIntrinsic(.normal, .none, .bswap, &.{llvm_operand_ty}, &.{operand}, "");
5562 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .by_value), "");5562 return self.wip.conv(.unsigned, result, try o.lowerType(inst_ty, .as_value), "");
5563}5563}
55645564
5565fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {5565fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
...@@ -5579,7 +5579,7 @@ fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Bui...@@ -5579,7 +5579,7 @@ fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Bui
55795579
5580 for (0..names.len) |name_index| {5580 for (0..names.len) |name_index| {
5581 const err_int = ip.getErrorValueIfExists(names.get(ip)[name_index]).?;5581 const err_int = ip.getErrorValueIfExists(names.get(ip)[name_index]).?;
5582 const this_tag_int_value = try o.builder.intConst(try o.errorIntType(.by_value), err_int);5582 const this_tag_int_value = try o.builder.intConst(try o.errorIntType(.as_value), err_int);
5583 try wip_switch.addCase(this_tag_int_value, valid_block, &self.wip);5583 try wip_switch.addCase(this_tag_int_value, valid_block, &self.wip);
5584 }5584 }
5585 self.wip.cursor = .{ .block = valid_block };5585 self.wip.cursor = .{ .block = valid_block };
...@@ -5638,7 +5638,7 @@ fn airErrorName(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va...@@ -5638,7 +5638,7 @@ fn airErrorName(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va
5638 const slice_ty = self.typeOfIndex(inst);5638 const slice_ty = self.typeOfIndex(inst);
56395639
5640 // If operand is small (e.g. `u8`), then signedness becomes a problem -- GEP always treats the index as signed.5640 // If operand is small (e.g. `u8`), then signedness becomes a problem -- GEP always treats the index as signed.
5641 const operand_usize = try self.wip.conv(.unsigned, operand, try o.lowerType(.usize, .by_value), "");5641 const operand_usize = try self.wip.conv(.unsigned, operand, try o.lowerType(.usize, .as_value), "");
56425642
5643 const error_name_table_ptr = try o.getErrorNameTable();5643 const error_name_table_ptr = try o.getErrorNameTable();
5644 const error_name_ptr = try self.ptraddScaled(error_name_table_ptr.toValue(&o.builder), operand_usize, slice_ty.abiSize(zcu));5644 const error_name_ptr = try self.ptraddScaled(error_name_table_ptr.toValue(&o.builder), operand_usize, slice_ty.abiSize(zcu));
...@@ -5649,7 +5649,7 @@ fn airSplat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value...@@ -5649,7 +5649,7 @@ fn airSplat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value
5649 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;5649 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;
5650 const scalar = try self.resolveInst(ty_op.operand);5650 const scalar = try self.resolveInst(ty_op.operand);
5651 const vector_ty = self.typeOfIndex(inst);5651 const vector_ty = self.typeOfIndex(inst);
5652 return self.wip.splatVector(try self.object.lowerType(vector_ty, .by_value), scalar, "");5652 return self.wip.splatVector(try self.object.lowerType(vector_ty, .as_value), scalar, "");
5653}5653}
56545654
5655fn airSelect(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {5655fn airSelect(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
...@@ -5672,9 +5672,9 @@ fn airShuffleOne(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -5672,9 +5672,9 @@ fn airShuffleOne(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
5672 const operand = try fg.resolveInst(unwrapped.operand);5672 const operand = try fg.resolveInst(unwrapped.operand);
5673 const mask = unwrapped.mask;5673 const mask = unwrapped.mask;
5674 const operand_ty = fg.typeOf(unwrapped.operand);5674 const operand_ty = fg.typeOf(unwrapped.operand);
5675 const llvm_operand_ty = try o.lowerType(operand_ty, .by_value);5675 const llvm_operand_ty = try o.lowerType(operand_ty, .as_value);
5676 const llvm_result_ty = try o.lowerType(unwrapped.result_ty, .by_value);5676 const llvm_result_ty = try o.lowerType(unwrapped.result_ty, .as_value);
5677 const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .by_value);5677 const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .as_value);
5678 const llvm_poison_elem = try o.builder.poisonConst(llvm_elem_ty);5678 const llvm_poison_elem = try o.builder.poisonConst(llvm_elem_ty);
5679 const llvm_poison_mask_elem = try o.builder.poisonConst(.i32);5679 const llvm_poison_mask_elem = try o.builder.poisonConst(.i32);
5680 const llvm_mask_ty = try o.builder.vectorType(.normal, @intCast(mask.len), .i32);5680 const llvm_mask_ty = try o.builder.vectorType(.normal, @intCast(mask.len), .i32);
...@@ -5704,7 +5704,7 @@ fn airShuffleOne(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -5704,7 +5704,7 @@ fn airShuffleOne(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
5704 .elem => llvm_poison_elem,5704 .elem => llvm_poison_elem,
5705 .value => |val| if (!Value.fromInterned(val).isUndef(zcu)) elem: {5705 .value => |val| if (!Value.fromInterned(val).isUndef(zcu)) elem: {
5706 any_defined_comptime_value = true;5706 any_defined_comptime_value = true;
5707 break :elem try o.lowerValue(val, .by_value);5707 break :elem try o.lowerValue(val, .as_value);
5708 } else llvm_poison_elem,5708 } else llvm_poison_elem,
5709 };5709 };
5710 }5710 }
...@@ -5776,7 +5776,7 @@ fn airShuffleTwo(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val...@@ -5776,7 +5776,7 @@ fn airShuffleTwo(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val
5776 const unwrapped = fg.air.unwrapShuffleTwo(zcu, inst);5776 const unwrapped = fg.air.unwrapShuffleTwo(zcu, inst);
57775777
5778 const mask = unwrapped.mask;5778 const mask = unwrapped.mask;
5779 const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .by_value);5779 const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .as_value);
5780 const llvm_mask_ty = try o.builder.vectorType(.normal, @intCast(mask.len), .i32);5780 const llvm_mask_ty = try o.builder.vectorType(.normal, @intCast(mask.len), .i32);
5781 const llvm_poison_mask_elem = try o.builder.poisonConst(.i32);5781 const llvm_poison_mask_elem = try o.builder.poisonConst(.i32);
57825782
...@@ -5866,7 +5866,7 @@ fn buildReducedCall(...@@ -5866,7 +5866,7 @@ fn buildReducedCall(
5866 accum_init: Builder.Value,5866 accum_init: Builder.Value,
5867) Allocator.Error!Builder.Value {5867) Allocator.Error!Builder.Value {
5868 const o = self.object;5868 const o = self.object;
5869 const llvm_usize_ty = try o.lowerType(.usize, .by_value);5869 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
5870 const llvm_vector_len = try o.builder.intValue(llvm_usize_ty, vector_len);5870 const llvm_vector_len = try o.builder.intValue(llvm_usize_ty, vector_len);
5871 const llvm_result_ty = accum_init.typeOfWip(&self.wip);5871 const llvm_result_ty = accum_init.typeOfWip(&self.wip);
58725872
...@@ -5924,9 +5924,9 @@ fn airReduce(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) A...@@ -5924,9 +5924,9 @@ fn airReduce(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) A
5924 const reduce = self.air.instructions.items(.data)[@backingInt(inst)].reduce;5924 const reduce = self.air.instructions.items(.data)[@backingInt(inst)].reduce;
5925 const operand = try self.resolveInst(reduce.operand);5925 const operand = try self.resolveInst(reduce.operand);
5926 const operand_ty = self.typeOf(reduce.operand);5926 const operand_ty = self.typeOf(reduce.operand);
5927 const llvm_operand_ty = try o.lowerType(operand_ty, .by_value);5927 const llvm_operand_ty = try o.lowerType(operand_ty, .as_value);
5928 const scalar_ty = self.typeOfIndex(inst);5928 const scalar_ty = self.typeOfIndex(inst);
5929 const llvm_scalar_ty = try o.lowerType(scalar_ty, .by_value);5929 const llvm_scalar_ty = try o.lowerType(scalar_ty, .as_value);
59305930
5931 switch (reduce.operation) {5931 switch (reduce.operation) {
5932 .And, .Or, .Xor => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {5932 .And, .Or, .Xor => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {
...@@ -6036,7 +6036,7 @@ fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde...@@ -6036,7 +6036,7 @@ fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde
60366036
6037 switch (result_ty.zigTypeTag(zcu)) {6037 switch (result_ty.zigTypeTag(zcu)) {
6038 .vector => {6038 .vector => {
6039 const llvm_result_ty = try o.lowerType(result_ty, .by_value);6039 const llvm_result_ty = try o.lowerType(result_ty, .as_value);
6040 var vector = try o.builder.poisonValue(llvm_result_ty);6040 var vector = try o.builder.poisonValue(llvm_result_ty);
6041 for (elements, 0..) |elem, i| {6041 for (elements, 0..) |elem, i| {
6042 const index_u32 = try o.builder.intValue(.i32, i);6042 const index_u32 = try o.builder.intValue(.i32, i);
...@@ -6153,10 +6153,10 @@ fn airUnionInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va...@@ -6153,10 +6153,10 @@ fn airUnionInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va
6153 const loaded_enum = ip.loadEnumType(tag_ty.toIntern());6153 const loaded_enum = ip.loadEnumType(tag_ty.toIntern());
6154 const llvm_tag_val = switch (loaded_enum.field_values.getOrNone(ip, extra.field_index)) {6154 const llvm_tag_val = switch (loaded_enum.field_values.getOrNone(ip, extra.field_index)) {
6155 .none => try o.builder.intConst(6155 .none => try o.builder.intConst(
6156 try o.lowerType(.fromInterned(union_obj.enum_tag_type), .by_value),6156 try o.lowerType(.fromInterned(union_obj.enum_tag_type), .as_value),
6157 extra.field_index, // auto-numbered6157 extra.field_index, // auto-numbered
6158 ),6158 ),
6159 else => |tag_val_ip| try o.lowerValue(tag_val_ip, .by_value),6159 else => |tag_val_ip| try o.lowerValue(tag_val_ip, .as_value),
6160 };6160 };
6161 const tag_ptr = try self.ptraddConst(result_ptr, layout.tagOffset());6161 const tag_ptr = try self.ptraddConst(result_ptr, layout.tagOffset());
6162 try self.store(tag_ptr, layout.tag_align, llvm_tag_val.toValue(), tag_ty, .normal);6162 try self.store(tag_ptr, layout.tag_align, llvm_tag_val.toValue(), tag_ty, .normal);
...@@ -6218,7 +6218,7 @@ fn airAddrSpaceCast(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde...@@ -6218,7 +6218,7 @@ fn airAddrSpaceCast(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde
6218 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;6218 const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op;
6219 const inst_ty = self.typeOfIndex(inst);6219 const inst_ty = self.typeOfIndex(inst);
6220 const operand = try self.resolveInst(ty_op.operand);6220 const operand = try self.resolveInst(ty_op.operand);
6221 return self.wip.cast(.addrspacecast, operand, try self.object.lowerType(inst_ty, .by_value), "");6221 return self.wip.cast(.addrspacecast, operand, try self.object.lowerType(inst_ty, .as_value), "");
6222}6222}
62236223
6224fn workIntrinsic(6224fn workIntrinsic(
...@@ -6370,7 +6370,7 @@ fn load(...@@ -6370,7 +6370,7 @@ fn load(
6370 };6370 };
63716371
6372 if (isByRef(load_ty, zcu)) {6372 if (isByRef(load_ty, zcu)) {
6373 const llvm_usize_ty = try o.lowerType(.usize, .by_value);6373 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
6374 const result_ptr = try fg.buildZigAlloca(load_ty, .none);6374 const result_ptr = try fg.buildZigAlloca(load_ty, .none);
6375 _ = try fg.wip.callMemCpy(6375 _ = try fg.wip.callMemCpy(
6376 result_ptr,6376 result_ptr,
...@@ -6385,7 +6385,7 @@ fn load(...@@ -6385,7 +6385,7 @@ fn load(
6385 }6385 }
63866386
6387 const llvm_memory_ty = try o.lowerType(load_ty, .in_memory);6387 const llvm_memory_ty = try o.lowerType(load_ty, .in_memory);
6388 const llvm_value_ty = try o.lowerType(load_ty, .by_value);6388 const llvm_value_ty = try o.lowerType(load_ty, .as_value);
63896389
6390 if (llvm_memory_ty != llvm_value_ty) {6390 if (llvm_memory_ty != llvm_value_ty) {
6391 assert(load_ty.isAbiInt(zcu));6391 assert(load_ty.isAbiInt(zcu));
...@@ -6443,7 +6443,7 @@ fn store(...@@ -6443,7 +6443,7 @@ fn store(
6443 };6443 };
64446444
6445 if (isByRef(elem_ty, zcu)) {6445 if (isByRef(elem_ty, zcu)) {
6446 const llvm_usize_ty = try o.lowerType(.usize, .by_value);6446 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
6447 _ = try fg.wip.callMemCpy(6447 _ = try fg.wip.callMemCpy(
6448 ptr,6448 ptr,
6449 llvm_ptr_align,6449 llvm_ptr_align,
...@@ -6456,10 +6456,10 @@ fn store(...@@ -6456,10 +6456,10 @@ fn store(
6456 return;6456 return;
6457 }6457 }
64586458
6459 assert(elem.typeOfWip(&fg.wip) == try o.lowerType(elem_ty, .by_value));6459 assert(elem.typeOfWip(&fg.wip) == try o.lowerType(elem_ty, .as_value));
64606460
6461 const llvm_memory_ty = try o.lowerType(elem_ty, .in_memory);6461 const llvm_memory_ty = try o.lowerType(elem_ty, .in_memory);
6462 const llvm_value_ty = try o.lowerType(elem_ty, .by_value);6462 const llvm_value_ty = try o.lowerType(elem_ty, .as_value);
64636463
6464 if (llvm_memory_ty != llvm_value_ty) {6464 if (llvm_memory_ty != llvm_value_ty) {
6465 assert(elem_ty.isAbiInt(zcu));6465 assert(elem_ty.isAbiInt(zcu));
...@@ -6494,7 +6494,7 @@ fn store(...@@ -6494,7 +6494,7 @@ fn store(
6494fn valgrindMarkUndef(fg: *FuncGen, ptr: Builder.Value, len: Builder.Value) Allocator.Error!void {6494fn valgrindMarkUndef(fg: *FuncGen, ptr: Builder.Value, len: Builder.Value) Allocator.Error!void {
6495 const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545;6495 const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545;
6496 const o = fg.object;6496 const o = fg.object;
6497 const usize_ty = try o.lowerType(.usize, .by_value);6497 const usize_ty = try o.lowerType(.usize, .as_value);
6498 const zero = try o.builder.intValue(usize_ty, 0);6498 const zero = try o.builder.intValue(usize_ty, 0);
6499 const req = try o.builder.intValue(usize_ty, VG_USERREQ__MAKE_MEM_UNDEFINED);6499 const req = try o.builder.intValue(usize_ty, VG_USERREQ__MAKE_MEM_UNDEFINED);
6500 const ptr_as_usize = try fg.wip.cast(.ptrtoint, ptr, usize_ty, "");6500 const ptr_as_usize = try fg.wip.cast(.ptrtoint, ptr, usize_ty, "");
...@@ -6516,7 +6516,7 @@ fn valgrindClientRequest(...@@ -6516,7 +6516,7 @@ fn valgrindClientRequest(
6516 const target = zcu.getTarget();6516 const target = zcu.getTarget();
6517 if (!target_util.hasValgrindSupport(target, .stage2_llvm)) return default_value;6517 if (!target_util.hasValgrindSupport(target, .stage2_llvm)) return default_value;
65186518
6519 const llvm_usize = try o.lowerType(.usize, .by_value);6519 const llvm_usize = try o.lowerType(.usize, .as_value);
6520 const usize_align = Type.usize.abiAlignment(zcu).toLlvm();6520 const usize_align = Type.usize.abiAlignment(zcu).toLlvm();
65216521
6522 const array_llvm_ty = try o.builder.arrayType(6, llvm_usize);6522 const array_llvm_ty = try o.builder.arrayType(6, llvm_usize);
...@@ -6798,7 +6798,7 @@ const ParamTypeIterator = struct {...@@ -6798,7 +6798,7 @@ const ParamTypeIterator = struct {
6798 while (field_it.next()) |field_index| {6798 while (field_it.next()) |field_index| {
6799 const field_ty = ty.fieldType(field_index, zcu);6799 const field_ty = ty.fieldType(field_index, zcu);
6800 if (!field_ty.hasRuntimeBits(zcu)) continue;6800 if (!field_ty.hasRuntimeBits(zcu)) continue;
6801 it.types_buffer[it.types_len] = try it.object.lowerType(field_ty, .by_value);6801 it.types_buffer[it.types_len] = try it.object.lowerType(field_ty, .as_value);
6802 it.offsets_buffer[it.types_len] = ty.structFieldOffset(field_index, zcu);6802 it.offsets_buffer[it.types_len] = ty.structFieldOffset(field_index, zcu);
6803 it.types_len += 1;6803 it.types_len += 1;
6804 }6804 }
...@@ -6815,7 +6815,7 @@ const ParamTypeIterator = struct {...@@ -6815,7 +6815,7 @@ const ParamTypeIterator = struct {
6815 it.llvm_index += 1;6815 it.llvm_index += 1;
6816 return .byval;6816 return .byval;
6817 } else {6817 } else {
6818 it.types_buffer[0..1].* = .{try it.object.lowerType(scalar_ty, .by_value)};6818 it.types_buffer[0..1].* = .{try it.object.lowerType(scalar_ty, .as_value)};
6819 it.offsets_buffer[0..2].* = .{ 0, scalar_ty.abiSize(zcu) };6819 it.offsets_buffer[0..2].* = .{ 0, scalar_ty.abiSize(zcu) };
6820 it.types_len = 1;6820 it.types_len = 1;
6821 it.llvm_index += 1;6821 it.llvm_index += 1;
...@@ -7080,7 +7080,7 @@ pub fn fnReturnStrat(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Err...@@ -7080,7 +7080,7 @@ pub fn fnReturnStrat(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Err
7080 for (0..ret_ty.structFieldCount(zcu)) |field_index| {7080 for (0..ret_ty.structFieldCount(zcu)) |field_index| {
7081 const field_ty = ret_ty.fieldType(field_index, zcu);7081 const field_ty = ret_ty.fieldType(field_index, zcu);
7082 if (!field_ty.hasRuntimeBits(zcu)) continue;7082 if (!field_ty.hasRuntimeBits(zcu)) continue;
7083 types[types_len] = try o.lowerType(field_ty, .by_value);7083 types[types_len] = try o.lowerType(field_ty, .as_value);
7084 types_len += 1;7084 types_len += 1;
7085 }7085 }
7086 return .{ .mem_cast = try o.builder.structType(.normal, types[0..types_len]) };7086 return .{ .mem_cast = try o.builder.structType(.normal, types[0..types_len]) };
...@@ -7091,7 +7091,7 @@ pub fn fnReturnStrat(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Err...@@ -7091,7 +7091,7 @@ pub fn fnReturnStrat(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Err
7091 assert(!isByRef(ret_ty, zcu));7091 assert(!isByRef(ret_ty, zcu));
7092 return .by_val;7092 return .by_val;
7093 } else {7093 } else {
7094 return .{ .mem_cast = try o.lowerType(scalar_ty, .by_value) };7094 return .{ .mem_cast = try o.lowerType(scalar_ty, .as_value) };
7095 },7095 },
7096 .indirect => return .sret,7096 .indirect => return .sret,
7097 },7097 },
...@@ -7392,7 +7392,7 @@ fn getAtomicAbiType(fg: *const FuncGen, ty: Type, is_rmw_xchg: bool) Allocator.E...@@ -7392,7 +7392,7 @@ fn getAtomicAbiType(fg: *const FuncGen, ty: Type, is_rmw_xchg: bool) Allocator.E
7392fn ptraddConst(fg: *FuncGen, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value {7392fn ptraddConst(fg: *FuncGen, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value {
7393 if (offset == 0) return ptr;7393 if (offset == 0) return ptr;
7394 const o = fg.object;7394 const o = fg.object;
7395 const llvm_usize_ty = try o.lowerType(.usize, .by_value);7395 const llvm_usize_ty = try o.lowerType(.usize, .as_value);
7396 const offset_val = try o.builder.intValue(llvm_usize_ty, offset);7396 const offset_val = try o.builder.intValue(llvm_usize_ty, offset);
7397 return fg.wip.gep(.inbounds, .i8, ptr, &.{offset_val}, "");7397 return fg.wip.gep(.inbounds, .i8, ptr, &.{offset_val}, "");
7398}7398}