diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-07-27 17:08:37 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-27 17:08:37 -0700 |
| commit | dc88864c9742029c2980fc16cd2c9e6f04ff3568 (patch) | |
| tree | 2569f14d189ef238ca7a281774e09ba49374113b /src/codegen.zig | |
| parent | 66e5920dc3411daa4f0c84a8f4c733c1263e8523 (diff) | |
| download | zig-dc88864c9742029c2980fc16cd2c9e6f04ff3568.tar.gz zig-dc88864c9742029c2980fc16cd2c9e6f04ff3568.zip | |
stage2: implement `@boolToInt`
This is the first commit in which some behavior tests are passing for
both stage1 and stage2.
Diffstat (limited to 'src/codegen.zig')
| -rw-r--r-- | src/codegen.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/codegen.zig b/src/codegen.zig index 4924b68ca3..3b822c0f88 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -835,6 +835,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .dbg_stmt => try self.airDbgStmt(inst), .floatcast => try self.airFloatCast(inst), .intcast => try self.airIntCast(inst), + .bool_to_int => try self.airBoolToInt(inst), .is_non_null => try self.airIsNonNull(inst), .is_non_null_ptr => try self.airIsNonNullPtr(inst), .is_null => try self.airIsNull(inst), @@ -1110,6 +1111,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.finishAir(inst, result, .{ ty_op.operand, .none, .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 airNot(self: *Self, inst: Air.Inst.Index) !void { const ty_op = self.air.instructions.items(.data)[inst].ty_op; const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
