| author | |
| committer | |
| log | f47db0a0dbf64f1fef0ba86bd9f684a5df29bc3d |
| tree | d6b639b6f06472aca726dd6c5314b5e94600ca32 |
| parent | 12d5efcbe621b98b5a99c5f84a9d5b605e4acc40 |
10 files changed, 40 insertions(+), 42 deletions(-)
src/Air.zig+5-8| ... | @@ -554,7 +554,7 @@ pub const Inst = struct { | ... | @@ -554,7 +554,7 @@ pub const Inst = struct { |
| 554 | /// Uses the `ty_pl` field with payload `Shuffle`. | 554 | /// Uses the `ty_pl` field with payload `Shuffle`. |
| 555 | shuffle, | 555 | shuffle, |
| 556 | /// Constructs a vector element-wise from `a` or `b` based on `pred`. | 556 | /// Constructs a vector element-wise from `a` or `b` based on `pred`. |
| 557 | /// Uses the `ty_pl` field with payload `Select`. | 557 | /// Uses the `pl_op` field with `pred` as operand, and payload `Bin`. |
| 558 | select, | 558 | select, |
| 559 | 559 | ||
| 560 | /// Given dest ptr, value, and len, set all elements at dest to value. | 560 | /// Given dest ptr, value, and len, set all elements at dest to value. |
| ... | @@ -788,12 +788,6 @@ pub const Shuffle = struct { | ... | @@ -788,12 +788,6 @@ pub const Shuffle = struct { |
| 788 | mask_len: u32, | 788 | mask_len: u32, |
| 789 | }; | 789 | }; |
| 790 | 790 | ||
| 791 | pub const Select = struct { | ||
| 792 | pred: Inst.Ref, | ||
| 793 | a: Inst.Ref, | ||
| 794 | b: Inst.Ref, | ||
| 795 | }; | ||
| 796 | |||
| 797 | pub const VectorCmp = struct { | 791 | pub const VectorCmp = struct { |
| 798 | lhs: Inst.Ref, | 792 | lhs: Inst.Ref, |
| 799 | rhs: Inst.Ref, | 793 | rhs: Inst.Ref, |
| ... | @@ -965,7 +959,6 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { | ... | @@ -965,7 +959,6 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { |
| 965 | .cmpxchg_weak, | 959 | .cmpxchg_weak, |
| 966 | .cmpxchg_strong, | 960 | .cmpxchg_strong, |
| 967 | .slice, | 961 | .slice, |
| 968 | .select, | ||
| 969 | .shuffle, | 962 | .shuffle, |
| 970 | .aggregate_init, | 963 | .aggregate_init, |
| 971 | .union_init, | 964 | .union_init, |
| ... | @@ -1077,6 +1070,10 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { | ... | @@ -1077,6 +1070,10 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { |
| 1077 | .reduce => return air.typeOf(datas[inst].reduce.operand).childType(), | 1070 | .reduce => return air.typeOf(datas[inst].reduce.operand).childType(), |
| 1078 | 1071 | ||
| 1079 | .mul_add => return air.typeOf(datas[inst].pl_op.operand), | 1072 | .mul_add => return air.typeOf(datas[inst].pl_op.operand), |
| 1073 | .select => { | ||
| 1074 | const extra = air.extraData(Air.Bin, datas[inst].pl_op.payload).data; | ||
| 1075 | return air.typeOf(extra.lhs); | ||
| 1076 | }, | ||
| 1080 | 1077 | ||
| 1081 | .add_with_overflow, | 1078 | .add_with_overflow, |
| 1082 | .sub_with_overflow, | 1079 | .sub_with_overflow, |
src/Liveness.zig+3-2| ... | @@ -434,8 +434,9 @@ fn analyzeInst( | ... | @@ -434,8 +434,9 @@ fn analyzeInst( |
| 434 | return extra_tombs.finish(); | 434 | return extra_tombs.finish(); |
| 435 | }, | 435 | }, |
| 436 | .select => { | 436 | .select => { |
| 437 | const extra = a.air.extraData(Air.Select, inst_datas[inst].ty_pl.payload).data; | 437 | const pl_op = inst_datas[inst].pl_op; |
| 438 | return trackOperands(a, new_set, inst, main_tomb, .{ extra.pred, extra.a, extra.b }); | 438 | const extra = a.air.extraData(Air.Bin, pl_op.payload).data; |
| 439 | return trackOperands(a, new_set, inst, main_tomb, .{ pl_op.operand, extra.lhs, extra.rhs }); | ||
| 439 | }, | 440 | }, |
| 440 | .shuffle => { | 441 | .shuffle => { |
| 441 | const extra = a.air.extraData(Air.Shuffle, inst_datas[inst].ty_pl.payload).data; | 442 | const extra = a.air.extraData(Air.Shuffle, inst_datas[inst].ty_pl.payload).data; |
src/Sema.zig+5-6| ... | @@ -14894,12 +14894,11 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -14894,12 +14894,11 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14894 | try sema.requireRuntimeBlock(block, runtime_src); | 14894 | try sema.requireRuntimeBlock(block, runtime_src); |
| 14895 | return block.addInst(.{ | 14895 | return block.addInst(.{ |
| 14896 | .tag = .select, | 14896 | .tag = .select, |
| 14897 | .data = .{ .ty_pl = .{ | 14897 | .data = .{ .pl_op = .{ |
| 14898 | .ty = try block.sema.addType(vec_ty), | 14898 | .operand = pred, |
| 14899 | .payload = try block.sema.addExtra(Air.Select{ | 14899 | .payload = try block.sema.addExtra(Air.Bin{ |
| 14900 | .pred = pred, | 14900 | .lhs = a, |
| 14901 | .a = a, | 14901 | .rhs = b, |
| 14902 | .b = b, | ||
| 14903 | }), | 14902 | }), |
| 14904 | } }, | 14903 | } }, |
| 14905 | }); | 14904 | }); |
src/arch/aarch64/CodeGen.zig+3-3| ... | @@ -3748,10 +3748,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3748,10 +3748,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 3748 | } | 3748 | } |
| 3749 | 3749 | ||
| 3750 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { | 3750 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 3751 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 3751 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 3752 | const extra = self.air.extraData(Air.Select, ty_pl.payload).data; | 3752 | const extra = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 3753 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for {}", .{self.target.cpu.arch}); | 3753 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for {}", .{self.target.cpu.arch}); |
| 3754 | return self.finishAir(inst, result, .{ extra.pred, extra.a, extra.b }); | 3754 | return self.finishAir(inst, result, .{ pl_op.operand, extra.lhs, extra.rhs }); |
| 3755 | } | 3755 | } |
| 3756 | 3756 | ||
| 3757 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { | 3757 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
src/arch/arm/CodeGen.zig+3-3| ... | @@ -4325,10 +4325,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4325,10 +4325,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 4325 | } | 4325 | } |
| 4326 | 4326 | ||
| 4327 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { | 4327 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 4328 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 4328 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 4329 | const extra = self.air.extraData(Air.Select, ty_pl.payload).data; | 4329 | const extra = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 4330 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for arm", .{}); | 4330 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for arm", .{}); |
| 4331 | return self.finishAir(inst, result, .{ extra.pred, extra.a, extra.b }); | 4331 | return self.finishAir(inst, result, .{ pl_op.operand, extra.lhs, extra.rhs }); |
| 4332 | } | 4332 | } |
| 4333 | 4333 | ||
| 4334 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { | 4334 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
src/arch/riscv64/CodeGen.zig+3-3| ... | @@ -2398,10 +2398,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2398,10 +2398,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 2398 | } | 2398 | } |
| 2399 | 2399 | ||
| 2400 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { | 2400 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 2401 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 2401 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 2402 | const extra = self.air.extraData(Air.Select, ty_pl.payload).data; | 2402 | const extra = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 2403 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for riscv64", .{}); | 2403 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for riscv64", .{}); |
| 2404 | return self.finishAir(inst, result, .{ extra.pred, extra.a, extra.b }); | 2404 | return self.finishAir(inst, result, .{ pl_op.operand, extra.lhs, extra.rhs }); |
| 2405 | } | 2405 | } |
| 2406 | 2406 | ||
| 2407 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { | 2407 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
src/arch/wasm/CodeGen.zig+3-3| ... | @@ -3269,10 +3269,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | ... | @@ -3269,10 +3269,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 3269 | fn airSelect(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | 3269 | fn airSelect(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 3270 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; | 3270 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; |
| 3271 | 3271 | ||
| 3272 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 3272 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 3273 | const ty = try self.resolveInst(ty_pl.ty); | 3273 | const operand = try self.resolveInst(pl_op.operand); |
| 3274 | 3274 | ||
| 3275 | _ = ty; | 3275 | _ = operand; |
| 3276 | return self.fail("TODO: Implement wasm airSelect", .{}); | 3276 | return self.fail("TODO: Implement wasm airSelect", .{}); |
| 3277 | } | 3277 | } |
| 3278 | 3278 |
src/arch/x86_64/CodeGen.zig+3-3| ... | @@ -5680,10 +5680,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -5680,10 +5680,10 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void { |
| 5680 | } | 5680 | } |
| 5681 | 5681 | ||
| 5682 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { | 5682 | fn airSelect(self: *Self, inst: Air.Inst.Index) !void { |
| 5683 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 5683 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 5684 | const extra = self.air.extraData(Air.Select, ty_pl.payload).data; | 5684 | const extra = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 5685 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for x86_64", .{}); | 5685 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airSelect for x86_64", .{}); |
| 5686 | return self.finishAir(inst, result, .{ extra.pred, extra.a, extra.b }); | 5686 | return self.finishAir(inst, result, .{ pl_op.operand, extra.lhs, extra.rhs }); |
| 5687 | } | 5687 | } |
| 5688 | 5688 | ||
| 5689 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { | 5689 | fn airShuffle(self: *Self, inst: Air.Inst.Index) !void { |
src/codegen/llvm.zig+5-5| ... | @@ -6359,11 +6359,11 @@ pub const FuncGen = struct { | ... | @@ -6359,11 +6359,11 @@ pub const FuncGen = struct { |
| 6359 | fn airSelect(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { | 6359 | fn airSelect(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |
| 6360 | if (self.liveness.isUnused(inst)) return null; | 6360 | if (self.liveness.isUnused(inst)) return null; |
| 6361 | 6361 | ||
| 6362 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 6362 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 6363 | const extra = self.air.extraData(Air.Select, ty_pl.payload).data; | 6363 | const extra = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 6364 | const pred = try self.resolveInst(extra.pred); | 6364 | const pred = try self.resolveInst(pl_op.operand); |
| 6365 | const a = try self.resolveInst(extra.a); | 6365 | const a = try self.resolveInst(extra.lhs); |
| 6366 | const b = try self.resolveInst(extra.b); | 6366 | const b = try self.resolveInst(extra.rhs); |
| 6367 | 6367 | ||
| 6368 | return self.builder.buildSelect(pred, a, b, ""); | 6368 | return self.builder.buildSelect(pred, a, b, ""); |
| 6369 | } | 6369 | } |
src/print_air.zig+7-6| ... | @@ -398,15 +398,16 @@ const Writer = struct { | ... | @@ -398,15 +398,16 @@ const Writer = struct { |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | fn writeSelect(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 400 | fn writeSelect(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 401 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; | 401 | const pl_op = w.air.instructions.items(.data)[inst].pl_op; |
| 402 | const extra = w.air.extraData(Air.Select, ty_pl.payload).data; | 402 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| 403 | 403 | ||
| 404 | try s.print("{}, ", .{w.air.getRefType(ty_pl.ty).fmtDebug()}); | 404 | const elem_ty = w.air.typeOfIndex(inst).childType(); |
| 405 | try w.writeOperand(s, inst, 0, extra.pred); | 405 | try s.print("{}, ", .{elem_ty.fmtDebug()}); |
| 406 | try w.writeOperand(s, inst, 0, pl_op.operand); | ||
| 406 | try s.writeAll(", "); | 407 | try s.writeAll(", "); |
| 407 | try w.writeOperand(s, inst, 1, extra.a); | 408 | try w.writeOperand(s, inst, 1, extra.lhs); |
| 408 | try s.writeAll(", "); | 409 | try s.writeAll(", "); |
| 409 | try w.writeOperand(s, inst, 2, extra.b); | 410 | try w.writeOperand(s, inst, 2, extra.rhs); |
| 410 | } | 411 | } |
| 411 | 412 | ||
| 412 | fn writeReduce(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 413 | fn writeReduce(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |