Commit Graph

149 Commits

Author SHA1 Message Date
Daniel Dunbar
a279bc3da5 Tabs -> spaces, and remove trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 02:20:51 +00:00
Duncan Sands
b7c5bdf843 Remove some unused variables and methods warned about by
icc (#177, partial).  Patch by Erick Tryzelaar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81106 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-06 08:33:48 +00:00
Chris Lattner
91021d3390 remove the dead std::ostream APInt inserter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79875 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 23:11:28 +00:00
Erick Tryzelaar
56c39eb232 Clean up the APInt function getDigit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79602 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 06:48:37 +00:00
Eric Christopher
e250f2a5ee Update error messages for '+'. Fix grammar and make the two
negative checks resemble each other.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79595 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 04:10:31 +00:00
Eric Christopher
d37eda8c1d Fix trailing whitespace and 80-col violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79594 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 04:06:45 +00:00
Erick Tryzelaar
ae8f78d4de Fix bug with APInt::getBitsNeeded with for base 10 numbers 0-9.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79593 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 03:15:28 +00:00
Erick Tryzelaar
bb97531a5a Allow '+' to appear in APInt strings, and add more unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79592 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 03:15:14 +00:00
Daniel Dunbar
dddfd34e32 Switch to SmallString::str from SmallString::c_str, and remove
SmallString::c_str.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79456 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 20:07:03 +00:00
Daniel Dunbar
689ad6ef3f Convert APint::{fromString,APInt,getBitsNeeded} to use StringRef.
- Patch by Erick Tryzelaar, with some edits (and a bug fix) from me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 02:33:34 +00:00
Dale Johannesen
4e97a0f0cb Add attempted idiotproofing comment per review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 18:04:11 +00:00
Dale Johannesen
39c177d8b7 Fix a nondeterministic bug in APInt::roundToDouble;
when !isSingleWord() but getActiveBits() is small,
we were using the pointer value instead of the low
word of the integer value.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 17:42:34 +00:00
Torok Edwin
c23197a26f llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 16:55:14 +00:00
Daniel Dunbar
a53902b258 Switch to raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 05:27:30 +00:00
Torok Edwin
c25e7581b9 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 20:10:48 +00:00
Dan Gohman
38a253ddf7 Reapply 74494, this time removing the conflicting definition of operator<<
in APIntTest.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 20:10:56 +00:00
Bill Wendling
527b6e6292 Temporarily revert r74494. It was causing failures in the unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74515 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 07:05:27 +00:00
Dan Gohman
670031666c Define an operator<< for APInt to be used with std::ostream.
This will allow it to be used in unittests that use gtest's
EXPECT_EQ.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74494 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 01:28:08 +00:00
Evan Cheng
cf69a743b7 80 column violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 23:47:47 +00:00
Mike Stump
f3dc0c048a Fix whitespacing (space after switch).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71738 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 23:23:20 +00:00
Jay Foad
4e5ea553d0 Move helper functions for optimizing division by constant into the APInt
class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70488 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 10:15:35 +00:00
Chris Lattner
38300e91f5 Fix PR4040: APInt's string constructor is too strict
patch by Jeff Yasskin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 18:34:04 +00:00
Dan Gohman
de551f91d8 Use CHAR_BIT instead of hard-coding 8 in several places where it
is appropriate. This helps visually differentiate host-oriented
calculations from target-oriented calculations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68227 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 18:45:54 +00:00
Duncan Sands
bf5836b075 Fix comment typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67302 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 11:37:15 +00:00
Stuart Hastings
d52ec65b6d Fix a hashing bug in APInt. A certain pathological testcase (too
large for the testsuite) took over six minutes to compile on my Mac.
The patched LLVM-GCC compiles that testcase in three seconds (GCC
takes less than one second).  This hash function is more complex
(about 35 instructions on x86) than what Chris wanted, but I expect it
will be well-behaved with arbitrary inputs.

Thank you to everyone who responded to my previous request for advice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:51:13 +00:00
Torok Edwin
2d0f1c57c3 APInt's countLeadingOnes() was broken for negative i128 values,
causing assertion failures in getSExtValue().
Fix it by making highWordBits actually contain what its name says,
and add some more unit-tests for APInt.
This fixes PR3419.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63107 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 18:06:03 +00:00
Chris Lattner
455e9abf36 Remove uses of uint32_t in favor of 'unsigned' for better
compatibility with cygwin.  Patch by Jay Foad!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62695 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 18:09:24 +00:00
Nick Lewycky
4bd4787785 Fix typo, sentence fragment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62512 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 17:42:33 +00:00
Chris Lattner
119c30b955 rearrange some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57384 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-11 22:07:19 +00:00
Chris Lattner
944fac71e0 Switch the asmprinter (.ll) and all the stuff it requires over to
use raw_ostream instead of std::ostream.  Among other goodness,
this speeds up llvm-dis of kc++ with a release build from 0.85s
to 0.49s (88% faster).

Other interesting changes:
 1) This makes Value::print be non-virtual.
 2) AP[S]Int and ConstantRange can no longer print to ostream directly, 
    use raw_ostream instead.
 3) This fixes a bug in raw_os_ostream where it didn't flush itself 
    when destroyed.
 4) This adds a new SDNode::print method, instead of only allowing "dump".


A lot of APIs have both std::ostream and raw_ostream versions, it would
be useful to go through and systematically anihilate the std::ostream 
versions.

This passes dejagnu, but there may be minor fallout, plz let me know if
so and I'll fix it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55263 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 22:23:09 +00:00
Chris Lattner
98f8ccfad0 Move the fast-path (<=i64) cases of various APInt methods inline
and the slow-path cases out of line.  This speeds up instcombine
a bit in real world cases.  Patch contributed by m-s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55063 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 17:02:31 +00:00
Dan Gohman
eace52f12d It's not necessary to check if a value is null before delete[].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55053 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 14:55:37 +00:00
Chris Lattner
fad86b003a Rework the routines that convert AP[S]Int into a string. Now, instead of
returning an std::string by value, it fills in a SmallString/SmallVector
passed in.  This significantly reduces string thrashing in some cases.

More specifically, this:
 - Adds an operator<< and a print method for APInt that allows you to 
   directly send them to an ostream.
 - Reimplements APInt::toString to be much simpler and more efficient
   algorithmically in addition to not thrashing strings quite as much.

This speeds up llvm-dis on kc++ by 7%, and may also slightly speed up the
asmprinter.  This also fixes a bug I introduced into the asmwriter in a
previous patch w.r.t. alias printing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54873 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 07:19:36 +00:00
Chris Lattner
9f17eb0b79 remove a dead APInt ctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54869 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 04:58:58 +00:00
Wojciech Matyjewicz
de0f2382e4 Fix PR2088. Use modulo linear equation solver to compute loop iteration
count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53810 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-20 15:55:14 +00:00
Wojciech Matyjewicz
300c6c5167 First step to fix PR2088. Implement routine to compute the
multiplicative inverse of a given number. Modify udivrem to allow input and 
output pairs of arguments to overlap. Patch is based on the work by Chandler
Carruth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 19:39:50 +00:00
Dan Gohman
95df6b3603 Avoid creating a redundant zero APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52602 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 22:03:12 +00:00
Zhou Sheng
bfde7d6b9e As comments said, for negative value, the arithmetic
over-shift-right should return -1. So here it should be signed-extended,
when bitwidth larger than 64.

test case: llvm/test/ExecutionEngine/2008-06-05-APInt-OverAShr.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51999 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 13:27:38 +00:00
Evan Cheng
48e8c80e17 Suppress -Wshorten-64-to-32 warnings for 64-bit hosts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50590 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02 21:15:08 +00:00
Dan Gohman
3bd659ba20 Make several symbols static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49496 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 21:11:47 +00:00
Dan Gohman
cfbb2f074d A quick nm audit turned up several fixed tables and objects that were
marked read-write. Use const so that they can be allocated in a
read-only segment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48800 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-25 21:45:14 +00:00
Bill Wendling
f7a91e68a8 Add assert for non-hexadecimal radixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48421 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-16 20:05:52 +00:00
Evan Cheng
a8de38f351 Fix a typo. It's causing consumer-typeset to miscompile. Perhaps more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48035 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-07 22:39:49 +00:00
Dan Gohman
cf609575ef Add support to APInt for shift and rotate operations with APInt
instead of uint32_t for the shift/rotate count operand type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47741 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-29 01:40:47 +00:00
Ted Kremenek
a795aca96a Fixed bug in APInt::Profile() where the BitWidth field was not included in the
profile of the APSInt object. This caused unexpected Profile collisions where
none should have occurred.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47338 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-19 20:50:41 +00:00
Dan Gohman
5a0e7b41c1 Fix a warning about comparison between signed and unsigned,
being consistent with the rest of the APInt implementation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-14 22:38:45 +00:00
Dan Gohman
42dd77f207 Add countTrailingOnes member functions to APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47086 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 21:11:05 +00:00
Ted Kremenek
e420debd26 Added FoldingSet style 'profiling' support for APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:23:33 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Anton Korobeynikov
97d37260df Cygwin defines uint32_t as unsigned long. Unbreak call to std::min in this case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45342 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-24 11:16:47 +00:00