Change TargetFolder's TD member from a reference to a

pointer, now that ConstantFoldConstantExpression can
accept a null TargetData pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-06-03 00:13:48 +00:00
parent 7714285efd
commit b3ae97cffe

View File

@ -9,8 +9,10 @@
// //
// This file defines the TargetFolder class, a helper for IRBuilder. // This file defines the TargetFolder class, a helper for IRBuilder.
// It provides IRBuilder with a set of methods for creating constants with // It provides IRBuilder with a set of methods for creating constants with
// target dependent folding. For general constant creation and folding, // target dependent folding, in addition to the same target-independent
// use ConstantExpr and the routines in llvm/Analysis/ConstantFolding.h. // folding that the ConstantFolder class provides. For general constant
// creation and folding, use ConstantExpr and the routines in
// llvm/Analysis/ConstantFolding.h.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -26,18 +28,18 @@ class TargetData;
/// TargetFolder - Create constants with target dependent folding. /// TargetFolder - Create constants with target dependent folding.
class TargetFolder { class TargetFolder {
const TargetData &TD; const TargetData *TD;
/// Fold - Fold the constant using target specific information. /// Fold - Fold the constant using target specific information.
Constant *Fold(Constant *C) const { Constant *Fold(Constant *C) const {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
if (Constant *CF = ConstantFoldConstantExpression(CE, &TD)) if (Constant *CF = ConstantFoldConstantExpression(CE, TD))
return CF; return CF;
return C; return C;
} }
public: public:
TargetFolder(const TargetData &TheTD) : TD(TheTD) {} explicit TargetFolder(const TargetData *TheTD) : TD(TheTD) {}
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Binary Operators // Binary Operators