commit 61265fba04001e7802cb3e3dc9bca50032afc8e3 (tree)
parent 4fc6df9f62f540fccc83bfe1723f37cf1f60d446
Author: Koakuma <koachan@protonmail.com>
Date: Fri, 8 Jul 2022 20:42:40 +0700
stage2: sparc64: Implement airBinop for bool_and/or
Diffstat:
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
@@ -548,8 +548,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
.cmp_vector => @panic("TODO try self.airCmpVector(inst)"),
.cmp_lt_errors_len => try self.airCmpLtErrorsLen(inst),
- .bool_and => @panic("TODO try self.airBoolOp(inst)"),
- .bool_or => @panic("TODO try self.airBoolOp(inst)"),
+ .bool_and => try self.airBinOp(inst, .bool_and),
+ .bool_or => try self.airBinOp(inst, .bool_or),
.bit_and => try self.airBinOp(inst, .bit_and),
.bit_or => try self.airBinOp(inst, .bit_or),
.xor => try self.airBinOp(inst, .xor),
@@ -2525,6 +2525,26 @@ fn binOp(
}
},
+ .bool_and,
+ .bool_or,
+ => {
+ switch (lhs_ty.zigTypeTag()) {
+ .Bool => {
+ assert(lhs != .immediate); // should have been handled by Sema
+ assert(rhs != .immediate); // should have been handled by Sema
+
+ const mir_tag: Mir.Inst.Tag = switch (tag) {
+ .bool_and => .@"and",
+ .bool_or => .@"or",
+ else => unreachable,
+ };
+
+ return try self.binOpRegister(mir_tag, lhs, rhs, lhs_ty, rhs_ty, metadata);
+ },
+ else => unreachable,
+ }
+ },
+
.shl => {
const base_tag: Air.Inst.Tag = switch (tag) {
.shl => .shl_exact,