| ... | ... | @@ -583,7 +583,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 583 | 583 | .dbg_stmt => try self.airDbgStmt(inst), |
| 584 | 584 | .fptrunc => @panic("TODO try self.airFptrunc(inst)"), |
| 585 | 585 | .fpext => @panic("TODO try self.airFpext(inst)"), |
| 586 | | .intcast => @panic("TODO try self.airIntCast(inst)"), |
| 586 | .intcast => try self.airIntCast(inst), |
| 587 | 587 | .trunc => @panic("TODO try self.airTrunc(inst)"), |
| 588 | 588 | .bool_to_int => @panic("TODO try self.airBoolToInt(inst)"), |
| 589 | 589 | .is_non_null => @panic("TODO try self.airIsNonNull(inst)"), |
| ... | ... | @@ -1465,6 +1465,24 @@ fn airFence(self: *Self, inst: Air.Inst.Index) !void { |
| 1465 | 1465 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | fn airIntCast(self: *Self, inst: Air.Inst.Index) !void { |
| 1469 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 1470 | if (self.liveness.isUnused(inst)) |
| 1471 | return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none }); |
| 1472 | |
| 1473 | const operand_ty = self.air.typeOf(ty_op.operand); |
| 1474 | const operand = try self.resolveInst(ty_op.operand); |
| 1475 | const info_a = operand_ty.intInfo(self.target.*); |
| 1476 | const info_b = self.air.typeOfIndex(inst).intInfo(self.target.*); |
| 1477 | if (info_a.signedness != info_b.signedness) |
| 1478 | return self.fail("TODO gen intcast sign safety in semantic analysis", .{}); |
| 1479 | |
| 1480 | if (info_a.bits == info_b.bits) |
| 1481 | return self.finishAir(inst, operand, .{ ty_op.operand, .none, .none }); |
| 1482 | |
| 1483 | return self.fail("TODO implement intCast for {}", .{self.target.cpu.arch}); |
| 1484 | } |
| 1485 | |
| 1468 | 1486 | fn airIsErr(self: *Self, inst: Air.Inst.Index) !void { |
| 1469 | 1487 | const un_op = self.air.instructions.items(.data)[inst].un_op; |
| 1470 | 1488 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |