X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FExpressions.cpp;h=bfab20c42c8f49feee9ee64c444956ba50664cef;hb=c53544af06acf3fba1788613a364f1f40317869e;hp=4a7646e4d76001b205bfd8385cebd40d48aac6c3;hpb=e590ff260edbe2e521506a9621c2b936b629a2ea;p=oota-llvm.git diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 4a7646e4d76..bfab20c42c8 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -8,12 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/Expressions.h" -#include "llvm/Transforms/Scalar/ConstantHandling.h" +#include "llvm/ConstantHandling.h" #include "llvm/Function.h" -#include "llvm/BasicBlock.h" -#include - -using namespace analysis; ExprType::ExprType(Value *Val) { if (Val) @@ -34,7 +30,7 @@ ExprType::ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset) { Scale = var ? scale : 0; Var = var; Offset = offset; ExprTy = Scale ? ScaledLinear : (Var ? Linear : Constant); - if (Scale && Scale->equalsInt(0)) { // Simplify 0*Var + const + if (Scale && Scale->isNullValue()) { // Simplify 0*Var + const Scale = 0; Var = 0; ExprTy = Constant; } @@ -76,7 +72,7 @@ struct DefOne : public DefVal { // happen for values in the range of 0 to 127. // static ConstantInt *getUnsignedConstant(uint64_t V, const Type *Ty) { - if (Ty->isPointerType()) Ty = Type::ULongTy; + if (isa(Ty)) Ty = Type::ULongTy; if (Ty->isSigned()) { // If this value is not a valid unsigned value for this type, return null! if (V > 127 && ((int64_t)V < 0 || @@ -232,7 +228,7 @@ static inline ExprType negate(const ExprType &E, Value *V) { // Note that this analysis cannot get into infinite loops because it treats PHI // nodes as being an unknown linear expression. // -ExprType analysis::ClassifyExpression(Value *Expr) { +ExprType ClassifyExpression(Value *Expr) { assert(Expr != 0 && "Can't classify a null expression!"); if (Expr->getType() == Type::FloatTy || Expr->getType() == Type::DoubleTy) return Expr; // FIXME: Can't handle FP expressions @@ -240,19 +236,17 @@ ExprType analysis::ClassifyExpression(Value *Expr) { switch (Expr->getValueType()) { case Value::InstructionVal: break; // Instruction... hmmm... investigate. case Value::TypeVal: case Value::BasicBlockVal: - case Value::FunctionVal: case Value::ModuleVal: default: + case Value::FunctionVal: default: //assert(0 && "Unexpected expression type to classify!"); std::cerr << "Bizarre thing to expr classify: " << Expr << "\n"; return Expr; case Value::GlobalVariableVal: // Global Variable & Function argument: - case Value::FunctionArgumentVal: // nothing known, return variable itself + case Value::ArgumentVal: // nothing known, return variable itself return Expr; case Value::ConstantVal: // Constant value, just return constant - Constant *CPV = cast(Expr); - if (CPV->getType()->isIntegral()) { // It's an integral constant! - ConstantInt *CPI = cast(Expr); - return ExprType(CPI->equalsInt(0) ? 0 : CPI); - } + if (ConstantInt *CPI = dyn_cast(cast(Expr))) + // It's an integral constant! + return ExprType(CPI->isNullValue() ? 0 : CPI); return Expr; } @@ -320,7 +314,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { case Instruction::Cast: { ExprType Src(ClassifyExpression(I->getOperand(0))); const Type *DestTy = I->getType(); - if (DestTy->isPointerType()) + if (isa(DestTy)) DestTy = Type::ULongTy; // Pointer types are represented as ulong /*