aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorWilliam Sengir <william@sengir.com>2022-03-19 23:49:53 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-21 16:54:19 -0700
commitb96699059c6224b0a425f2fe5010469ef6049cad (patch)
tree652a5a4a0950ecb9dbc08e1d122b0f53f7736d6a /src/codegen/llvm.zig
parent0f4830704171b734bb4a0235fc14809282457dc3 (diff)
downloadzig-b96699059c6224b0a425f2fe5010469ef6049cad.tar.gz
zig-b96699059c6224b0a425f2fe5010469ef6049cad.zip
stage2: implement `cmp_vector` for LLVM backend
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index edf8992c56..a90a2eeda3 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -3642,8 +3642,17 @@ pub const FuncGen = struct {
}
fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
- _ = inst;
- return self.todo("implement airCmpVector");
+ if (self.liveness.isUnused(inst)) return null;
+
+ const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ const extra = self.air.extraData(Air.VectorCmp, ty_pl.payload).data;
+
+ const lhs = try self.resolveInst(extra.lhs);
+ const rhs = try self.resolveInst(extra.rhs);
+ const vec_ty = self.air.typeOf(extra.lhs);
+ const cmp_op = extra.compareOperator();
+
+ return self.cmp(lhs, rhs, vec_ty, cmp_op);
}
fn cmp(
@@ -3656,9 +3665,10 @@ pub const FuncGen = struct {
var int_buffer: Type.Payload.Bits = undefined;
var opt_buffer: Type.Payload.ElemType = undefined;
- const int_ty = switch (operand_ty.zigTypeTag()) {
- .Enum => operand_ty.intTagType(&int_buffer),
- .Int, .Bool, .Pointer, .ErrorSet => operand_ty,
+ const scalar_ty = operand_ty.scalarType();
+ const int_ty = switch (scalar_ty.zigTypeTag()) {
+ .Enum => scalar_ty.intTagType(&int_buffer),
+ .Int, .Bool, .Pointer, .ErrorSet => scalar_ty,
.Optional => blk: {
const payload_ty = operand_ty.optionalChild(&opt_buffer);
if (!payload_ty.hasRuntimeBitsIgnoreComptime() or operand_ty.isPtrLikeOptional()) {