| ... | ... | @@ -1464,26 +1464,6 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError { |
| 1464 | 1464 | return error.AnalysisFail; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | | /// Appropriate to call when the coercion has already been done by result |
| 1468 | | /// location semantics. Asserts the value fits in the provided `Int` type. |
| 1469 | | /// Only supports `Int` types 64 bits or less. |
| 1470 | | /// TODO don't ever call this since we're migrating towards ResultLoc.coerced_ty. |
| 1471 | | fn resolveAlreadyCoercedInt( |
| 1472 | | sema: *Sema, |
| 1473 | | block: *Block, |
| 1474 | | src: LazySrcLoc, |
| 1475 | | zir_ref: Zir.Inst.Ref, |
| 1476 | | comptime Int: type, |
| 1477 | | ) !Int { |
| 1478 | | comptime assert(@typeInfo(Int).Int.bits <= 64); |
| 1479 | | const air_inst = sema.resolveInst(zir_ref); |
| 1480 | | const val = try sema.resolveConstValue(block, src, air_inst); |
| 1481 | | switch (@typeInfo(Int).Int.signedness) { |
| 1482 | | .signed => return @intCast(Int, val.toSignedInt()), |
| 1483 | | .unsigned => return @intCast(Int, val.toUnsignedInt()), |
| 1484 | | } |
| 1485 | | } |
| 1486 | | |
| 1487 | 1467 | fn resolveAlign( |
| 1488 | 1468 | sema: *Sema, |
| 1489 | 1469 | block: *Block, |
| ... | ... | @@ -3380,7 +3360,7 @@ fn storeToInferredAllocComptime( |
| 3380 | 3360 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3381 | 3361 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3382 | 3362 | const src = inst_data.src(); |
| 3383 | | const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32); |
| 3363 | const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32)); |
| 3384 | 3364 | if (sema.branch_quota < quota) |
| 3385 | 3365 | sema.branch_quota = quota; |
| 3386 | 3366 | } |
| ... | ... | @@ -5080,11 +5060,11 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 5080 | 5060 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 5081 | 5061 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 5082 | 5062 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 5083 | | const len = try sema.resolveAlreadyCoercedInt(block, len_src, extra.lhs, u32); |
| 5063 | const len = try sema.resolveInt(block, len_src, extra.lhs, Type.u32); |
| 5084 | 5064 | const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs); |
| 5085 | 5065 | try sema.checkVectorElemType(block, elem_type_src, elem_type); |
| 5086 | 5066 | const vector_type = try Type.Tag.vector.create(sema.arena, .{ |
| 5087 | | .len = len, |
| 5067 | .len = @intCast(u32, len), |
| 5088 | 5068 | .elem_type = elem_type, |
| 5089 | 5069 | }); |
| 5090 | 5070 | return sema.addType(vector_type); |
| ... | ... | @@ -11341,7 +11321,8 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 11341 | 11321 | const abi_align = if (inst_data.flags.has_align) blk: { |
| 11342 | 11322 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 11343 | 11323 | extra_i += 1; |
| 11344 | | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u32); |
| 11324 | const abi_align = try sema.resolveInt(block, .unneeded, ref, Type.u32); |
| 11325 | break :blk @intCast(u32, abi_align); |
| 11345 | 11326 | } else 0; |
| 11346 | 11327 | |
| 11347 | 11328 | const address_space = if (inst_data.flags.has_addrspace) blk: { |
| ... | ... | @@ -11353,13 +11334,15 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 11353 | 11334 | const bit_offset = if (inst_data.flags.has_bit_range) blk: { |
| 11354 | 11335 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 11355 | 11336 | extra_i += 1; |
| 11356 | | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 11337 | const bit_offset = try sema.resolveInt(block, .unneeded, ref, Type.u16); |
| 11338 | break :blk @intCast(u16, bit_offset); |
| 11357 | 11339 | } else 0; |
| 11358 | 11340 | |
| 11359 | 11341 | const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 11360 | 11342 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 11361 | 11343 | extra_i += 1; |
| 11362 | | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 11344 | const host_size = try sema.resolveInt(block, .unneeded, ref, Type.u16); |
| 11345 | break :blk @intCast(u16, host_size); |
| 11363 | 11346 | } else 0; |
| 11364 | 11347 | |
| 11365 | 11348 | if (host_size != 0 and bit_offset >= host_size * 8) { |