From 46b3d30bf63fa1e48c1109a38d9ad9cada23bd20 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 16 Apr 2003 22:40:51 +0000 Subject: Change the interface to constant expressions to allow automatic folding llvm-svn: 5793 --- llvm/lib/Transforms/IPO/FunctionResolution.cpp | 2 +- llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 2 +- llvm/lib/VMCore/Constants.cpp | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/IPO/FunctionResolution.cpp b/llvm/lib/Transforms/IPO/FunctionResolution.cpp index 734b62b9dc2..932cdf46e89 100644 --- a/llvm/lib/Transforms/IPO/FunctionResolution.cpp +++ b/llvm/lib/Transforms/IPO/FunctionResolution.cpp @@ -207,7 +207,7 @@ static bool ResolveGlobalVariables(Module &M, std::vector Args; Args.push_back(Constant::getNullValue(Type::LongTy)); Args.push_back(Constant::getNullValue(Type::LongTy)); - ConstantExpr *Replacement = + Constant *Replacement = ConstantExpr::getGetElementPtr(ConstantPointerRef::get(Concrete), Args); for (unsigned i = 0; i != Globals.size(); ++i) diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 38494f206d1..70fc952891f 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1011,7 +1011,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Indices.push_back(cast(*I)); if (I == E) { // If they are all constants... - ConstantExpr *CE = + Constant *CE = ConstantExpr::getGetElementPtr(ConstantPointerRef::get(GV), Indices); // Replace all uses of the GEP with the new constexpr... diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 84f2566e468..27c48c87748 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -418,7 +418,7 @@ void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To) { void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *To) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); - ConstantExpr *Replacement = 0; + Constant *Replacement = 0; if (getOpcode() == Instruction::GetElementPtr) { std::vector Indices; Constant *Pointer = cast(getOperand(0)); @@ -635,8 +635,7 @@ void ConstantPointerRef::destroyConstant() { typedef pair > ExprMapKeyType; static ValueMap ExprConstants; -ConstantExpr *ConstantExpr::getCast(Constant *C, const Type *Ty) { - +Constant *ConstantExpr::getCast(Constant *C, const Type *Ty) { // Look up the constant in the table first to ensure uniqueness vector argVec(1, C); const ExprMapKeyType &Key = make_pair(Instruction::Cast, argVec); @@ -649,7 +648,7 @@ ConstantExpr *ConstantExpr::getCast(Constant *C, const Type *Ty) { return Result; } -ConstantExpr *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { +Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { // Look up the constant in the table first to ensure uniqueness vector argVec(1, C1); argVec.push_back(C2); const ExprMapKeyType &Key = make_pair(Opcode, argVec); @@ -670,8 +669,8 @@ ConstantExpr *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { return Result; } -ConstantExpr *ConstantExpr::getGetElementPtr(Constant *C, - const std::vector &IdxList) { +Constant *ConstantExpr::getGetElementPtr(Constant *C, + const std::vector &IdxList){ const Type *Ty = C->getType(); // Look up the constant in the table first to ensure uniqueness -- cgit v1.2.3