diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2026-02-02 14:28:16 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2026-02-02 14:28:16 +0000 |
| commit | bb7496a2fcc58238a4e3abcc431313385a15183f (patch) | |
| tree | 1bced935d1c3ad3b74dc530cc60d95a103b0db28 /src/llvm_backend_utility.cpp | |
| parent | 80c948277455eb9deaf79ac910fdc8957038fb75 (diff) | |
Add `intrinsics.count_trailing_ones` and `intrinsics.count_leading_ones`
Diffstat (limited to 'src/llvm_backend_utility.cpp')
| -rw-r--r-- | src/llvm_backend_utility.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 367e7be75..8a7bced59 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -648,6 +648,18 @@ gb_internal lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type return res; } +gb_internal lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type); + +gb_internal lbValue lb_emit_count_trailing_ones(lbProcedure *p, lbValue x, Type *type) { + lbValue z = lb_emit_unary_arith(p, Token_Xor, x, type); + return lb_emit_count_trailing_zeros(p, z, type); +} + +gb_internal lbValue lb_emit_count_leading_ones(lbProcedure *p, lbValue x, Type *type) { + lbValue z = lb_emit_unary_arith(p, Token_Xor, x, type); + return lb_emit_count_leading_zeros(p, z, type); +} + gb_internal lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type) { |