diff options
| author | William Sengir <william@sengir.com> | 2022-03-19 23:44:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-21 16:54:19 -0700 |
| commit | 0f4830704171b734bb4a0235fc14809282457dc3 (patch) | |
| tree | f14d426793b2878db30315195c068e6d28ca608d /src/codegen | |
| parent | 862e63f535ec8d65e33ed7ea67eb9cf03bfc7d6a (diff) | |
| download | zig-0f4830704171b734bb4a0235fc14809282457dc3.tar.gz zig-0f4830704171b734bb4a0235fc14809282457dc3.zip | |
stage2: add AIR instruction `cmp_vector`
The existing `cmp_*` instructions get their result type from `lhs`, but
vector comparison will always return a vector of bools with only the
length derived from its operands. This necessitates the creation of a
new AIR instruction.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 2 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 23ccdc007b..f5a1036479 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1715,6 +1715,8 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO .cmp_eq => try airEquality(f, inst, "((", "=="), .cmp_neq => try airEquality(f, inst, "!((", "!="), + .cmp_vector => return f.fail("TODO: C backend: implement binary op for tag '{s}'", .{@tagName(Air.Inst.Tag.cmp_vector)}), + // bool_and and bool_or are non-short-circuit operations .bool_and => try airBinOp(f, inst, " & "), .bool_or => try airBinOp(f, inst, " | "), diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 139c1f25cb..edf8992c56 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3375,6 +3375,7 @@ pub const FuncGen = struct { .cmp_lt => try self.airCmp(inst, .lt), .cmp_lte => try self.airCmp(inst, .lte), .cmp_neq => try self.airCmp(inst, .neq), + .cmp_vector => try self.airCmpVector(inst), .is_non_null => try self.airIsNonNull(inst, false, false, .NE), .is_non_null_ptr => try self.airIsNonNull(inst, true , false, .NE), @@ -3640,6 +3641,11 @@ pub const FuncGen = struct { return self.cmp(lhs, rhs, operand_ty, op); } + fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { + _ = inst; + return self.todo("implement airCmpVector"); + } + fn cmp( self: *FuncGen, lhs: *const llvm.Value, |
