aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-27 17:08:37 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-27 17:08:37 -0700
commitdc88864c9742029c2980fc16cd2c9e6f04ff3568 (patch)
tree2569f14d189ef238ca7a281774e09ba49374113b /src/codegen/llvm.zig
parent66e5920dc3411daa4f0c84a8f4c733c1263e8523 (diff)
downloadzig-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/llvm.zig')
-rw-r--r--src/codegen/llvm.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 74a51e6634..22f117aa1c 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -961,6 +961,7 @@ pub const FuncGen = struct {
.alloc => try self.airAlloc(inst),
.arg => try self.airArg(inst),
.bitcast => try self.airBitCast(inst),
+ .bool_to_int=> try self.airBoolToInt(inst),
.block => try self.airBlock(inst),
.br => try self.airBr(inst),
.switch_br => try self.airSwitchBr(inst),
@@ -1656,6 +1657,15 @@ pub const FuncGen = struct {
return self.builder.buildBitCast(operand, dest_type, "");
}
+ fn airBoolToInt(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
+ if (self.liveness.isUnused(inst))
+ return null;
+
+ const un_op = self.air.instructions.items(.data)[inst].un_op;
+ const operand = try self.resolveInst(un_op);
+ return operand;
+ }
+
fn airArg(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
const arg_val = self.args[self.arg_index];
self.arg_index += 1;