projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
295e40a
)
Add an abs() function to get the absolute value.
author
Reid Spencer
<rspencer@reidspencer.com>
Thu, 1 Mar 2007 23:37:09 +0000
(23:37 +0000)
committer
Reid Spencer
<rspencer@reidspencer.com>
Thu, 1 Mar 2007 23:37:09 +0000
(23:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34819
91177308
-0d34-0410-b5e6-
96231b3b80d8
include/llvm/ADT/APInt.h
patch
|
blob
|
history
diff --git
a/include/llvm/ADT/APInt.h
b/include/llvm/ADT/APInt.h
index 15652a2b71b868f2a1b11cc8998c317c0c7f4844..07e22fc9828dd6bd696537c3827dcdbc039f08a9 100644
(file)
--- a/
include/llvm/ADT/APInt.h
+++ b/
include/llvm/ADT/APInt.h
@@
-759,6
+759,14
@@
public:
/// @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) {