Reid Spencer
091d6cf3b7
Don't invoke undefined behavior in shifts in the functions getHighBitsSet
...
and getLowBitsSet.
llvm-svn: 35311
2007-03-24 23:35:54 +00:00
Reid Spencer
0e466b183f
Implement the getBitsSet function.
...
llvm-svn: 35310
2007-03-24 23:27:48 +00:00
Reid Spencer
1aa3f64ef4
Implement the getHighBitsSet and getLowBitsSet functions.
...
llvm-svn: 35308
2007-03-24 23:05:35 +00:00
Reid Spencer
30351837ca
Get the signs in the right place!
...
llvm-svn: 35307
2007-03-24 22:50:43 +00:00
Reid Spencer
0ceb493ee2
Undo the last change and make this really implement remainder and not
...
modulus. The previous change was a result of incorrect documentation in
the LangRef.html.
llvm-svn: 35305
2007-03-24 22:37:23 +00:00
Reid Spencer
c1dfceab8b
Correct the implementation of srem to be remainder, not modulus. The sign of
...
the result must follow the sign of the divisor.
llvm-svn: 35302
2007-03-24 21:56:22 +00:00
Reid Spencer
52ea41bb97
Clean up this interface:
...
1. Group similar methods into doxygen groups
2. Reorganize the groups into a consist flow.
3. Significantly improve the quality of the documentation on several methods
4. Rewrite srem and sdiv to eliminate a copy and improve readability.
5. Eliminate unneeded forward references.
llvm-svn: 35300
2007-03-24 18:09:18 +00:00
Reid Spencer
76c1fef30a
Fix a comment.
...
llvm-svn: 35246
2007-03-21 22:22:19 +00:00
Zhou Sheng
a9c0018850
Correct the name: isStrictPositive --> isStrictlyPositive.
...
llvm-svn: 35201
2007-03-20 02:18:16 +00:00
Chris Lattner
305c3525af
Add a dtor to fix leaks from all clients of BitVector.
...
llvm-svn: 35200
2007-03-20 02:10:56 +00:00
Reid Spencer
c3422e56d6
Add an indication of signedness to the uint64_t constructor so sign bits
...
can be extended. This helps fix test/Assembler/2007-03-19-NegValue.ll
llvm-svn: 35179
2007-03-19 20:36:48 +00:00
Zhou Sheng
6ecf1045a6
Add isStrictPositive() to APInt to determine if this APInt Value > 0.
...
llvm-svn: 35156
2007-03-19 05:22:18 +00:00
Zhou Sheng
dfcf9376bc
Add zextOrCopy() into APInt for convenience.
...
llvm-svn: 35079
2007-03-13 06:16:26 +00:00
Zhou Sheng
9643d0a422
Add getSignBit() and operator<<= into APInt for convenience.
...
llvm-svn: 35059
2007-03-11 07:16:10 +00:00
Jeff Cohen
84d84f7381
The hack won't work on VS 2005, and it might not be needed anyway.
...
llvm-svn: 34930
2007-03-05 17:22:33 +00:00
Zhou Sheng
b6d1ac8682
Correct the calculation in APInt::logBase2().
...
llvm-svn: 34929
2007-03-05 16:42:58 +00:00
Jeff Cohen
b58af23ff3
Elminate tabs and improve comments.
...
llvm-svn: 34921
2007-03-05 00:46:22 +00:00
Jeff Cohen
98c99a3a02
Unbreak VC++ build.
...
llvm-svn: 34917
2007-03-05 00:00:42 +00:00
Chris Lattner
2510829eba
add iterator range version of ctor.
...
llvm-svn: 34899
2007-03-04 04:04:43 +00:00
Reid Spencer
e2bf55dfe8
Regularize the interface for conversion functions to/from float/double.
...
llvm-svn: 34881
2007-03-03 08:34:02 +00:00
Reid Spencer
503dda5840
Make getNumWords public so that those using getRawData stand a chance of
...
not reading beyond the end of the buffer returned.
llvm-svn: 34873
2007-03-03 06:17:23 +00:00
Reid Spencer
47b01d6acb
Add names for some of the operators. This is needed for the macros in
...
the Interpreter.
llvm-svn: 34872
2007-03-03 05:37:23 +00:00
Reid Spencer
e5244b132b
Add isPositive for symmetry with isNegative.
...
llvm-svn: 34862
2007-03-03 00:24:39 +00:00
Chris Lattner
68244ce570
Fix PR1234 by working around a compiler bug.
...
llvm-svn: 34845
2007-03-02 18:16:29 +00:00
Evan Cheng
44257955c8
Make it 64-bit safe.
...
llvm-svn: 34829
2007-03-02 02:31:37 +00:00
Reid Spencer
d86182b19b
Add an abs() function to get the absolute value.
...
llvm-svn: 34819
2007-03-01 23:37:09 +00:00
Reid Spencer
003170430b
Add doubleToBits and floatToBits methods.
...
llvm-svn: 34807
2007-03-01 20:39:01 +00:00
Reid Spencer
90b6227b81
Add bitsToDouble and bitsToFloat methods for re-interpretation of bits as FP.
...
llvm-svn: 34800
2007-03-01 20:06:51 +00:00
Reid Spencer
6a95676875
Add methods for bit width modification: sextOrTrunc, zextOrTrunc.
...
llvm-svn: 34789
2007-03-01 17:15:32 +00:00
Reid Spencer
b6dd32889e
Add a square root function.
...
llvm-svn: 34775
2007-03-01 05:39:56 +00:00
Reid Spencer
0f2d45e42c
Make APInt a little more friendly to its users:
...
* Add support for + and - of a uint64_t.
* Make trunc/sext/zext return *this so it can be chained with other ops
* Add smin, smax, umin, umax functions for getting min/max values.
llvm-svn: 34742
2007-02-28 17:33:36 +00:00
Reid Spencer
949b3612a8
getActiveWords should return the number of words, not the index of the
...
highest active words. Increment its result by one.
llvm-svn: 34713
2007-02-28 02:20:49 +00:00
Reid Spencer
355cec42d1
Add some syntactic sugar.
...
llvm-svn: 34704
2007-02-27 23:47:33 +00:00
Reid Spencer
edbe747bab
Implement countLeadingOnes() and getMinSignedBits(). This helps to minimize
...
the bit width of negative numbers by computing the minimum bit width for a
negative value. E.g. 0x1800000000000000 could be just 0x8000000000000000
llvm-svn: 34695
2007-02-27 21:59:26 +00:00
Reid Spencer
9e66d0921a
Improve APInt interface:
...
1. Add unsigned and signed versions of methods so a "bool" argument doesn't
need to be passed in.
2. Make the various getMin/getMax functions all be inline since they are
so simple.
3. Simplify sdiv and srem code.
llvm-svn: 34680
2007-02-27 20:24:31 +00:00
Reid Spencer
612dfe195b
Allow the RoundDoubleToAPInt function to specify a width to use.
...
llvm-svn: 34672
2007-02-27 18:22:31 +00:00
Reid Spencer
9bc19eab08
Fix indentation.
...
llvm-svn: 34643
2007-02-26 21:06:05 +00:00
Reid Spencer
18629544d3
1. Split getValue() into getSExtValue() and getZExtValue() to match
...
ConstantInt better.
2. Add a getHashValue() method.
llvm-svn: 34641
2007-02-26 20:57:12 +00:00
Reid Spencer
11f19f730c
Implement inline methods that make transition of ConstantInt to use APInt
...
easier to comprehend and might be useful elsewhere.
llvm-svn: 34635
2007-02-26 17:50:32 +00:00
Reid Spencer
1252a271a1
Make isNegative() a const function since it doesn't modify the APInt.
...
llvm-svn: 34630
2007-02-26 07:45:40 +00:00
Reid Spencer
e8e8ea4fba
Add an isNegative method to determine if the APInt's value is negative.
...
This is much less expensive than a test against zero.
llvm-svn: 34619
2007-02-26 01:20:59 +00:00
Reid Spencer
a4ab1c36d2
Fix clearUnusedBits to not depend on "undefined behavior" of >> operator
...
when the bit size is equal to the word size. This happens to work out okay
on x86, but might not on other platforms. The change just detects when
there are no bits to clear (because BitWidth is a multiple of the word size)
and returns early.
Also, move some comments from .cpp file into header.
llvm-svn: 34602
2007-02-25 19:26:01 +00:00
Reid Spencer
e7d8a0e3b7
Add a private constructor for efficiency.
...
llvm-svn: 34580
2007-02-25 07:29:03 +00:00
Reid Spencer
a2a4a55915
Improve documentation.
...
Make divide function internal (it was briefly external for testing).
llvm-svn: 34557
2007-02-24 09:50:13 +00:00
Reid Spencer
807eadb51a
Add a dump() method for debugging.
...
llvm-svn: 34464
2007-02-21 03:56:12 +00:00
Reid Spencer
2e50b9ed5b
Add an internal convenience method for division that urem and udiv use.
...
llvm-svn: 34448
2007-02-20 08:43:42 +00:00
Reid Spencer
6eb099875c
Add some new constants.
...
llvm-svn: 34398
2007-02-19 03:18:22 +00:00
Reid Spencer
79d2fad9f5
1. "unsigned" -> "uint32_t" to gaurantee its bit width on all platforms.
...
Size matters in this case.
2. Remove the unused whichByte private function, which was also broken.
3. Remove the non-const overload of the getWord function, getWord() is
never used as an lvalue.
4. Rename some local variables for clarity (e.g. API -> Result).
llvm-svn: 34390
2007-02-18 18:42:35 +00:00
Reid Spencer
62b55a934b
Implement signed output for toString.
...
Fix bugs in countLeadingZeros and countTrailingZeros.
llvm-svn: 34386
2007-02-18 00:44:22 +00:00
Reid Spencer
9c5efbcef2
Fix bugs introduced by constructor parameter order change.
...
llvm-svn: 34357
2007-02-17 00:18:01 +00:00