1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

558 Commits

Author SHA1 Message Date
Reid Spencer
728cf2d5cf Re-enable this. The header was committed.
llvm-svn: 34634
2007-02-26 08:10:54 +00:00
Chris Lattner
4b7b0a145a another missing header :( :( :(
llvm-svn: 34632
2007-02-26 07:51:00 +00:00
Reid Spencer
050bd4479e 1. Remove redundant calls to clearUsedBits().
2. Fix countTrailingZeros to use a faster algorithm.
3. Simplify sext() slightly by using isNegative().
4. Implement ashr using word-at-a-time logic instead of bit-at-a-time
5. Rename locals named isNegative so they don't clash with method name.
6. Fix fromString to compute negated value correctly.

llvm-svn: 34629
2007-02-26 07:44:38 +00:00
Reid Spencer
6177d67365 Rewrite lshr to not do bit by bit copy but to copy and shift whole words.
This makes it much more efficient.

llvm-svn: 34618
2007-02-26 01:19:48 +00:00
Reid Spencer
82a5b300ad Fix sext operation. Shifting by zero would leave an incorrect mask.
llvm-svn: 34617
2007-02-25 23:54:00 +00:00
Reid Spencer
c0d07ad61a 1. Fix the flip() method to correctly flip all words of the APInt.
2. Implement the trunc, sext, and zext operations.
3. Improve fromString to accept negative values as input.

llvm-svn: 34616
2007-02-25 23:44:53 +00:00
Reid Spencer
e6f7201099 1. Provide more detail in file comment.
2. Move comments for methods to .h file, delete them in .cpp file.
3. All places that were doing manual clear of high order bits now call the
   clearUnusedBits() method in order to not depend on undefined behavior
   of the >> operator when the number of bits shifted equals the word size.
4. Reduced # of loc by using the new result of clearUnusedBits() method.
5. Simplified logic (decreased indentation) in a few places.
6. Added code comments to larger functions that needed them.
7. Added FIXME notes about weak implementations of things (e.g. bit-by-bit
   shift right is sub-optimal).

llvm-svn: 34603
2007-02-25 19:32:03 +00:00
Reid Spencer
ec6159bbea Allow this to compile now that the header file is checked in.
llvm-svn: 34581
2007-02-25 07:30:14 +00:00
Chris Lattner
5adebeb207 this doesn't compile, disable it
llvm-svn: 34571
2007-02-25 02:32:44 +00:00
Reid Spencer
0fd90c3447 Clean up lshr and ashr to coding standards.
Handle the single word cases for shiftAmt == BitWidth.

llvm-svn: 34569
2007-02-25 01:56:07 +00:00
Reid Spencer
66e162cfcd Whoops, last word with bits in large shift left wasn't correct.
llvm-svn: 34565
2007-02-25 01:08:58 +00:00
Reid Spencer
4dcbccdc99 Fix the > 64 bits case for left shift.
llvm-svn: 34564
2007-02-25 00:56:44 +00:00
Reid Spencer
ecc067a698 Fix the remainder shifting in KnuthDiv.
llvm-svn: 34562
2007-02-24 20:38:01 +00:00
Reid Spencer
d6956a0e8c 1. Fix a bug in fromString for the <= 64bits case
2. Fix shl when shiftAmount == BitWidth.

llvm-svn: 34560
2007-02-24 20:19:37 +00:00
Reid Spencer
e2bb0cf83e 1. Fix last bug in KnuthDiv. All divide tests pass up to 1024 bits now.
2. Clean up comments, style, coding standards, etc.
3. Simplify a constructor.

Extended testing revealed some additional bugs in shifting. I'll fix these
tomorrow.

llvm-svn: 34559
2007-02-24 10:01:42 +00:00
Reid Spencer
b45646b14e 1. Make internal functions take const arguments where they should, just
to be safe.
2. Make internal functions that return a carry/borrow return bool instead
   of uint64_t because the carry/borrow can only be in range [0,1].
3. Assert that the pointers to KnuthDiv are all different so that the
   result and operands can't overlap.
4. Add debug output to KnuthDiv function.
5. Fix a problem with KnuthDiv by separating the b's complement operation
   from the subtraction borrow operation. This fixes a wide range of
   division problems, but alas, not all of them.

llvm-svn: 34554
2007-02-24 03:58:46 +00:00
Chris Lattner
e37ee33c4e remove folding set debug output
llvm-svn: 34549
2007-02-24 01:41:48 +00:00
Chris Lattner
042d3195c9 Avoid TBAA issue.
llvm-svn: 34539
2007-02-23 22:31:24 +00:00
Reid Spencer
3573b012d3 1. Fix a carry out problem in add if destination and x point to the same
memory (as done in fromString).
2. Implement Knuth divide more closely to what is recommended in his book.
3. Fix computation of the remainder for Knuth Divide (bad shifting).
4. Remove some cruft from the file

llvm-svn: 34518
2007-02-23 01:57:13 +00:00
Reid Spencer
cbff120eeb When converting from 64 to 32-bits, use the actual number of words to
extract the value, not the number of words implied by the active bits.
This fixes numerous, but not all divide bugs.

llvm-svn: 34484
2007-02-22 00:58:45 +00:00
Reid Spencer
d51b03d452 Fix countLeadingZeros in the case that the bitwidth evenly divides the
word size. This fixes all reads of uninitialized data (buffer over read)
and makes APInt.cpp memory clean, per valgrind. The only remaining
problem is division in a few cases.

llvm-svn: 34483
2007-02-22 00:22:00 +00:00
Reid Spencer
df5fe8163d Reorganize some code to make it clearer, avoid a few uninitialized memory
reads, and reduce the number of temporary APInt instances we construct.

llvm-svn: 34467
2007-02-21 08:21:52 +00:00
Reid Spencer
95874f6bc9 Fix the carry in addition.
llvm-svn: 34465
2007-02-21 05:44:56 +00:00
Reid Spencer
c4662ad089 1. Add a dump() method for faster debugging.
2. Change 0 initialization of union to larger component so all is zeroed.
3. Fix the borrow logic in subtraction so it works for > 128 bits.
4. Rewrite fromString to use a simpler but correct algorithm and also to
   not set the bit width contrary to the user's request.
5. Optimize toString a bit by making it only do one Knuth divide per
   iteration instead of two.

With these changes, all arithmetic passes (verified by pari/GP) up to
1024 bits except for certain division cases.

llvm-svn: 34463
2007-02-21 03:55:44 +00:00
Reid Spencer
1fbf856864 Fix countLeadingZeros to actually return the correct number.
Fix toString to correctly return "0" for zero valued APInts over 128 bits.

llvm-svn: 34459
2007-02-21 00:29:48 +00:00
Reid Spencer
17d47c5062 Make long addition and subtraction work. Speed things up by using internal
functions more.

llvm-svn: 34458
2007-02-20 23:40:25 +00:00
Reid Spencer
b27fcd8cb6 Clean up variable names in operator*.
Attempt #3 for getting a portable INFINITY value.

llvm-svn: 34454
2007-02-20 20:42:10 +00:00
Reid Spencer
4caebb1af8 Use INFINITY macro from math.h instead of constructing hex floating point
constants (avoids warnings).

llvm-svn: 34452
2007-02-20 18:29:12 +00:00
Reid Spencer
80b41ab5f7 First version that can process arith.cpp test case up to 1024 bits:
1. Ensure pVal is set to 0 in each constructor.
2. Fix roundToDouble to make correct calculations and not read beyond the
   end of allocated memory.
3. Implement Knuth's "classical algorithm" for division from scratch and
   eliminate buffer overflows and uninitialized mememory reads. Document
   it properly too.
4. Implement a wrapper function for KnuthDiv which handles the 64-bit to
   32-bit conversion and back. It also implement short division for the
   n == 1 case that Knuth's algorithm can't handle.
5. Simplify the logic of udiv and urem a little, make them exit early, and
   have them use the "divide" wrapper function to perform the division
   or remainder operation.
6. Move the toString function to the end of the file, closer to where
   the division functions are located.

Note: division is still broken for some > 64 bit values, but at least it
      doesn't crash any more.
llvm-svn: 34449
2007-02-20 08:51:03 +00:00
Chris Lattner
b22fb7fc60 Not all managedstatics need object pointers.
llvm-svn: 34444
2007-02-20 06:18:57 +00:00
Reid Spencer
a177605511 1. Fix some indentation and variable names in the get{Min,Max}Value methods.
2. Implement toString for power-of-2 radix without using divide and always
   printing full words. This allows hex/binary to look at the bit
   respresentation of the APInt as well as avoid bugs in divide.

llvm-svn: 34396
2007-02-18 22:29:05 +00:00
Reid Spencer
ce1322ccf6 1. Use APINT_WORD_SIZE instead of sizeof(uint64_t)
2. Teach slt about signedness.
3. Teach roundToDouble to properly sign extend.

llvm-svn: 34391
2007-02-18 20:09:41 +00:00
Reid Spencer
035cf2fca2 1. Remove dead code (lshift function).
2. Consolidate memory allocation into just two inline functions.
3. Convert "unsigned" to uint32_t to gaurantee its size.
4. Eliminate magic constants and replace with symbolic equivalent.
5. Improve code documentation slightly.
6. Simplify the logical operator code because bitwidths must be the same.
7. Fix indentation per coding standards.
8. Use exit-early style to reduce indentation in several functions.

llvm-svn: 34389
2007-02-18 18:38:44 +00:00
Reid Spencer
19f4e9457e Make add_1 exit early if carry is 0.
Fix line breaks and 80 cols violation.
Simplify operator^= since bitwidths must be the same.

llvm-svn: 34388
2007-02-18 06:39:42 +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
3390126870 Fix some bugs in division logic.
llvm-svn: 34384
2007-02-17 22:38:07 +00:00
Reid Spencer
401a49c4e2 Move static functions closer to their usage.
llvm-svn: 34363
2007-02-17 03:16:00 +00:00
Reid Spencer
31731e9a99 Clean up the divide and remainder logic a bit (exit early). Use more
meaningful variable names. Add comments to document the flow.

llvm-svn: 34362
2007-02-17 02:07:07 +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
Anton Korobeynikov
87e945c62d Add possibility to set memory limit for binaries run via libSystem. This
is especially needed for bugpoint. This partly implements PR688

llvm-svn: 34349
2007-02-16 19:11:07 +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
5e1e7c4e59 Use brute-force algorithm for to_string. It doesn't have to be efficient
at this point, it just needs to work so we can test things reliably.

llvm-svn: 34262
2007-02-14 02:52:25 +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
Chris Lattner
ce3f5f906a Add support for removing elements out of StringMap.
llvm-svn: 34185
2007-02-11 20:58:00 +00:00
Chris Lattner
3a9d38035f Replace the ugly FindValue method with STL-like find methods.
llvm-svn: 34183
2007-02-11 19:49:41 +00:00
Chris Lattner
f1e2e9e259 remove support for stringmap visitors now that iterators exist.
llvm-svn: 34180
2007-02-11 08:22:15 +00:00
Chris Lattner
e98f4bc0ce add support for iterators.
llvm-svn: 34179
2007-02-11 08:20:35 +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
Chris Lattner
d16cc5ebcb Rename CStringMap -> StringMap, since it now supports nul characters in the
strings.

llvm-svn: 34064
2007-02-08 19:20:57 +00:00
Chris Lattner
3705cf294c Allow cstringmap to contain strings with nul characters in them.
llvm-svn: 34062
2007-02-08 19:08:37 +00:00
Zhou Sheng
a6babf6288 Switched this file on accidently.
llvm-svn: 34054
2007-02-08 16:45:48 +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
Zhou Sheng
9495a1a5c7 As Chris suggested, fixed some problems. (This is the first part)
llvm-svn: 33989
2007-02-07 06:14:53 +00:00
Chris Lattner
2c3df2a958 do not let the table fill up with tombstones.
llvm-svn: 33973
2007-02-07 01:11:25 +00:00
Zhou Sheng
cdcd2d0201 As Reid suggested, fixed some problems.
llvm-svn: 33955
2007-02-06 06:04:53 +00:00
Chris Lattner
5a58c58552 Disable this for now.
llvm-svn: 33953
2007-02-06 05:38:37 +00:00
Zhou Sheng
677cc21b01 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: 33951
2007-02-06 03:00:16 +00:00
Chris Lattner
153ccbe7f9 Fix a bug in smallptrset::erase: in the small case, return true if the
element was in the set.

llvm-svn: 33931
2007-02-05 23:10:31 +00:00
Chris Lattner
8b8100ecf5 Encode small integers more densely in foldingset, avoiding overflowing the SmallVector as often.
llvm-svn: 33864
2007-02-04 01:48:10 +00:00
Chris Lattner
9795be05c4 improve comments, add an assertion
llvm-svn: 33750
2007-02-01 05:33:21 +00:00
Devang Patel
46a1a617f5 Add PrintVersionMessage() that tools can use to print version number
without exiting program.

llvm-svn: 33737
2007-02-01 01:43:37 +00:00
Reid Spencer
6d6e7a072b Add some debug output.
llvm-svn: 33718
2007-01-31 21:27:38 +00:00
Chris Lattner
b8f4cada84 minor cleanups. Fix off-by-one in accounting the number of nodes when the
table grows.

llvm-svn: 33698
2007-01-31 06:04:41 +00:00
Chris Lattner
6bd1447e03 reformat comment
llvm-svn: 33675
2007-01-30 23:16:22 +00:00
Chris Lattner
2ca5edd29e implement SmallPtrSet::erase
llvm-svn: 33581
2007-01-27 07:59:10 +00:00
Chris Lattner
a7fec4020b add a note
llvm-svn: 33578
2007-01-27 07:18:32 +00:00
Chris Lattner
22513a4828 Add a new SmallSet ADT specialized for pointers.
llvm-svn: 33577
2007-01-27 07:10:46 +00:00
Anton Korobeynikov
2079992c16 Moved disassembler to libSystem
llvm-svn: 33461
2007-01-23 10:26:08 +00:00
Anton Korobeynikov
944088f221 Adding disassembler interface and external hook to udis86 library.
llvm-svn: 33358
2007-01-19 17:25:17 +00:00
Chris Lattner
051f1b7f78 wow, the link was already broken :)
llvm-svn: 32963
2007-01-06 23:20:51 +00:00
Chris Lattner
94f6358ce0 add a note
llvm-svn: 32962
2007-01-06 23:19:38 +00:00
Bill Wendling
05f7a367a2 The previous implementation of LLVM Streams wasn't removing symbols. This
one should.

llvm-svn: 32845
2007-01-03 22:37:27 +00:00
Chris Lattner
87e0f0787e eliminate constructor from Statistic class. It is now impossible to get a
static constructor for them :).   Transition complete.

llvm-svn: 32710
2006-12-19 23:17:40 +00:00
Chris Lattner
c18ec8716e Refactor statistic a big and introduce a horrible-but-necessary macro
(STATISTIC), which allows us to define statistics that don't introduce
static ctors into the .o files.  I'm migrating code over to use this
incrementally.

llvm-svn: 32687
2006-12-19 21:27:47 +00:00
Bill Wendling
7f6a73eb5c Added an automatic cast to "std::ostream*" etc. from OStream. We then can
rework the hacks that had us passing OStream in. We pass in std::ostream*
instead, check for null, and then dispatch to the correct print() method.

llvm-svn: 32636
2006-12-17 05:15:13 +00:00
Chris Lattner
9c52dc6c34 Change the implementation of statistic to not need destructors at all.
Instead, the stat info is printed when llvm_shutdown() is called.
These also don't need static ctors, but getting rid of them is uglier:
still investigating.  This reduces the number of static dtors in llvm from
~1400 to ~750.

llvm-svn: 32372
2006-12-08 20:00:42 +00:00
Bill Wendling
fe0af72bc4 Don't use <sstream> in Streams.h but <iosfwd> instead.
llvm-svn: 32340
2006-12-07 23:41:45 +00:00
Bill Wendling
4d1444725b Removed more <iostream> includes
llvm-svn: 32321
2006-12-07 20:28:15 +00:00
Bill Wendling
a3246c4272 Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.

llvm-svn: 32298
2006-12-07 01:30:32 +00:00
Chris Lattner
e626f6de68 merge the Statistic and StatisticBase classes, eliminating virtual methods
and eliminating #includes from the Statistic.h file.

llvm-svn: 32282
2006-12-06 18:20:44 +00:00
Chris Lattner
a531ce882e Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.

llvm-svn: 32279
2006-12-06 17:46:33 +00:00
Chris Lattner
339c732e0b Add a helper function
llvm-svn: 31981
2006-11-28 22:32:35 +00:00
Bill Wendling
d933b6630c Removed #include <iostream> and replace with llvm_* streams.
llvm-svn: 31927
2006-11-26 10:52:51 +00:00
Reid Spencer
b1fe5794f7 Make the absolute/relative tolerance information easier to read/understand.
llvm-svn: 31908
2006-11-25 08:38:44 +00:00
Bill Wendling
a3ba38284c Moved definition of llvm_ostream wrappers to the Streams.cpp file.
llvm-svn: 31819
2006-11-17 09:54:47 +00:00
Bill Wendling
dbbb5112c5 Added wrappers for the std::cerr/std::cout objects. The wrappers will
soon replace all uses of those objects.

llvm-svn: 31817
2006-11-17 09:51:22 +00:00
Bill Wendling
748f1ae70b Added "DOUT" macro. This is used as a replacement for the std::cerr
stream. It centralizes the use of std::cerr so that static c'tor/d'tors
aren't scattered around all over the place. The way to use it is like this:

       DOUT << "This is a status line: " << Var << "\n";

If "-debug" is specified, it will print. Otherwise, it'll not print. If
NDEBUG is defined, the DOUT does nothing.

llvm-svn: 31798
2006-11-17 00:49:12 +00:00
Jim Laskey
28fec74f1b Remove redundant <cmath>.
llvm-svn: 31561
2006-11-08 19:16:44 +00:00
John Criswell
335eb0232a Include llvm/Support/DataTypes.h to define intptr_t.
This fixes the build on OpenBSD and potentially other systems.

llvm-svn: 31550
2006-11-08 15:04:35 +00:00
Rafael Espindola
ef14a04371 assert.h -> cassert
llvm-svn: 31399
2006-11-03 01:38:14 +00:00
Rafael Espindola
e2f969dccb #include <assert.h>
llvm-svn: 31386
2006-11-02 23:48:53 +00:00
Jim Laskey
c770e68c11 Allow FoldingSet clients to pump up the initial hash size.
llvm-svn: 31377
2006-11-02 14:21:26 +00:00
Chris Lattner
1db6efc297 add a highly efficient hash table that is specialized for mapping C strings
to some other type.

llvm-svn: 31286
2006-10-29 23:42:03 +00:00
Chris Lattner
6a498a7658 Add a new llvm::Allocator abstraction, which will be used by a container
I'm about to add.  This is similar to, but necessarily different than, the
STL allocator class.

llvm-svn: 31285
2006-10-29 22:08:03 +00:00
Jim Laskey
0a32281238 Try again.
llvm-svn: 31278
2006-10-29 09:19:59 +00:00
Jim Laskey
7c8f89c34e Not handling zero length strings.
llvm-svn: 31277
2006-10-29 08:27:07 +00:00
Jim Laskey
d3d001e012 SmallVector append not insert.
llvm-svn: 31224
2006-10-27 19:38:32 +00:00
Jim Laskey
904dfc49e6 Grrr.
llvm-svn: 31223
2006-10-27 19:20:12 +00:00