[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Thu Mar 1 15:37:26 PST 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.34 -> 1.35
---
Log message:
Add an abs() function to get the absolute value.
---
Diffs of the changes: (+8 -0)
APInt.h | 8 ++++++++
1 files changed, 8 insertions(+)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.34 llvm/include/llvm/ADT/APInt.h:1.35
--- llvm/include/llvm/ADT/APInt.h:1.34 Thu Mar 1 14:39:01 2007
+++ llvm/include/llvm/ADT/APInt.h Thu Mar 1 17:37:09 2007
@@ -759,6 +759,14 @@
/// @brief Compute the square root
APInt sqrt() const;
+
+ /// If *this is < 0 then return -(*this), otherwise *this;
+ /// @brief Get the absolute value;
+ APInt abs() const {
+ if (isNegative())
+ return -(*this);
+ return *this;
+ }
};
inline bool operator==(uint64_t V1, const APInt& V2) {
More information about the llvm-commits
mailing list