1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

31 Commits

Author SHA1 Message Date
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
Reid Spencer
d22266f456 Review changes:
1. Function style changes.
2. 80-col violations.
3. Better names for things.
4. Arrange constructors so they all take bit width first.
5. Add named signed and unsigned comparison functions and remove the
   corresponding operators.
6. Remove operator&& and operator|| but provide a getBoolValue function which
   converts to bool as comparison against 0. This allows the normal && and
   || operators to be used as if (X.getBoolValue() && Y.getBoolValue())

Note: this still doesn't function 100% yet. I'm working on the bugs now.
llvm-svn: 34353
2007-02-16 22:36:51 +00:00
Zhou Sheng
9868d8d7db Fix some buges:
1. Make getMinValue() returns the right value.
2. Fix the ByteSwap() crash problem.
3. Make Postfix increment work correctly.
4. Fix some bugs in LogBase2, Hi/LoBits and UDiv.

llvm-svn: 34304
2007-02-15 06:36:31 +00:00
Reid Spencer
80ac48cfdf Make some minor improvements to APInt:
1. Make all the operators use uppercase
2. Rename APIntRoundToDouble method just RoundToDouble, the APInt is
   redundant.
3. Turn the class on for compilation.

llvm-svn: 34253
2007-02-13 22:41:58 +00:00
Zhou Sheng
7b47556f5c 1. Make APInt::shl work correctly and more efficiently.
2. Add functions to support the numberical conversion between APInt and
   double/float.

llvm-svn: 34201
2007-02-12 20:02:55 +00:00
Zhou Sheng
20d0f4e319 Eliminates friend function declaration inside APInt, instead, adds public
methods as those global function's internal implementation.

llvm-svn: 34083
2007-02-09 07:48:24 +00:00
Zhou Sheng
6efcdc8049 As Chris and Reid suggested, remove "isSigned" field from APInt, instead,
add some signed/unsigned arithmetic operation functions into APInt.h to
handle the signed/unsigned issue. These functions will be defined inside a
namespace "APIntOps" which is inside llvm namespace.

llvm-svn: 34053
2007-02-08 14:35:19 +00:00
Lauro Ramos Venancio
30734ef2e7 Fix build error.
include/llvm/ADT/APInt.h:326: error: ‘assert’ was not declared in this scope

llvm-svn: 34002
2007-02-07 16:59:17 +00:00
Zhou Sheng
7881ec420f As Chris suggested, fixed some problems. (This is the first part.)
llvm-svn: 33986
2007-02-07 05:58:38 +00:00
Zhou Sheng
8eba14bd31 As Reid suggested, fixed some problems.
llvm-svn: 33954
2007-02-06 05:59:47 +00:00
Zhou Sheng
4967eb71b1 Add a class APInt to represent arbitrary precision constant integral values.
It is a functional replacement for common case integer type like "unsigned",
"uint64_t", but also allows non-byte-width integer type and large integer
value types such as 3-bits, 15-bits, or more than 64-bits of precision. For
more details, see pr1043.

llvm-svn: 33913
2007-02-05 17:29:16 +00:00