authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-06-16 23:31:04+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-06-24 21:19:33+07:00
log513ab4eb568da6fb926dd33ae067d31cf4831e79
tree6a0f172d23fe64219a4eebd568b7e70f7e429677
parent36bfe4b7efedd1b030c335151b2d6a61bbeab1eb

stage2: sparc64: Implement airIntCast basics


1 files changed, 19 insertions(+), 1 deletions(-)

src/arch/sparc64/CodeGen.zig+19-1
......@@ -583,7 +583,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
583583 .dbg_stmt => try self.airDbgStmt(inst),
584584 .fptrunc => @panic("TODO try self.airFptrunc(inst)"),
585585 .fpext => @panic("TODO try self.airFpext(inst)"),
586 .intcast => @panic("TODO try self.airIntCast(inst)"),
586 .intcast => try self.airIntCast(inst),
587587 .trunc => @panic("TODO try self.airTrunc(inst)"),
588588 .bool_to_int => @panic("TODO try self.airBoolToInt(inst)"),
589589 .is_non_null => @panic("TODO try self.airIsNonNull(inst)"),
......@@ -1465,6 +1465,24 @@ fn airFence(self: *Self, inst: Air.Inst.Index) !void {
14651465 return self.finishAir(inst, .dead, .{ .none, .none, .none });
14661466}
14671467
1468fn 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
14681486fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
14691487 const un_op = self.air.instructions.items(.data)[inst].un_op;
14701488 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {