| ... | ... | @@ -164,7 +164,7 @@ fn resolveValue(self: *FuncGen, val: Value) Allocator.Error!Builder.Constant { |
| 164 | 164 | const zcu = o.zcu; |
| 165 | 165 | const ty = val.typeOf(zcu); |
| 166 | 166 | if (!isByRef(ty, zcu)) { |
| 167 | | return o.lowerValue(val.toIntern(), .by_value); |
| 167 | return o.lowerValue(val.toIntern(), .as_value); |
| 168 | 168 | } else { |
| 169 | 169 | // We need a pointer to a global constant, i.e. a UAV. |
| 170 | 170 | return o.lowerUavRef( |
| ... | ... | @@ -264,7 +264,7 @@ pub fn genMainBody(fg: *FuncGen) TodoError!void { |
| 264 | 264 | const param_ty: Type = .fromInterned(param_types[it.zig_index - 1]); |
| 265 | 265 | assert(!isByRef(param_ty, zcu)); |
| 266 | 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 | 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 | 998 | }, |
| 999 | 999 | cc_info.llvm_cc, |
| 1000 | 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 | 1002 | llvm_fn, |
| 1003 | 1003 | llvm_args.items, |
| 1004 | 1004 | "", |
| ... | ... | @@ -1038,7 +1038,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v |
| 1038 | 1038 | const target = zcu.getTarget(); |
| 1039 | 1039 | const panic_func = zcu.funcInfo(zcu.std_lang_decl_values.get(panic_id.toStdLangDecl())); |
| 1040 | 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); |
| 1042 | 1042 | |
| 1043 | 1043 | const llvm_panic_fn_ref = try o.lowerNavRef(panic_func.owner_nav); |
| 1044 | 1044 | |
| ... | ... | @@ -1076,7 +1076,7 @@ fn airRet(self: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!vo |
| 1076 | 1076 | .none => try self.buildZigAlloca(ret_ty, .none), |
| 1077 | 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 | 1080 | _ = try self.wip.callMemSet( |
| 1081 | 1081 | rp, |
| 1082 | 1082 | ret_ty_align.toLlvm(), |
| ... | ... | @@ -1165,7 +1165,7 @@ fn airCVaArg(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 1165 | 1165 | const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 1166 | 1166 | const list = try self.resolveInst(ty_op.operand); |
| 1167 | 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); |
| 1169 | 1169 | |
| 1170 | 1170 | return self.wip.vaArg(list, llvm_arg_ty, ""); |
| 1171 | 1171 | } |
| ... | ... | @@ -1378,7 +1378,7 @@ fn lowerBlock( |
| 1378 | 1378 | if (have_block_result) { |
| 1379 | 1379 | const llvm_ty: Builder.Type = switch (isByRef(inst_ty, zcu)) { |
| 1380 | 1380 | true => .ptr, |
| 1381 | | false => try o.lowerType(inst_ty, .by_value), |
| 1381 | false => try o.lowerType(inst_ty, .as_value), |
| 1382 | 1382 | }; |
| 1383 | 1383 | parent_bb.ptr(&self.wip).incoming = @intCast(breaks.list.len); |
| 1384 | 1384 | const phi = try self.wip.phi(llvm_ty, ""); |
| ... | ... | @@ -1485,7 +1485,7 @@ fn lowerSwitchDispatch( |
| 1485 | 1485 | const table_index = try self.wip.conv( |
| 1486 | 1486 | .unsigned, |
| 1487 | 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 | 1491 | const target_ptr_ptr = try self.ptraddScaled( |
| ... | ... | @@ -1510,7 +1510,7 @@ fn lowerSwitchDispatch( |
| 1510 | 1510 | // The switch prongs will correspond to our scalar cases. Ranges will |
| 1511 | 1511 | // be handled by conditional branches in the `else` prong. |
| 1512 | 1512 | |
| 1513 | | const llvm_usize = try o.lowerType(.usize, .by_value); |
| 1513 | const llvm_usize = try o.lowerType(.usize, .as_value); |
| 1514 | 1514 | const cond_int = if (cond_ty.zigTypeTag(zcu) == .pointer) |
| 1515 | 1515 | try self.wip.cast(.ptrtoint, cond, llvm_usize, "") |
| 1516 | 1516 | else |
| ... | ... | @@ -1725,7 +1725,7 @@ fn lowerTry( |
| 1725 | 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 | 1729 | const is_err = try fg.wip.icmp(.ne, loaded, zero, ""); |
| 1730 | 1730 | |
| 1731 | 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 | 1862 | const table_includes_else = item_count != table_len; |
| 1863 | 1863 | |
| 1864 | 1864 | break :jmp_table .{ |
| 1865 | | .min = try o.lowerValue(min.toIntern(), .by_value), |
| 1866 | | .max = try o.lowerValue(max.toIntern(), .by_value), |
| 1865 | .min = try o.lowerValue(min.toIntern(), .as_value), |
| 1866 | .max = try o.lowerValue(max.toIntern(), .as_value), |
| 1867 | 1867 | .in_bounds_hint = if (table_includes_else) .none else switch (switch_br.getElseHint()) { |
| 1868 | 1868 | .none, .cold => .none, |
| 1869 | 1869 | .unpredictable => .unpredictable, |
| ... | ... | @@ -2021,9 +2021,9 @@ fn airArrayToSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder |
| 2021 | 2021 | const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 2022 | 2022 | const operand_ty = self.typeOf(ty_op.operand); |
| 2023 | 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 | 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 | 2027 | const operand = try self.resolveInst(ty_op.operand); |
| 2028 | 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 | 2040 | |
| 2041 | 2041 | const dest_ty = self.typeOfIndex(inst); |
| 2042 | 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 | 2044 | const target = zcu.getTarget(); |
| 2045 | 2045 | |
| 2046 | 2046 | if (intrinsicsAllowed(dest_scalar_ty, target)) return self.wip.conv( |
| ... | ... | @@ -2108,7 +2108,7 @@ fn airIntFromFloat( |
| 2108 | 2108 | |
| 2109 | 2109 | const dest_ty = self.typeOfIndex(inst); |
| 2110 | 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); |
| 2112 | 2112 | |
| 2113 | 2113 | if (intrinsicsAllowed(operand_scalar_ty, target)) { |
| 2114 | 2114 | // TODO set fast math flag |
| ... | ... | @@ -2142,7 +2142,7 @@ fn airIntFromFloat( |
| 2142 | 2142 | compiler_rt_dest_abbrev, |
| 2143 | 2143 | }); |
| 2144 | 2144 | |
| 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 | 2146 | const libc_fn = try o.getLibcFunction(fn_name, &.{operand_llvm_ty}, libc_ret_ty); |
| 2147 | 2147 | var result = try self.wip.call( |
| 2148 | 2148 | .normal, |
| ... | ... | @@ -2167,7 +2167,7 @@ fn sliceOrArrayPtr(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!B |
| 2167 | 2167 | fn sliceOrArrayLenInBytes(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!Builder.Value { |
| 2168 | 2168 | const o = fg.object; |
| 2169 | 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 | 2171 | switch (ty.ptrSize(zcu)) { |
| 2172 | 2172 | .slice => { |
| 2173 | 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 | 2365 | }, |
| 2366 | 2366 | .float => { |
| 2367 | 2367 | // 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 | 2395 | const field_offset = parent_ty.structFieldOffset(extra.field_index, zcu); |
| 2396 | 2396 | if (field_offset == 0) return field_ptr; |
| 2397 | 2397 | |
| 2398 | | const res_ty = try o.lowerType(ty_pl.ty.toType(), .by_value); |
| 2399 | | const llvm_usize = try o.lowerType(.usize, .by_value); |
| 2398 | const res_ty = try o.lowerType(ty_pl.ty.toType(), .as_value); |
| 2399 | const llvm_usize = try o.lowerType(.usize, .as_value); |
| 2400 | 2400 | |
| 2401 | 2401 | const field_ptr_int = try self.wip.cast(.ptrtoint, field_ptr, llvm_usize, ""); |
| 2402 | 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 | 2612 | const output_inst = try self.resolveInst(output.operand); |
| 2613 | 2613 | const output_ty = self.typeOf(output.operand); |
| 2614 | 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); |
| 2616 | 2616 | |
| 2617 | 2617 | switch (constraint[0]) { |
| 2618 | 2618 | '=' => {}, |
| ... | ... | @@ -2650,7 +2650,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value { |
| 2650 | 2650 | llvm_ret_indirect[output.index] = false; |
| 2651 | 2651 | |
| 2652 | 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 | 2654 | llvm_ret_i += 1; |
| 2655 | 2655 | } |
| 2656 | 2656 | |
| ... | ... | @@ -2689,7 +2689,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value { |
| 2689 | 2689 | llvm_param_types[llvm_param_i] = arg_llvm_value.typeOfWip(&self.wip); |
| 2690 | 2690 | } else { |
| 2691 | 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 | 2693 | const load_inst = try self.wip.load(.normal, arg_llvm_ty, arg_llvm_value, alignment, ""); |
| 2694 | 2694 | llvm_param_values[llvm_param_i] = load_inst; |
| 2695 | 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 | 2729 | llvm_param_attrs[llvm_param_i] = if (constraint[0] == '*') blk: { |
| 2730 | 2730 | if (!is_by_ref) self.maybeMarkAllowZeroAccess(arg_ty.ptrInfo(zcu)); |
| 2731 | 2731 | |
| 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 | 2733 | } else .none; |
| 2734 | 2734 | |
| 2735 | 2735 | llvm_param_i += 1; |
| ... | ... | @@ -2743,7 +2743,7 @@ fn airAssembly(self: *FuncGen, inst: Air.Inst.Index) TodoError!Builder.Value { |
| 2743 | 2743 | if (constraint[0] != '+') continue; |
| 2744 | 2744 | |
| 2745 | 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 | 2747 | if (llvm_ret_indirect[output.index]) { |
| 2748 | 2748 | llvm_param_values[llvm_param_i] = llvm_rw_vals[output.index]; |
| 2749 | 2749 | llvm_param_types[llvm_param_i] = llvm_rw_vals[output.index].typeOfWip(&self.wip); |
| ... | ... | @@ -2957,7 +2957,7 @@ fn airIsNonNull( |
| 2957 | 2957 | )); |
| 2958 | 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 | } |
| 2962 | 2962 | |
| 2963 | 2963 | comptime assert(optional_layout_version == 3); |
| ... | ... | @@ -2986,7 +2986,7 @@ fn airIsErr( |
| 2986 | 2986 | const operand_ty = self.typeOf(un_op); |
| 2987 | 2987 | const err_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty; |
| 2988 | 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); |
| 2990 | 2990 | |
| 2991 | 2991 | const access_kind: Builder.MemoryAccessKind = |
| 2992 | 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 | 3156 | const err_union_ptr_align = err_union_ptr_ty.ptrAlignment(zcu); |
| 3157 | 3157 | |
| 3158 | 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); |
| 3160 | 3160 | |
| 3161 | 3161 | const access_kind: Builder.MemoryAccessKind = |
| 3162 | 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 | 3234 | const payload_ty = self.typeOf(ty_op.operand); |
| 3235 | 3235 | assert(payload_ty.hasRuntimeBits(zcu)); |
| 3236 | 3236 | 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); |
| 3238 | 3238 | |
| 3239 | 3239 | const result_ptr = try self.buildZigAlloca(err_un_ty, .none); |
| 3240 | 3240 | |
| ... | ... | @@ -3273,7 +3273,7 @@ fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build |
| 3273 | 3273 | const o = self.object; |
| 3274 | 3274 | const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op; |
| 3275 | 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 | 3277 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{llvm_usize}, &.{ |
| 3278 | 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 | 3283 | const o = self.object; |
| 3284 | 3284 | const pl_op = self.air.instructions.items(.data)[@backingInt(inst)].pl_op; |
| 3285 | 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 | 3287 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{llvm_isize}, &.{ |
| 3288 | 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 | 3310 | .normal, |
| 3311 | 3311 | .none, |
| 3312 | 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 | 3314 | &.{ lhs, rhs }, |
| 3315 | 3315 | "", |
| 3316 | 3316 | ); |
| ... | ... | @@ -3330,7 +3330,7 @@ fn airMax(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 3330 | 3330 | .normal, |
| 3331 | 3331 | .none, |
| 3332 | 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 | 3334 | &.{ lhs, rhs }, |
| 3335 | 3335 | "", |
| 3336 | 3336 | ); |
| ... | ... | @@ -3342,7 +3342,7 @@ fn airSlice(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 3342 | 3342 | const ptr = try self.resolveInst(bin_op.lhs); |
| 3343 | 3343 | const len = try self.resolveInst(bin_op.rhs); |
| 3344 | 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 | } |
| 3347 | 3347 | |
| 3348 | 3348 | fn airAdd(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allocator.Error!Builder.Value { |
| ... | ... | @@ -3373,7 +3373,7 @@ fn airSafeArithmetic( |
| 3373 | 3373 | const scalar_ty = inst_ty.scalarType(zcu); |
| 3374 | 3374 | |
| 3375 | 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 | 3377 | const results = |
| 3378 | 3378 | try fg.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, ""); |
| 3379 | 3379 | |
| ... | ... | @@ -3423,7 +3423,7 @@ fn airAddSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 3423 | 3423 | .normal, |
| 3424 | 3424 | .none, |
| 3425 | 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 | 3427 | &.{ lhs, rhs }, |
| 3428 | 3428 | "", |
| 3429 | 3429 | ); |
| ... | ... | @@ -3462,7 +3462,7 @@ fn airSubSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 3462 | 3462 | .normal, |
| 3463 | 3463 | .none, |
| 3464 | 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 | 3466 | &.{ lhs, rhs }, |
| 3467 | 3467 | "", |
| 3468 | 3468 | ); |
| ... | ... | @@ -3501,7 +3501,7 @@ fn airMulSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 3501 | 3501 | .normal, |
| 3502 | 3502 | .none, |
| 3503 | 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 | 3505 | &.{ lhs, rhs, .@"0" }, |
| 3506 | 3506 | "", |
| 3507 | 3507 | ); |
| ... | ... | @@ -3545,8 +3545,8 @@ fn airDivFloor(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) |
| 3545 | 3545 | return self.buildFloatOp(.floor, fast, inst_ty, 1, .{result}); |
| 3546 | 3546 | } |
| 3547 | 3547 | if (scalar_ty.isSignedInt(zcu)) { |
| 3548 | | const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value); |
| 3549 | | const inst_llvm_ty = try o.lowerType(inst_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, .as_value); |
| 3550 | 3550 | |
| 3551 | 3551 | const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb; |
| 3552 | 3552 | var bfa_buf: ExpectedContents = undefined; |
| ... | ... | @@ -3594,8 +3594,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) |
| 3594 | 3594 | return self.buildFloatOp(.ceil, fast, inst_ty, 1, .{result}); |
| 3595 | 3595 | } |
| 3596 | 3596 | if (scalar_ty.isSignedInt(zcu)) { |
| 3597 | | const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value); |
| 3598 | | const inst_llvm_ty = try o.lowerType(inst_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, .as_value); |
| 3599 | 3599 | |
| 3600 | 3600 | const ExpectedContents = [std.math.big.int.calcTwosCompLimbCount(256)]std.math.big.Limb; |
| 3601 | 3601 | var bfa_buf: ExpectedContents = undefined; |
| ... | ... | @@ -3634,8 +3634,8 @@ fn airDivCeil(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) |
| 3634 | 3634 | const correction = try self.wip.cast(.zext, need_correction, inst_llvm_ty, "divCeil.correction"); |
| 3635 | 3635 | return self.wip.bin(.@"add nsw", div, correction, "divCeil"); |
| 3636 | 3636 | } else { |
| 3637 | | const scalar_llvm_ty = try o.lowerType(scalar_ty, .by_value); |
| 3638 | | const inst_llvm_ty = try o.lowerType(inst_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, .as_value); |
| 3639 | 3639 | |
| 3640 | 3640 | const zero = try o.builder.splatValue( |
| 3641 | 3641 | inst_llvm_ty, |
| ... | ... | @@ -3692,7 +3692,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo |
| 3692 | 3692 | const lhs = try self.resolveInst(bin_op.lhs); |
| 3693 | 3693 | const rhs = try self.resolveInst(bin_op.rhs); |
| 3694 | 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 | 3696 | const scalar_ty = inst_ty.scalarType(zcu); |
| 3697 | 3697 | |
| 3698 | 3698 | if (scalar_ty.isRuntimeFloat()) { |
| ... | ... | @@ -3721,7 +3721,7 @@ fn airMod(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) Allo |
| 3721 | 3721 | defer allocator.free(smin_big_int.limbs); |
| 3722 | 3722 | smin_big_int.setTwosCompIntLimit(.min, .signed, scalar_bits); |
| 3723 | 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 | 3725 | smin_big_int.toConst(), |
| 3726 | 3726 | )); |
| 3727 | 3727 | |
| ... | ... | @@ -3757,7 +3757,7 @@ fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 3757 | 3757 | const ty_pl = self.air.instructions.items(.data)[@backingInt(inst)].ty_pl; |
| 3758 | 3758 | const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 3759 | 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 | 3761 | const ptr_ty = self.typeOf(bin_op.lhs); |
| 3762 | 3762 | const elem_ty = ptr_ty.indexableElem(zcu); |
| 3763 | 3763 | const ptr = switch (ptr_ty.ptrSize(zcu)) { |
| ... | ... | @@ -3790,7 +3790,7 @@ fn airOverflow( |
| 3790 | 3790 | assert(isByRef(inst_ty, zcu)); // auto structs are by-ref |
| 3791 | 3791 | |
| 3792 | 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 | 3794 | const results = |
| 3795 | 3795 | try self.wip.callIntrinsic(.normal, .none, intrinsic, &.{llvm_lhs_ty}, &.{ lhs, rhs }, ""); |
| 3796 | 3796 | |
| ... | ... | @@ -3863,7 +3863,7 @@ fn buildFloatCmp( |
| 3863 | 3863 | const zcu = o.zcu; |
| 3864 | 3864 | const target = zcu.getTarget(); |
| 3865 | 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); |
| 3867 | 3867 | |
| 3868 | 3868 | if (intrinsicsAllowed(scalar_ty, target)) { |
| 3869 | 3869 | const cond: Builder.FloatCondition = switch (pred) { |
| ... | ... | @@ -3969,7 +3969,7 @@ fn buildFloatOp( |
| 3969 | 3969 | const zcu = o.zcu; |
| 3970 | 3970 | const target = zcu.getTarget(); |
| 3971 | 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); |
| 3973 | 3973 | |
| 3974 | 3974 | if (op != .tan and intrinsicsAllowed(scalar_ty, target)) switch (op) { |
| 3975 | 3975 | // Some operations are dedicated LLVM instructions, not available as intrinsics |
| ... | ... | @@ -4074,7 +4074,7 @@ fn buildFloatOp( |
| 4074 | 4074 | }), |
| 4075 | 4075 | }; |
| 4076 | 4076 | |
| 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 | 4078 | const libc_fn = try o.getLibcFunction( |
| 4079 | 4079 | fn_name, |
| 4080 | 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 | 4129 | const dest_ty = self.typeOfIndex(inst); |
| 4130 | 4130 | assert(isByRef(dest_ty, zcu)); // auto structs are by-ref |
| 4131 | 4131 | |
| 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), ""); |
| 4133 | 4133 | |
| 4134 | 4134 | const result = try self.wip.bin(.shl, lhs, casted_rhs, ""); |
| 4135 | 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 | 4196 | } |
| 4197 | 4197 | const lhs_scalar_ty = lhs_ty.scalarType(zcu); |
| 4198 | 4198 | |
| 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 | 4200 | return self.wip.bin(if (lhs_scalar_ty.isSignedInt(zcu)) |
| 4201 | 4201 | .@"shl nsw" |
| 4202 | 4202 | else |
| ... | ... | @@ -4217,7 +4217,7 @@ fn airShl(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 4217 | 4217 | // features which we do not use. Therefore this branch is currently impossible. |
| 4218 | 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 | 4221 | return self.wip.bin(.shl, lhs, casted_rhs, ""); |
| 4222 | 4222 | } |
| 4223 | 4223 | |
| ... | ... | @@ -4231,8 +4231,8 @@ fn airShlSat(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value |
| 4231 | 4231 | |
| 4232 | 4232 | const lhs_ty = self.typeOf(bin_op.lhs); |
| 4233 | 4233 | const lhs_info = lhs_ty.intInfo(zcu); |
| 4234 | | const llvm_lhs_ty = try o.lowerType(lhs_ty, .by_value); |
| 4235 | | const llvm_lhs_scalar_ty = try o.lowerType(lhs_ty.scalarType(zcu), .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), .as_value); |
| 4236 | 4236 | |
| 4237 | 4237 | const rhs_ty = self.typeOf(bin_op.rhs); |
| 4238 | 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 | 4242 | } |
| 4243 | 4243 | const rhs_info = rhs_ty.intInfo(zcu); |
| 4244 | 4244 | assert(rhs_info.signedness == .unsigned); |
| 4245 | | const llvm_rhs_ty = try o.lowerType(rhs_ty, .by_value); |
| 4246 | | const llvm_rhs_scalar_ty = try o.lowerType(rhs_ty.scalarType(zcu), .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), .as_value); |
| 4247 | 4247 | |
| 4248 | 4248 | const result = try self.wip.callIntrinsic( |
| 4249 | 4249 | .normal, |
| ... | ... | @@ -4319,7 +4319,7 @@ fn airShr(self: *FuncGen, inst: Air.Inst.Index, is_exact: bool) Allocator.Error! |
| 4319 | 4319 | } |
| 4320 | 4320 | const lhs_scalar_ty = lhs_ty.scalarType(zcu); |
| 4321 | 4321 | |
| 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 | 4323 | const is_signed_int = lhs_scalar_ty.isSignedInt(zcu); |
| 4324 | 4324 | |
| 4325 | 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 | 4340 | .normal, |
| 4341 | 4341 | .none, |
| 4342 | 4342 | .abs, |
| 4343 | | &.{try o.lowerType(operand_ty, .by_value)}, |
| 4343 | &.{try o.lowerType(operand_ty, .as_value)}, |
| 4344 | 4344 | &.{ operand, .false }, |
| 4345 | 4345 | "", |
| 4346 | 4346 | ), |
| ... | ... | @@ -4354,7 +4354,7 @@ fn airIntCast(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error! |
| 4354 | 4354 | const zcu = o.zcu; |
| 4355 | 4355 | const ty_op = fg.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 4356 | 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 | 4358 | const operand = try fg.resolveInst(ty_op.operand); |
| 4359 | 4359 | const operand_ty = fg.typeOf(ty_op.operand); |
| 4360 | 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 | 4382 | |
| 4383 | 4383 | if (!have_min_check and !have_max_check) break :bounds_check; |
| 4384 | 4384 | |
| 4385 | | const operand_llvm_ty = try o.lowerType(operand_ty, .by_value); |
| 4386 | | const operand_scalar_llvm_ty = try o.lowerType(operand_scalar, .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, .as_value); |
| 4387 | 4387 | |
| 4388 | 4388 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; |
| 4389 | 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 | 4461 | fn airTrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 4462 | 4462 | const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 4463 | 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 | 4465 | return self.wip.cast(.trunc, operand, dest_llvm_ty, ""); |
| 4466 | 4466 | } |
| 4467 | 4467 | |
| ... | ... | @@ -4475,10 +4475,10 @@ fn airFptrunc(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu |
| 4475 | 4475 | const target = zcu.getTarget(); |
| 4476 | 4476 | |
| 4477 | 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 | 4479 | } else { |
| 4480 | | const operand_llvm_ty = try o.lowerType(operand_ty, .by_value); |
| 4481 | | const dest_llvm_ty = try o.lowerType(dest_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, .as_value); |
| 4482 | 4482 | |
| 4483 | 4483 | const dest_bits = dest_ty.floatBits(target); |
| 4484 | 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 | 4509 | const target = zcu.getTarget(); |
| 4510 | 4510 | |
| 4511 | 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 | 4513 | } else { |
| 4514 | | const operand_llvm_ty = try o.lowerType(operand_ty, .by_value); |
| 4515 | | const dest_llvm_ty = try o.lowerType(dest_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, .as_value); |
| 4516 | 4516 | |
| 4517 | 4517 | const dest_bits = dest_ty.scalarType(zcu).floatBits(target); |
| 4518 | 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 | 4563 | assert(!isByRef(operand_ty, zcu)); |
| 4564 | 4564 | assert(!isByRef(dest_ty, zcu)); |
| 4565 | 4565 | |
| 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 | 4567 | const result = try fg.wip.cast(.bitcast, operand, llvm_dest_ty, ""); |
| 4568 | 4568 | if (safety and dest_ty.zigTypeTag(zcu) == .@"enum" and !dest_ty.isNonexhaustiveEnum(zcu)) { |
| 4569 | 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 | 4606 | assert(dest_ty.scalarType(zcu).isPtrAtRuntime(zcu)); |
| 4607 | 4607 | |
| 4608 | 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 | 4610 | return fg.wip.cast(.inttoptr, operand, llvm_dest_ty, ""); |
| 4611 | 4611 | } |
| 4612 | 4612 | |
| ... | ... | @@ -4620,7 +4620,7 @@ fn airIntFromPtr(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Val |
| 4620 | 4620 | assert(dest_ty.scalarType(zcu).toIntern() == .usize_type); |
| 4621 | 4621 | |
| 4622 | 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 | 4624 | return fg.wip.cast(.ptrtoint, operand, llvm_dest_ty, ""); |
| 4625 | 4625 | } |
| 4626 | 4626 | |
| ... | ... | @@ -4832,7 +4832,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu |
| 4832 | 4832 | return .none; |
| 4833 | 4833 | } |
| 4834 | 4834 | |
| 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 | 4836 | _ = try fg.wip.callMemSet( |
| 4837 | 4837 | ptr, |
| 4838 | 4838 | ptr_alignment.toLlvm(), |
| ... | ... | @@ -4867,7 +4867,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu |
| 4867 | 4867 | if (ptr_info.packed_offset.host_size != 0) { |
| 4868 | 4868 | // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`. |
| 4869 | 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); |
| 4871 | 4871 | |
| 4872 | 4872 | const backing_int_val = try fg.load(ptr, ptr_alignment, backing_int_ty, access_kind); |
| 4873 | 4873 | |
| ... | ... | @@ -4945,14 +4945,14 @@ fn airLoad(fg: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 4945 | 4945 | |
| 4946 | 4946 | // Accepted proposal https://github.com/ziglang/zig/issues/24061 will eliminate this usage of `pt`. |
| 4947 | 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); |
| 4949 | 4949 | |
| 4950 | 4950 | const backing_int_val = try fg.load(ptr, ptr_align, backing_int_ty, .normal); |
| 4951 | 4951 | |
| 4952 | 4952 | const elem_bits = ptr_ty.childType(zcu).bitSize(zcu); |
| 4953 | 4953 | const shift_amt = try o.builder.intValue(llvm_backing_int_ty, ptr_info.packed_offset.bit_offset); |
| 4954 | 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); |
| 4956 | 4956 | |
| 4957 | 4957 | if (elem_ty.zigTypeTag(zcu) == .float or elem_ty.zigTypeTag(zcu) == .vector) { |
| 4958 | 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 | 5002 | fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 5003 | 5003 | _ = inst; |
| 5004 | 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 | 5006 | if (!target_util.supportsReturnAddress(self.object.zcu.getTarget(), self.ownerModule().optimize_mode)) { |
| 5007 | 5007 | // https://github.com/ziglang/zig/issues/11946 |
| 5008 | 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 | 5014 | fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { |
| 5015 | 5015 | _ = inst; |
| 5016 | 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 | } |
| 5019 | 5019 | |
| 5020 | 5020 | fn airCmpxchg( |
| ... | ... | @@ -5031,7 +5031,7 @@ fn airCmpxchg( |
| 5031 | 5031 | var expected_value = try self.resolveInst(extra.expected_value); |
| 5032 | 5032 | var new_value = try self.resolveInst(extra.new_value); |
| 5033 | 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 | 5035 | const llvm_abi_ty = try self.getAtomicAbiType(operand_ty, false); |
| 5036 | 5036 | if (llvm_abi_ty != .none) { |
| 5037 | 5037 | // operand needs widening and truncating |
| ... | ... | @@ -5101,7 +5101,7 @@ fn airAtomicRmw(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va |
| 5101 | 5101 | const op = toLlvmAtomicRmwBinOp(extra.op(), is_signed_int, is_float); |
| 5102 | 5102 | const ordering = toLlvmAtomicOrdering(extra.ordering()); |
| 5103 | 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); |
| 5105 | 5105 | |
| 5106 | 5106 | const access_kind: Builder.MemoryAccessKind = |
| 5107 | 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 | 5130 | |
| 5131 | 5131 | // If we are storing a pointer we need to convert to and from a plain old integer. |
| 5132 | 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 | 5134 | else => operand, |
| 5135 | 5135 | }; |
| 5136 | 5136 | |
| ... | ... | @@ -5169,7 +5169,7 @@ fn airAtomicLoad(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.V |
| 5169 | 5169 | Type.fromInterned(info.child).abiAlignment(zcu)).toLlvm(); |
| 5170 | 5170 | const access_kind: Builder.MemoryAccessKind = |
| 5171 | 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); |
| 5173 | 5173 | |
| 5174 | 5174 | self.maybeMarkAllowZeroAccess(info); |
| 5175 | 5175 | |
| ... | ... | @@ -5503,11 +5503,11 @@ fn airClzCtz(self: *FuncGen, inst: Air.Inst.Index, intrinsic: Builder.Intrinsic) |
| 5503 | 5503 | .normal, |
| 5504 | 5504 | .none, |
| 5505 | 5505 | intrinsic, |
| 5506 | | &.{try o.lowerType(operand_ty, .by_value)}, |
| 5506 | &.{try o.lowerType(operand_ty, .as_value)}, |
| 5507 | 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 | } |
| 5512 | 5512 | |
| 5513 | 5513 | fn 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 | 5521 | .normal, |
| 5522 | 5522 | .none, |
| 5523 | 5523 | intrinsic, |
| 5524 | | &.{try o.lowerType(operand_ty, .by_value)}, |
| 5524 | &.{try o.lowerType(operand_ty, .as_value)}, |
| 5525 | 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 | } |
| 5530 | 5530 | |
| 5531 | 5531 | fn 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 | 5538 | |
| 5539 | 5539 | const inst_ty = self.typeOfIndex(inst); |
| 5540 | 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); |
| 5542 | 5542 | |
| 5543 | 5543 | if (bits % 16 == 8) { |
| 5544 | 5544 | // 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 | 5559 | |
| 5560 | 5560 | const result = |
| 5561 | 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 | } |
| 5564 | 5564 | |
| 5565 | 5565 | fn 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 | 5579 | |
| 5580 | 5580 | for (0..names.len) |name_index| { |
| 5581 | 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 | 5583 | try wip_switch.addCase(this_tag_int_value, valid_block, &self.wip); |
| 5584 | 5584 | } |
| 5585 | 5585 | self.wip.cursor = .{ .block = valid_block }; |
| ... | ... | @@ -5638,7 +5638,7 @@ fn airErrorName(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Va |
| 5638 | 5638 | const slice_ty = self.typeOfIndex(inst); |
| 5639 | 5639 | |
| 5640 | 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), ""); |
| 5642 | 5642 | |
| 5643 | 5643 | const error_name_table_ptr = try o.getErrorNameTable(); |
| 5644 | 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 | 5649 | const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 5650 | 5650 | const scalar = try self.resolveInst(ty_op.operand); |
| 5651 | 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 | } |
| 5654 | 5654 | |
| 5655 | 5655 | fn 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 | 5672 | const operand = try fg.resolveInst(unwrapped.operand); |
| 5673 | 5673 | const mask = unwrapped.mask; |
| 5674 | 5674 | const operand_ty = fg.typeOf(unwrapped.operand); |
| 5675 | | const llvm_operand_ty = try o.lowerType(operand_ty, .by_value); |
| 5676 | | const llvm_result_ty = try o.lowerType(unwrapped.result_ty, .by_value); |
| 5677 | | const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .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, .as_value); |
| 5677 | const llvm_elem_ty = try o.lowerType(unwrapped.result_ty.childType(zcu), .as_value); |
| 5678 | 5678 | const llvm_poison_elem = try o.builder.poisonConst(llvm_elem_ty); |
| 5679 | 5679 | const llvm_poison_mask_elem = try o.builder.poisonConst(.i32); |
| 5680 | 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 | 5704 | .elem => llvm_poison_elem, |
| 5705 | 5705 | .value => |val| if (!Value.fromInterned(val).isUndef(zcu)) elem: { |
| 5706 | 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 | 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 | 5776 | const unwrapped = fg.air.unwrapShuffleTwo(zcu, inst); |
| 5777 | 5777 | |
| 5778 | 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 | 5780 | const llvm_mask_ty = try o.builder.vectorType(.normal, @intCast(mask.len), .i32); |
| 5781 | 5781 | const llvm_poison_mask_elem = try o.builder.poisonConst(.i32); |
| 5782 | 5782 | |
| ... | ... | @@ -5866,7 +5866,7 @@ fn buildReducedCall( |
| 5866 | 5866 | accum_init: Builder.Value, |
| 5867 | 5867 | ) Allocator.Error!Builder.Value { |
| 5868 | 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 | 5870 | const llvm_vector_len = try o.builder.intValue(llvm_usize_ty, vector_len); |
| 5871 | 5871 | const llvm_result_ty = accum_init.typeOfWip(&self.wip); |
| 5872 | 5872 | |
| ... | ... | @@ -5924,9 +5924,9 @@ fn airReduce(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind) A |
| 5924 | 5924 | const reduce = self.air.instructions.items(.data)[@backingInt(inst)].reduce; |
| 5925 | 5925 | const operand = try self.resolveInst(reduce.operand); |
| 5926 | 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 | 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); |
| 5930 | 5930 | |
| 5931 | 5931 | switch (reduce.operation) { |
| 5932 | 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 | 6036 | |
| 6037 | 6037 | switch (result_ty.zigTypeTag(zcu)) { |
| 6038 | 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 | 6040 | var vector = try o.builder.poisonValue(llvm_result_ty); |
| 6041 | 6041 | for (elements, 0..) |elem, i| { |
| 6042 | 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 | 6153 | const loaded_enum = ip.loadEnumType(tag_ty.toIntern()); |
| 6154 | 6154 | const llvm_tag_val = switch (loaded_enum.field_values.getOrNone(ip, extra.field_index)) { |
| 6155 | 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 | 6157 | 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 | 6161 | const tag_ptr = try self.ptraddConst(result_ptr, layout.tagOffset()); |
| 6162 | 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 | 6218 | const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; |
| 6219 | 6219 | const inst_ty = self.typeOfIndex(inst); |
| 6220 | 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 | } |
| 6223 | 6223 | |
| 6224 | 6224 | fn workIntrinsic( |
| ... | ... | @@ -6370,7 +6370,7 @@ fn load( |
| 6370 | 6370 | }; |
| 6371 | 6371 | |
| 6372 | 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 | 6374 | const result_ptr = try fg.buildZigAlloca(load_ty, .none); |
| 6375 | 6375 | _ = try fg.wip.callMemCpy( |
| 6376 | 6376 | result_ptr, |
| ... | ... | @@ -6385,7 +6385,7 @@ fn load( |
| 6385 | 6385 | } |
| 6386 | 6386 | |
| 6387 | 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); |
| 6389 | 6389 | |
| 6390 | 6390 | if (llvm_memory_ty != llvm_value_ty) { |
| 6391 | 6391 | assert(load_ty.isAbiInt(zcu)); |
| ... | ... | @@ -6443,7 +6443,7 @@ fn store( |
| 6443 | 6443 | }; |
| 6444 | 6444 | |
| 6445 | 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 | 6447 | _ = try fg.wip.callMemCpy( |
| 6448 | 6448 | ptr, |
| 6449 | 6449 | llvm_ptr_align, |
| ... | ... | @@ -6456,10 +6456,10 @@ fn store( |
| 6456 | 6456 | return; |
| 6457 | 6457 | } |
| 6458 | 6458 | |
| 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)); |
| 6460 | 6460 | |
| 6461 | 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); |
| 6463 | 6463 | |
| 6464 | 6464 | if (llvm_memory_ty != llvm_value_ty) { |
| 6465 | 6465 | assert(elem_ty.isAbiInt(zcu)); |
| ... | ... | @@ -6494,7 +6494,7 @@ fn store( |
| 6494 | 6494 | fn valgrindMarkUndef(fg: *FuncGen, ptr: Builder.Value, len: Builder.Value) Allocator.Error!void { |
| 6495 | 6495 | const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545; |
| 6496 | 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 | 6498 | const zero = try o.builder.intValue(usize_ty, 0); |
| 6499 | 6499 | const req = try o.builder.intValue(usize_ty, VG_USERREQ__MAKE_MEM_UNDEFINED); |
| 6500 | 6500 | const ptr_as_usize = try fg.wip.cast(.ptrtoint, ptr, usize_ty, ""); |
| ... | ... | @@ -6516,7 +6516,7 @@ fn valgrindClientRequest( |
| 6516 | 6516 | const target = zcu.getTarget(); |
| 6517 | 6517 | if (!target_util.hasValgrindSupport(target, .stage2_llvm)) return default_value; |
| 6518 | 6518 | |
| 6519 | | const llvm_usize = try o.lowerType(.usize, .by_value); |
| 6519 | const llvm_usize = try o.lowerType(.usize, .as_value); |
| 6520 | 6520 | const usize_align = Type.usize.abiAlignment(zcu).toLlvm(); |
| 6521 | 6521 | |
| 6522 | 6522 | const array_llvm_ty = try o.builder.arrayType(6, llvm_usize); |
| ... | ... | @@ -6798,7 +6798,7 @@ const ParamTypeIterator = struct { |
| 6798 | 6798 | while (field_it.next()) |field_index| { |
| 6799 | 6799 | const field_ty = ty.fieldType(field_index, zcu); |
| 6800 | 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 | 6802 | it.offsets_buffer[it.types_len] = ty.structFieldOffset(field_index, zcu); |
| 6803 | 6803 | it.types_len += 1; |
| 6804 | 6804 | } |
| ... | ... | @@ -6815,7 +6815,7 @@ const ParamTypeIterator = struct { |
| 6815 | 6815 | it.llvm_index += 1; |
| 6816 | 6816 | return .byval; |
| 6817 | 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 | 6819 | it.offsets_buffer[0..2].* = .{ 0, scalar_ty.abiSize(zcu) }; |
| 6820 | 6820 | it.types_len = 1; |
| 6821 | 6821 | it.llvm_index += 1; |
| ... | ... | @@ -7080,7 +7080,7 @@ pub fn fnReturnStrat(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Err |
| 7080 | 7080 | for (0..ret_ty.structFieldCount(zcu)) |field_index| { |
| 7081 | 7081 | const field_ty = ret_ty.fieldType(field_index, zcu); |
| 7082 | 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 | 7084 | types_len += 1; |
| 7085 | 7085 | } |
| 7086 | 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 | 7091 | assert(!isByRef(ret_ty, zcu)); |
| 7092 | 7092 | return .by_val; |
| 7093 | 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 | 7096 | .indirect => return .sret, |
| 7097 | 7097 | }, |
| ... | ... | @@ -7392,7 +7392,7 @@ fn getAtomicAbiType(fg: *const FuncGen, ty: Type, is_rmw_xchg: bool) Allocator.E |
| 7392 | 7392 | fn ptraddConst(fg: *FuncGen, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value { |
| 7393 | 7393 | if (offset == 0) return ptr; |
| 7394 | 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 | 7396 | const offset_val = try o.builder.intValue(llvm_usize_ty, offset); |
| 7397 | 7397 | return fg.wip.gep(.inbounds, .i8, ptr, &.{offset_val}, ""); |
| 7398 | 7398 | } |