Jay Foad
583abbc4df
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
...
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.
llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Benjamin Kramer
f1a04edb42
APInt: microoptimize a few methods.
...
llvm-svn: 120912
2010-12-04 18:05:36 +00:00
Jay Foad
25a5e4ca1f
PR5207: Rename overloaded APInt methods set(), clear(), flip() to
...
setAllBits(), setBit(unsigned), etc.
llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Jay Foad
15084f085d
PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.
...
llvm-svn: 120413
2010-11-30 09:02:01 +00:00
Dan Gohman
5ed61fe6a1
Bounds-check APInt's operator[].
...
llvm-svn: 119708
2010-11-18 17:14:56 +00:00
Chris Lattner
b9681ad442
fix a bug I introduced, no idea how this didn't repro right.
...
llvm-svn: 116462
2010-10-14 00:30:00 +00:00
Chris Lattner
698661c741
add uadd_ov/usub_ov to apint, consolidate constant folding
...
logic to use the new APInt methods. Among other things this
implements rdar://8501501 - llvm.smul.with.overflow.i32 should constant fold
which comes from "clang -ftrapv", originally brought to my attention from PR8221.
llvm-svn: 116457
2010-10-14 00:05:07 +00:00
Chris Lattner
2c819b0358
constify these methods.
...
llvm-svn: 116455
2010-10-13 23:54:10 +00:00
Chris Lattner
79bdd88fa4
add a few operations for signed operations that also
...
return an overflow flag.
llvm-svn: 116452
2010-10-13 23:46:33 +00:00
Chris Lattner
b91c903f46
stomp some more undefined behavior, PR7775.
...
llvm-svn: 111337
2010-08-18 00:33:47 +00:00
Benjamin Kramer
92d8998348
Don't pass StringRef by reference.
...
llvm-svn: 108366
2010-07-14 22:38:02 +00:00
Chris Lattner
9e01b615a4
improve portability to systems that don't have round, patch by
...
Evzen Muller!
llvm-svn: 103877
2010-05-15 17:11:55 +00:00
Chris Lattner
35a069b3a5
improve portability to minix, patch by
...
Kees van Reeuwijk for PR6704
llvm-svn: 99677
2010-03-26 23:54:15 +00:00
Dan Gohman
b452d4e9e4
Fix minor style issues.
...
llvm-svn: 99414
2010-03-24 19:38:02 +00:00
John McCall
dcb9a7ad3d
Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-width
...
payloads. APFloat's internal folding routines always make QNaNs now,
instead of sometimes making QNaNs and sometimes SNaNs depending on the
type.
llvm-svn: 97364
2010-02-28 02:51:25 +00:00
Dan Gohman
4a618827de
Fix "the the" and similar typos.
...
llvm-svn: 95781
2010-02-10 16:03:48 +00:00
John McCall
df951bddb8
Make APInt::countLeadingZerosSlowCase() treat the contents of padding bits
...
as undefined. Fixes an assertion in APFloat::toString noticed by Dale.
llvm-svn: 95196
2010-02-03 03:42:44 +00:00
David Greene
f32fcb4d31
Change errs() to dbgs().
...
llvm-svn: 92643
2010-01-05 01:28:52 +00:00
John McCall
bd8d1e35a6
Set Remainder before Quotient in case Quotient and LHS alias. The new
...
order should be immune to such problems.
llvm-svn: 92124
2009-12-24 08:52:06 +00:00
Daniel Dunbar
7d6781b0fe
Tabs -> spaces, and remove trailing whitespace.
...
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Duncan Sands
2fbeaf084f
Remove some unused variables and methods warned about by
...
icc (#177 , partial). Patch by Erick Tryzelaar.
llvm-svn: 81106
2009-09-06 08:33:48 +00:00
Chris Lattner
96cffa63a2
remove the dead std::ostream APInt inserter
...
llvm-svn: 79875
2009-08-23 23:11:28 +00:00
Erick Tryzelaar
6096409238
Clean up the APInt function getDigit.
...
llvm-svn: 79602
2009-08-21 06:48:37 +00:00
Eric Christopher
43a1decc8c
Update error messages for '+'. Fix grammar and make the two
...
negative checks resemble each other.
llvm-svn: 79595
2009-08-21 04:10:31 +00:00
Eric Christopher
820256bc99
Fix trailing whitespace and 80-col violation.
...
llvm-svn: 79594
2009-08-21 04:06:45 +00:00
Erick Tryzelaar
dadb1571b7
Fix bug with APInt::getBitsNeeded with for base 10 numbers 0-9.
...
llvm-svn: 79593
2009-08-21 03:15:28 +00:00
Erick Tryzelaar
1264bcb4de
Allow '+' to appear in APInt strings, and add more unit tests.
...
llvm-svn: 79592
2009-08-21 03:15:14 +00:00
Daniel Dunbar
8b0b11582d
Switch to SmallString::str from SmallString::c_str, and remove
...
SmallString::c_str.
llvm-svn: 79456
2009-08-19 20:07:03 +00:00
Daniel Dunbar
3a1efd11bb
Convert APint::{fromString,APInt,getBitsNeeded} to use StringRef.
...
- Patch by Erick Tryzelaar, with some edits (and a bug fix) from me.
llvm-svn: 78885
2009-08-13 02:33:34 +00:00
Dale Johannesen
54be785be7
Add attempted idiotproofing comment per review.
...
llvm-svn: 78825
2009-08-12 18:04:11 +00:00
Dale Johannesen
34c08bbbf9
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.
llvm-svn: 78821
2009-08-12 17:42:34 +00:00
Torok Edwin
fbcc663cbf
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").
llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Daniel Dunbar
763ace92c0
Switch to raw_ostream.
...
llvm-svn: 75451
2009-07-13 05:27:30 +00:00
Torok Edwin
56d0659726
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.
llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Dan Gohman
10f1733d9a
Reapply 74494, this time removing the conflicting definition of operator<<
...
in APIntTest.cpp.
llvm-svn: 74550
2009-06-30 20:10:56 +00:00
Bill Wendling
778a517725
Temporarily revert r74494. It was causing failures in the unit tests.
...
llvm-svn: 74515
2009-06-30 07:05:27 +00:00
Dan Gohman
e95d409bdd
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.
llvm-svn: 74494
2009-06-30 01:28:08 +00:00
Evan Cheng
db338f3f41
80 column violation.
...
llvm-svn: 72235
2009-05-21 23:47:47 +00:00
Mike Stump
889285d467
Fix whitespacing (space after switch).
...
llvm-svn: 71738
2009-05-13 23:23:20 +00:00
Jay Foad
fe0c648fee
Move helper functions for optimizing division by constant into the APInt
...
class.
llvm-svn: 70488
2009-04-30 10:15:35 +00:00
Chris Lattner
b869a0ade1
Fix PR4040: APInt's string constructor is too strict
...
patch by Jeff Yasskin!
llvm-svn: 70058
2009-04-25 18:34:04 +00:00
Dan Gohman
cff6953c45
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.
llvm-svn: 68227
2009-04-01 18:45:54 +00:00
Duncan Sands
8208465036
Fix comment typo.
...
llvm-svn: 67302
2009-03-19 11:37:15 +00:00
Stuart Hastings
7440952c01
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.
llvm-svn: 66962
2009-03-13 21:51:13 +00:00
Torok Edwin
ec39eb8519
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.
llvm-svn: 63107
2009-01-27 18:06:03 +00:00
Chris Lattner
77527f5812
Remove uses of uint32_t in favor of 'unsigned' for better
...
compatibility with cygwin. Patch by Jay Foad!
llvm-svn: 62695
2009-01-21 18:09:24 +00:00
Nick Lewycky
030c450fdc
Fix typo, sentence fragment.
...
llvm-svn: 62512
2009-01-19 17:42:33 +00:00
Chris Lattner
d57b7603f9
rearrange some code.
...
llvm-svn: 57384
2008-10-11 22:07:19 +00:00
Chris Lattner
0c19df4871
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.
llvm-svn: 55263
2008-08-23 22:23:09 +00:00
Chris Lattner
1ac3e2545b
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.
llvm-svn: 55063
2008-08-20 17:02:31 +00:00