aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2022-06-19 10:46:50 +0700
committerKoakuma <koachan@protonmail.com>2022-06-24 21:19:33 +0700
commit4fd0500bb570572a89c8f342c6d9bdb4a69331a7 (patch)
treeaa9fb25e31698dce66ba4cb53761d1ca20a0ea38 /src
parent837cd0d8af294405316dc6757ce3d0e105c86218 (diff)
downloadzig-4fd0500bb570572a89c8f342c6d9bdb4a69331a7.tar.gz
zig-4fd0500bb570572a89c8f342c6d9bdb4a69331a7.zip
stage2: sparc64: Implement airBoolToInt
Diffstat (limited to 'src')
-rw-r--r--src/arch/sparc64/CodeGen.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
index cf93ed6e4d..b77d76a10e 100644
--- a/src/arch/sparc64/CodeGen.zig
+++ b/src/arch/sparc64/CodeGen.zig
@@ -585,7 +585,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
.fpext => @panic("TODO try self.airFpext(inst)"),
.intcast => try self.airIntCast(inst),
.trunc => @panic("TODO try self.airTrunc(inst)"),
- .bool_to_int => @panic("TODO try self.airBoolToInt(inst)"),
+ .bool_to_int => try self.airBoolToInt(inst),
.is_non_null => try self.airIsNonNull(inst),
.is_non_null_ptr => @panic("TODO try self.airIsNonNullPtr(inst)"),
.is_null => try self.airIsNull(inst),
@@ -985,6 +985,13 @@ fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
}
+fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
+ const un_op = self.air.instructions.items(.data)[inst].un_op;
+ const operand = try self.resolveInst(un_op);
+ const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
+ return self.finishAir(inst, result, .{ un_op, .none, .none });
+}
+
fn airPtrArithmetic(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;