Commit Graph

81 Commits

Author SHA1 Message Date
Jay Foad
40f8f6264d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 08:25:19 +00:00
Nick Lewycky
f2d7b7c879 Make ConstantRange::makeICmpRegion handle all the edge cases properly. This
also fixes PR8250.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28 18:18:36 +00:00
Nick Lewycky
198381e542 Add completely hokey binary-and and binary-or operations to ConstantRange and
teach LazyValueInfo to use them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113196 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 05:39:02 +00:00
Nick Lewycky
32cda119ef Add a new isSignWrappedSet() method to ConstantRange.
Fix zeroExtend and signExtend to support empty sets, and to return the smallest
possible result set which contains the extension of each element in their
inputs. For example zext i8 [100, 10) to i16 is now [0, 256), not i16 [100, 10)
which contains 63446 members.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113187 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-06 23:52:49 +00:00
Nick Lewycky
7f9ef4bb51 Clean up ConstantRange a bit:
- remove ashr which never worked.
 - fix lshr and shl and add tests.
 - remove dead function "intersect1Wrapped".
 - add a new sub method to subtract ranges, with test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110861 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 22:04:36 +00:00
Owen Anderson
0aede9e2a8 Remove layering violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110505 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07 06:01:13 +00:00
Owen Anderson
9773e45a1e Add an inverse() method to ConstantRange.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110504 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07 05:47:46 +00:00
Owen Anderson
634bab148c Add a convenience constructor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110493 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07 00:42:06 +00:00
Dan Gohman
8dcc58e6b4 Fix a typo that several people pointed out. Also, address the case of
wrapping that Duncan pointed out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94547 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 15:56:18 +00:00
Dan Gohman
153f1ebeb8 Add a comment about a missed opportunity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94507 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 04:13:15 +00:00
Dan Gohman
df6d5e0394 Print empty and full sets specially.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94506 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 04:12:55 +00:00
David Greene
7fd5fb4b47 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:32 +00:00
Nuno Lopes
4459145c2c fix crash in my previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 15:10:33 +00:00
Nuno Lopes
34e992da38 implement shl, ashr, and lshr methods. shl is not fully implemented as it is quite tricky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86986 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 14:53:53 +00:00
Nuno Lopes
95a3be0ba4 add zextOrTrunc and sextOrTrunc methods, that are similar to the ones in APInt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86549 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 15:36:28 +00:00
Chris Lattner
45cfe545ec Change Pass::print to take a raw ostream instead of std::ostream,
update all code that this affects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79830 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 06:03:38 +00:00
Nick Lewycky
7e7dc45eb1 Fix ConstantRange::unionWith. Also make it work a little hard in some cases to
return the smallest union of two ranges instead of just any range that happens
to contain the union.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76360 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-19 03:44:35 +00:00
Nick Lewycky
3a4a884c16 Replace intersectWith with maximalIntersectWith. The latter guarantees that
all values belonging to the intersection will belong to the resulting range.
The former was inconsistent about that point (either way is fine, just pick
one.) This is part of PR4545.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 06:34:42 +00:00
Nick Lewycky
780905e9f9 Fix an error in ConstantRange::getSignedMax on wrapped ranges. Thanks once
again to Daniel Dunbar and KLEE!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75449 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 04:50:21 +00:00
Nick Lewycky
ff84de767a 'i8 full-range' sign extended to i16 should equal [-128, 128) not [-128, 127).
Found by Daniel Dunbar and KLEE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75448 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 04:17:23 +00:00
Nick Lewycky
f1db120d04 Multiply was very wrong for wrapped ranges. This supplies a half-fix that will
generally return Full on all wrapped inputs. "Fixes" PR4545.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75444 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 03:27:41 +00:00
Nick Lewycky
cf9e07dea8 Fix a bug summing two full sets. The overflow checking doesn't handle sets as
large as the full set, only those one size smaller. Thanks to Daniel Dunbar
who found this bug using Klee!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75443 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 02:49:08 +00:00
Nick Lewycky
956daf0f7f Implement udiv for ConstantRanges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75413 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 05:18:18 +00:00
Nick Lewycky
2ff893f486 Implement ConstantRange::multiply based on the code in LoopVR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75410 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 02:19:05 +00:00
Nick Lewycky
646ca92bfc Fix handling of max and full set.
A full set is a constant range that represents any number. If you take the
umax of that and [5, 10) you end up with [5, INT_MAX] because the values less
than 5 would be umax's against a value which is at least 5.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 19:22:21 +00:00
Nick Lewycky
f067a23356 Clarify and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 17:04:01 +00:00
Nick Lewycky
bf8c7f0adf Move a method that creates constant ranges relative to another constant range
per icmp predicate out of predsimplify and into ConstantRange.

Add another utility method that determines whether one range is a subset of
another. Combine with the former to determine whether icmp pred range, range
is known to be true or not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 06:15:39 +00:00
Dan Gohman
38b0644761 Revert the part of 75177 that split ConstantRange into two classes, and
merge the new functionality and unittests into ConstantRange. Thanks to
Nick Lewycky for pointing out that it isn't necessary to have two separate
classes here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75191 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 23:16:10 +00:00
Dan Gohman
a3755d8d36 Add a ConstantSignedRange class, which does for signed integers
what ConstantRange does for unsigned integers. Factor out a
common base class for common functionality.

Add some new functions for performing arithmetic on constant
ranges. Some of these are currently just stubbed out with
conservative implementations.

Add unittests for ConstantRange and ConstantSignedRange.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 22:07:27 +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
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
Dan Gohman
7edd009efe Tidy up whitespace in ConstantRange::print output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51606 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 20:29:07 +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
Nick Lewycky
28753f8df2 Clarify the language. Pointed out by Duncan Sands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39857 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 17:41:03 +00:00
Nick Lewycky
377b1190cb Add alternate ConstantRange intersection algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39851 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 02:51:34 +00:00
Nick Lewycky
ae5eb7accf Fix edge case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37532 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-09 04:20:33 +00:00
Zhou Sheng
c125c00e68 Using APInt more efficiently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 16:42:07 +00:00
Zhou Sheng
daacf22537 Make the apint construction more effective.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35960 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 05:57:32 +00:00
Nick Lewycky
e32157c609 Add signExtend to ConstantRange, to complement zeroExtend and truncate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35733 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 15:41:33 +00:00
Nick Lewycky
9babd0e0f2 Implement union of wrapped sets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35534 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 03:47:44 +00:00
Nick Lewycky
3400e6af6b Add getter methods for the extremes of a ConstantRange.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35056 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-10 15:54:12 +00:00
Nick Lewycky
c6a28fcf5d Implement unionWith.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34833 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 03:33:05 +00:00
Reid Spencer
a6e8a955d6 Remove the "isSigned" parameters from ConstantRange. It turns out they
are not needed as the results are the same with or without it.

Patch by Nicholas Lewycky.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 07:54:15 +00:00
Reid Spencer
bb626a6751 Move ConstantRange class to lib/Support from lib/Analysis and make its
interface not depend on Type or ICmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34761 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 22:02:48 +00:00
Reid Spencer
581b0d453a For PR1205:
Remove ConstantInt from ConstantRange interface and adjust its users to
compensate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34758 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 19:57:34 +00:00
Reid Spencer
dc5c159701 For PR1205:
First round of ConstantRange changes. This makes all CR constructors use
only APInt and not use ConstantInt. Clients are adjusted accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34756 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 18:57:32 +00:00
Reid Spencer
663e711dc2 For PR1205:
Convert ConstantRange class to use APInt internally as its value type for
the constant range, instead of ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34745 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 17:36:23 +00:00
Nick Lewycky
3e051647c0 Fix comments to match names of functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34173 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 00:58:49 +00:00
Reid Spencer
c10305743c For PR1043:
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*

This also fixes PR1120.

Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33370 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-19 21:13:56 +00:00
Chris Lattner
42a7551725 rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent.  For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33225 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 02:27:26 +00:00