diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-17 20:47:02 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-17 20:47:02 +0000 |
commit | ca178908c8dc2303a1fb54a8a93bab0f0b964e11 (patch) | |
tree | 80aa85f4b479a948b080f13679535c4c29b7a145 /lib/Transforms | |
parent | e2cf37b88c089a71727b3ecd466856f0cd638813 (diff) | |
download | external_llvm-ca178908c8dc2303a1fb54a8a93bab0f0b964e11.zip external_llvm-ca178908c8dc2303a1fb54a8a93bab0f0b964e11.tar.gz external_llvm-ca178908c8dc2303a1fb54a8a93bab0f0b964e11.tar.bz2 |
Add a new Operator class, for handling Instructions and ConstantExprs
in a convenient manner, factoring out some common code from
InstructionCombining and ValueTracking. Move the contents of
BinaryOperators.h into Operator.h and use Operator to generalize them
to support ConstantExprs as well as Instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76232 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2b7ca6b..1c25bec 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -40,6 +40,7 @@ #include "llvm/Pass.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" +#include "llvm/Operator.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" @@ -650,17 +651,6 @@ static User *dyn_castGetElementPtr(Value *V) { return false; } -/// getOpcode - If this is an Instruction or a ConstantExpr, return the -/// opcode value. Otherwise return UserOp1. -static unsigned getOpcode(const Value *V) { - if (const Instruction *I = dyn_cast<Instruction>(V)) - return I->getOpcode(); - if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) - return CE->getOpcode(); - // Use UserOp1 to mean there's no opcode. - return Instruction::UserOp1; -} - /// AddOne - Add one to a ConstantInt static Constant *AddOne(Constant *C, LLVMContext *Context) { return Context->getConstantExprAdd(C, @@ -8710,7 +8700,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) { // See if the value being truncated is already sign extended. If so, just // eliminate the trunc/sext pair. - if (getOpcode(Src) == Instruction::Trunc) { + if (Operator::getOpcode(Src) == Instruction::Trunc) { Value *Op = cast<User>(Src)->getOperand(0); unsigned OpBits = Op->getType()->getScalarSizeInBits(); unsigned MidBits = Src->getType()->getScalarSizeInBits(); @@ -9625,7 +9615,7 @@ static unsigned EnforceKnownAlignment(Value *V, User *U = dyn_cast<User>(V); if (!U) return Align; - switch (getOpcode(U)) { + switch (Operator::getOpcode(U)) { default: break; case Instruction::BitCast: return EnforceKnownAlignment(U->getOperand(0), Align, PrefAlign); |