diff options
Diffstat (limited to 'lib')
57 files changed, 854 insertions, 868 deletions
diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index fda1bf3c91..d0ab480772 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -17,7 +17,7 @@ using namespace analysis; ExprType::ExprType(Value *Val) { if (Val) - if (ConstPoolInt *CPI = dyn_cast<ConstPoolInt>(Val)) { + if (ConstantInt *CPI = dyn_cast<ConstantInt>(Val)) { Offset = CPI; Var = 0; ExprTy = Constant; @@ -30,8 +30,8 @@ ExprType::ExprType(Value *Val) { Scale = 0; } -ExprType::ExprType(const ConstPoolInt *scale, Value *var, - const ConstPoolInt *offset) { +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 @@ -50,31 +50,31 @@ const Type *ExprType::getExprType(const Type *Default) const { class DefVal { - const ConstPoolInt * const Val; + const ConstantInt * const Val; const Type * const Ty; protected: - inline DefVal(const ConstPoolInt *val, const Type *ty) : Val(val), Ty(ty) {} + inline DefVal(const ConstantInt *val, const Type *ty) : Val(val), Ty(ty) {} public: inline const Type *getType() const { return Ty; } - inline const ConstPoolInt *getVal() const { return Val; } - inline operator const ConstPoolInt * () const { return Val; } - inline const ConstPoolInt *operator->() const { return Val; } + inline const ConstantInt *getVal() const { return Val; } + inline operator const ConstantInt * () const { return Val; } + inline const ConstantInt *operator->() const { return Val; } }; struct DefZero : public DefVal { - inline DefZero(const ConstPoolInt *val, const Type *ty) : DefVal(val, ty) {} - inline DefZero(const ConstPoolInt *val) : DefVal(val, val->getType()) {} + inline DefZero(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {} + inline DefZero(const ConstantInt *val) : DefVal(val, val->getType()) {} }; struct DefOne : public DefVal { - inline DefOne(const ConstPoolInt *val, const Type *ty) : DefVal(val, ty) {} + inline DefOne(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {} }; -static ConstPoolInt *getUnsignedConstant(uint64_t V, const Type *Ty) { +static ConstantInt *getUnsignedConstant(uint64_t V, const Type *Ty) { if (Ty->isPointerType()) Ty = Type::ULongTy; - return Ty->isSigned() ? (ConstPoolInt*)ConstPoolSInt::get(Ty, V) - : (ConstPoolInt*)ConstPoolUInt::get(Ty, V); + return Ty->isSigned() ? (ConstantInt*)ConstantSInt::get(Ty, V) + : (ConstantInt*)ConstantUInt::get(Ty, V); } // Add - Helper function to make later code simpler. Basically it just adds @@ -89,16 +89,16 @@ static ConstPoolInt *getUnsignedConstant(uint64_t V, const Type *Ty) { // 3. If DefOne is true, a null return value indicates a value of 1, if DefOne // is false, a null return value indicates a value of 0. // -static const ConstPoolInt *Add(const ConstPoolInt *Arg1, - const ConstPoolInt *Arg2, bool DefOne) { +static const ConstantInt *Add(const ConstantInt *Arg1, + const ConstantInt *Arg2, bool DefOne) { assert(Arg1 && Arg2 && "No null arguments should exist now!"); assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!"); // Actually perform the computation now! - ConstPoolVal *Result = *Arg1 + *Arg2; + Constant *Result = *Arg1 + *Arg2; assert(Result && Result->getType() == Arg1->getType() && "Couldn't perform addition!"); - ConstPoolInt *ResultI = cast<ConstPoolInt>(Result); + ConstantInt *ResultI = cast<ConstantInt>(Result); // Check to see if the result is one of the special cases that we want to // recognize... @@ -108,13 +108,13 @@ static const ConstPoolInt *Add(const ConstPoolInt *Arg1, return ResultI; } -inline const ConstPoolInt *operator+(const DefZero &L, const DefZero &R) { +inline const ConstantInt *operator+(const DefZero &L, const DefZero &R) { if (L == 0) return R; if (R == 0) return L; return Add(L, R, false); } -inline const ConstPoolInt *operator+(const DefOne &L, const DefOne &R) { +inline const ConstantInt *operator+(const DefOne &L, const DefOne &R) { if (L == 0) { if (R == 0) return getUnsignedConstant(2, L.getType()); @@ -139,16 +139,16 @@ inline const ConstPoolInt *operator+(const DefOne &L, const DefOne &R) { // 3. If DefOne is true, a null return value indicates a value of 1, if DefOne // is false, a null return value indicates a value of 0. // -inline const ConstPoolInt *Mul(const ConstPoolInt *Arg1, - const ConstPoolInt *Arg2, bool DefOne) { +inline const ConstantInt *Mul(const ConstantInt *Arg1, + const ConstantInt *Arg2, bool DefOne) { assert(Arg1 && Arg2 && "No null arguments should exist now!"); assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!"); // Actually perform the computation now! - ConstPoolVal *Result = *Arg1 * *Arg2; + Constant *Result = *Arg1 * *Arg2; assert(Result && Result->getType() == Arg1->getType() && "Couldn't perform multiplication!"); - ConstPoolInt *ResultI = cast<ConstPoolInt>(Result); + ConstantInt *ResultI = cast<ConstantInt>(Result); // Check to see if the result is one of the special cases that we want to // recognize... @@ -158,16 +158,16 @@ inline const ConstPoolInt *Mul(const ConstPoolInt *Arg1, return ResultI; } -inline const ConstPoolInt *operator*(const DefZero &L, const DefZero &R) { +inline const ConstantInt *operator*(const DefZero &L, const DefZero &R) { if (L == 0 || R == 0) return 0; return Mul(L, R, false); } -inline const ConstPoolInt *operator*(const DefOne &L, const DefZero &R) { +inline const ConstantInt *operator*(const DefOne &L, const DefZero &R) { if (R == 0) return getUnsignedConstant(0, L.getType()); if (L == 0) return R->equalsInt(1) ? 0 : R.getVal(); return Mul(L, R, true); } -inline const ConstPoolInt *operator*(const DefZero &L, const DefOne &R) { +inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) { if (L == 0 || R == 0) return L.getVal(); return Mul(R, L, false); } @@ -203,9 +203,9 @@ static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) { static inline ExprType negate(const ExprType &E, Value *V) { const Type *Ty = V->getType(); const Type *ETy = E.getExprType(Ty); - ConstPoolInt *Zero = getUnsignedConstant(0, ETy); - ConstPoolInt *One = getUnsignedConstant(1, ETy); - ConstPoolInt *NegOne = cast<ConstPoolInt>(*Zero - *One); + ConstantInt *Zero = getUnsignedConstant(0, ETy); + ConstantInt *One = getUnsignedConstant(1, ETy); + ConstantInt *NegOne = cast<ConstantInt>(*Zero - *One); if (NegOne == 0) return V; // Couldn't subtract values... return ExprType(DefOne (E.Scale , Ty) * NegOne, E.Var, @@ -230,9 +230,9 @@ ExprType analysis::ClassifyExpression(Value *Expr) { case Value::MethodArgumentVal: // nothing known, return variable itself return Expr; case Value::ConstantVal: // Constant value, just return constant - ConstPoolVal *CPV = cast<ConstPoolVal>(Expr); + Constant *CPV = cast<Constant>(Expr); if (CPV->getType()->isIntegral()) { // It's an integral constant! - ConstPoolInt *CPI = cast<ConstPoolInt>(Expr); + ConstantInt *CPI = cast<ConstantInt>(Expr); return ExprType(CPI->equalsInt(0) ? 0 : CPI); } return Expr; @@ -264,8 +264,8 @@ ExprType analysis::ClassifyExpression(Value *Expr) { if (Right.Offset == 0) return Left; // shl x, 0 = x assert(Right.Offset->getType() == Type::UByteTy && "Shift amount must always be a unsigned byte!"); - uint64_t ShiftAmount = ((ConstPoolUInt*)Right.Offset)->getValue(); - ConstPoolInt *Multiplier = getUnsignedConstant(1ULL << ShiftAmount, Ty); + uint64_t ShiftAmount = ((ConstantUInt*)Right.Offset)->getValue(); + ConstantInt *Multiplier = getUnsignedConstant(1ULL << ShiftAmount, Ty); return ExprType(DefOne(Left.Scale, Ty) * Multiplier, Left.Var, DefZero(Left.Offset, Ty) * Multiplier); @@ -280,7 +280,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { if (Left.ExprTy != ExprType::Constant) // RHS must be > constant return I; // Quadratic eqn! :( - const ConstPoolInt *Offs = Left.Offset; + const ConstantInt *Offs = Left.Offset; if (Offs == 0) return ExprType(); return ExprType( DefOne(Right.Scale , Ty) * Offs, Right.Var, DefZero(Right.Offset, Ty) * Offs); @@ -299,17 +299,17 @@ ExprType analysis::ClassifyExpression(Value *Expr) { } */ - const ConstPoolInt *Offset = Src.Offset; - const ConstPoolInt *Scale = Src.Scale; + const ConstantInt *Offset = Src.Offset; + const ConstantInt *Scale = Src.Scale; if (Offset) { - const ConstPoolVal *CPV = ConstantFoldCastInstruction(Offset, DestTy); + const Constant *CPV = ConstantFoldCastInstruction(Offset, DestTy); if (!CPV) return I; - Offset = cast<ConstPoolInt>(CPV); + Offset = cast<ConstantInt>(CPV); } if (Scale) { - const ConstPoolVal *CPV = ConstantFoldCastInstruction(Scale, DestTy); + const Constant *CPV = ConstantFoldCastInstruction(Scale, DestTy); if (!CPV) return I; - Scale = cast<ConstPoolInt>(CPV); + Scale = cast<ConstantInt>(CPV); } return ExprType(Scale, Src.Var, Offset); } // end case Instruction::Cast diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 73f4e7fe57..339bc3862a 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -22,13 +22,13 @@ #include "llvm/iPHINode.h" #include "llvm/InstrTypes.h" #include "llvm/Type.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" using analysis::ExprType; static bool isLoopInvariant(const Value *V, const cfg::Loop *L) { - if (isa<ConstPoolVal>(V) || isa<MethodArgument>(V) || isa<GlobalValue>(V)) + if (isa<Constant>(V) || isa<MethodArgument>(V) || isa<GlobalValue>(V)) return true; const Instruction *I = cast<Instruction>(V); @@ -41,8 +41,8 @@ enum InductionVariable::iType InductionVariable::Classify(const Value *Start, const Value *Step, const cfg::Loop *L = 0) { // Check for cannonical and simple linear expressions now... - if (ConstPoolInt *CStart = dyn_cast<ConstPoolInt>(Start)) - if (ConstPoolInt *CStep = dyn_cast<ConstPoolInt>(Step)) { + if (ConstantInt *CStart = dyn_cast<ConstantInt>(Start)) + if (ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) { if (CStart->equalsInt(0) && CStep->equalsInt(1)) return Cannonical; else @@ -97,8 +97,8 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { const Type *ETy = Phi->getType(); if (ETy->isPointerType()) ETy = Type::ULongTy; - Start = (Value*)(E1.Offset ? E1.Offset : ConstPoolInt::get(ETy, 0)); - Step = (Value*)(E2.Offset ? E2.Offset : ConstPoolInt::get(ETy, 0)); + Start = (Value*)(E1.Offset ? E1.Offset : ConstantInt::get(ETy, 0)); + Step = (Value*)(E2.Offset ? E2.Offset : ConstantInt::get(ETy, 0)); } else { // Okay, at this point, we know that we have loop information... @@ -111,7 +111,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { Step = 0; if (V2 == Phi) { // referencing the PHI directly? Must have zero step - Step = ConstPoolVal::getNullConstant(Phi->getType()); + Step = Constant::getNullConstant(Phi->getType()); } else if (BinaryOperator *I = dyn_cast<BinaryOperator>(V2)) { // TODO: This could be much better... if (I->getOpcode() == Instruction::Add) { @@ -129,7 +129,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { const Type *ETy = Phi->getType(); if (ETy->isPointerType()) ETy = Type::ULongTy; - Step = (Value*)(StepE.Offset ? StepE.Offset : ConstPoolInt::get(ETy, 0)); + Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0)); } } diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp index c93bc2028c..6806d1c563 100644 --- a/lib/Analysis/LiveVar/ValueSet.cpp +++ b/lib/Analysis/LiveVar/ValueSet.cpp @@ -1,6 +1,6 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" void printValue( const Value *const v) // func to print a Value @@ -8,8 +8,8 @@ void printValue( const Value *const v) // func to print a Value if (v->hasName()) cerr << v << "(" << ((*v).getName()) << ") "; - else if (v->getValueType() == Value::ConstantVal) // if const - cerr << v << "(" << ((ConstPoolVal *) v)->getStrValue() << ") "; + else if (Constant *C = dyn_cast<Constant>(v)) + cerr << v << "(" << C->getStrValue() << ") "; else cerr << v << " "; } diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp index dc6ee710c4..583378c98e 100644 --- a/lib/Analysis/ModuleAnalyzer.cpp +++ b/lib/Analysis/ModuleAnalyzer.cpp @@ -11,7 +11,6 @@ #include "llvm/Module.h" #include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" -#include "llvm/ConstPoolVals.h" #include "Support/STLExtras.h" #include <map> diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 76052fa541..b05bb0ddac 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -13,7 +13,7 @@ #include "llvm/InstrTypes.h" #include "llvm/BasicBlock.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/iOther.h" #include "llvm/Method.h" #include "llvm/DerivedTypes.h" diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index b5816f20ac..acc3cfdb19 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -58,7 +58,7 @@ static struct PerModuleInfo { // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward // references to global values. Global values may be referenced before they // are defined, and if so, the temporary object that they represent is held - // here. This is used for forward references of ConstPoolPointerRefs. + // here. This is used for forward references of ConstantPointerRefs. // typedef map<pair<const PointerType *, ValID>, GlobalVariable*> GlobalRefsType; GlobalRefsType GlobalRefs; @@ -100,11 +100,11 @@ static struct PerModuleInfo { I->first.second.destroy(); // Free string memory if neccesary // Loop over all of the uses of the GlobalValue. The only thing they are - // allowed to be at this point is ConstPoolPointerRef's. + // allowed to be at this point is ConstantPointerRef's. assert(OldGV->use_size() == 1 && "Only one reference should exist!"); while (!OldGV->use_empty()) { - User *U = OldGV->use_back(); // Must be a ConstPoolPointerRef... - ConstPoolPointerRef *CPPR = cast<ConstPoolPointerRef>(U); + User *U = OldGV->use_back(); // Must be a ConstantPointerRef... + ConstantPointerRef *CPPR = cast<ConstantPointerRef>(U); assert(CPPR->getValue() == OldGV && "Something isn't happy"); // Change the const pool reference to point to the real global variable @@ -296,24 +296,24 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { // value will fit into the specified type... case ValID::ConstSIntVal: // Is it a constant pool reference?? if (Ty == Type::BoolTy) { // Special handling for boolean data - return ConstPoolBool::get(D.ConstPool64 != 0); + return ConstantBool::get(D.ConstPool64 != 0); } else { - if (!ConstPoolSInt::isValueValidForType(Ty, D.ConstPool64)) + if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) ThrowException("Symbolic constant pool value '" + itostr(D.ConstPool64) + "' is invalid for type '" + Ty->getName() + "'!"); - return ConstPoolSInt::get(Ty, D.ConstPool64); + return ConstantSInt::get(Ty, D.ConstPool64); } case ValID::ConstUIntVal: // Is it an unsigned const pool reference? - if (!ConstPoolUInt::isValueValidForType(Ty, D.UConstPool64)) { - if (!ConstPoolSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { + if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { ThrowException("Integral constant pool reference is invalid!"); } else { // This is really a signed reference. Transmogrify. - return ConstPoolSInt::get(Ty, D.ConstPool64); + return ConstantSInt::get(Ty, D.ConstPool64); } } else { - return ConstPoolUInt::get(Ty, D.UConstPool64); + return ConstantUInt::get(Ty, D.UConstPool64); } case ValID::ConstStringVal: // Is it a string const pool reference? @@ -322,14 +322,14 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { return 0; case ValID::ConstFPVal: // Is it a floating point const pool reference? - if (!ConstPoolFP::isValueValidForType(Ty, D.ConstPoolFP)) + if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) ThrowException("FP constant invalid for type!!"); - return ConstPoolFP::get(Ty, D.ConstPoolFP); + return ConstantFP::get(Ty, D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!Ty->isPointerType()) ThrowException("Cannot create a a non pointer null!"); - return ConstPoolPointerNull::get(cast<PointerType>(Ty)); + return ConstantPointerNull::get(cast<PointerType>(Ty)); default: assert(0 && "Unhandled case!"); @@ -635,7 +635,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) { BasicBlock *BasicBlockVal; TerminatorInst *TermInstVal; Instruction *InstVal; - ConstPoolVal *ConstVal; + Constant *ConstVal; const Type *PrimType; PATypeHolder<Type> *TypeVal; @@ -645,8 +645,8 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) { vector<Value*> *ValueList; list<PATypeHolder<Type> > *TypeList; list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node - list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable; - vector<ConstPoolVal*> *ConstVector; + list<pair<Constant*, BasicBlock*> > *JumpTable; + vector<Constant*> *ConstVector; int64_t SInt64Val; uint64_t UInt64Val; @@ -894,7 +894,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr (*$3)[i]->getType()->getName() + "'."); } - $$ = ConstPoolArray::get(ATy, *$3); + $$ = ConstantArray::get(ATy, *$3); delete $1; delete $3; } | Types '[' ']' { @@ -907,7 +907,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr if (NumElements != -1 && NumElements != 0) ThrowException("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +"!"); - $$ = ConstPoolArray::get(ATy, vector<ConstPoolVal*>()); + $$ = ConstantArray::get(ATy, vector<Constant*>()); delete $1; } | Types 'c' STRINGCONSTANT { @@ -923,19 +923,19 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr ThrowException("Can't build string constant of size " + itostr((int)(EndStr-$3)) + " when array has size " + itostr(NumElements) + "!"); - vector<ConstPoolVal*> Vals; + vector<Constant*> Vals; if (ETy == Type::SByteTy) { for (char *C = $3; C != EndStr; ++C) - Vals.push_back(ConstPoolSInt::get(ETy, *C)); + Vals.push_back(ConstantSInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { for (char *C = $3; C != EndStr; ++C) - Vals.push_back(ConstPoolUInt::get(ETy, *C)); + Vals.push_back(ConstantUInt::get(ETy, *C)); } else { free($3); ThrowException("Cannot build string arrays of non byte sized elements!"); } free($3); - $$ = ConstPoolArray::get(ATy, Vals); + $$ = ConstantArray::get(ATy, Vals); delete $1; < |