summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ADT/APInt.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 5c8e0ee553d..3d479da4b83 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -450,6 +450,15 @@ public:
/// @brief Zero extend or truncate to width
APInt &zextOrTrunc(uint32_t width);
+ /// This is a help function for convenience. If the given \p width equals to
+ /// this APInt's BitWidth, just return this APInt, otherwise, just zero
+ /// extend it.
+ inline APInt &zextOrCopy(uint32_t width) {
+ if (width == BitWidth)
+ return *this;
+ return zext(width);
+ }
+
/// @brief Set every bit to 1.
APInt& set();
OpenPOWER on IntegriCloud