diff options
author | Chaitanya Koparkar <ckoparkar@gmail.com> | 2025-08-21 07:52:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-21 12:52:18 +0100 |
commit | ad63a70d6da0fd2a1b6033d44c278eb9f6b3c2d3 (patch) | |
tree | f05456736873f639dd22017e593886dc063c2721 /llvm/lib/Support/APInt.cpp | |
parent | 35f01cea6551f577133200e29d160d35fa4b76f4 (diff) | |
download | llvm-ad63a70d6da0fd2a1b6033d44c278eb9f6b3c2d3.zip llvm-ad63a70d6da0fd2a1b6033d44c278eb9f6b3c2d3.tar.gz llvm-ad63a70d6da0fd2a1b6033d44c278eb9f6b3c2d3.tar.bz2 |
[ADT] Add fshl/fshr operations to APInt (#153790)
These operations are required for #153151.
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 0c0e1d0..f6fd5f9 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -3169,3 +3169,21 @@ APInt APIntOps::pow(const APInt &X, int64_t N) { } return Acc; } + +APInt llvm::APIntOps::fshl(const APInt &Hi, const APInt &Lo, + const APInt &Shift) { + assert(Hi.getBitWidth() == Lo.getBitWidth()); + unsigned ShiftAmt = rotateModulo(Hi.getBitWidth(), Shift); + if (ShiftAmt == 0) + return Hi; + return Hi.shl(ShiftAmt) | Lo.lshr(Hi.getBitWidth() - ShiftAmt); +} + +APInt llvm::APIntOps::fshr(const APInt &Hi, const APInt &Lo, + const APInt &Shift) { + assert(Hi.getBitWidth() == Lo.getBitWidth()); + unsigned ShiftAmt = rotateModulo(Hi.getBitWidth(), Shift); + if (ShiftAmt == 0) + return Lo; + return Hi.shl(Hi.getBitWidth() - ShiftAmt) | Lo.lshr(ShiftAmt); +} |