summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-17 20:47:02 +0000
committerDan Gohman <gohman@apple.com>2009-07-17 20:47:02 +0000
commit80ca01c4666da8f192b4360239094fb45099ac43 (patch)
treee54f8b676f8a4ef5699ab4c7736496968b40b331 /llvm/lib/Transforms
parente79b2bc088755e55948d2cc950135809983c14de (diff)
downloadbcm5719-llvm-80ca01c4666da8f192b4360239094fb45099ac43.tar.gz
bcm5719-llvm-80ca01c4666da8f192b4360239094fb45099ac43.zip
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. llvm-svn: 76232
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 2b7ca6bbaaa..1c25bec304b 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud