Commit Graph

69 Commits

Author SHA1 Message Date
Chris Lattner 5a945e3616 Rename ConstantHandling.* -> ConstantFolding.*
Move a bunch of (now) private stuff from ConstantFolding.h into
ConstantFolding.cpp.

This _finally_ gets us to a place where we have a sane constant folder.  The
rules are:

1. LLVM clients now use ConstantExpr::get* methods to fold constants.  If they
   cannot be folded, a constantexpr is created, so these methods always return
   valid Constant*'s.
2. The implementation of ConstantExpr::get* uses the functions exposed by
   ConstantFolding.h to try to fold constants.  If they cannot be folded,
   they should return a null pointer.
3. The implementation of ConstantFolding can do whatever it wants, and only
   has one client (Constants.cpp)

This cuts down on the wierd dependencies, and eliminates the two interfaces.
The old constanthandling interface was especially bad for clients to use
because almost none of them took the failure condition into consideration,
thus leading to obscure problems.

llvm-svn: 10807
2004-01-12 21:13:12 +00:00
Chris Lattner 2361bd02a1 Move ConstantHandling.h into lib/VMCore and out of include/llvm
llvm-svn: 10805
2004-01-12 20:48:11 +00:00
Chris Lattner 0bba771f49 Eliminate ConstantFoldShiftInstruction reference
llvm-svn: 10801
2004-01-12 20:40:42 +00:00
Chris Lattner 9eb2b527ad Fix out of date comment, remove use of ConstantExpr::getShift
llvm-svn: 10794
2004-01-12 19:12:58 +00:00
Chris Lattner 5645e8a82d Make ConstantExpr::get work for shifts as well
llvm-svn: 10790
2004-01-12 19:04:55 +00:00
Chris Lattner 189d19fb04 Finegrainify namespacification
llvm-svn: 10131
2003-11-21 20:23:48 +00:00
Chris Lattner e120a73166 The ConstantPointer class is now gone.
llvm-svn: 10057
2003-11-17 19:47:21 +00:00
Brian Gaeke 960707c335 Put all LLVM code into the llvm namespace, as per bug 109.
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
Chris Lattner b36e8a1a2e Add support for constant expr shifts
llvm-svn: 9735
2003-11-05 19:53:03 +00:00
Chris Lattner 8a55262c76 Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll
llvm-svn: 9403
2003-10-23 05:21:48 +00:00
Chris Lattner 7267b352fb Fix problem which effected linking apache
llvm-svn: 9335
2003-10-21 17:39:59 +00:00
John Criswell 482202a601 Added LLVM project notice to the top of every C++ source file.
Header files will be on the way.

llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Chris Lattner 815ae2bfe3 Add a sanity check for constant expression casts
llvm-svn: 8951
2003-10-07 22:19:19 +00:00
Chris Lattner b50d135710 Type tables are now AbstractTypeUsers. This allows them to merge together
constants as necessary due to type resolution.  With this change, the
following spec benchmarks now link: 176.gcc, 177.mesa, 252.eon,
253.perlbmk, & 300.twolf.  IOW, all SPEC INT and FP benchmarks now link.

llvm-svn: 8853
2003-10-05 00:17:43 +00:00
Chris Lattner 3e88ef9f93 Minor random speedup: make Constant::getNullValue only call ConstantFOO::get
once!

llvm-svn: 8845
2003-10-03 19:34:51 +00:00
Chris Lattner 29dc65a324 These methods are dead, remove them. Because the bodies will soon be
ressurected, just ifdef them out for now.

llvm-svn: 8840
2003-10-03 18:39:57 +00:00
Chris Lattner 22e4ca8863 There is no reason for Value to be an AbstractTypeUser. This just makes things
significantly more complete.  Instead, just make DerivedType's AbstractTypeUser's,
and make Value contain a PATypeHolder.

llvm-svn: 8828
2003-10-02 19:44:40 +00:00
Chris Lattner c27038d7b5 Implement "unsafe" replaceAllUsesWWith stuff for use during type resolution.
llvm-svn: 8209
2003-08-29 05:36:46 +00:00
Chris Lattner 9f15812e88 Refactor code to make it useful outside of Constants.cpp
llvm-svn: 8205
2003-08-29 05:09:37 +00:00
Misha Brukman be372b91e1 The word `dependent' has no `a'.
llvm-svn: 8030
2003-08-21 22:14:26 +00:00
Chris Lattner ab69ecc6d5 Fix linking bug in xboard
llvm-svn: 7952
2003-08-18 16:54:48 +00:00
Chris Lattner 3a5c2826d5 Fix a bug that brian reported
llvm-svn: 7428
2003-07-30 19:04:37 +00:00
Chris Lattner 6077c3195f Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting

llvm-svn: 7252
2003-07-23 15:22:26 +00:00
Chris Lattner 22ced56476 Fix bug: InstCombine/2003-06-22-ConstantExprCrash.ll
llvm-svn: 6857
2003-06-22 20:48:30 +00:00
Chris Lattner cc7d6ff656 Fix bug: Linker/2003-06-02-TypeResolveProblem2.ll
llvm-svn: 6699
2003-06-16 12:11:33 +00:00
Chris Lattner 93c8f14906 * Make assertion message useful
* Kill dead conditional

llvm-svn: 6544
2003-06-02 17:42:47 +00:00
Chris Lattner 7fa6783a01 Fix bug: Linker/2003-06-02-TypeResolveProblem.ll
llvm-svn: 6542
2003-06-02 17:25:46 +00:00
Chris Lattner 20ec7bc0db Fix problem with last checkin.
llvm-svn: 6328
2003-05-25 16:15:32 +00:00
Chris Lattner 98fa07b1d5 Fix Bug: Linker/2003-04-26-NullPtrLinkProblem.ll
This was a problem with constants having their types resolved to some new type,
but there was already a constant of the new type created.  Before, these types
were never merged together, now they are.

llvm-svn: 6314
2003-05-23 20:03:32 +00:00
Chris Lattner 38a9bcde76 Add support for shift constant expressions
llvm-svn: 6260
2003-05-21 17:49:25 +00:00
Chris Lattner cb4d26fb95 Fix bug: Assembler/2003-05-15-AssemblerProblem.llx
llvm-svn: 6234
2003-05-15 19:37:21 +00:00
Chris Lattner 55ed6561a1 Remove unnecessary casts
llvm-svn: 6201
2003-05-14 17:51:05 +00:00
Chris Lattner 2b383d2ef2 Eliminate using declarations
llvm-svn: 6179
2003-05-13 21:37:02 +00:00
Chris Lattner acdbe7158d Don't build constantexprs that could be folded
llvm-svn: 5801
2003-04-17 19:24:48 +00:00
Chris Lattner 46b3d30bf6 Change the interface to constant expressions to allow automatic folding
llvm-svn: 5793
2003-04-16 22:40:51 +00:00
Chris Lattner 83e5d39566 Fix ConstantUInt::isAllOnesValue
llvm-svn: 5734
2003-03-10 22:39:02 +00:00
Chris Lattner c33ae67237 Remove #include
Extend getNullValue to work with struct and array types

llvm-svn: 5718
2003-03-06 21:02:18 +00:00
Chris Lattner 163b890dfb - Dramatically simplify the Constant::mutateReferences implementation,
allowing it to be called on all constant types (structures/arrays)

llvm-svn: 4160
2002-10-14 03:30:23 +00:00
Chris Lattner 69ce8674b5 - Rename Instruction::First*Op to *OpsBegin, and Num*Ops to *OpsEnd to
reflect the fact that it's a range being defined.

llvm-svn: 4147
2002-10-13 19:39:16 +00:00
Chris Lattner b1dd9bbc68 - Add new Constant::replaceUsesOfWithOnConstant which has an end result
similar to User::replaceUsesOfWith but actually does the right thing for
    constants.

llvm-svn: 4102
2002-10-09 23:12:25 +00:00
Chris Lattner 0d779712e7 Fix bug: Assembler/2002-10-08-LargeArrayPerformance.ll by using
std::vector::reserve when possible

llvm-svn: 4085
2002-10-08 23:33:52 +00:00
Chris Lattner 426752738b include/llvm/DataTypes.h includes this #define so we don't need it anymore
llvm-svn: 3708
2002-09-13 22:24:57 +00:00
Chris Lattner 236c129844 Give better assertion message for error conditions
llvm-svn: 3680
2002-09-11 01:21:04 +00:00
Chris Lattner b0b412e66e - Renamed Type::isIntegral() to Type::isInteger()
- Added new method Type::isIntegral() that is the same as isInteger, but
    also accepts bool.

llvm-svn: 3574
2002-09-03 01:08:28 +00:00
Chris Lattner 81fabb05e5 Add support for turning an array of characters into a string.
llvm-svn: 3509
2002-08-26 17:53:56 +00:00
Chris Lattner 0c6e0b9042 - ConstantPointerRefs are now automatically removed from the module table
when they are destroyed, which makes Constant::destroyConstant an actually
    useful external interface.  Expose these methods publicly.
  - Implement destroyConstant on ConstPointerNull so that destroyConstant can
    be used on any derived type constant safely.

llvm-svn: 3379
2002-08-18 00:40:04 +00:00
Chris Lattner 330b7ac76c Remove support for Not ConstantExpr. This simplifies the unary case to only
have to support the cast instruction, so the function is renamed to getCast.

llvm-svn: 3328
2002-08-14 18:24:09 +00:00
Chris Lattner 31408f7a80 Return null on failure, instead of aborting.
llvm-svn: 3308
2002-08-14 17:12:13 +00:00
Chris Lattner b1585a90d9 - Rename ConstantGenericIntegral -> ConstantIntegral
- Add new methods to ConstantIntegral: getMaxValue, getMinValue,
   getAllOnesValue

llvm-svn: 3299
2002-08-13 17:50:20 +00:00
Chris Lattner 41e99a07f1 - Added a new superclass of ConstantBool/ConstantInt: ConstantGenericIntegral
- Moved InstCombine: isMaxValue, isMinValue, isAllOnesValue to Constants.h

llvm-svn: 3293
2002-08-12 21:21:21 +00:00