diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-29 17:48:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-29 17:49:02 -0700 |
| commit | d6067db06267e37dec65202667741bc1b63fe980 (patch) | |
| tree | a693698a60b30a7d0ca2764056858c8b74066cd7 /src/codegen.zig | |
| parent | 5ff01bd820ea08005a422f046ad5bbad663b0dab (diff) | |
| download | zig-d6067db06267e37dec65202667741bc1b63fe980.tar.gz zig-d6067db06267e37dec65202667741bc1b63fe980.zip | |
stage2: implement `@popCount` for non-vectors
Diffstat (limited to 'src/codegen.zig')
| -rw-r--r-- | src/codegen.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/codegen.zig b/src/codegen.zig index 374a9353e1..82aa9430e8 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -836,6 +836,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .get_union_tag => try self.airGetUnionTag(inst), .clz => try self.airClz(inst), .ctz => try self.airCtz(inst), + .popcount => try self.airPopcount(inst), .atomic_store_unordered => try self.airAtomicStore(inst, .Unordered), .atomic_store_monotonic => try self.airAtomicStore(inst, .Monotonic), @@ -1610,6 +1611,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); } + fn airPopcount(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 switch (arch) { + else => return self.fail("TODO implement airPopcount for {}", .{self.target.cpu.arch}), + }; + return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); + } + fn reuseOperand(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, op_index: Liveness.OperandInt, mcv: MCValue) bool { if (!self.liveness.operandDies(inst, op_index)) return false; |
