diff options
70 files changed, 5035 insertions, 4082 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index bd79747626..950c937824 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -2390,8 +2390,8 @@ provide a name for it (probably based on the name of the translation unit).</p> <div class="doc_text"> <p>Constant represents a base class for different types of constants. It -is subclassed by ConstantBool, ConstantInt, ConstantSInt, ConstantUInt, -ConstantArray etc for representing the various types of Constants.</p> +is subclassed by ConstantBool, ConstantInt, ConstantArray etc for representing +the various types of Constants.</p> </div> @@ -2406,17 +2406,12 @@ ConstantArray etc for representing the various types of Constants.</p> <div class="doc_subsubsection">Important Subclasses of Constant </div> <div class="doc_text"> <ul> - <li>ConstantSInt : This subclass of Constant represents a signed integer - constant. + <li>ConstantInt : This subclass of Constant represents an integer constant. <ul> - <li><tt>int64_t getValue() const</tt>: Returns the underlying value of - this constant. </li> - </ul> - </li> - <li>ConstantUInt : This class represents an unsigned integer. - <ul> - <li><tt>uint64_t getValue() const</tt>: Returns the underlying value of - this constant. </li> + <li><tt>int64_t getSExtValue() const</tt>: Returns the underlying value of + this constant as a sign extended signed integer value.</li> + <li><tt>uint64_t getZExtValue() const</tt>: Returns the underlying value + of this constant as a zero extended unsigned integer value.</li> </ul> </li> <li>ConstantFP : This class represents a floating point constant. diff --git a/docs/Stacker.html b/docs/Stacker.html index 7656dc10c0..a49b56de86 100644 --- a/docs/Stacker.html +++ b/docs/Stacker.html @@ -139,7 +139,7 @@ this: </p> Value* expression(BasicBlock* bb, Value* a, Value* b, Value* x, Value* y ) { - ConstantSInt* one = ConstantSInt::get(Type::IntTy, 1); + ConstantInt* one = ConstantInt::get(Type::IntTy, 1); BinaryOperator* or1 = BinaryOperator::createOr(a, b, "", bb); BinaryOperator* add1 = BinaryOperator::createAdd(x, one, "", bb); BinaryOperator* add2 = BinaryOperator::createAdd(y, one, "", bb); @@ -308,7 +308,7 @@ things, this leads to the idiom: </p> <pre> std::vector<Value*> index_vector; -index_vector.push_back( ConstantSInt::get( Type::LongTy, 0 ); +index_vector.push_back( ConstantInt::get( Type::LongTy, 0 ); // ... push other indices ... GetElementPtrInst* gep = new GetElementPtrInst( ptr, index_vector ); </pre> @@ -367,9 +367,9 @@ functions in the LLVM IR that make things easier. Here's what I learned: </p> <ul> <li>Constants are Values like anything else and can be operands of instructions</li> <li>Integer constants, frequently needed, can be created using the static "get" - methods of the ConstantInt, ConstantSInt, and ConstantUInt classes. The nice thing - about these is that you can "get" any kind of integer quickly.</li> - <li>There's a special method on Constant class which allows you to get the null + methods of the ConstantInt class. The nice thing about these is that you can + "get" any kind of integer quickly.</li> + <li>There's a special method on Constant class which allows you to get the null constant for <em>any</em> type. This is really handy for initializing large arrays or structures, etc.</li> </ul> diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index cdc84ca212..6f775515fb 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -45,8 +45,8 @@ static Function *CreateFibFunction(Module *M) { BasicBlock *BB = new BasicBlock("EntryBlock", FibF); // Get pointers to the constants. - Value *One = ConstantSInt::get(Type::IntTy, 1); - Value *Two = ConstantSInt::get(Type::IntTy, 2); + Value *One = ConstantInt::get(Type::IntTy, 1); + Value *Two = ConstantInt::get(Type::IntTy, 2); // Get pointer to the integer argument of the add1 function... Argument *ArgX = FibF->arg_begin(); // Get the arg. diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index 8fb9e5659d..8023cc7a18 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -60,7 +60,7 @@ int main() { BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); // Get pointers to the constant `1'. - Value *One = ConstantSInt::get(Type::IntTy, 1); + Value *One = ConstantInt::get(Type::IntTy, 1); // Get pointers to the integer argument of the add1 function... assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg @@ -84,7 +84,7 @@ int main() { BB = new BasicBlock("EntryBlock", FooF); // Get pointers to the constant `10'. - Value *Ten = ConstantSInt::get(Type::IntTy, 10); + Value *Ten = ConstantInt::get(Type::IntTy, 10); // Pass Ten to the call call: std::vector<Value*> Params; diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 04c6a9f95b..2ec5437c36 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -40,8 +40,8 @@ int main() { BasicBlock *BB = new BasicBlock("EntryBlock", F); // Get pointers to the constant integers... - Value *Two = ConstantSInt::get(Type::IntTy, 2); - Value *Three = ConstantSInt::get(Type::IntTy, 3); + Value *Two = ConstantInt::get(Type::IntTy, 2); + Value *Three = ConstantInt::get(Type::IntTy, 3); // Create the add instruction... does not insert... Instruction *Add = BinaryOperator::create(Instruction::Add, Two, Three, diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index b70f3db5bb..dfda126378 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -42,7 +42,7 @@ static Function* createAdd1(Module* M) BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); // Get pointers to the constant `1'. - Value *One = ConstantSInt::get(Type::IntTy, 1); + Value *One = ConstantInt::get(Type::IntTy, 1); // Get pointers to the integer argument of the add1 function... assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg @@ -70,8 +70,8 @@ static Function *CreateFibFunction(Module *M) BasicBlock *BB = new BasicBlock("EntryBlock", FibF); // Get pointers to the constants. - Value *One = ConstantSInt::get(Type::IntTy, 1); - Value *Two = ConstantSInt::get(Type::IntTy, 2); + Value *One = ConstantInt::get(Type::IntTy, 1); + Value *Two = ConstantInt::get(Type::IntTy, 2); // Get pointer to the integer argument of the add1 function... Argument *ArgX = FibF->arg_begin(); // Get the arg. diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 6b8e91958b..bc76248c15 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -41,22 +41,14 @@ struct ConvertConstantType; /// @brief An abstract class for integer constants. class ConstantIntegral : public Constant { protected: - union { - int64_t Signed; - uint64_t Unsigned; - } Val; + uint64_t Val; ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V); public: - - /// @brief Return the raw value of the constant as a 64-bit integer value. - inline uint64_t getRawValue() const { return Val.Unsigned; } - /// Return the constant as a 64-bit unsigned integer value after it /// has been zero extended as appropriate for the type of this constant. /// @brief Return the zero extended value. inline uint64_t getZExtValue() const { - unsigned Size = getType()->getPrimitiveSizeInBits(); - return Val.Unsigned & (~uint64_t(0UL) >> (64-Size)); + return Val; } /// Return the constant as a 64-bit integer value after it has been sign @@ -64,7 +56,7 @@ public: /// @brief Return the sign extended value. inline int64_t getSExtValue() const { unsigned Size = getType()->getPrimitiveSizeInBits(); - return (Val.Signed << (64-Size)) >> (64-Size); + return (int64_t(Val) << (64-Size)) >> (64-Size); } /// This function is implemented by subclasses and will return true iff this @@ -111,8 +103,7 @@ public: static inline bool classof(const ConstantIntegral *) { return true; } static bool classof(const Value *V) { return V->getValueType() == ConstantBoolVal || - V->getValueType() == ConstantSIntVal || - V->getValueType() == ConstantUIntVal; + V->getValueType() == ConstantIntVal; } }; @@ -147,7 +138,7 @@ public: /// @returns the value of this ConstantBool /// @brief return the boolean value of this constant. - inline bool getValue() const { return static_cast<bool>(getRawValue()); } + inline bool getValue() const { return static_cast<bool>(getZExtValue()); } /// @see ConstantIntegral for details /// @brief Implement overrides @@ -165,13 +156,15 @@ public: //===----------------------------------------------------------------------===// -/// This is the abstract superclass of ConstantSInt & ConstantUInt, to make -/// dealing with integral constants easier when sign is irrelevant. -/// @brief Abstract clas for constant integers. +/// This is concrete integer subclass of ConstantIntegral that represents +/// both signed and unsigned integral constants, other than boolean. +/// @brief Class for constant integers. class ConstantInt : public ConstantIntegral { protected: ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT - ConstantInt(const Type *Ty, ValueTy VT, uint64_t V); + ConstantInt(const Type *Ty, uint64_t V); + ConstantInt(const Type *Ty, int64_t V); + friend struct ConstantCreator<ConstantInt, Type, uint64_t>; public: /// A helper method that can be used to determine if the constant contained /// within is equal to a constant. This only works for very small values, @@ -180,48 +173,15 @@ public: bool equalsInt(unsigned char V) const { assert(V <= 127 && "equalsInt: Can only be used with very small positive constants!"); - return Val.Unsigned == V; + return Val == V; } /// Return a ConstantInt with the specified value for the specified type. - /// This only works for very small values, because this is all that can be - /// represented with all types integer types. + /// Overloads for ll the integer types are provided to ensure that implicit + /// conversions don't bite us and to get around compiler errors where the + /// compiler can't find a suitable overload for a given integer value. /// @brief Get a ConstantInt for a specific value. - static ConstantInt *get(const Type *Ty, unsigned char V); - - /// @returns true if this is the null integer value. - /// @see ConstantIntegral for details - /// @brief Implement override. - virtual bool isNullValue() const { return Val.Unsigned == 0; } - - /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. - static inline bool classof(const ConstantInt *) { return true; } - static bool classof(const Value *V) { - return V->getValueType() == ConstantSIntVal || - V->getValueType() == ConstantUIntVal; - } -}; - - -//===----------------------------------------------------------------------===// -/// A concrete class to represent constant signed integer values for the types -/// sbyte, short, int, and long. -/// @brief Constant Signed Integer Class. -class ConstantSInt : public ConstantInt { - ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT - friend struct ConstantCreator<ConstantSInt, Type, int64_t>; - -protected: - ConstantSInt(const Type *Ty, int64_t V); -public: - /// This static factory methods returns objects of the specified value. Note - /// that repeated calls with the same operands return the same object. - /// @returns A ConstantSInt instant for the type and value requested. - /// @brief Get a signed integer constant. - static ConstantSInt *get( - const Type *Ty, ///< The type of constant (SByteTy, IntTy, ShortTy, LongTy) - int64_t V ///< The value for the constant integer. - ); + static ConstantInt *get(const Type *Ty, int64_t V); /// This static method returns true if the type Ty is big enough to /// represent the value V. This can be used to avoid having the get method @@ -230,24 +190,28 @@ public: /// @brief Determine if the value is in range for the given type. static bool isValueValidForType(const Type *Ty, int64_t V); - /// @returns the underlying value of this constant. - /// @brief Get the constant value. - inline int64_t getValue() const { return Val.Signed; } + /// @returns true if this is the null integer value. + /// @see ConstantIntegral for details + /// @brief Implement override. + virtual bool isNullValue() const { return Val == 0; } /// @returns true iff this constant's bits are all set to true. /// @see ConstantIntegral /// @brief Override implementation - virtual bool isAllOnesValue() const { return getValue() == -1; } + virtual bool isAllOnesValue() const { return getSExtValue() == -1; } /// @returns true iff this is the largest value that may be represented /// by this type. /// @see ConstantIntegeral /// @brief Override implementation virtual bool isMaxValue() const { - int64_t V = getValue(); - if (V < 0) return false; // Be careful about wrap-around on 'long's - ++V; - return !isValueValidForType(getType(), V) || V < 0; + if (getType()->isSigned()) { + int64_t V = getSExtValue(); + if (V < 0) return false; // Be careful about wrap-around on 'long's + ++V; + return !isValueValidForType(getType(), V) || V < 0; + } + return isAllOnesValue(); } /// @returns true if this is the smallest value that may be represented by @@ -255,52 +219,19 @@ public: /// @see ConstantIntegral /// @brief Override implementation virtual bool isMinValue() const { - int64_t V = getValue(); - if (V > 0) return false; // Be careful about wrap-around on 'long's - --V; - return !isValueValidForType(getType(), V) || V > 0; + if (getType()->isSigned()) { + int64_t V = getSExtValue(); + if (V > 0) return false; // Be careful about wrap-around on 'long's + --V; + return !isValueValidForType(getType(), V) || V > 0; + } + return getZExtValue() == 0; } - /// @brief Methods to support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const ConstantSInt *) { return true; } - static bool classof(const Value *V) { - return V->getValueType() == ConstantSIntVal; - } -}; - -//===----------------------------------------------------------------------===// -/// A concrete class that represents constant unsigned integer values of type -/// Type::UByteTy, Type::UShortTy, Type::UIntTy, or Type::ULongTy. -/// @brief Constant Unsigned Integer Class -class ConstantUInt : public ConstantInt { - ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT - friend struct ConstantCreator<ConstantUInt, Type, uint64_t>; -protected: - ConstantUInt(const Type *Ty, uint64_t V); -public: - /// get() - Static factory methods - Return objects of the specified value - /// - static ConstantUInt *get(const Type *Ty, uint64_t V); - - /// isValueValidForType - return true if Ty is big enough to represent V. - /// - static bool isValueValidForType(const Type *Ty, uint64_t V); - - /// getValue - return the underlying value of this constant. - /// - inline uint64_t getValue() const { return Val.Unsigned; } - - /// isMaxValue - Return true if this is the largest value that may be - /// represented by this type. - /// - virtual bool isAllOnesValue() const; - virtual bool isMaxValue() const { return isAllOnesValue(); } - virtual bool isMinValue() const { return getValue() == 0; } - - /// Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const ConstantUInt *) { return true; } + /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. + static inline bool classof(const ConstantInt *) { return true; } static bool classof(const Value *V) { - return V->getValueType() == ConstantUIntVal; + return V->getValueType() == ConstantIntVal; } }; @@ -591,8 +522,7 @@ public: } /// getSizeOf constant expr - computes the size of a type in a target - /// independent way (Note: the return type is ULong but the object is not - /// necessarily a ConstantUInt). + /// independent way (Note: the return type is a ULong). /// static Constant *getSizeOf(const Type *Ty); diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index 996c83cb8e..4e4d47513d 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -97,10 +97,10 @@ namespace llvm { } unsigned getLine() const { - return unsigned(cast<ConstantInt>(getOperand(1))->getRawValue()); + return unsigned(cast<ConstantInt>(getOperand(1))->getZExtValue()); } unsigned getColumn() const { - return unsigned(cast<ConstantInt>(getOperand(2))->getRawValue()); + return unsigned(cast<ConstantInt>(getOperand(2))->getZExtValue()); } std::string getFileName() const; diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 72a4ed9146..157ef6e2b6 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -151,8 +151,7 @@ public: ConstantExprVal, // This is an instance of ConstantExpr ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull ConstantBoolVal, // This is an instance of ConstantBool - ConstantSIntVal, // This is an instance of ConstantSInt - ConstantUIntVal, // This is an instance of ConstantUInt + ConstantIntVal, // This is an instance of ConstantInt ConstantFPVal, // This is an instance of ConstantFP ConstantArrayVal, // This is an instance of ConstantArray ConstantStructVal, // This is an instance of ConstantStruct diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index fdc452b44f..8d4cbdb93d 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -468,11 +468,10 @@ static bool ValuesEqual(Value *V1, Value *V2) { /// CheckGEPInstructions - Check two GEP instructions with known must-aliasing /// base pointers. This checks to see if the index expressions preclude the /// pointers from aliasing... -AliasAnalysis::AliasResult BasicAliasAnalysis:: -CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, - unsigned G1S, - const Type *BasePtr2Ty, std::vector<Value*> &GEP2Ops, - unsigned G2S) { +AliasAnalysis::AliasResult +BasicAliasAnalysis::CheckGEPInstructions( + const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, unsigned G1S, + const Type *BasePtr2Ty, std::vector<Value*> &GEP2Ops, unsigned G2S) { // We currently can't handle the case when the base pointers have different // primitive types. Since this is uncommon anyway, we are happy being // extremely conservative. @@ -670,7 +669,7 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, if (const ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) { // If this is an array index, make sure the array element is in range. if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) - if (Op1C->getRawValue() >= AT->getNumElements()) + if (Op1C->getZExtValue() >= AT->getNumElements()) return MayAlias; // Be conservative with out-of-range accesses } else { @@ -685,7 +684,7 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, // value possible. // if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) - GEP1Ops[i] = ConstantSInt::get(Type::LongTy,AT->getNumElements()-1); + GEP1Ops[i] = ConstantInt::get(Type::LongTy, AT->getNumElements()-1); } } @@ -693,7 +692,7 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, if (const ConstantInt *Op2C = dyn_cast<ConstantInt>(Op2)) { // If this is an array index, make sure the array element is in range. if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) - if (Op2C->getRawValue() >= AT->getNumElements()) + if (Op2C->getZExtValue() >= AT->getNumElements()) return MayAlias; // Be conservative with out-of-range accesses } else { // Conservatively assume the minimum value for this index GEP2Ops[i] = Constant::getNullValue(Op2->getType()); diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 7e802ba7dd..359766d444 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -163,14 +163,15 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) { default: break; } - } else if (ConstantUInt *Op = dyn_cast<ConstantUInt>(Operands[0])) { - uint64_t V = Op->getValue(); + } else if (ConstantInt *Op = dyn_cast<ConstantInt>(Operands[0])) { + assert(Op->getType()->isUnsigned() && "bswap args must be unsigned"); + uint64_t V = Op->getZExtValue(); if (Name == "llvm.bswap.i16") - return ConstantUInt::get(Ty, ByteSwap_16(V)); + return ConstantInt::get(Ty, ByteSwap_16(V)); else if (Name == "llvm.bswap.i32") - return ConstantUInt::get(Ty, ByteSwap_32(V)); + return ConstantInt::get(Ty, ByteSwap_32(V)); else if (Name == "llvm.bswap.i64") - return ConstantUInt::get(Ty, ByteSwap_64(V)); + return ConstantInt::get(Ty, ByteSwap_64(V)); } } else if (Operands.size() == 2) { if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) { diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index beb61754fc..9e12c9343d 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -161,7 +161,7 @@ uint64_t ConstantRange::getSetSize() const { // Simply subtract the bounds... Constant *Result = ConstantExpr::getSub(Upper, Lower); - return cast<ConstantInt>(Result)->getRawValue(); + return cast<ConstantInt>(Result)->getZExtValue(); } /// contains - Return true if the specified value is in the set. @@ -288,7 +288,7 @@ ConstantRange ConstantRange::zeroExtend(const Type *Ty) const { // Change a source full set into [0, 1 << 8*numbytes) unsigned SrcTySize = getLower()->getType()->getPrimitiveSize(); return ConstantRange(Constant::getNullValue(Ty), - ConstantUInt::get(Ty, 1ULL << SrcTySize*8)); + ConstantInt::get(Ty, 1ULL << SrcTySize*8)); } Constant *Lower = getLower(); diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index dbfbea3981..c5c68b3a69 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -407,7 +407,7 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) { I != E; ++I) if (const StructType *STy = dyn_cast<StructType>(*I)) { unsigned FieldNo = - (unsigned)cast<ConstantUInt>(I.getOperand())->getValue(); + (unsigned)cast<ConstantInt>(I.getOperand())->getZExtValue(); Offset += (unsigned)TD.getStructLayout(STy)->MemberOffsets[FieldNo]; } else if (const PointerType *PTy = dyn_cast<PointerType>(*I)) { if (!isa<Constant>(I.getOperand()) || diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 93d20f474f..a992e51e0f 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -177,7 +177,7 @@ SCEVHandle SCEVConstant::get(ConstantInt *V) { // Make sure that SCEVConstant instances are all unsigned. if (V->getType()->isSigned()) { const Type *NewTy = V->getType()->getUnsignedVersion(); - V = cast<ConstantUInt>(ConstantExpr::getCast(V, NewTy)); + V = cast<ConstantInt>(ConstantExpr::getCast(V, NewTy)); } SCEVConstant *&R = (*SCEVConstants)[V]; @@ -463,9 +463,9 @@ SCEVHandle SCEVUnknown::getIntegerSCEV(int Val, const Type *Ty) { else if (Ty->isFloatingPoint()) C = ConstantFP::get(Ty, Val); else if (Ty->isSigned()) - C = ConstantSInt::get(Ty, Val); + C = ConstantInt::get(Ty, Val); else { - C = ConstantSInt::get(Ty->getSignedVersion(), Val); + C = ConstantInt::get(Ty->getSignedVersion(), Val); C = ConstantExpr::getCast(C, Ty); } return SCEVUnknown::get(C); @@ -507,11 +507,11 @@ static SCEVHandle PartialFact(SCEVHandle V, unsigned NumSteps) { // Handle this case efficiently, it is common to have constant iteration // counts while computing loop exit values. if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) { - uint64_t Val = SC->getValue()->getRawValue(); + uint64_t Val = SC->getValue()->getZExtValue(); uint64_t Result = 1; for (; NumSteps; --NumSteps) Result *= Val-(NumSteps-1); - Constant *Res = ConstantUInt::get(Type::ULongTy, Result); + Constant *Res = ConstantInt::get(Type::ULongTy, Result); return SCEVUnknown::get(ConstantExpr::getCast(Res, V->getType())); } @@ -1605,7 +1605,7 @@ GetAddressedElementFromGlobal(GlobalVariable *GV, const std::vector<ConstantInt*> &Indices) { Constant *Init = GV->getInitializer(); for (unsigned i = 0, e = Indices.size(); i != e; ++i) { - uint64_t Idx = Indices[i]->getRawValue(); + uint64_t Idx = Indices[i]->getZExtValue(); if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Init)) { assert(Idx < CS->getNumOperands() && "Bad struct index!"); Init = cast<Constant>(CS->getOperand(Idx)); @@ -1679,8 +1679,8 @@ ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS, unsigned MaxSteps = MaxBruteForceIterations; for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) { - ConstantUInt *ItCst = - ConstantUInt::get(IdxExpr->getType()->getUnsignedVersion(), IterationNum); + ConstantInt *ItCst = + ConstantInt::get(IdxExpr->getType()->getUnsignedVersion(), IterationNum); ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst); // Form the GEP offset. @@ -1896,7 +1896,7 @@ ComputeIterationCountExhaustively(const Loop *L, Value *Cond, bool ExitWhen) { if (CondVal->getValue() == ExitWhen) { ConstantEvolutionLoopExitValue[PN] = PHIVal; ++NumBruteForceTripCountsComputed; - return SCEVConstant::get(ConstantUInt::get(Type::UIntTy, IterationNum)); + return SCEVConstant::get(ConstantInt::get(Type::UIntTy, IterationNum)); } // Compute the value of the PHI node for the next iteration. @@ -1935,7 +1935,7 @@ SCEVHandle ScalarEvolutionsImpl::getSCEVAtScope(SCEV *V, const Loop *L) { // this is a constant evolving PHI node, get the final value at // the specified iteration number. Constant *RV = getConstantEvolutionLoopExitValue(PN, - ICC->getValue()->getRawValue(), + ICC->getValue()->getZExtValue(), LI); if (RV) return SCEVUnknown::get(RV); } @@ -2076,10 +2076,10 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { SqrtTerm = ConstantExpr::getSub(ConstantExpr::getMul(B, B), SqrtTerm); // Compute floor(sqrt(B^2-4ac)) - ConstantUInt *SqrtVal = - cast<ConstantUInt>(ConstantExpr::getCast(SqrtTerm, + ConstantInt *SqrtVal = + cast<ConstantInt>(ConstantExpr::getCast(SqrtTerm, SqrtTerm->getType()->getUnsignedVersion())); - uint64_t SqrtValV = SqrtVal->getValue(); + uint64_t SqrtValV = SqrtVal->getZExtValue(); uint64_t SqrtValV2 = (uint64_t)sqrt((double)SqrtValV); // The square root might not be precise for arbitrary 64-bit integer // values. Do some sanity checks to ensure it's correct. @@ -2089,7 +2089,7 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { return std::make_pair(CNC, CNC); } - SqrtVal = ConstantUInt::get(Type::ULongTy, SqrtValV2); + SqrtVal = ConstantInt::get(Type::ULongTy, SqrtValV2); SqrtTerm = ConstantExpr::getCast(SqrtVal, SqrtTerm->getType()); Constant *NegB = ConstantExpr::getNeg(B); diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index fd33e2fae2..68b52dd4fa 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -144,7 +144,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { // IF the step is by one, just return the inserted IV. if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(F)) - if (CI->getRawValue() == 1) + if (CI->getZExtValue() == 1) return I; // If the insert point is directly inside of the loop, emit the multiply at diff --git a/lib/AsmParser/Lexer.cpp.cvs b/lib/AsmParser/Lexer.cpp.cvs index f6306aff9d..605a8c9230 100644 --- a/lib/AsmParser/Lexer.cpp.cvs +++ b/lib/AsmParser/Lexer.cpp.cvs @@ -17,7 +17,7 @@ #define yylineno llvmAsmlineno #line 20 "Lexer.cpp" -/* A lexical scanner generated by flex */ +/* A lexical scanner generated by flex*/ /* Scanner skeleton version: * $Header$ @@ -28,6 +28,7 @@ #define YY_FLEX_MINOR_VERSION 5 #include <stdio.h> +#include <unistd.h> /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ @@ -41,7 +42,6 @@ #ifdef __cplusplus #include <stdlib.h> -#include <unistd.h> /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -153,6 +153,15 @@ extern FILE *yyin, *yyout; #define unput(c) yyunput( c, yytext_ptr ) +/* Some routines like yy_flex_realloc() are emitted as static but are + not called by all lexers. This generates warnings in some compilers, + notably GCC. Arrange to suppress these. */ +#ifdef __GNUC__ +#define YY_MAY_BE_UNUSED __attribute__((unused)) +#else +#define YY_MAY_BE_UNUSED +#endif + /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). @@ -259,7 +268,7 @@ YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static inline void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static inline void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED; static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer @@ -829,7 +838,7 @@ goto find_rule; \ #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 1 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" #define INITIAL 0 /*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===// // @@ -844,7 +853,7 @@ char *yytext; // //===----------------------------------------------------------------------===*/ #define YY_NEVER_INTERACTIVE 1 -#line 28 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 28 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" #include "ParserInternals.h" #include "llvm/Module.h" #include <list> @@ -970,7 +979,7 @@ using namespace llvm; /* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing * it to deal with 64 bit numbers. */ -#line 974 "Lexer.cpp" +#line 983 "Lexer.cpp" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1118,13 +1127,13 @@ YY_MALLOC_DECL YY_DECL { register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; + register char *yy_cp = NULL, *yy_bp = NULL; register int yy_act; -#line 179 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 179 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" -#line 1128 "Lexer.cpp" +#line 1137 "Lexer.cpp" if ( yy_init ) { @@ -1217,507 +1226,507 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 1: YY_RULE_SETUP -#line 181 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 181 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { /* Ignore comments for now */ } YY_BREAK case 2: YY_RULE_SETUP -#line 183 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 183 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return BEGINTOK; } YY_BREAK case 3: YY_RULE_SETUP -#line 184 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 184 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return ENDTOK; } YY_BREAK case 4: YY_RULE_SETUP -#line 185 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 185 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TRUETOK; } YY_BREAK case 5: YY_RULE_SETUP -#line 186 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 186 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return FALSETOK; } YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 187 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DECLARE; } YY_BREAK case 7: YY_RULE_SETUP -#line 188 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 188 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return GLOBAL; } YY_BREAK case 8: YY_RULE_SETUP -#line 189 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 189 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return CONSTANT; } YY_BREAK case 9: YY_RULE_SETUP -#line 190 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 190 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return INTERNAL; } YY_BREAK case 10: YY_RULE_SETUP -#line 191 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 191 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return LINKONCE; } YY_BREAK case 11: YY_RULE_SETUP -#line 192 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 192 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return WEAK; } YY_BREAK case 12: YY_RULE_SETUP -#line 193 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 193 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return APPENDING; } YY_BREAK case 13: YY_RULE_SETUP -#line 194 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 194 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DLLIMPORT; } YY_BREAK case 14: YY_RULE_SETUP -#line 195 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 195 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DLLEXPORT; } YY_BREAK case 15: YY_RULE_SETUP -#line 196 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 196 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return EXTERN_WEAK; } YY_BREAK case 16: YY_RULE_SETUP -#line 197 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 197 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return EXTERNAL; } /* Deprecated, turn into external */ YY_BREAK case 17: YY_RULE_SETUP -#line 198 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 198 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return EXTERNAL; } YY_BREAK case 18: YY_RULE_SETUP -#line 199 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 199 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return IMPLEMENTATION; } YY_BREAK case 19: YY_RULE_SETUP -#line 200 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 200 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return ZEROINITIALIZER; } YY_BREAK case 20: YY_RULE_SETUP -#line 201 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 201 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DOTDOTDOT; } YY_BREAK case 21: YY_RULE_SETUP -#line 202 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 202 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return UNDEF; } YY_BREAK case 22: YY_RULE_SETUP -#line 203 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 203 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return NULL_TOK; } YY_BREAK case 23: YY_RULE_SETUP -#line 204 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 204 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TO; } YY_BREAK case 24: YY_RULE_SETUP -#line 205 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 205 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Unwind, UNWIND); } YY_BREAK case 25: YY_RULE_SETUP -#line 206 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 206 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return NOT; } /* Deprecated, turned into XOR */ YY_BREAK case 26: YY_RULE_SETUP -#line 207 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 207 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TAIL; } YY_BREAK case 27: YY_RULE_SETUP -#line 208 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 208 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TARGET; } YY_BREAK case 28: YY_RULE_SETUP -#line 209 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 209 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TRIPLE; } YY_BREAK case 29: YY_RULE_SETUP -#line 210 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 210 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DEPLIBS; } YY_BREAK case 30: YY_RULE_SETUP -#line 211 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 211 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return ENDIAN; } YY_BREAK case 31: YY_RULE_SETUP -#line 212 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 212 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return POINTERSIZE; } YY_BREAK case 32: YY_RULE_SETUP -#line 213 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 213 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return DATA; } YY_BREAK case 33: YY_RULE_SETUP -#line 214 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 214 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return LITTLE; } YY_BREAK case 34: YY_RULE_SETUP -#line 215 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 215 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return BIG; } YY_BREAK case 35: YY_RULE_SETUP -#line 216 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 216 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return VOLATILE; } YY_BREAK case 36: YY_RULE_SETUP -#line 217 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 217 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return ALIGN; } YY_BREAK case 37: YY_RULE_SETUP -#line 218 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 218 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return SECTION; } YY_BREAK case 38: YY_RULE_SETUP -#line 219 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 219 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return MODULE; } YY_BREAK case 39: YY_RULE_SETUP -#line 220 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 220 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return ASM_TOK; } YY_BREAK case 40: YY_RULE_SETUP -#line 221 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 221 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return SIDEEFFECT; } YY_BREAK case 41: YY_RULE_SETUP -#line 223 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 223 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return CC_TOK; } YY_BREAK case 42: YY_RULE_SETUP -#line 224 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 224 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return CCC_TOK; } YY_BREAK case 43: YY_RULE_SETUP -#line 225 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 225 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return CSRETCC_TOK; } YY_BREAK case 44: YY_RULE_SETUP -#line 226 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 226 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return FASTCC_TOK; } YY_BREAK case 45: YY_RULE_SETUP -#line 227 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 227 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return COLDCC_TOK; } YY_BREAK case 46: YY_RULE_SETUP -#line 228 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 228 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return X86_STDCALLCC_TOK; } YY_BREAK case 47: YY_RULE_SETUP -#line 229 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 229 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return X86_FASTCALLCC_TOK; } YY_BREAK case 48: YY_RULE_SETUP -#line 231 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 231 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; } YY_BREAK case 49: YY_RULE_SETUP -#line 232 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 232 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; } YY_BREAK case 50: YY_RULE_SETUP -#line 233 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 233 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::SByteTy ; return SBYTE; } YY_BREAK case 51: YY_RULE_SETUP -#line 234 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 234 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::UByteTy ; return UBYTE; } YY_BREAK case 52: YY_RULE_SETUP -#line 235 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 235 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::ShortTy ; return SHORT; } YY_BREAK case 53: YY_RULE_SETUP -#line 236 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 236 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::UShortTy; return USHORT; } YY_BREAK case 54: YY_RULE_SETUP -#line 237 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 237 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::IntTy ; return INT; } YY_BREAK case 55: YY_RULE_SETUP -#line 238 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 238 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::UIntTy ; return UINT; } YY_BREAK case 56: YY_RULE_SETUP -#line 239 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 239 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::LongTy ; return LONG; } YY_BREAK case 57: YY_RULE_SETUP -#line 240 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 240 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG; } YY_BREAK case 58: YY_RULE_SETUP -#line 241 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 241 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT; } YY_BREAK case 59: YY_RULE_SETUP -#line 242 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 242 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; } YY_BREAK case 60: YY_RULE_SETUP -#line 243 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 243 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; } YY_BREAK case 61: YY_RULE_SETUP -#line 244 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 244 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return TYPE; } YY_BREAK case 62: YY_RULE_SETUP -#line 245 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 245 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return OPAQUE; } YY_BREAK case 63: YY_RULE_SETUP -#line 247 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 247 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Add, ADD); } YY_BREAK case 64: YY_RULE_SETUP -#line 248 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 248 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Sub, SUB); } YY_BREAK case 65: YY_RULE_SETUP -#line 249 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 249 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Mul, MUL); } YY_BREAK case 66: YY_RULE_SETUP -#line 250 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 250 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Div, DIV); } YY_BREAK case 67: YY_RULE_SETUP -#line 251 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 251 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Rem, REM); } YY_BREAK case 68: YY_RULE_SETUP -#line 252 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 252 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, And, AND); } YY_BREAK case 69: YY_RULE_SETUP -#line 253 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 253 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Or , OR ); } YY_BREAK case 70: YY_RULE_SETUP -#line 254 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 254 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, Xor, XOR); } YY_BREAK case 71: YY_RULE_SETUP -#line 255 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 255 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetNE, SETNE); } YY_BREAK case 72: YY_RULE_SETUP -#line 256 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 256 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetEQ, SETEQ); } YY_BREAK case 73: YY_RULE_SETUP -#line 257 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 257 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetLT, SETLT); } YY_BREAK case 74: YY_RULE_SETUP -#line 258 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 258 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetGT, SETGT); } YY_BREAK case 75: YY_RULE_SETUP -#line 259 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 259 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetLE, SETLE); } YY_BREAK case 76: YY_RULE_SETUP -#line 260 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 260 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(BinaryOpVal, SetGE, SETGE); } YY_BREAK case 77: YY_RULE_SETUP -#line 262 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 262 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, PHI, PHI_TOK); } YY_BREAK case 78: YY_RULE_SETUP -#line 263 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 263 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, Call, CALL); } YY_BREAK case 79: YY_RULE_SETUP -#line 264 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 264 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, Cast, CAST); } YY_BREAK case 80: YY_RULE_SETUP -#line 265 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 265 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, Select, SELECT); } YY_BREAK case 81: YY_RULE_SETUP -#line 266 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 266 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, Shl, SHL); } YY_BREAK case 82: YY_RULE_SETUP -#line 267 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 267 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, Shr, SHR); } YY_BREAK case 83: YY_RULE_SETUP -#line 268 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 268 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return VANEXT_old; } YY_BREAK case 84: YY_RULE_SETUP -#line 269 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 269 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return VAARG_old; } YY_BREAK case 85: YY_RULE_SETUP -#line 270 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 270 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, VAArg , VAARG); } YY_BREAK case 86: YY_RULE_SETUP -#line 271 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 271 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Ret, RET); } YY_BREAK case 87: YY_RULE_SETUP -#line 272 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 272 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Br, BR); } YY_BREAK case 88: YY_RULE_SETUP -#line 273 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 273 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Switch, SWITCH); } YY_BREAK case 89: YY_RULE_SETUP -#line 274 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 274 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Invoke, INVOKE); } YY_BREAK case 90: YY_RULE_SETUP -#line 275 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 275 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Unwind, UNWIND); } YY_BREAK case 91: YY_RULE_SETUP -#line 276 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 276 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); } YY_BREAK case 92: YY_RULE_SETUP -#line 278 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 278 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, Malloc, MALLOC); } YY_BREAK case 93: YY_RULE_SETUP -#line 279 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 279 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, Alloca, ALLOCA); } YY_BREAK case 94: YY_RULE_SETUP -#line 280 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 280 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, Free, FREE); } YY_BREAK case 95: YY_RULE_SETUP -#line 281 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 281 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, Load, LOAD); } YY_BREAK case 96: YY_RULE_SETUP -#line 282 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 282 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, Store, STORE); } YY_BREAK case 97: YY_RULE_SETUP -#line 283 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 283 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); } YY_BREAK case 98: YY_RULE_SETUP -#line 285 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 285 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); } YY_BREAK case 99: YY_RULE_SETUP -#line 286 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 286 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); } YY_BREAK case 100: YY_RULE_SETUP -#line 287 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 287 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); } YY_BREAK case 101: YY_RULE_SETUP -#line 290 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 290 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { UnEscapeLexed(yytext+1); llvmAsmlval.StrVal = strdup(yytext+1); // Skip % @@ -1726,7 +1735,7 @@ YY_RULE_SETUP YY_BREAK case 102: YY_RULE_SETUP -#line 295 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 295 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { yytext[strlen(yytext)-1] = 0; // nuke colon UnEscapeLexed(yytext); @@ -1736,7 +1745,7 @@ YY_RULE_SETUP YY_BREAK case 103: YY_RULE_SETUP -#line 301 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 301 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { yytext[strlen(yytext)-2] = 0; // nuke colon, end quote UnEscapeLexed(yytext+1); @@ -1746,7 +1755,7 @@ YY_RULE_SETUP YY_BREAK case 104: YY_RULE_SETUP -#line 308 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 308 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { // Note that we cannot unescape a string constant here! The // string constant might contain a \00 which would not be // understood by the string stuff. It is valid to make a @@ -1759,12 +1768,12 @@ YY_RULE_SETUP YY_BREAK case 105: YY_RULE_SETUP -#line 319 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 319 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; } YY_BREAK case 106: YY_RULE_SETUP -#line 320 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 320 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { uint64_t Val = atoull(yytext+1); // +1: we have bigger negative range @@ -1776,7 +1785,7 @@ YY_RULE_SETUP YY_BREAK case 107: YY_RULE_SETUP -#line 328 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 328 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.UInt64Val = HexIntToVal(yytext+3); return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL; @@ -1784,7 +1793,7 @@ YY_RULE_SETUP YY_BREAK case 108: YY_RULE_SETUP -#line 333 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 333 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { uint64_t Val = atoull(yytext+1); if ((unsigned)Val != Val) @@ -1795,7 +1804,7 @@ YY_RULE_SETUP YY_BREAK case 109: YY_RULE_SETUP -#line 340 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 340 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { uint64_t Val = atoull(yytext+2); // +1: we have bigger negative range @@ -1807,16 +1816,16 @@ YY_RULE_SETUP YY_BREAK case 110: YY_RULE_SETUP -#line 349 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 349 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.FPVal = atof(yytext); return FPVAL; } YY_BREAK case 111: YY_RULE_SETUP -#line 350 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 350 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 352 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 352 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { /* Make sure to free the internal buffers for flex when we are * done reading our input! @@ -1827,20 +1836,20 @@ case YY_STATE_EOF(INITIAL): YY_BREAK case 112: YY_RULE_SETUP -#line 360 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 360 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { /* Ignore whitespace */ } YY_BREAK case 113: YY_RULE_SETUP -#line 361 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 361 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" { return yytext[0]; } YY_BREAK case 114: YY_RULE_SETUP -#line 363 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 363 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1844 "Lexer.cpp" +#line 1853 "Lexer.cpp" case YY_END_OF_BUFFER: { @@ -2216,6 +2225,7 @@ register char *yy_bp; #endif /* ifndef YY_NO_UNPUT */ +#ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput() #else @@ -2289,7 +2299,7 @@ static int input() return c; } - +#endif /* YY_NO_INPUT */ #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) @@ -2400,11 +2410,6 @@ YY_BUFFER_STATE b; } -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) @@ -2722,5 +2727,5 @@ int main() return 0; } #endif -#line 363 "/Users/resistor/llvm/src/llvm/lib/AsmParser/Lexer.l" +#line 363 "/proj/llvm/llvm/lib/AsmParser/Lexer.l" diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs index 8116e98962..2bcfe0144b 100644 --- a/lib/AsmParser/llvmAsmParser.cpp.cvs +++ b/lib/AsmParser/llvmAsmParser.cpp.cvs @@ -1,124 +1,290 @@ +/* A Bison parser, made by GNU Bison 2.1. */ -/* A Bison parser, made from /Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y - by GNU Bison version 1.28 */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -#define YYBISON 1 /* Identify Bison output. */ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ #define yyparse llvmAsmparse -#define yylex llvmAsmlex +#define yylex llvmAsmlex #define yyerror llvmAsmerror -#define yylval llvmAsmlval -#define yychar llvmAsmchar +#define yylval llvmAsmlval +#define yychar llvmAsmchar #define yydebug llvmAsmdebug #define yynerrs llvmAsmnerrs -#define ESINT64VAL 257 -#define EUINT64VAL 258 -#define SINTVAL 259 -#define UINTVAL 260 -#define FPVAL 261 -#define VOID 262 -#define BOOL 263 -#define SBYTE 264 -#define UBYTE 265 -#define SHORT 266 -#define USHORT 267 -#define INT 268 -#define UINT 269 -#define LONG 270 -#define ULONG 271 -#define FLOAT 272 -#define DOUBLE 273 -#define TYPE 274 -#define LABEL 275 -#define VAR_ID 276 -#define LABELSTR 277 -#define STRINGCONSTANT 278 -#define IMPLEMENTATION 279 -#define ZEROINITIALIZER 280 -#define TRUETOK 281 -#define FALSETOK 282 -#define BEGINTOK 283 -#define ENDTOK 284 -#define DECLARE 285 -#define GLOBAL 286 -#define CONSTANT 287 -#define SECTION 288 -#define VOLATILE 289 -#define TO 290 -#define DOTDOTDOT 291 -#define NULL_TOK 292 -#define UNDEF 293 -#define CONST 294 -#define INTERNAL 295 -#define LINKONCE 296 -#define WEAK 297 -#define APPENDING 298 -#define DLLIMPORT 299 -#define DLLEXPORT 300 -#define EXTERN_WEAK 301 -#define OPAQUE 302 -#define NOT 303 -#define EXTERNAL 304 -#define TARGET 305 -#define TRIPLE 306 -#define ENDIAN 307 -#define POINTERSIZE 308 -#define LITTLE 309 -#define BIG 310 -#define ALIGN 311 -#define DEPLIBS 312 -#define CALL 313 -#define TAIL 314 -#define ASM_TOK 315 -#define MODULE 316 -#define SIDEEFFECT 317 -#define CC_TOK 318 -#define CCC_TOK 319 -#define CSRETCC_TOK 320 -#define FASTCC_TOK 321 -#define COLDCC_TOK 322 -#define X86_STDCALLCC_TOK 323 -#define X86_FASTCALLCC_TOK 324 -#define DATA 325 -#define RET 326 -#define BR 327 -#define SWITCH 328 -#define INVOKE 329 -#define UNWIND 330 -#define UNREACHABLE 331 -#define ADD 332 -#define SUB 333 -#define MUL 334 -#define DIV 335 -#define REM 336 -#define AND 337 -#define OR 338 -#define XOR 339 -#define SETLE 340 -#define SETGE 341 -#define SETLT 342 -#define SETGT 343 -#define SETEQ 344 -#define SETNE 345 -#define MALLOC 346 -#define ALLOCA 347 -#define FREE 348 -#define LOAD 349 -#define STORE 350 -#define GETELEMENTPTR 351 -#define PHI_TOK 352 -#define CAST 353 -#define SELECT 354 -#define SHL 355 -#define SHR 356 -#define VAARG 357 -#define EXTRACTELEMENT 358 -#define INSERTELEMENT 359 -#define SHUFFLEVECTOR 360 -#define VAARG_old 361 -#define VANEXT_old 362 - -#line 14 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ESINT64VAL = 258, + EUINT64VAL = 259, + SINTVAL = 260, + UINTVAL = 261, + FPVAL = 262, + VOID = 263, + BOOL = 264, + SBYTE = 265, + UBYTE = 266, + SHORT = 267, + USHORT = 268, + INT = 269, + UINT = 270, + LONG = 271, + ULONG = 272, + FLOAT = 273, + DOUBLE = 274, + TYPE = 275, + LABEL = 276, + VAR_ID = 277, + LABELSTR = 278, + STRINGCONSTANT = 279, + IMPLEMENTATION = 280, + ZEROINITIALIZER = 281, + TRUETOK = 282, + FALSETOK = 283, + BEGINTOK = 284, + ENDTOK = 285, + DECLARE = 286, + GLOBAL = 287, + CONSTANT = 288, + SECTION = 289, + VOLATILE = 290, + TO = 291, + DOTDOTDOT = 292, + NULL_TOK = 293, + UNDEF = 294, + CONST = 295, + INTERNAL = 296, + LINKONCE = 297, + WEAK = 298, + APPENDING = 299, + DLLIMPORT = 300, + DLLEXPORT = 301, + EXTERN_WEAK = 302, + OPAQUE = 303, + NOT = 304, + EXTERNAL = 305, + TARGET = 306, + TRIPLE = 307, + ENDIAN = 308, + POINTERSIZE = 309, + LITTLE = 310, + BIG = 311, + ALIGN = 312, + DEPLIBS = 313, + CALL = 314, + TAIL = 315, + ASM_TOK = 316, + MODULE = 317, + SIDEEFFECT = 318, + CC_TOK = 319, + CCC_TOK = 320, + CSRETCC_TOK = 321, + FASTCC_TOK = 322, + COLDCC_TOK = 323, + X86_STDCALLCC_TOK = 324, + X86_FASTCALLCC_TOK = 325, + DATA = 326, + RET = 327, + BR = 328, + SWITCH = 329, + INVOKE = 330, + UNWIND = 331, + UNREACHABLE = 332, + ADD = 333, + SUB = 334, + MUL = 335, + DIV = 336, + REM = 337, + AND = 338, + OR = 339, + XOR = 340, + SETLE = 341, + SETGE = 342, + SETLT = 343, + SETGT = 344, + SETEQ = 345, + SETNE = 346, + MALLOC = 347, + ALLOCA = 348, + FREE = 349, + LOAD = 350, + STORE = 351, + GETELEMENTPTR = 352, + PHI_TOK = 353, + CAST = 354, + SELECT = 355, + SHL = 356, + SHR = 357, + VAARG = 358, + EXTRACTELEMENT = 359, + INSERTELEMENT = 360, + SHUFFLEVECTOR = 361, + VAARG_old = 362, + VANEXT_old = 363 + }; +#endif +/* Tokens. */ +#define ESINT64VAL 258 +#define EUINT64VAL 259 +#define SINTVAL 260 +#define UINTVAL 261 +#define FPVAL 262 +#define VOID 263 +#define BOOL 264 +#define SBYTE 265 +#define UBYTE 266 +#define SHORT 267 +#define USHORT 268 +#define INT 269 +#define UINT 270 +#define LONG 271 +#define ULONG 272 +#define FLOAT 273 +#define DOUBLE 274 +#define TYPE 275 +#define LABEL 276 +#define VAR_ID 277 +#define LABELSTR 278 +#define STRINGCONSTANT 279 +#define IMPLEMENTATION 280 +#define ZEROINITIALIZER 281 +#define TRUETOK 282 +#define FALSETOK 283 +#define BEGINTOK 284 +#define ENDTOK 285 +#define DECLARE 286 +#define GLOBAL 287 +#define CONSTANT 288 +#define SECTION 289 +#define VOLATILE 290 +#define TO 291 +#define DOTDOTDOT 292 +#define NULL_TOK 293 +#define UNDEF 294 +#define CONST 295 +#define INTERNAL 296 +#define LINKONCE 297 +#define WEAK 298 +#define APPENDING 299 +#define DLLIMPORT 300 +#define DLLEXPORT 301 +#define EXTERN_WEAK 302 +#define OPAQUE 303 +#define NOT 304 +#define EXTERNAL 305 +#define TARGET 306 +#define TRIPLE 307 +#define ENDIAN 308 +#define POINTERSIZE 309 +#define LITTLE 310 +#define BIG 311 +#define ALIGN 312 +#define DEPLIBS 313 +#define CALL 314 +#define TAIL 315 +#define ASM_TOK 316 +#define MODULE 317 +#define SIDEEFFECT 318 +#define CC_TOK 319 +#define CCC_TOK 320 +#define CSRETCC_TOK 321 +#define FASTCC_TOK 322 +#define COLDCC_TOK 323 +#define X86_STDCALLCC_TOK 324 +#define X86_FASTCALLCC_TOK 325 +#define DATA 326 +#define RET 327 +#define BR 328 +#define SWITCH 329 +#define INVOKE 330 +#define UNWIND 331 +#define UNREACHABLE 332 +#define ADD 333 +#define SUB 334 +#define MUL 335 +#define DIV 336 +#define REM 337 +#define AND 338 +#define OR 339 +#define XOR 340 +#define SETLE 341 +#define SETGE 342 +#define SETLT 343 +#define SETGT 344 +#define SETEQ 345 +#define SETNE 346 +#define MALLOC 347 +#define ALLOCA 348 +#define FREE 349 +#define LOAD 350 +#define STORE 351 +#define GETELEMENTPTR 352 +#define PHI_TOK 353 +#define CAST 354 +#define SELECT 355 +#define SHL 356 +#define SHR 357 +#define VAARG 358 +#define EXTRACTELEMENT 359 +#define INSERTELEMENT 360 +#define SHUFFLEVECTOR 361 +#define VAARG_old 362 +#define VANEXT_old 363 + + + + +/* Copy the first part of user declarations. */ +#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -415,25 +581,25 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { // Check to make sure that "Ty" is an integral type, and that our // value will fit into the specified type... case ValID::ConstSIntVal: // Is it a constant pool reference?? - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Signed integral constant '" + itostr(D.ConstPool64) + "' is invalid for type '" + Ty->getDescription() + "'!"); return 0; } - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); case ValID::ConstUIntVal: // Is it an unsigned const pool reference? - if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Integral constant '" + utostr(D.UConstPool64) + "' is invalid or out of range!"); return 0; } else { // This is really a signed reference. Transmogrify. - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); } } else { - return ConstantUInt::get(Ty, D.UConstPool64); + return ConstantInt::get(Ty, D.UConstPool64); } case ValID::ConstFPVal: // Is it a floating point const pool reference? @@ -1078,8 +1244,28 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { } -#line 974 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -typedef union { + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 974 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" +typedef union YYSTYPE { llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair<llvm::PATypeHolder*, char*> *ArgVal; @@ -1118,1003 +1304,1457 @@ typedef union { llvm::Instruction::OtherOps OtherOpVal; llvm::Module::Endianness Endianness; } YYSTYPE; -#include <stdio.h> - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif +/* Line 196 of yacc.c. */ +#line 1309 "llvmAsmParser.tab.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif -#define YYFINAL 517 -#define YYFLAG -32768 -#define YYNTBASE 123 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 362 ? yytranslate[x] : 197) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 112, - 113, 121, 2, 110, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 117, - 109, 118, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 114, 111, 116, 2, 2, 2, 2, 2, 122, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 115, - 2, 2, 119, 2, 120, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108 -}; +/* Copy the second part of user declarations. */ -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, - 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 67, 68, 70, 72, 74, 76, 78, - 80, 82, 83, 84, 86, 88, 90, 92, 94, 96, - 99, 100, 103, 104, 108, 111, 112, 114, 115, 119, - 121, 124, 126, 128, 130, 132, 134, 136, 138, 140, - 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, - 162, 164, 166, 169, 174, 180, 186, 190, 193, 196, - 198, 202, 204, 208, 210, 211, 216, 220, 224, 229, - 234, 238, 241, 244, 247, 250, 253, 256, 259, 262, - 265, 268, 275, 281, 290, 297, 304, 311, 318, 325, - 334, 343, 347, 349, 351, 353, 355, 358, 361, 366, - 369, 371, 376, 379, 384, 385, 393, 394, 402, 403, - 411, 412, 420, 424, 429, 430, 432, 434, 436, 440, - 444, 448, 452, 456, 460, 462, 463, 465, 467, 469, - 470, 473, 477, 479, 481, 485, 487, 488, 497, 499, - 501, 505, 507, 509, 512, 513, 515, 517, 518, 523, - 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, - 546, 548, 554, 556, 558, 560, 562, 565, 568, 571, - 575, 578, 579, 581, 584, 587, 591, 601, 611, 620, - 634, 636, 638, 645, 651, 654, 661, 669, 671, 675, - 677, 678, 681, 683, 689, 695, 701, 704, 709, 714, - 721, 726, 731, 736, 741, 748, 755, 758, 766, 768, - 771, 772, 774, 775, 779, 786, 790, 797, 800, 805, - 812 -}; -static const short yyrhs[] = { 5, - 0, 6, 0, 3, 0, 4, 0, 78, 0, 79, - 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, - 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, - 0, 90, 0, 91, 0, 101, 0, 102, 0, 16, - 0, 14, 0, 12, 0, 10, 0, 17, 0, 15, - 0, 13, 0, 11, 0, 129, 0, 130, 0, 18, - 0, 19, 0, 165, 109, 0, 0, 41, 0, 42, - 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, - 0, 0, 0, 65, 0, 66, 0, 67, 0, 68, - 0, 69, 0, 70, 0, 64, 4, 0, 0, 57, - 4, 0, 0, 110, 57, 4, 0, 34, 24, 0, - 0, 138, 0, 0, 110, 141, 140, 0, 138, 0, - 57, 4, 0, 144, 0, 8, 0, 146, 0, 8, - 0, 146, 0, 9, 0, 10, 0, 11, 0, 12, - 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, - 0, 18, 0, 19, 0, 20, 0, 21, 0, 48, - 0, 145, 0, 180, 0, 111, 4, 0, 143, 112, - 148, 113, 0, 114, 4, 115, 146, 116, 0, 117, - 4, 115, 146, 118, 0, 119, 147, 120, 0, 119, - 120, 0, 146, 121, 0, 146, 0, 147, 110, 146, - 0, 147, 0, 147, 110, 37, 0, 37, 0, 0, - 144, 114, 151, 116, 0, 144, 114, 116, 0, 144, - 122, 24, 0, 144, 117, 151, 118, 0, 144, 119, - 151, 120, 0, 144, 119, 120, 0, 144, 38, 0, - 144, 39, 0, 144, 180, 0, 144, 150, 0, 144, - 26, 0, 129, 124, 0, 130, 4, 0, 9, 27, - 0, 9, 28, 0, 132, 7, 0, 99, 112, 149, - 36, 144, 113, 0, 97, 112, 149, 194, 113, 0, - 100, 112, 149, 110, 149, 110, 149, 113, 0, 125, - 112, 149, 110, 149, 113, 0, 126, 112, 149, 110, - 149, 113, 0, 127, 112, 149, 110, 149, 113, 0, - 128, 112, 149, 110, 149, 113, 0, 104, 112, 149, - 110, 149, 113, 0, 105, 112, 149, 110, 149, 110, - 149, 113, 0, 106, 112, 149, 110, 149, 110, 149, - 113, 0, 151, 110, 149, 0, 149, 0, 32, 0, - 33, 0, 154, 0, 154, 174, 0, 154, 176, 0, - 154, 62, 61, 160, 0, 154, 25, 0, 155, 0, - 155, 133, 20, 142, 0, 155, 176, 0, 155, 62, - 61, 160, 0, 0, 155, 133, 134, 152, 149, 156, - 140, 0, 0, 155, 133, 50, 152, 144, 157, 140, - 0, 0, 155, 133, 45, 152, 144, 158, 140, 0, - 0, 155, 133, 47, 152, 144, 159, 140, 0, 155, - 51, 162, 0, 155, 58, 109, 163, 0, 0, 24, - 0, 56, 0, 55, 0, 53, 109, 161, 0, 54, - 109, 4, 0, 52, 109, 24, 0, 71, 109, 24, - 0, 114, 164, 116, 0, 164, 110, 24, 0, 24, - 0, 0, 22, 0, 24, 0, 165, 0, 0, 144, - 166, 0, 168, 110, 167, 0, 167, 0, 168, 0, - 168, 110, 37, 0, 37, 0, 0, 135, 142, 165, - 112, 169, 113, 139, 136, 0, 29, 0, 119, 0, - 134, 170, 171, 0, 30, 0, 120, 0, 183, 173, - 0, 0, 45, 0, 47, 0, 0, 31, 177, 175, - 170, 0, 0, 63, 0, 3, 0, 4, 0, 7, - 0, 27, 0, 28, 0, 38, 0, 39, 0, 26, - 0, 117, 151, 118, 0, 150, 0, 61, 178, 24, - 110, 24, 0, 123, 0, 165, 0, 180, 0, 179, - 0, 144, 181, 0, 183, 184, 0, 172, 184, 0, - 185, 133, 186, 0, 185, 188, 0, 0, 23, 0, - 72, 182, 0, 72, 8, 0, 73, 21, 181, 0, - 73, 9, 181, 110, 21, 181, 110, 21, 181, 0, - 74, 131, 181, 110, 21, 181, 114, 187, 116, 0, - 74, 131, 181, 110, 21, 181, 114, 116, 0, 75, - 135, 142, 181, 112, 191, 113, 36, 21, 181, 76, - 21, 181, 0, 76, 0, 77, 0, 187, 131, 179, - 110, 21, 181, 0, 131, 179, 110, 21, 181, 0, - 133, 193, 0, 144, 114, 181, 110, 181, 116, 0, - 189, 110, 114, 181, 110, 181, 116, 0, 182, 0, - 190, 110, 182, 0, 190, 0, 0, 60, 59, 0, - 59, 0, 125, 144, 181, 110, 181, 0, 126, 144, - 181, 110, 181, 0, 127, 144, 181, 110, 181, 0, - 49, 182, 0, 128, 182, 110, 182, 0, 99, 182, - 36, 144, 0, 100, 182, 110, 182, 110, 182, 0, - 103, 182, 110, 144, 0, 107, 182, 110, 144, 0, - 108, 182, 110, 144, 0, 104, 182, 110, 182, 0, - 105, 182, 110, 182, 110, 182, 0, 106, 182, 110, - 182, 110, 182, 0, 98, 189, 0, 192, 135, 142, - 181, 112, 191, 113, 0, 196, 0, 110, 190, 0, - 0, 35, 0, 0, 92, 144, 137, 0, 92, 144, - 110, 15, 181, 137, 0, 93, 144, 137, 0, 93, - 144, 110, 15, 181, 137, 0, 94, 182, 0, 195, - 95, 144, 181, 0, 195, 96, 182, 110, 144, 181, - 0, 97, 144, 181, 194, 0 -}; +/* Line 219 of yacc.c. */ +#line 1321 "llvmAsmParser.tab.c" +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int #endif -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 1097, 1098, 1106, 1107, 1117, 1117, 1117, 1117, 1117, 1118, - 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, 1121, 1121, - 1125, 1125, 1125, 1125, 1126, 1126, 1126, 1126, 1127, 1127, - 1128, 1128, 1131, 1135, 1140, 1140, 1141, 1142, 1143, 1144, - 1145, 1146, 1149, 1149, 1150, 1151, 1152, 1153, 1154, 1155, - 1165, 1165, 1172, 1172, 1181, 1189, 1189, 1195, 1195, 1197, - 1202, 1216, 1216, 1217, 1217, 1219, 1229, 1229, 1229, 1229, - 1229, 1229, 1229, 1230, 1230, 1230, 1230, 1230, 1230, 1231, - 1235, 1239, 1247, 1255, 1268, 1273, 1285, 1295, 1299, 1310, - 1315, 1321, 1322, 1326, 1330, 1341, 1367, 1381, 1411, 1437, - 1458, 1471, 1481, 1486, 1547, 1554, 1563, 1569, 1575, 1579, - 1583, 1591, 1602, 1634, 1642, 1664, 1675, 1681, 1689, 1695, - 1701, 1710, 1714, 1722, 1722, 1732, 1740, 1745, 1749, 1753, - 1757, 1772, 1794, 1797, 1800, 1805, 1808, 1812, 1816, 1820, - 1824, 1829, 1833, 1836, 1839, 1843, 1856, 1857, 1859, 1863, - 1872, 1877, 1883, 1885, 1890, 1895, 1904, 1904, 1905, 1905, - 1907, 1914, 1920, 1927, 1931, 1937, 1942, 1947, 2042, 2042, - 2044, 2052, 2052, 2054, 2059, 2059, 2060, 2063, 2063, 2073, - 2077, 2082, 2086, 2090, 2094, 2098, 2102, 2106, 2110, 2114, - 2139, 2143, 2157, 2161, 2167, 2167, 2173, 2178, 2182, 2191, - 2202, 2207, 2219, 2232, 2236, 2240, 2245, 2254, 2273, 2282, - 2338, 2342, 2349, 2360, 2373, 2382, 2391, 2401, 2405, 2412, - 2412, 2414, 2418, 2423, 2439, 2454, 2468, 2481, 2489, 2497, - 2505, 2511, 2531, 2554, 2560, 2566, 2572, 2587, 2646, 2653, - 2656, 2661, 2665, 2672, 2677, 2683, 2688, 2694, 2702, 2714, - 2729 -}; +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif #endif +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# if defined (__STDC__) || defined (__cplusplus) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# define YYINCLUDED_STDLIB_H +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# endif +# ifdef __cplusplus +extern "C" { +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifdef __cplusplus +} +# endif +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", -"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT", -"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID", -"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK", -"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO", -"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING", -"DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE", -"ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK", -"MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK", -"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATA","RET","BR","SWITCH","INVOKE", -"UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE", -"SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE", -"GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT", -"INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'", -"'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL", -"ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType", -"FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString", -"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV", -"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr", -"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","@3", -"@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition","LibList", -"Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader", -"END","Function","FnDeclareLinkage","FunctionProto","@5","OptSideEffect","ConstValueRef", -"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList", -"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE", -"OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL -}; #endif -static const short yyr1[] = { 0, - 123, 123, 124, 124, 125, 125, 125, 125, 125, 126, - 126, 126, 127, 127, 127, 127, 127, 127, 128, 128, - 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, - 132, 132, 133, 133, 134, 134, 134, 134, 134, 134, - 134, 134, 135, 135, 135, 135, 135, 135, 135, 135, - 136, 136, 137, 137, 138, 139, 139, 140, 140, 141, - 141, 142, 142, 143, 143, 144, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 146, - 146, 146, 146, 146, 146, 146, 146, 146, 146, 147, - 147, 148, 148, 148, 148, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 151, 151, 152, 152, 153, 154, 154, 154, 154, - 154, 155, 155, 155, 156, 155, 157, 155, 158, 155, - 159, 155, 155, 155, 155, 160, 161, 161, 162, 162, - 162, 162, 163, 164, 164, 164, 165, 165, 166, 166, - 167, 168, 168, 169, 169, 169, 169, 170, 171, 171, - 172, 173, 173, 174, 175, 175, 175, 177, 176, 178, - 178, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 180, 180, 181, 181, 182, 183, 183, 184, - 185, 185, 185, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 187, 187, 188, 189, 189, 190, 190, 191, - 191, 192, 192, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, - 194, 195, 195, 196, 196, 196, 196, 196, 196, 196, - 196 -}; +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif -static const short yyr2[] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 1, 1, 1, 1, 1, 1, 2, - 0, 2, 0, 3, 2, 0, 1, 0, 3, 1, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 4, 5, 5, 3, 2, 2, 1, - 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, - 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 6, 5, 8, 6, 6, 6, 6, 6, 8, - 8, 3, 1, 1, 1, 1, 2, 2, 4, 2, - 1, 4, 2, 4, 0, 7, 0, 7, 0, 7, - 0, 7, 3, 4, 0, 1, 1, 1, 3, 3, - 3, 3, 3, 3, 1, 0, 1, 1, 1, 0, - 2, 3, 1, 1, 3, 1, 0, 8, 1, 1, - 3, 1, 1, 2, 0, 1, 1, 0, 4, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, - 1, 5, 1, 1, 1, 1, 2, 2, 2, 3, - 2, 0, 1, 2, 2, 3, 9, 9, 8, 13, - 1, 1, 6, 5, 2, 6, 7, 1, 3, 1, - 0, 2, 1, 5, 5, 5, 2, 4, 4, 6, - 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, - 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, - 4 +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 4 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 1339 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 123 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 75 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 252 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 517 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 363 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 112, 113, 121, 2, 110, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 117, 109, 118, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 114, 111, 116, 2, 2, 2, 2, 2, 122, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 115, 2, 2, 119, 2, 120, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108 }; -static const short yydefact[] = { 145, - 42, 131, 130, 178, 35, 36, 37, 38, 39, 40, - 41, 0, 43, 202, 127, 128, 202, 157, 158, 0, - 0, 0, 42, 0, 133, 175, 0, 0, 44, 45, - 46, 47, 48, 49, 0, 0, 203, 199, 34, 172, - 173, 174, 198, 0, 0, 0, 0, 143, 0, 0, - 0, 0, 0, 0, 0, 33, 176, 177, 43, 146, - 129, 50, 1, 2, 63, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 0, - 0, 0, 0, 193, 0, 0, 62, 81, 66, 194, - 82, 169, 170, 171, 243, 201, 0, 0, 0, 0, - 156, 144, 134, 132, 124, 125, 0, 0, 0, 0, - 179, 83, 0, 0, 65, 88, 90, 0, 0, 95, - 89, 242, 0, 223, 0, 0, 0, 0, 43, 211, - 212, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 0, 0, 0, 0, 0, - 0, 0, 19, 20, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 200, 43, 215, 0, 239, 151, - 148, 147, 149, 150, 152, 155, 0, 139, 141, 137, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 0, 0, 0, 0, 135, 0, 0, 0, 87, - 167, 94, 92, 0, 0, 227, 222, 205, 204, 0, - 0, 24, 28, 23, 27, 22, 26, 21, 25, 29, - 30, 0, 0, 53, 53, 248, 0, 0, 237, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 153, 58, 58, 58, 109, - 110, 3, 4, 107, 108, 111, 106, 102, 103, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 105, 104, 58, 64, 64, 91, 166, - 160, 163, 164, 0, 0, 84, 182, 183, 184, 189, - 185, 186, 187, 188, 180, 0, 191, 196, 195, 197, - 0, 206, 0, 0, 0, 244, 0, 246, 241, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 154, 0, 140, 142, - 138, 0, 0, 0, 0, 0, 0, 97, 123, 0, - 0, 101, 0, 98, 0, 0, 0, 0, 136, 85, - 86, 159, 161, 0, 56, 93, 181, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 251, 0, 0, 229, - 0, 231, 234, 0, 0, 232, 233, 0, 0, 0, - 228, 0, 249, 0, 0, 0, 60, 58, 241, 0, - 0, 0, 0, 0, 0, 96, 99, 100, 0, 0, - 0, 0, 165, 162, 57, 51, 0, 190, 0, 0, - 221, 53, 54, 53, 218, 240, 0, 0, 0, 0, - 0, 224, 225, 226, 221, 0, 55, 61, 59, 0, - 0, 0, 0, 0, 0, 122, 0, 0, 0, 0, - 0, 168, 0, 0, 0, 220, 0, 0, 245, 247, - 0, 0, 0, 230, 235, 236, 0, 250, 113, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 192, - 0, 0, 0, 219, 216, 0, 238, 112, 0, 119, - 0, 0, 115, 116, 117, 118, 0, 209, 0, 0, - 0, 217, 0, 0, 0, 207, 0, 208, 0, 0, - 114, 120, 121, 0, 0, 0, 0, 0, 0, 214, - 0, 0, 213, 210, 0, 0, 0 +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short int yyprhs[] = +{ + 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, + 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, + 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, + 59, 61, 63, 65, 67, 70, 71, 73, 75, 77, + 79, 81, 83, 85, 86, 87, 89, 91, 93, 95, + 97, 99, 102, 103, 106, 107, 111, 114, 115, 117, + 118, 122, 124, 127, 129, 131, 133, 135, 137, 139, + 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, + 161, 163, 165, 167, 169, 172, 177, 183, 189, 193, + 196, 199, 201, 205, 207, 211, 213, 214, 219, 223, + 227, 232, 237, 241, 244, 247, 250, 253, 256, 259, + 262, 265, 268, 271, 278, 284, 293, 300, 307, 314, + 321, 328, 337, 346, 350, 352, 354, 356, 358, 361, + 364, 369, 372, 374, 379, 382, 387, 388, 396, 397, + 405, 406, 414, 415, 423, 427, 432, 433, 435, 437, + 439, 443, 447, 451, 455, 459, 463, 465, 466, 468, + 470, 472, 473, 476, 480, 482, 484, 488, 490, 491, + 500, 502, 504, 508, 510, 512, 515, 516, 518, 520, + 521, 526, 527, 529, 531, 533, 535, 537, 539, 541, + 543, 545, 549, 551, 557, 559, 561, 563, 565, 568, + 571, 574, 578, 581, 582, 584, 587, 590, 594, 604, + 614, 623, 637, 639, 641, 648, 654, 657, 664, 672, + 674, 678, 680, 681, 684, 686, 692, 698, 704, 707, + 712, 717, 724, 729, 734, 739, 744, 751, 758, 761, + 769, 771, 774, 775, 777, 778, 782, 789, 793, 800, + 803, 808, 815 }; -static const short yydefgoto[] = { 84, - 254, 270, 271, 272, 273, 192, 193, 222, 194, 23, - 13, 35, 442, 306, 387, 406, 329, 388, 85, 86, - 195, 88, 89, 118, 204, 339, 297, 340, 107, 515, - 1, 2, 276, 249, 247, 248, 61, 173, 48, 102, - 177, 90, 353, 282, 283, 284, 36, 94, 14, 42, - 15, 59, 16, 26, 358, 298, 91, 300, 415, 17, - 38, 39, 165, 490, 96, 229, 446, 447, 166, 167, - 367, 168, 169 +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const short int yyrhs[] = +{ + 154, 0, -1, 5, -1, 6, -1, 3, -1, 4, + -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, + -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, + -1, 88, -1, 89, -1, 90, -1, 91, -1, 101, + -1, 102, -1, 16, -1, 14, -1, 12, -1, 10, + -1, 17, -1, 15, -1, 13, -1, 11, -1, 130, + -1, 131, -1, 18, -1, 19, -1, 166, 109, -1, + -1, 41, -1, 42, -1, 43, -1, 44, -1, 45, + -1, 46, -1, 47, -1, -1, -1, 65, -1, 66, + -1, 67, -1, 68, -1, 69, -1, 70, -1, 64, + 4, -1, -1, 57, 4, -1, -1, 110, 57, 4, + -1, 34, 24, -1, -1, 139, -1, -1, 110, 142, + 141, -1, 139, -1, 57, 4, -1, 145, -1, 8, + -1, 147, -1, 8, -1, 147, -1, 9, -1, 10, + -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, + -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, + -1, 21, -1, 48, -1, 146, -1, 181, -1, 111, + 4, -1, 144, 112, 149, 113, -1, 114, 4, 115, + 147, 116, -1, 117, 4, 115, 147, 118, -1, 119, + 148, 120, -1, 119, 120, -1, 147, 121, -1, 147, + -1, 148, 110, 147, -1, 148, -1, 148, 110, 37, + -1, 37, -1, -1, 145, 114, 152, 116, -1, 145, + 114, 116, -1, 145, 122, 24, -1, 145, 117, 152, + 118, -1, 145, 119, 152, 120, -1, 145, 119, 120, + -1, 145, 38, -1, 145, 39, -1, 145, 181, -1, + 145, 151, -1, 145, 26, -1, 130, 125, -1, 131, + 4, -1, 9, 27, -1, 9, 28, -1, 133, 7, + -1, 99, 112, 150, 36, 145, 113, -1, 97, 112, + 150, 195, 113, -1, 100, 112, 150, 110, 150, 110, + 150, 113, -1, 126, 112, 150, 110, 150, 113, -1, + 127, 112, 150, 110, 150, 113, -1, 128, 112, 150, + 110, 150, 113, -1, 129, 112, 150, 110, 150, 113, + -1, 104, 112, 150, 110, 150, 113, -1, 105, 112, + 150, 110, 150, 110, 150, 113, -1, 106, 112, 150, + 110, 150, 110, 150, 113, -1, 152, 110, 150, -1, + 150, -1, 32, -1, 33, -1, 155, -1, 155, 175, + -1, 155, 177, -1, 155, 62, 61, 161, -1, 155, + 25, -1, 156, -1, 156, 134, 20, 143, -1, 156, + 177, -1, 156, 62, 61, 161, -1, -1, 156, 134, + 135, 153, 150, 157, 141, -1, -1, 156, 134, 50, + 153, 145, 158, 141, -1, -1, 156, 134, 45, 153, + 145, 159, 141, -1, -1, 156, 134, 47, 153, 145, + 160, 141, -1, 156, 51, 163, -1, 156, 58, 109, + 164, -1, -1, 24, -1, 56, -1, 55, -1, 53, + 109, 162, -1, 54, 109, 4, -1, 52, 109, 24, + -1, 71, 109, 24, -1, 114, 165, 116, -1, 165, + 110, 24, -1, 24, -1, -1, 22, -1, 24, -1, + 166, -1, -1, 145, 167, -1, 169, 110, 168, -1, + 168, -1, 169, -1, 169, 110, 37, -1, 37, -1, + -1, 136, 143, 166, 112, 170, 113, 140, 137, -1, + 29, -1, 119, -1, 135, 171, 172, -1, 30, -1, + 120, -1, 184, 174, -1, -1, 45, -1, 47, -1, + -1, 31, 178, 176, 171, -1, -1, 63, -1, 3, + -1, 4, -1, 7, -1, 27, -1, 28, -1, 38, + -1, 39, -1, 26, -1, 117, 152, 118, -1, 151, + -1, 61, 179, 24, 110, 24, -1, 124, -1, 166, + -1, 181, -1, 180, -1, 145, 182, -1, 184, 185, + -1, 173, 185, -1, 186, 134, 187, -1, 186, 189, + -1, -1, 23, -1, 72, 183, -1, 72, 8, -1, + 73, 21, 182, -1, 73, 9, 182, 110, 21, 182, + 110, 21, 182, -1, 74, 132, 182, 110, 21, 182, + 114, 188, 116, -1, 74, 132, 182, 110, 21, 182, + 114, 116, -1, 75, 136, 143, 182, 112, 192, 113, + 36, 21, 182, 76, 21, 182, -1, 76, -1, 77, + -1, 188, 132, 180, 110, 21, 182, -1, 132, 180, + 110, 21, 182, -1, 134, 194, -1, 145, 114, 182, + 110, 182, 116, -1, 190, 110, 114, 182, 110, 182, + 116, -1, 183, -1, 191, 110, 183, -1, 191, -1, + -1, 60, 59, -1, 59, -1, 126, 145, 182, 110, + 182, -1, 127, 145, 182, 110, 182, -1, 128, 145, + 182, 110, 182, -1, 49, 183, -1, 129, 183, 110, + 183, -1, 99, 183, 36, 145, -1, 100, 183, 110, + 183, 110, 183, -1, 103, 183, 110, 145, -1, 107, + 183, 110, 145, -1, 108, 183, 110, 145, -1, 104, + 183, 110, 183, -1, 105, 183, 110, 183, 110, 183, + -1, 106, 183, 110, 183, 110, 183, -1, 98, 190, + -1, 193, 136, 143, 182, 112, 192, 113, -1, 197, + -1, 110, 191, -1, -1, 35, -1, -1, 92, 145, + 138, -1, 92, 145, 110, 15, 182, 138, -1, 93, + 145, 138, -1, 93, 145, 110, 15, 182, 138, -1, + 94, 183, -1, 196, 95, 145, 182, -1, 196, 96, + 183, 110, 145, 182, -1, 97, 145, 182, 195, -1 }; -static const short yypact[] = {-32768, - 118, 605,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768, -46, 131, 10,-32768,-32768, -18,-32768,-32768, 29, - -69, 58, 51, -19,-32768, 106, 114, 144,-32768,-32768, --32768,-32768,-32768,-32768, 1060, -20,-32768,-32768, 130,-32768, --32768,-32768,-32768, 80, 81, 83, 94,-32768, 57, 114, - 1060, 44, 44, 44, 44,-32768,-32768,-32768, 131,-32768, --32768,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 200, - 201, 202, 572,-32768, 130, 99,-32768,-32768, -34,-32768, --32768,-32768,-32768,-32768, 1231,-32768, 191, 77, 212, 193, - 194,-32768,-32768,-32768,-32768,-32768, 1101, 1101, 1101, 1142, --32768,-32768, 104, 107,-32768,-32768, -34, -74, 109, 852, --32768,-32768, 1101,-32768, 165, 1183, 30, 93, 131,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768, 1101, 1101, 1101, 1101, 1101, - 1101, 1101,-32768,-32768, 1101, 1101, 1101, 1101, 1101, 1101, - 1101, 1101, 1101, 1101,-32768, 131,-32768, 62,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768, -72,-32768,-32768,-32768, - 142, 170, 221, 173, 222, 175, 223, 178, 224, 231, - 232, 183, 225, 233, 425,-32768, 1101, 1101, 1101,-32768, - 893,-32768, 120, 128, 638,-32768,-32768, 90,-32768, 638, - 638,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768, 638, 1060, 121, 132,-32768, 638, 129, 134, 214, - 141, 143, 146, 147, 148, 149, 150, 638, 638, 638, - 151, 1060, 1101, 1101, 228,-32768, 152, 152, 152,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 153, - 154, 155, 156, 159, 160, 934, 1142, 592, 230, 161, - 164, 177, 180,-32768,-32768, 152, -37, -99, -34,-32768, - 130,-32768, 184, 174, 978,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768, 227, 1142,-32768,-32768,-32768,-32768, - 186,-32768, 187, 638, 2,-32768, 3,-32768, 188, 638, - 179, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 189, - 190, 195, 1101, 638, 638, 196,-32768, -23,-32768,-32768, --32768, 1142, 1142, 1142, 1142, 1142, 1142,-32768,-32768, -30, - 21,-32768, -73,-32768, 1142, 1142, 1142, 1142,-32768,-32768, --32768,-32768,-32768, 1019, 229,-32768,-32768, 240, 24, 280, - 286, 197, 638, 307, 638, 1101,-32768, 203, 638,-32768, - 205,-32768,-32768, 210, 211,-32768,-32768, 638, 638, 638, --32768, 215,-32768, 1101, 288, 318,-32768, 152, 188, 290, - 218, 219, 220, 226, 1142,-32768,-32768,-32768, 234, 237, - 241, 242,-32768,-32768,-32768, 284, 243,-32768, 638, 638, - 1101, 246,-32768, 246,-32768, 247, 638, 248, 1101, 1101, - 1101,-32768,-32768,-32768, 1101, 638,-32768,-32768,-32768, 252, - 1101, 1142, 1142, 1142, 1142,-32768, 1142, 1142, 1142, 1142, - 338,-32768, 319, 249, 236, 247, 253, 303,-32768,-32768, - 1101, 245, 638,-32768,-32768,-32768, 254,-32768,-32768, 256, - 260, 259, 263, 265, 264, 267, 270, 274,-32768,-32768, - 357, 14, 355,-32768,-32768, 276,-32768,-32768, 1142,-32768, - 1142, 1142,-32768,-32768,-32768,-32768, 638,-32768, 742, 52, - 372,-32768, 281, 282, 287,-32768, 289,-32768, 742, 638, --32768,-32768,-32768, 376, 291, 326, 638, 382, 383,-32768, - 638, 638,-32768,-32768, 405, 406,-32768 +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 1097, 1097, 1098, 1106, 1107, 1117, 1117, 1117, 1117, + 1117, 1118, 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, + 1121, 1121, 1125, 1125, 1125, 1125, 1126, 1126, 1126, 1126, + 1127, 1127, 1128, 1128, 1131, 1135, 1140, 1141, 1142, 1143, + 1144, 1145, 1146, 1147, 1149, 1150, 1151, 1152, 1153, 1154, + 1155, 1156, 1165, 1166, 1172, 1173, 1181, 1189, 1190, 1195, + 1196, 1197, 1202, 1216, 1216, 1217, 1217, 1219, 1229, 1229, + 1229, 1229, 1229, 1229, 1229, 1230, 1230, 1230, 1230, 1230, + 1230, 1231, 1235, 1239, 1247, 1255, 1268, 1273, 1285, 1295, + 1299, 1310, 1315, 1321, 1322, 1326, 1330, 1341, 1367, 1381, + 1411, 1437, 1458, 1471, 1481, 1486, 1547, 1554, 1563, 1569, + 1575, 1579, 1583, 1591, 1602, 1634, 1642, 1664, 1675, 1681, + 1689, 1695, 1701, 1710, 1714, 1722, 1722, 1732, 1740, 1745, + 1749, 1753, 1757, 1772, 1794, 1797, 1800, 1800, 1808, 1808, + 1816, 1816, 1824, 1824, 1833, 1836, 1839, 1843, 1856, 1857, + 1859, 1863, 1872, 1877, 1883, 1885, 1890, 1895, 1904, 1904, + 1905, 1905, 1907, 1914, 1920, 1927, 1931, 1937, 1942, 1947, + 2042, 2042, 2044, 2052, 2052, 2054, 2059, 2060, 2061, 2063, + 2063, 2073, 2077, 2082, 2086, 2090, 2094, 2098, 2102, 2106, + 2110, 2114, 2139, 2143, 2157, 2161, 2167, 2167, 2173, 2178, + 2182, 2191, 2202, 2207, 2219, 2232, 2236, 2240, 2245, 2254, + 2273, 2282, 2338, 2342, 2349, 2360, 2373, 2382, 2391, 2401, + 2405, 2412, 2412, 2414, 2418, 2423, 2439, 2454, 2468, 2481, + 2489, 2497, 2505, 2511, 2531, 2554, 2560, 2566, 2572, 2587, + 2646, 2653, 2656, 2661, 2665, 2672, 2677, 2683, 2688, 2694, + 2702, 2714, 2729 }; +#endif -static const short yypgoto[] = {-32768, --32768, 312, 313, 314, 315, -127, -126, -458,-32768, 373, - 388, -116,-32768, -221, 59,-32768, -241,-32768, -48,-32768, - -35,-32768, -62, 293,-32768, -100, 239, -226, 91,-32768, --32768,-32768,-32768,-32768,-32768,-32768, 365,-32768,-32768,-32768, --32768, 4,-32768, 63,-32768,-32768, 359,-32768,-32768,-32768, --32768,-32768, 417,-32768,-32768, -414, -55, 64, -103,-32768, - 403,-32768,-32768,-32768,-32768,-32768, 55, -3,-32768,-32768, - 34,-32768,-32768 +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", + "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", + "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", + "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", + "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", + "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", + "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", + "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", + "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", + "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", + "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", + "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATA", "RET", + "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", + "DIV", "REM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", + "SETEQ", "SETNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", + "GETELEMENTPTR", "PHI_TOK", "CAST", "SELECT", "SHL", "SHR", "VAARG", + "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", + "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", + "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", + "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "ShiftOps", + "SIntType", "UIntType", "IntType", "FPType", "OptAssign", "OptLinkage", + "OptCallingConv", "OptAlign", "OptCAlign", "SectionString", "OptSection", + "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV", + "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", + "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList", + "ConstPool", "@1", "@2", "@3", "@4", "AsmBlock", "BigOrLittle", + "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName", + "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", + "FunctionHeader", "END", "Function", "FnDeclareLinkage", "FunctionProto", + "@5", "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", + "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", + "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList", + "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile", + "MemoryInst", 0 }; +#endif - -#define YYLAST 1339 - - -static const short yytable[] = { 87, - 220, 221, 104, 308, 37, 24, 330, 331, 92, 196, - 385, 40, 223, 489, 27, 87, 363, 365, 351, 206, - 117, 121, 209, 212, 213, 214, 215, 216, 217, 218, - 219, 499, 37, 386, 349, 199, 395, 245, 210, 49, - 341, 343, 24, 246, 226, 200, 398, 230, 231, 242, - 211, 232, 233, 234, 235, 236, 237, 117, 364, 364, - 241, 212, 213, 214, 215, 216, 217, 218, 219, 359, - 51, 178, 179, 180, 497, 105, 106, -64, 350, 395, - 44, 45, 46, 121, 505, 396, 121, 205, 119, 56, - 205, 5, 6, 7, 8, 52, 10, 53, 93, 47, - 54, 41, 212, 213, 214, 215, 216, 217, 218, 219, - 224, 225, 205, 227, 228, 205, 205, -126, 50, 205, - 205, 205, 205, 205, 205, 238, 239, 240, 205, 488, - 395, 171, 172, 395, 277, 278, 279, 60, 397, 275, - 326, 408, 3, 108, 109, 110, 429, 62, 4, 299, - 57, 18, 58, 19, 299, 299, 243, 244, 5, 6, - 7, 8, 9, 10, 11, 281, 299, 498, 250, 251, - 101, 299, -24, -24, 304, -23, -23, -22, -22, 12, - -21, -21, 299, 299, 299, 252, 253, 87, 97, 98, - 449, 99, 450, 324, 28, 29, 30, 31, 32, 33, - 34, -65, 100, 112, 113, 114, 87, 325, 205, 371, - 120, 373, 374, 375, 170, 174, 175, 176, 197, 381, - 201, 198, 279, 207, -28, -27, -26, -25, 255, 285, - 305, 389, 390, 391, 392, 393, 394, -31, -32, 256, - 286, 307, 310, 311, 399, 400, 401, 402, 299, 312, - 313, 327, 314, 344, 299, 315, 316, 317, 318, 319, - 323, 328, 385, 407, 332, 333, 334, 335, 299, 299, - 336, 337, 345, 301, 302, 346, 370, 205, 372, 205, - 205, 205, 376, 377, 352, 303, 355, 205, 347, 357, - 309, 348, 369, 354, 436, 360, 361, 366, 378, 379, - 409, 320, 321, 322, 380, 384, 410, 299, 411, 299, - 413, 427, 417, 299, 419, 454, 455, 456, 281, 420, - 421, 428, 299, 299, 299, 431, 425, 432, 433, 434, - 205, 461, 462, 463, 464, 435, 465, 466, 467, 468, - 441, 469, 470, 437, 220, 221, 438, 474, 426, 472, - 439, 440, 443, 299, 299, 448, 451, 453, 471, 364, - 475, 299, 220, 221, 459, 473, 477, 362, 478, 479, - 299, 480, 481, 368, 482, 205, 483, 487, 493, 484, - 494, 495, 485, 205, 205, 205, 486, 382, 383, 205, - 491, 492, 500, 501, 502, 460, 507, 299, 504, 503, - 508, 509, 511, 512, 516, 517, 161, 162, 163, 164, - 55, 95, 203, 405, 103, 205, 404, 111, 25, 43, - 416, 457, 430, 0, 0, 0, 412, 0, 414, 63, - 64, 299, 418, 274, 0, 0, 0, 0, 0, 0, - 0, 422, 423, 424, 299, 0, 18, 0, 19, 0, - 257, 299, 0, 0, 0, 299, 299, 0, 0, 0, - 0, 0, 258, 259, 0, 0, 0, 0, 0, 0, - 0, 0, 444, 445, 0, 0, 0, 0, 0, 0, - 452, 0, 0, 0, 0, 0, 0, 0, 0, 458, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 476, 0, 0, 0, - 0, 260, 0, 261, 262, 153, 154, 0, 263, 264, - 265, 0, 0, 0, 0, 0, 0, 0, 266, 0, - 0, 267, 0, 268, 0, 0, 269, 0, 0, 0, - 496, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 506, 0, 0, 0, 0, 0, 0, - 510, 0, 0, 0, 513, 514, 63, 64, 0, 115, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 18, 0, 19, 63, 64, 0, 115, - 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, - 191, 77, 78, 18, 0, 19, 0, 0, 0, 79, - 0, 0, 0, 0, -34, 0, 18, 0, 19, 0, - 0, 0, 0, 0, 0, 4, -34, -34, 0, 79, - 287, 288, 63, 64, 289, -34, -34, -34, -34, -34, - -34, -34, 0, 0, -34, 20, 0, 0, 0, 18, - 0, 19, 21, 290, 291, 292, 22, 0, 0, 0, - 0, 0, 0, 0, 0, 293, 294, 0, 0, 0, - 0, 0, 80, 0, 0, 81, 0, 0, 82, 0, - 83, 116, 0, 0, 0, 0, 0, 0, 295, 0, - 0, 0, 80, 0, 0, 81, 0, 0, 82, 0, - 83, 342, 0, 0, 0, 132, 133, 134, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 0, - 0, 0, 0, 0, 260, 0, 261, 262, 153, 154, - 0, 263, 264, 265, 287, 288, 0, 0, 289, 0, - 0, 0, 0, 0, 296, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 290, 291, 292, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 293, - 294, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 295, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, - 143, 144, 145, 0, 0, 0, 0, 0, 260, 0, - 261, 262, 153, 154, 0, 263, 264, 265, 0, 0, - 0, 0, 0, 0, 0, 0, 63, 64, 296, 115, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 18, 0, 19, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 202, 0, - 0, 0, 0, 0, 0, 0, 0, 63, 64, 79, - 115, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 18, 0, 19, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 280, - 0, 0, 0, 0, 0, 0, 0, 0, 63, 64, - 79, 115, 181, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 77, 78, 18, 0, 19, 0, 0, - 0, 0, 80, 0, 0, 81, 0, 0, 82, 0, - 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 79, 63, 64, 0, 115, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 18, - 0, 19, 0, 80, 0, 0, 81, 0, 0, 82, - 0, 83, 0, 0, 356, 0, 0, 0, 0, 0, - 0, 0, 0, 63, 64, 79, 115, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 18, 0, 19, 0, 80, 0, 0, 81, 0, 338, - 82, 0, 83, 0, 0, 403, 0, 0, 0, 0, - 0, 0, 0, 0, 63, 64, 79, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 18, 0, 19, 0, 0, 0, 0, 80, 0, - 0, 81, 0, 0, 82, 0, 83, 0, 0, 0, - 0, 0, 0, 0, 0, 63, 64, 79, 115, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 18, 0, 19, 0, 0, 0, 0, 80, - 0, 0, 81, 0, 0, 82, 0, 83, 0, 0, - 0, 0, 0, 0, 0, 0, 63, 64, 79, 115, - 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, - 191, 77, 78, 18, 0, 19, 0, 0, 0, 0, - 80, 0, 0, 81, 0, 0, 82, 0, 83, 0, - 0, 0, 0, 0, 0, 0, 0, 63, 64, 79, - 208, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 18, 0, 19, 0, 0, 0, - 0, 80, 0, 0, 81, 0, 0, 82, 0, 83, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 80, 0, 0, 81, 0, 0, 82, 0, - 83, 0, 0, 0, 0, 122, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, - 125, 0, 0, 80, 0, 0, 81, 0, 0, 82, - 0, 83, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 0, 0, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, 160 +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 61, + 44, 92, 40, 41, 91, 120, 93, 60, 62, 123, + 125, 42, 99 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 123, 124, 124, 125, 125, 126, 126, 126, 126, + 126, 127, 127, 127, 128, 128, 128, 128, 128, 128, + 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, + 132, 132, 133, 133, 134, 134, 135, 135, 135, 135, + 135, 135, 135, 135, 136, 136, 136, 136, 136, 136, + 136, 136, 137, 137, 138, 138, 139, 140, 140, 141, + 141, 142, 142, 143, 143, 144, 144, 145, 146, 146, + 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, + 146, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 148, 148, 149, 149, 149, 149, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 152, 152, 153, 153, 154, 155, 155, + 155, 155, 155, 156, 156, 156, 157, 156, 158, 156, + 159, 156, 160, 156, 156, 156, 156, 161, 162, 162, + 163, 163, 163, 163, 164, 165, 165, 165, 166, 166, + 167, 167, 168, 169, 169, 170, 170, 170, 170, 171, + 172, 172, 173, 174, 174, 175, 176, 176, 176, 178, + 177, 179, 179, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 181, 181, 182, 182, 183, 184, + 184, 185, 186, 186, 186, 187, 187, 187, 187, 187, + 187, 187, 187, 187, 188, 188, 189, 190, 190, 191, + 191, 192, 192, 193, 193, 194, 194, 194, 194, 194, + 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + 194, 195, 195, 196, 196, 197, 197, 197, 197, 197, + 197, 197, 197 }; -static const short yycheck[] = { 35, - 128, 128, 51, 225, 23, 2, 248, 249, 29, 110, - 34, 30, 129, 472, 61, 51, 15, 15, 118, 123, - 83, 121, 126, 10, 11, 12, 13, 14, 15, 16, - 17, 490, 23, 57, 276, 110, 110, 110, 9, 109, - 267, 268, 39, 116, 148, 120, 120, 151, 152, 166, - 21, 155, 156, 157, 158, 159, 160, 120, 57, 57, - 164, 10, 11, 12, 13, 14, 15, 16, 17, 296, - 20, 107, 108, 109, 489, 32, 33, 112, 116, 110, - 52, 53, 54, 121, 499, 116, 121, 123, 85, 109, - 126, 41, 42, 43, 44, 45, 46, 47, 119, 71, - 50, 120, 10, 11, 12, 13, 14, 15, 16, 17, - 146, 147, 148, 149, 150, 151, 152, 0, 61, 155, - 156, 157, 158, 159, 160, 161, 162, 163, 164, 116, - 110, 55, 56, 110, 197, 198, 199, 24, 118, 195, - 244, 118, 25, 53, 54, 55, 388, 4, 31, 205, - 45, 22, 47, 24, 210, 211, 95, 96, 41, 42, - 43, 44, 45, 46, 47, 201, 222, 116, 27, 28, - 114, 227, 3, 4, 223, 3, 4, 3, 4, 62, - 3, 4, 238, 239, 240, 3, 4, 223, 109, 109, - 412, 109, 414, 242, 64, 65, 66, 67, 68, 69, - 70, 112, 109, 4, 4, 4, 242, 243, 244, 313, - 112, 315, 316, 317, 24, 4, 24, 24, 115, 323, - 112, 115, 285, 59, 4, 4, 4, 4, 4, 110, - 110, 332, 333, 334, 335, 336, 337, 7, 7, 7, - 113, 110, 114, 110, 345, 346, 347, 348, 304, 36, - 110, 24, 110, 24, 310, 110, 110, 110, 110, 110, - 110, 110, 34, 24, 112, 112, 112, 112, 324, 325, - 112, 112, 112, 210, 211, 112, 312, 313, 314, 315, - 316, 317, 318, 319, 281, 222, 113, 323, 112, 63, - 227, 112, 114, 110, 395, 110, 110, 110, 110, 110, - 21, 238, 239, 240, 110, 110, 21, 363, 112, 365, - 4, 24, 110, 369, 110, 419, 420, 421, 354, 110, - 110, 4, 378, 379, 380, 36, 112, 110, 110, 110, - 366, 432, 433, 434, 435, 110, 437, 438, 439, 440, - 57, 4, 24, 110, 472, 472, 110, 451, 384, 114, - 110, 110, 110, 409, 410, 110, 110, 110, 110, 57, - 116, 417, 490, 490, 113, 113, 113, 304, 113, 110, - 426, 113, 110, 310, 110, 411, 113, 21, 479, 113, - 481, 482, 113, 419, 420, 421, 113, 324, 325, 425, - 36, 116, 21, 113, 113, 431, 21, 453, 110, 113, - 110, 76, 21, 21, 0, 0, 95, 95, 95, 95, - 23, 39, 120, 355, 50, 451, 354, 59, 2, 17, - 366, 425, 389, -1, -1, -1, 363, -1, 365, 5, - 6, 487, 369, 195, -1, -1, -1, -1, -1, -1, - -1, 378, 379, 380, 500, -1, 22, -1, 24, -1, - 26, 507, -1, -1, -1, 511, 512, -1, -1, -1, - -1, -1, 38, 39, -1, -1, -1, -1, -1, -1, - -1, -1, 409, 410, -1, -1, -1, -1, -1, -1, - 417, -1, -1, -1, -1, -1, -1, -1, -1, 426, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, 453, -1, -1, -1, - -1, 97, -1, 99, 100, 101, 102, -1, 104, 105, - 106, -1, -1, -1, -1, -1, -1, -1, 114, -1, - -1, 117, -1, 119, -1, -1, 122, -1, -1, -1, - 487, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 500, -1, -1, -1, -1, -1, -1, - 507, -1, -1, -1, 511, 512, 5, 6, -1, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, -1, 24, 5, 6, -1, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, -1, 24, -1, -1, -1, 48, - -1, -1, -1, -1, 20, -1, 22, -1, 24, -1, - -1, -1, -1, -1, -1, 31, 32, 33, -1, 48, - 3, 4, 5, 6, 7, 41, 42, 43, 44, 45, - 46, 47, -1, -1, 50, 51, -1, -1, -1, 22, - -1, 24, 58, 26, 27, 28, 62, -1, -1, -1, - -1, -1, -1, -1, -1, 38, 39, -1, -1, -1, - -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, - 119, 120, -1, -1, -1, -1, -1, -1, 61, -1, - -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, - 119, 120, -1, -1, -1, 78, 79, 80, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, -1, - -1, -1, -1, -1, 97, -1, 99, 100, 101, 102, - -1, 104, 105, 106, 3, 4, -1, -1, 7, -1, - -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, - 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 61, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, -1, -1, -1, -1, -1, 97, -1, - 99, 100, 101, 102, -1, 104, 105, 106, -1, -1, - -1, -1, -1, -1, -1, -1, 5, 6, 117, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 37, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 48, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, - 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, - -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, - 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 48, 5, 6, -1, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - -1, 24, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, -1, -1, 37, -1, -1, -1, -1, -1, - -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, -1, 24, -1, 111, -1, -1, 114, -1, 116, - 117, -1, 119, -1, -1, 37, -1, -1, -1, -1, - -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, -1, 24, -1, -1, -1, -1, 111, -1, - -1, 114, -1, -1, 117, -1, 119, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, -1, 24, -1, -1, -1, -1, 111, - -1, -1, 114, -1, -1, 117, -1, 119, -1, -1, - -1, -1, -1, -1, -1, -1, 5, 6, 48, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, - 111, -1, -1, 114, -1, -1, 117, -1, 119, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 48, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, - -1, 111, -1, -1, 114, -1, -1, 117, -1, 119, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, - 119, -1, -1, -1, -1, 35, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - 60, -1, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, -1, -1, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108 +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, + 1, 2, 0, 2, 0, 3, 2, 0, 1, 0, + 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 4, 5, 5, 3, 2, + 2, 1, 3, 1, 3, 1, 0, 4, 3, 3, + 4, 4, 3, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 6, 5, 8, 6, 6, 6, 6, + 6, 8, 8, 3, 1, 1, 1, 1, 2, 2, + 4, 2, 1, 4, 2, 4, 0, 7, 0, 7, + 0, 7, 0, 7, 3, 4, 0, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, + 1, 0, 2, 3, 1, 1, 3, 1, 0, 8, + 1, 1, 3, 1, 1, 2, 0, 1, 1, 0, + 4, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 5, 1, 1, 1, 1, 2, 2, + 2, 3, 2, 0, 1, 2, 2, 3, 9, 9, + 8, 13, 1, 1, 6, 5, 2, 6, 7, 1, + 3, 1, 0, 2, 1, 5, 5, 5, 2, 4, + 4, 6, 4, 4, 4, 4, 6, 6, 2, 7, + 1, 2, 0, 1, 0, 3, 6, 3, 6, 2, + 4, 6, 4 }; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison.simple" -/* This file comes from bison-1.28. */ -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 146, 0, 43, 132, 1, 131, 179, 36, 37, 38, + 39, 40, 41, 42, 0, 44, 203, 128, 129, 203, + 158, 159, 0, 0, 0, 43, 0, 134, 176, 0, + 0, 45, 46, 47, 48, 49, 50, 0, 0, 204, + 200, 35, 173, 174, 175, 199, 0, 0, 0, 0, + 144, 0, 0, 0, 0, 0, 0, 0, 34, 177, + 178, 44, 147, 130, 51, 2, 3, 64, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 0, 0, 0, 0, 194, 0, 0, 63, + 82, 67, 195, 83, 170, 171, 172, 244, 202, 0, + 0, 0, 0, 157, 145, 135, 133, 125, 126, 0, + 0, 0, 0, 180, 84, 0, 0, 66, 89, 91, + 0, 0, 96, 90, 243, 0, 224, 0, 0, 0, + 0, 44, 212, 213, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, + 0, 0, 0, 0, 0, 20, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 201, 44, 216, + 0, 240, 152, 149, 148, 150, 151, 153, 156, 0, + 140, 142, 138, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 0, 0, 0, 0, 136, 0, + 0, 0, 88, 168, 95, 93, 0, 0, 228, 223, + 206, 205, 0, 0, 25, 29, 24, 28, 23, 27, + 22, 26, 30, 31, 0, 0, 54, 54, 249, 0, + 0, 238, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 154, 59, + 59, 59, 110, 111, 4, 5, 108, 109, 112, 107, + 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 106, 105, 59, 65, + 65, 92, 167, 161, 164, 165, 0, 0, 85, 183, + 184, 185, 190, 186, 187, 188, 189, 181, 0, 192, + 197, 196, 198, 0, 207, 0, 0, 0, 245, 0, + 247, 242, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, + 0, 141, 143, 139, 0, 0, 0, 0, 0, 0, + 98, 124, 0, 0, 102, 0, 99, 0, 0, 0, + 0, 137, 86, 87, 160, 162, 0, 57, 94, 182, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, + 0, 0, 230, 0, 232, 235, 0, 0, 233, 234, + 0, 0, 0, 229, 0, 250, 0, 0, 0, 61, + 59, 242, 0, 0, 0, 0, 0, 0, 97, 100, + 101, 0, 0, 0, 0, 166, 163, 58, 52, 0, + 191, 0, 0, 222, 54, 55, 54, 219, 241, 0, + 0, 0, 0, 0, 225, 226, 227, 222, 0, 56, + 62, 60, 0, 0, 0, 0, 0, 0, 123, 0, + 0, 0, 0, 0, 169, 0, 0, 0, 221, 0, + 0, 246, 248, 0, 0, 0, 231, 236, 237, 0, + 251, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 53, 193, 0, 0, 0, 220, 217, 0, 239, + 113, 0, 120, 0, 0, 116, 117, 118, 119, 0, + 210, 0, 0, 0, 218, 0, 0, 0, 208, 0, + 209, 0, 0, 115, 121, 122, 0, 0, 0, 0, + 0, 0, 215, 0, 0, 214, 211 +}; - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. +/* YYDEFGOTO[NTERM-NUM]. */ +static const short int yydefgoto[] = +{ + -1, 86, 256, 272, 273, 274, 275, 194, 195, 224, + 196, 25, 15, 37, 444, 308, 389, 408, 331, 390, + 87, 88, 197, 90, 91, 120, 206, 341, 299, 342, + 109, 1, 2, 3, 278, 251, 249, 250, 63, 175, + 50, 104, 179, 92, 355, 284, 285, 286, 38, 96, + 16, 44, 17, 61, 18, 28, 360, 300, 93, 302, + 417, 19, 40, 41, 167, 492, 98, 231, 448, 449, + 168, 169, 369, 170, 171 +}; - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -410 +static const short int yypact[] = +{ + -410, 17, 118, 605, -410, -410, -410, -410, -410, -410, + -410, -410, -410, -410, 24, 160, 67, -410, -410, -15, + -410, -410, 27, -5, 46, -6, 10, -410, 86, 147, + 138, -410, -410, -410, -410, -410, -410, 1060, -20, -410, + -410, 110, -410, -410, -410, -410, 69, 70, 72, 73, + -410, 63, 147, 1060, 68, 68, 68, 68, -410, -410, + -410, 160, -410, -410, -410, -410, -410, 64, -410, -410, + -410, -410, -410, -410, -410, -410, -410, -410, -410, -410, + -410, -410, 182, 183, 186, 572, -410, 110, 77, -410, + -410, -28, -410, -410, -410, -410, -410, 1231, -410, 168, + 83, 199, 180, 181, -410, -410, -410, -410, -410, 1101, + 1101, 1101, 1142, -410, -410, 91, 96, -410, -410, -28, + -98, 103, 852, -410, -410, 1101, -410, 157, 1183, 50, + 185, 160, -410, -410, -410, -410, -410, -410, -410, -410, + -410, -410, -410, -410, -410, -410, -410, -410, 1101, 1101, + 1101, 1101, 1101, 1101, 1101, -410, -410, 1101, 1101, 1101, + 1101, 1101, 1101, 1101, 1101, 1101, 1101, -410, 160, -410, + 49, -410, -410, -410, -410, -410, -410, -410, -410, -14, + -410, -410, -410, 120, 148, 213, 150, 214, 154, 215, + 166, 217, 224, 231, 170, 218, 232, 425, -410, 1101, + 1101, 1101, -410, 893, -410, 130, 128, 638, -410, -410, + 64, -410, 638, 638, -410, -410, -410, -410, -410, -410, + -410, -410, -410, -410, 638, 1060, 132, 133, -410, 638, + 136, 134, 216, 141, 143, 144, 146, 149, 151, 152, + 638, 638, 638, 153, 1060, 1101, 1101, 233, -410, 155, + 155, 155, -410, -410, -410, -410, -410, -410, -410, -410, + -410, -410, 156, 159, 161, 164, 175, 177, 934, 1142, + 592, 234, 178, 184, 187, 188, -410, -410, 155, -70, + -35, -28, -410, 110, -410, 162, 179, 978, -410, -410, + -410, -410, -410, -410, -410, -410, -410, 197, 1142, -410, + -410, -410, -410, 191, -410, 195, 638, 3, -410, 18, + -410, 196, 638, 193, 1101, 1101, 1101, 1101, 1101, 1101, + 1101, 1101, 201, 202, 203, 1101, 638, 638, 205, -410, + 13, -410, -410, -410, 1142, 1142, 1142, 1142, 1142, 1142, + -410, -410, -13, -99, -410, -78, -410, 1142, 1142, 1142, + 1142, -410, -410, -410, -410, -410, 1019, 230, -410, -410, + 242, -23, 246, 272, 208, 638, 290, 638, 1101, -410, + 211, 638, -410, 212, -410, -410, 219, 220, -410, -410, + 638, 638, 638, -410, 229, -410, 1101, 273, 294, -410, + 155, 196, 291, 226, 237, 240, 241, 1142, -410, -410, + -410, 243, 247, 248, 249, -410, -410, -410, 252, 250, + -410, 638, 638, 1101, 251, -410, 251, -410, 255, 638, + 256, 1101, 1101, 1101, -410, -410, -410, 1101, 638, -410, + -410, -410, 239, 1101, 1142, 1142, 1142, 1142, -410, 1142, + 1142, 1142, 1142, 322, -410, 304, 257, 228, 255, 259, + 286, -410, -410, 1101, 253, 638, -410, -410, -410, 260, + -410, -410, 262, 267, 265, 270, 277, 278, 279, 280, + 281, -410, -410, 323, 14, 320, -410, -410, 254, -410, + -410, 1142, -410, 1142, 1142, -410, -410, -410, -410, 638, + -410, 742, 52, 362, -410, 282, 284, 287, -410, 289, + -410, 742, 638, -410, -410, -410, 380, 292, 327, 638, + 383, 384, -410, 638, 638, -410, -410 +}; - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ +/* YYPGOTO[NTERM-NUM]. */ +static const short int yypgoto[] = +{ + -410, -410, -410, 309, 310, 311, 312, -129, -128, -398, + -410, 369, 386, -118, -410, -223, 55, -410, -244, -410, + -50, -410, -37, -410, -64, 293, -410, -102, 221, -192, + 53, -410, -410, -410, -410, -410, -410, -410, 361, -410, + -410, -410, -410, 2, -410, 58, -410, -410, 356, -410, + -410, -410, -410, -410, 416, -410, -410, -409, -57, 62, + -105, -410, 401, -410, -410, -410, -410, -410, 54, -4, + -410, -410, 30, -410, -410 +}; -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -128 +static const short int yytable[] = +{ + 89, 222, 223, 106, 310, 26, 332, 333, 39, 94, + 198, 397, 201, 225, 53, 42, 89, 4, 365, 399, + 208, 119, 202, 211, 214, 215, 216, 217, 218, 219, + 220, 221, 397, 367, 351, 7, 8, 9, 10, 54, + 12, 55, 400, 26, 56, 228, 352, 387, 232, 233, + 244, 123, 234, 235, 236, 237, 238, 239, 119, 212, + 366, 243, 214, 215, 216, 217, 218, 219, 220, 221, + 388, 213, 180, 181, 182, 366, 491, 343, 345, 46, + 47, 48, 499, 353, -65, 29, 123, 397, 207, 121, + 39, 207, 507, 123, 501, 410, 247, 397, 49, 95, + 107, 108, 248, 398, 51, 43, 361, 52, 110, 111, + 112, 226, 227, 207, 229, 230, 207, 207, -127, 58, + 207, 207, 207, 207, 207, 207, 240, 241, 242, 207, + 490, 59, 20, 60, 21, 279, 280, 281, 173, 174, + 277, 328, 64, 5, 245, 246, 431, 252, 253, 6, + 301, -25, -25, -24, -24, 301, 301, -23, -23, 7, + 8, 9, 10, 11, 12, 13, 283, 301, 500, -22, + -22, 62, 301, 254, 255, 306, -66, 103, 99, 100, + 14, 101, 102, 301, 301, 301, 114, 115, 89, 122, + 116, 451, 172, 452, 326, 214, 215, 216, 217, 218, + 219, 220, 221, 176, 177, 178, 199, 89, 327, 207, + 373, 200, 375, 376, 377, 203, 209, -29, -28, -27, + 383, -26, 257, 281, 30, 31, 32, 33, 34, 35, + 36, -32, 391, 392, 393, 394, 395, 396, -33, 258, + 287, 288, 307, 309, 313, 401, 402, 403, 404, 301, + 312, 315, 314, 316, 317, 301, 318, 329, 346, 319, + 359, 320, 321, 325, 387, 330, 409, 411, 334, 301, + 301, 335, 356, 336, 303, 304, 337, 372, 207, 374, + 207, 207, 207, 378, 379, 354, 305, 338, 207, 339, + 347, 311, 357, 412, 415, 438, 348, 429, 430, 349, + 350, 362, 322, 323, 324, 363, 368, 371, 301, 443, + 301, 380, 381, 382, 301, 386, 456, 457, 458, 283, + 413, 419, 421, 301, 301, 301, 471, 433, 472, 422, + 423, 207, 463, 464, 465, 466, 434, 467, 468, 469, + 470, 427, 474, 366, 489, 222, 223, 435, 476, 428, + 436, 437, 461, 439, 301, 301, 493, 440, 441, 442, + 445, 450, 301, 222, 223, 453, 455, 473, 364, 477, + 494, 301, 475, 479, 370, 480, 207, 481, 482, 495, + 483, 496, 497, 502, 207, 207, 207, 484, 384, 385, + 207, 485, 486, 487, 488, 503, 462, 504, 301, 506, + 505, 509, 510, 511, 513, 514, 163, 164, 165, 166, + 97, 57, 407, 105, 406, 205, 207, 113, 276, 27, + 45, 432, 418, 459, 0, 0, 0, 414, 0, 416, + 65, 66, 301, 420, 0, 0, 0, 0, 0, 0, + 0, 0, 424, 425, 426, 301, 0, 20, 0, 21, + 0, 259, 301, 0, 0, 0, 301, 301, 0, 0, + 0, 0, 0, 260, 261, 0, 0, 0, 0, 0, + 0, 0, 0, 446, 447, 0, 0, 0, 0, 0, + 0, 454, 0, 0, 0, 0, 0, 0, 0, 0, + 460, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 478, 0, 0, + 0, 0, 262, 0, 263, 264, 155, 156, 0, 265, + 266, 267, 0, 0, 0, 0, 0, 0, 0, 268, + 0, 0, 269, 0, 270, 0, 0, 271, 0, 0, + 0, 498, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 508, 0, 0, 0, 0, 0, + 0, 512, 0, 0, 0, 515, 516, 65, 66, 0, + 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 20, 0, 21, 65, 66, 0, + 117, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 79, 80, 20, 0, 21, 0, 0, 0, + 81, 0, 0, 0, 0, -35, 0, 20, 0, 21, + 0, 0, 0, 0, 0, 0, 6, -35, -35, 0, + 81, 289, 290, 65, 66, 291, -35, -35, -35, -35, + -35, -35, -35, 0, 0, -35, 22, 0, 0, 0, + 20, 0, 21, 23, 292, 293, 294, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 295, 296, 0, 0, + 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, + 0, 85, 118, 0, 0, 0, 0, 0, 0, 297, + 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, + 0, 85, 344, 0, 0, 0, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 0, 0, 0, 0, 0, 262, 0, 263, 264, 155, + 156, 0, 265, 266, 267, 289, 290, 0, 0, 291, + 0, 0, 0, 0, 0, 298, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 292, 293, + 294, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 295, 296, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 297, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 0, 0, 0, 0, 0, 262, + 0, 263, 264, 155, 156, 0, 265, 266, 267, 0, + 0, 0, 0, 0, 0, 0, 0, 65, 66, 298, + 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 20, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, + 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, + 81, 117, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 282, 0, 0, 0, 0, 0, 0, 0, 0, 65, + 66, 81, 117, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 79, 80, 20, 0, 21, 0, + 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, + 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 81, 65, 66, 0, 117, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 20, 0, 21, 0, 82, 0, 0, 83, 0, 0, + 84, 0, 85, 0, 0, 358, 0, 0, 0, 0, + 0, 0, 0, 0, 65, 66, 81, 117, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 20, 0, 21, 0, 82, 0, 0, 83, 0, + 340, 84, 0, 85, 0, 0, 405, 0, 0, 0, + 0, 0, 0, 0, 0, 65, 66, 81, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 20, 0, 21, 0, 0, 0, 0, 82, + 0, 0, 83, 0, 0, 84, 0, 85, 0, 0, + 0, 0, 0, 0, 0, 0, 65, 66, 81, 117, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 20, 0, 21, 0, 0, 0, 0, + 82, 0, 0, 83, 0, 0, 84, 0, 85, 0, + 0, 0, 0, 0, 0, 0, 0, 65, 66, 81, + 117, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 79, 80, 20, 0, 21, 0, 0, 0, + 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, + 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, + 81, 210, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, + 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, + 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, + 0, 85, 0, 0, 0, 0, 124, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 126, 127, 0, 0, 82, 0, 0, 83, 0, 0, + 84, 0, 85, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 0, 0, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162 +}; -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include <alloca.h> -#else /* not sparc */ -/* We think this test detects Watcom and Microsoft C. */ -/* This used to test MSDOS, but that is a bad idea - since that symbol is in the user namespace. */ -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -#if 0 /* No need for malloc.h, which pollutes the namespace; - instead, just don't use alloca. */ -#include <malloc.h> -#endif -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -/* I don't know what this was needed for, but it pollutes the namespace. - So I turned it off. rms, 2 May 1997. */ -/* #include <malloc.h> */ - #pragma alloca -#define YYSTACK_USE_ALLOCA -#else /* not MSDOS, or __TURBOC__, or _AIX */ -#if 0 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, - and on HPUX 10. Eventually we can turn this on. */ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#endif /* __hpux */ -#endif -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif +static const short int yycheck[] = +{ + 37, 130, 130, 53, 227, 3, 250, 251, 23, 29, + 112, 110, 110, 131, 20, 30, 53, 0, 15, 118, + 125, 85, 120, 128, 10, 11, 12, 13, 14, 15, + 16, 17, 110, 15, 278, 41, 42, 43, 44, 45, + 46, 47, 120, 41, 50, 150, 116, 34, 153, 154, + 168, 121, 157, 158, 159, 160, 161, 162, 122, 9, + 57, 166, 10, 11, 12, 13, 14, 15, 16, 17, + 57, 21, 109, 110, 111, 57, 474, 269, 270, 52, + 53, 54, 491, 118, 112, 61, 121, 110, 125, 87, + 23, 128, 501, 121, 492, 118, 110, 110, 71, 119, + 32, 33, 116, 116, 109, 120, 298, 61, 55, 56, + 57, 148, 149, 150, 151, 152, 153, 154, 0, 109, + 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, + 116, 45, 22, 47, 24, 199, 200, 201, 55, 56, + 197, 246, 4, 25, 95, 96, 390, 27, 28, 31, + 207, 3, 4, 3, 4, 212, 213, 3, 4, 41, + 42, 43, 44, 45, 46, 47, 203, 224, 116, 3, + 4, 24, 229, 3, 4, 225, 112, 114, 109, 109, + 62, 109, 109, 240, 241, 242, 4, 4, 225, 112, + 4, 414, 24, 416, 244, 10, 11, 12, 13, 14, + 15, 16, 17, 4, 24, 24, 115, 244, 245, 246, + 315, 115, 317, 318, 319, 112, 59, 4, 4, 4, + 325, 4, 4, 287, 64, 65, 66, 67, 68, 69, + 70, 7, 334, 335, 336, 337, 338, 339, 7, 7, + 110, 113, 110, 110, 110, 347, 348, 349, 350, 306, + 114, 110, 36, 110, 110, 312, 110, 24, 24, 110, + 63, 110, 110, 110, 34, 110, 24, 21, 112, 326, + 327, 112, 110, 112, 212, 213, 112, 314, 315, 316, + 317, 318, 319, 320, 321, 283, 224, 112, 325, 112, + 112, 229, 113, 21, 4, 397, 112, 24, 4, 112, + 112, 110, 240, 241, 242, 110, 110, 114, 365, 57, + 367, 110, 110, 110, 371, 110, 421, 422, 423, 356, + 112, 110, 110, 380, 381, 382, 4, 36, 24, 110, + 110, 368, 434, 435, 436, 437, 110, 439, 440, 441, + 442, 112, 114, 57, 21, 474, 474, 110, 453, 386, + 110, 110, 113, 110, 411, 412, 36, 110, 110, 110, + 110, 110, 419, 492, 492, 110, 110, 110, 306, 116, + 116, 428, 113, 113, 312, 113, 413, 110, 113, 481, + 110, 483, 484, 21, 421, 422, 423, 110, 326, 327, + 427, 113, 113, 113, 113, 113, 433, 113, 455, 110, + 113, 21, 110, 76, 21, 21, 97, 97, 97, 97, + 41, 25, 357, 52, 356, 122, 453, 61, 197, 3, + 19, 391, 368, 427, -1, -1, -1, 365, -1, 367, + 5, 6, 489, 371, -1, -1, -1, -1, -1, -1, + -1, -1, 380, 381, 382, 502, -1, 22, -1, 24, + -1, 26, 509, -1, -1, -1, 513, 514, -1, -1, + -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, + -1, -1, -1, 411, 412, -1, -1, -1, -1, -1, + -1, 419, -1, -1, -1, -1, -1, -1, -1, -1, + 428, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 455, -1, -1, + -1, -1, 97, -1, 99, 100, 101, 102, -1, 104, + 105, 106, -1, -1, -1, -1, -1, -1, -1, 114, + -1, -1, 117, -1, 119, -1, -1, 122, -1, -1, + -1, 489, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 502, -1, -1, -1, -1, -1, + -1, 509, -1, -1, -1, 513, 514, 5, 6, -1, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, -1, 24, 5, 6, -1, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, + 48, -1, -1, -1, -1, 20, -1, 22, -1, 24, + -1, -1, -1, -1, -1, -1, 31, 32, 33, -1, + 48, 3, 4, 5, 6, 7, 41, 42, 43, 44, + 45, 46, 47, -1, -1, 50, 51, -1, -1, -1, + 22, -1, 24, 58, 26, 27, 28, 62, -1, -1, + -1, -1, -1, -1, -1, -1, 38, 39, -1, -1, + -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, + -1, 119, 120, -1, -1, -1, -1, -1, -1, 61, + -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, + -1, 119, 120, -1, -1, -1, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + -1, -1, -1, -1, -1, 97, -1, 99, 100, 101, + 102, -1, 104, 105, 106, 3, 4, -1, -1, 7, + -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, + 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 61, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, -1, -1, -1, -1, -1, 97, + -1, 99, 100, 101, 102, -1, 104, 105, 106, -1, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 117, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, + -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, + 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 37, -1, -1, -1, -1, -1, -1, -1, -1, 5, + 6, 48, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, + -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, + -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 48, 5, 6, -1, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, -1, 24, -1, 111, -1, -1, 114, -1, -1, + 117, -1, 119, -1, -1, 37, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, -1, 24, -1, 111, -1, -1, 114, -1, + 116, 117, -1, 119, -1, -1, 37, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, -1, 24, -1, -1, -1, -1, 111, + -1, -1, 114, -1, -1, 117, -1, 119, -1, -1, + -1, -1, -1, -1, -1, -1, 5, 6, 48, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, + 111, -1, -1, 114, -1, -1, 117, -1, 119, -1, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 48, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, + -1, 111, -1, -1, 114, -1, -1, 117, -1, 119, + -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, + 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, + -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, + 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, + -1, 119, -1, -1, -1, -1, 35, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 59, 60, -1, -1, 111, -1, -1, 114, -1, -1, + 117, -1, 119, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, -1, -1, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108 +}; -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 154, 155, 156, 0, 25, 31, 41, 42, 43, + 44, 45, 46, 47, 62, 135, 173, 175, 177, 184, + 22, 24, 51, 58, 62, 134, 166, 177, 178, 61, + 64, 65, 66, 67, 68, 69, 70, 136, 171, 23, + 185, 186, 30, 120, 174, 185, 52, 53, 54, 71, + 163, 109, 61, 20, 45, 47, 50, 135, 109, 45, + 47, 176, 24, 161, 4, 5, 6, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 48, 111, 114, 117, 119, 124, 143, 144, 145, + 146, 147, 166, 181, 29, 119, 172, 134, 189, 109, + 109, 109, 109, 114, 164, 161, 143, 32, 33, 153, + 153, 153, 153, 171, 4, 4, 4, 8, 120, 147, + 148, 166, 112, 121, 35, 49, 59, 60, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 94, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 126, 127, 128, 129, 187, 193, 194, + 196, 197, 24, 55, 56, 162, 4, 24, 24, 165, + 145, 145, 145, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 130, 131, 133, 145, 150, 115, + 115, 110, 120, 112, 37, 148, 149, 145, 183, 59, + 8, 183, 9, 21, 10, 11, 12, 13, 14, 15, + 16, 17, 130, 131, 132, 136, 145, 145, 183, 145, + 145, 190, 183, 183, 183, 183, 183, 183, 183, 183, + 145, 145, 145, 183, 136, 95, 96, 110, 116, 159, + 160, 158, 27, 28, 3, 4, 125, 4, 7, 26, + 38, 39, 97, 99, 100, 104, 105, 106, 114, 117, + 119, 122, 126, 127, 128, 129, 151, 181, 157, 147, + 147, 147, 37, 145, 168, 169, 170, 110, 113, 3, + 4, 7, 26, 27, 28, 38, 39, 61, 117, 151, + 180, 181, 182, 182, 182, 182, 143, 110, 138, 110, + 138, 182, 114, 110, 36, 110, 110, 110, 110, 110, + 110, 110, 182, 182, 182, 110, 143, 145, 183, 24, + 110, 141, 141, 141, 112, 112, 112, 112, 112, 112, + 116, 150, 152, 152, 120, 152, 24, 112, 112, 112, + 112, 141, 116, 118, 166, 167, 110, 113, 37, 63, + 179, 152, 110, 110, 182, 15, 57, 15, 110, 195, + 182, 114, 145, 183, 145, 183, 183, 183, 145, 145, + 110, 110, 110, 183, 182, 182, 110, 34, 57, 139, + 142, 150, 150, 150, 150, 150, 150, 110, 116, 118, + 120, 150, 150, 150, 150, 37, 168, 139, 140, 24, + 118, 21, 21, 112, 182, 4, 182, 183, 191, 110, + 182, 110, 110, 110, 182, 182, 182, 112, 145, 24, + 4, 141, 195, 36, 110, 110, 110, 110, 150, 110, + 110, 110, 110, 57, 137, 110, 182, 182, 191, 192, + 110, 138, 138, 110, 182, 110, 183, 183, 183, 192, + 182, 113, 145, 150, 150, 150, 150, 150, 150, 150, + 150, 4, 24, 110, 114, 113, 183, 116, 182, 113, + 113, 110, 113, 110, 110, 113, 113, 113, 113, 21, + 116, 132, 188, 36, 116, 150, 150, 150, 182, 180, + 116, 132, 21, 113, 113, 113, 110, 180, 182, 21, + 110, 76, 182, 21, 21, 182, 182 +}; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 +#define YYEMPTY (-2) #define YYEOF 0 + #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ + #define YYFAIL goto yyerrlab + #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ + +#define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ while (0) + #define YYTERROR 1 #define YYERRCODE 256 -#ifndef YYPURE -#define YYLEX yylex() + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) #endif -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif -#else /* not YYLSP_NEEDED */ + + +/* YYLEX -- calling `yylex' with the right arguments. */ + #ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) +# define YYLEX yylex (YYLEX_PARAM) #else -#define YYLEX yylex(&yylval) +# define YYLEX yylex () #endif -#endif /* not YYLSP_NEEDED */ + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; #endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} -/* If nonreentrant, generate the variables here */ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) -#ifndef YYPURE -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; #endif +{ + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); +} -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ -/* YYINITDEPTH indicates the initial size of the parser's stacks */ +/* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -#define YYINITDEPTH 200 +# define YYINITDEPTH 200 #endif -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 +# define YYMAXDEPTH 10000 #endif + -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif { - register char *f = from; - register char *t = to; - register int i = count; + const char *yys = yystr; + + while (*yys++ != '\0') + continue; - while (i-- > 0) - *t++ = *f++; + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; } +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + size_t yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +#endif /* YYERROR_VERBOSE */ + + -#else /* __cplusplus */ +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else static void -__yy_memcpy (char *to, char *from, unsigned int count) +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif { - register char *t = to; - register char *f = from; - register int i = count; + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; - while (i-- > 0) - *t++ = *f++; + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); } +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; #endif -#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} -#line 217 "/usr/share/bison.simple" -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ +/* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); +#else +int yyparse (); #endif -#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL +yyparse () + +#endif +#endif { - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + short int *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else #define YYPOPSTACK (yyvsp--, yyssp--) -#endif - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; + YYSIZE_T yystacksize = YYINITDEPTH; -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ int yylen; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -2126,742 +2766,749 @@ yyparse(YYPARSE_PARAM_ARG) so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss - 1; + yyssp = yyss; yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: + goto yysetstate; - *++yyssp = yystate; +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif + yysetstate: + *yyssp = yystate; + if (yyss + yystacksize - 1 <= yyssp) + { /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; + YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif + + { + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif #endif /* no yyoverflow */ - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - if (yyssp >= yyss + yystacksize - 1) + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; - yybackup: + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* Not known => get a look-ahead token if don't already have one. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) + if (yyn <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } - else if (yyn == 0) - goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; yystate = yyn; goto yynewstate; -/* Do the default action for the current state. */ -yydefault: +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; + goto yyreduce; -/* Do a reduction. yyn is the number of a rule to reduce with. */ + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ yyreduce: + /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ -#if YYDEBUG != 0 - if (yydebug) - { - int i; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { -case 2: -#line 1098 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: +#line 1098 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); - yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; + (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); CHECK_FOR_ERROR -; - break;} -case 4: -#line 1107 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! +;} + break; + + case 5: +#line 1107 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); - yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; + (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); CHECK_FOR_ERROR -; - break;} -case 33: -#line 1131 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.StrVal = yyvsp[-1].StrVal; +;} + break; + + case 34: +#line 1131 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.StrVal) = (yyvsp[-1].StrVal); CHECK_FOR_ERROR - ; - break;} -case 34: -#line 1135 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.StrVal = 0; - CHECK_FOR_ERROR - ; - break;} -case 35: -#line 1140 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::InternalLinkage; ; - break;} -case 36: -#line 1141 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ; - break;} -case 37: -#line 1142 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::WeakLinkage; ; - break;} -case 38: -#line 1143 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::AppendingLinkage; ; - break;} -case 39: -#line 1144 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::DLLImportLinkage; ; - break;} -case 40: -#line 1145 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::DLLExportLinkage; ; - break;} -case 41: -#line 1146 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; - break;} -case 42: -#line 1147 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Linkage = GlobalValue::ExternalLinkage; ; - break;} -case 43: -#line 1149 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::C; ; - break;} -case 44: -#line 1150 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::C; ; - break;} -case 45: -#line 1151 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::CSRet; ; - break;} -case 46: -#line 1152 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::Fast; ; - break;} -case 47: -#line 1153 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::Cold; ; - break;} -case 48: -#line 1154 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::X86_StdCall; ; - break;} -case 49: -#line 1155 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = CallingConv::X86_FastCall; ; - break;} -case 50: -#line 1156 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) + ;} + break; + + case 35: +#line 1135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.StrVal) = 0; + CHECK_FOR_ERROR + ;} + break; + + case 36: +#line 1140 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} + break; + + case 37: +#line 1141 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} + break; + + case 38: +#line 1142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} + break; + + case 39: +#line 1143 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} + break; + + case 40: +#line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} + break; + + case 41: +#line 1145 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} + break; + + case 42: +#line 1146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} + break; + + case 43: +#line 1147 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} + break; + + case 44: +#line 1149 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::C; ;} + break; + + case 45: +#line 1150 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::C; ;} + break; + + case 46: +#line 1151 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::CSRet; ;} + break; + + case 47: +#line 1152 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::Fast; ;} + break; + + case 48: +#line 1153 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::Cold; ;} + break; + + case 49: +#line 1154 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} + break; + + case 50: +#line 1155 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} + break; + + case 51: +#line 1156 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) GEN_ERROR("Calling conv too large!"); - yyval.UIntVal = yyvsp[0].UInt64Val; + (yyval.UIntVal) = (yyvsp[0].UInt64Val); CHECK_FOR_ERROR - ; - break;} -case 51: -#line 1165 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = 0; ; - break;} -case 52: -#line 1166 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.UIntVal = yyvsp[0].UInt64Val; - if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) + ;} + break; + + case 52: +#line 1165 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = 0; ;} + break; + + case 53: +#line 1166 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.UIntVal) = (yyvsp[0].UInt64Val); + if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) GEN_ERROR("Alignment must be a power of two!"); CHECK_FOR_ERROR -; - break;} -case 53: -#line 1172 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.UIntVal = 0; ; - break;} -case 54: -#line 1173 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.UIntVal = yyvsp[0].UInt64Val; - if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) +;} + break; + + case 54: +#line 1172 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.UIntVal) = 0; ;} + break; + + case 55: +#line 1173 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.UIntVal) = (yyvsp[0].UInt64Val); + if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) GEN_ERROR("Alignment must be a power of two!"); CHECK_FOR_ERROR -; - break;} -case 55: -#line 1181 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) - if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') +;} + break; + + case 56: +#line 1181 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) + if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') GEN_ERROR("Invalid character in section name!"); - yyval.StrVal = yyvsp[0].StrVal; + (yyval.StrVal) = (yyvsp[0].StrVal); CHECK_FOR_ERROR -; - break;} -case 56: -#line 1189 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.StrVal = 0; ; - break;} -case 57: -#line 1190 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.StrVal = yyvsp[0].StrVal; ; - break;} -case 58: -#line 1195 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{; - break;} -case 59: -#line 1196 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{; - break;} -case 60: -#line 1197 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurGV->setSection(yyvsp[0].StrVal); - free(yyvsp[0].StrVal); +;} + break; + + case 57: +#line 1189 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.StrVal) = 0; ;} + break; + + case 58: +#line 1190 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.StrVal) = (yyvsp[0].StrVal); ;} + break; + + case 59: +#line 1195 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + {;} + break; + + case 60: +#line 1196 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + {;} + break; + + case 61: +#line 1197 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurGV->setSection((yyvsp[0].StrVal)); + free((yyvsp[0].StrVal)); CHECK_FOR_ERROR - ; - break;} -case 61: -#line 1202 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) + ;} + break; + + case 62: +#line 1202 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) GEN_ERROR("Alignment must be a power of two!"); - CurGV->setAlignment(yyvsp[0].UInt64Val); - CHECK_FOR_ERROR - ; - break;} -case 63: -#line 1216 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ; - break;} -case 65: -#line 1217 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ; - break;} -case 66: -#line 1219 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + CurGV->setAlignment((yyvsp[0].UInt64Val)); + CHECK_FOR_ERROR + ;} + break; + + case 64: +#line 1216 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} + break; + + case 66: +#line 1217 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} + break; + + case 67: +#line 1219 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); - yyval.TypeVal = yyvsp[0].TypeVal; + GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); + (yyval.TypeVal) = (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 80: -#line 1231 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TypeVal = new PATypeHolder(OpaqueType::get()); + ;} + break; + + case 81: +#line 1231 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); CHECK_FOR_ERROR - ; - break;} -case 81: -#line 1235 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); - CHECK_FOR_ERROR - ; - break;} -case 82: -#line 1239 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Named types are also simple types... - const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); + ;} + break; + + case 82: +#line 1235 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); + CHECK_FOR_ERROR + ;} + break; + + case 83: +#line 1239 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Named types are also simple types... + const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.TypeVal = new PATypeHolder(tmp); -; - break;} -case 83: -#line 1247 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Type UpReference - if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!"); + (yyval.TypeVal) = new PATypeHolder(tmp); +;} + break; + + case 84: +#line 1247 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Type UpReference + if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder - UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... - yyval.TypeVal = new PATypeHolder(OT); + UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... + (yyval.TypeVal) = new PATypeHolder(OT); UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR - ; - break;} -case 84: -#line 1255 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Function derived type? + ;} + break; + + case 85: +#line 1255 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Function derived type? std::vector<const Type*> Params; - for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), - E = yyvsp[-1].TypeList->end(); I != E; ++I) + for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), + E = (yyvsp[-1].TypeList)->end(); I != E; ++I) Params.push_back(*I); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg))); - delete yyvsp[-1].TypeList; // Delete the argument list - delete yyvsp[-3].TypeVal; // Delete the return type handle - CHECK_FOR_ERROR - ; - break;} -case 85: -#line 1268 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Sized array type? - yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); - delete yyvsp[-1].TypeVal; - CHECK_FOR_ERROR - ; - break;} -case 86: -#line 1273 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Packed array type? - const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); - if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg))); + delete (yyvsp[-1].TypeList); // Delete the argument list + delete (yyvsp[-3].TypeVal); // Delete the return type handle + CHECK_FOR_ERROR + ;} + break; + + case 86: +#line 1268 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Sized array type? + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); + delete (yyvsp[-1].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 87: +#line 1273 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Packed array type? + const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); + if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) GEN_ERROR("Unsigned result not equal to signed result"); if (!ElemTy->isPrimitiveType()) GEN_ERROR("Elemental type of a PackedType must be primitive"); - if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) + if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) GEN_ERROR("Vector length should be a power of 2!"); - yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); - delete yyvsp[-1].TypeVal; + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); + delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 87: -#line 1285 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Structure type? + ;} + break; + + case 88: +#line 1285 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Structure type? std::vector<const Type*> Elements; - for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), - E = yyvsp[-1].TypeList->end(); I != E; ++I) + for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), + E = (yyvsp[-1].TypeList)->end(); I != E; ++I) Elements.push_back(*I); - yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); - delete yyvsp[-1].TypeList; - CHECK_FOR_ERROR - ; - break;} -case 88: -#line 1295 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Empty structure type? - yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); - CHECK_FOR_ERROR - ; - break;} -case 89: -#line 1299 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Pointer type? - if (*yyvsp[-1].TypeVal == Type::LabelTy) + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); + delete (yyvsp[-1].TypeList); + CHECK_FOR_ERROR + ;} + break; + + case 89: +#line 1295 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Empty structure type? + (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); + CHECK_FOR_ERROR + ;} + break; + + case 90: +#line 1299 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Pointer type? + if (*(yyvsp[-1].TypeVal) == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); - yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); - delete yyvsp[-1].TypeVal; + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); + delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 90: -#line 1310 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TypeList = new std::list<PATypeHolder>(); - yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; + ;} + break; + + case 91: +#line 1310 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TypeList) = new std::list<PATypeHolder>(); + (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 91: -#line 1315 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; + ;} + break; + + case 92: +#line 1315 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 93: -#line 1322 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy); + ;} + break; + + case 94: +#line 1322 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy); CHECK_FOR_ERROR - ; - break;} -case 94: -#line 1326 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy); + ;} + break; + + case 95: +#line 1326 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy); CHECK_FOR_ERROR - ; - break;} -case 95: -#line 1330 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TypeList = new std::list<PATypeHolder>(); - CHECK_FOR_ERROR - ; - break;} -case 96: -#line 1341 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Nonempty unsized arr - const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); + ;} + break; + + case 96: +#line 1330 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TypeList) = new std::list<PATypeHolder>(); + CHECK_FOR_ERROR + ;} + break; + + case 97: +#line 1341 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Nonempty unsized arr + const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*yyvsp[-3].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); const Type *ETy = ATy->getElementType(); int NumElements = ATy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) + if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) GEN_ERROR("Type mismatch: constant sized array initialized with " + - utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + + utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + itostr(NumElements) + "!"); // Verify all elements are correct type! - for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { - if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) + for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); + (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); } - yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); - delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; + (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); + delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); CHECK_FOR_ERROR - ; - break;} -case 97: -#line 1367 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); + ;} + break; + + case 98: +#line 1367 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*yyvsp[-2].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) GEN_ERROR("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +"!"); - yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); - delete yyvsp[-2].TypeVal; + (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); + delete (yyvsp[-2].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 98: -#line 1381 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); + ;} + break; + + case 99: +#line 1381 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*yyvsp[-2].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); int NumElements = ATy->getNumElements(); const Type *ETy = ATy->getElementType(); - char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); - if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) + char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); + if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) GEN_ERROR("Can't build string constant of size " + - itostr((int)(EndStr-yyvsp[0].StrVal)) + + itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " + itostr(NumElements) + "!"); std::vector<Constant*> Vals; if (ETy == Type::SByteTy) { - for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C) - Vals.push_back(ConstantSInt::get(ETy, *C)); + for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C) + Vals.push_back(ConstantInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { - for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; + for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); C != (unsigned char*)EndStr; ++C) - Vals.push_back(ConstantUInt::get(ETy, *C)); + Vals.push_back(ConstantInt::get(ETy, *C)); } else { - free(yyvsp[0].StrVal); + free((yyvsp[0].StrVal)); GEN_ERROR("Cannot build string arrays of non byte sized elements!"); } - free(yyvsp[0].StrVal); - yyval.ConstVal = ConstantArray::get(ATy, Vals); - delete yyvsp[-2].TypeVal; - CHECK_FOR_ERROR - ; - break;} -case 99: -#line 1411 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Nonempty unsized arr - const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get()); + free((yyvsp[0].StrVal)); + (yyval.ConstVal) = ConstantArray::get(ATy, Vals); + delete (yyvsp[-2].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 100: +#line 1411 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Nonempty unsized arr + const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get()); if (PTy == 0) GEN_ERROR("Cannot make packed constant with type: '" + - (*yyvsp[-3].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); const Type *ETy = PTy->getElementType(); int NumElements = PTy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) + if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) GEN_ERROR("Type mismatch: constant sized packed initialized with " + - utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + + utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + itostr(NumElements) + "!"); // Verify all elements are correct type! - for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { - if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) + for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); + (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); } - yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector); - delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; + (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); + delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); CHECK_FOR_ERROR - ; - break;} -case 100: -#line 1437 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); + ;} + break; + + case 101: +#line 1437 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*yyvsp[-3].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); - if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) + if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) GEN_ERROR("Illegal number of initializers for structure type!"); // Check to ensure that constants are compatible with the type initializer! - for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) - if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) + for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) + if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) GEN_ERROR("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + " of structure initializer!"); - yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); - delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; + (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); + delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); CHECK_FOR_ERROR - ; - break;} -case 101: -#line 1458 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); + ;} + break; + + case 102: +#line 1458 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*yyvsp[-2].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type!"); - yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); - delete yyvsp[-2].TypeVal; + (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); + delete (yyvsp[-2].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 102: -#line 1471 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); + ;} + break; + + case 103: +#line 1471 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); if (PTy == 0) GEN_ERROR("Cannot make null pointer constant with type: '" + - (*yyvsp[-1].TypeVal)->getDescription() + "'!"); + (*(yyvsp[-1].TypeVal))->getDescription() + "'!"); - yyval.ConstVal = ConstantPointerNull::get(PTy); - delete yyvsp[-1].TypeVal; + (yyval.ConstVal) = ConstantPointerNull::get(PTy); + delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 103: -#line 1481 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); - delete yyvsp[-1].TypeVal; + ;} + break; + + case 104: +#line 1481 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); + delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 104: -#line 1486 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); + ;} + break; + + case 105: +#line 1486 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); if (Ty == 0) GEN_ERROR("Global const reference must be a pointer type!"); @@ -2875,7 +3522,7 @@ case 104: Function *SavedCurFn = CurFun.CurrentFunction; CurFun.CurrentFunction = 0; - Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); + Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR CurFun.CurrentFunction = SavedCurFn; @@ -2890,14 +3537,14 @@ case 104: // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); + CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); if (I != CurModule.GlobalRefs.end()) { V = I->second; // Placeholder already exists, use it... - yyvsp[0].ValIDVal.destroy(); + (yyvsp[0].ValIDVal).destroy(); } else { std::string Name; - if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; + if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; // Create the forward referenced global. GlobalValue *GV; @@ -2912,149 +3559,160 @@ case 104: } // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); V = GV; } } - yyval.ConstVal = cast<GlobalValue>(V); - delete yyvsp[-1].TypeVal; // Free the type handle + (yyval.ConstVal) = cast<GlobalValue>(V); + delete (yyvsp[-1].TypeVal); // Free the type handle CHECK_FOR_ERROR - ; - break;} -case 105: -#line 1547 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) + ;} + break; + + case 106: +#line 1547 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) GEN_ERROR("Mismatched types for constant expression!"); - yyval.ConstVal = yyvsp[0].ConstVal; - delete yyvsp[-1].TypeVal; + (yyval.ConstVal) = (yyvsp[0].ConstVal); + delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 106: -#line 1554 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const Type *Ty = yyvsp[-1].TypeVal->get(); + ;} + break; + + case 107: +#line 1554 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const Type *Ty = (yyvsp[-1].TypeVal)->get(); if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) GEN_ERROR("Cannot create a null initialized value of this type!"); - yyval.ConstVal = Constant::getNullValue(Ty); - delete yyvsp[-1].TypeVal; - CHECK_FOR_ERROR - ; - break;} -case 107: -#line 1563 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // integral constants - if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) + (yyval.ConstVal) = Constant::getNullValue(Ty); + delete (yyvsp[-1].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 108: +#line 1563 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // integral constants + if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); - yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); - CHECK_FOR_ERROR - ; - break;} -case 108: -#line 1569 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // integral constants - if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) + (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); + CHECK_FOR_ERROR + ;} + break; + + case 109: +#line 1569 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // integral constants + if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); - yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); - CHECK_FOR_ERROR - ; - break;} -case 109: -#line 1575 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Boolean constants - yyval.ConstVal = ConstantBool::getTrue(); - CHECK_FOR_ERROR - ; - break;} -case 110: -#line 1579 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Boolean constants - yyval.ConstVal = ConstantBool::getFalse(); - CHECK_FOR_ERROR - ; - break;} -case 111: -#line 1583 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Float & Double constants - if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) + (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); + CHECK_FOR_ERROR + ;} + break; + + case 110: +#line 1575 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Boolean constants + (yyval.ConstVal) = ConstantBool::getTrue(); + CHECK_FOR_ERROR + ;} + break; + + case 111: +#line 1579 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Boolean constants + (yyval.ConstVal) = ConstantBool::getFalse(); + CHECK_FOR_ERROR + ;} + break; + + case 112: +#line 1583 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Float & Double constants + if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) GEN_ERROR("Floating point constant invalid for type!!"); - yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); + (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); CHECK_FOR_ERROR - ; - break;} -case 112: -#line 1591 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!yyvsp[-3].ConstVal->getType()->isFirstClassType()) + ;} + break; + + case 113: +#line 1591 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType()) GEN_ERROR("cast constant expression from a non-primitive type: '" + - yyvsp[-3].ConstVal->getType()->getDescription() + "'!"); - if (!yyvsp[-1].TypeVal->get()->isFirstClassType()) + (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!"); + if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType()) GEN_ERROR("cast constant expression to a non-primitive type: '" + - yyvsp[-1].TypeVal->get()->getDescription() + "'!"); - yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get()); - delete yyvsp[-1].TypeVal; - CHECK_FOR_ERROR - ; - break;} -case 113: -#line 1602 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) + (yyvsp[-1].TypeVal)->get()->getDescription() + "'!"); + (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get()); + delete (yyvsp[-1].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 114: +#line 1602 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) GEN_ERROR("GetElementPtr requires a pointer operand!"); // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct // indices to uint struct indices for compatibility. generic_gep_type_iterator<std::vector<Value*>::iterator> - GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()), - GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()); - for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) + GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()), + GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()); + for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i])) if (CUI->getType() == Type::UByteTy) - (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); + (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); const Type *IdxTy = - GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true); + GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); if (!IdxTy) GEN_ERROR("Index list invalid for constant getelementptr!"); std::vector<Constant*> IdxVec; - for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) - if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) + for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) + if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) IdxVec.push_back(C); else GEN_ERROR("Indices to constant getelementptr must be constants!"); - delete yyvsp[-1].ValueList; + delete (yyvsp[-1].ValueList); - yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec); + (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); CHECK_FOR_ERROR - ; - break;} -case 114: -#line 1634 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-5].ConstVal->getType() != Type::BoolTy) + ;} + break; + + case 115: +#line 1634 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) GEN_ERROR("Select condition must be of boolean type!"); - if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) + if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("Select operand types must match!"); - yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 115: -#line 1642 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) + ;} + break; + + case 116: +#line 1642 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("Binary operator types must match!"); // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. // To retain backward compatibility with these early compilers, we emit a // cast to the appropriate integer type automatically if we are in the // broken case. See PR424 for more information. - if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) { - yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) { + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); } else { const Type *IntPtrTy = 0; switch (CurModule.CurrentModule->getPointerSize()) { @@ -3062,138 +3720,154 @@ case 115: case Module::Pointer64: IntPtrTy = Type::LongTy; break; default: GEN_ERROR("invalid pointer binary constant expr!"); } - yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy), - ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy)); - yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType()); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy), + ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy)); + (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType()); } CHECK_FOR_ERROR - ; - break;} -case 116: -#line 1664 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) + ;} + break; + + case 117: +#line 1664 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("Logical operator types must match!"); - if (!yyvsp[-3].ConstVal->getType()->isIntegral()) { - if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) || - !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral()) + if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) { + if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || + !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 117: -#line 1675 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) + ;} + break; + + case 118: +#line 1675 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("setcc operand types must match!"); - yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 118: -#line 1681 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-1].ConstVal->getType() != Type::UByteTy) + ;} + break; + + case 119: +#line 1681 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) GEN_ERROR("Shift count for shift constant must be unsigned byte!"); - if (!yyvsp[-3].ConstVal->getType()->isInteger()) + if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 119: -#line 1689 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) + ;} + break; + + case 120: +#line 1689 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid extractelement operands!"); - yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 120: -#line 1695 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) + ;} + break; + + case 121: +#line 1695 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid insertelement operands!"); - yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 121: -#line 1701 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) + ;} + break; + + case 122: +#line 1701 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid shufflevector operands!"); - yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 122: -#line 1710 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); + ;} + break; + + case 123: +#line 1710 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 123: -#line 1714 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ConstVector = new std::vector<Constant*>(); - yyval.ConstVector->push_back(yyvsp[0].ConstVal); - CHECK_FOR_ERROR - ; - break;} -case 124: -#line 1722 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.BoolVal = false; ; - break;} -case 125: -#line 1722 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.BoolVal = true; ; - break;} -case 126: -#line 1732 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; + ;} + break; + + case 124: +#line 1714 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ConstVector) = new std::vector<Constant*>(); + (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); + CHECK_FOR_ERROR + ;} + break; + + case 125: +#line 1722 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.BoolVal) = false; ;} + break; + + case 126: +#line 1722 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.BoolVal) = true; ;} + break; + + case 127: +#line 1732 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); CurModule.ModuleDone(); CHECK_FOR_ERROR; -; - break;} -case 127: -#line 1740 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = yyvsp[-1].ModuleVal; +;} + break; + + case 128: +#line 1740 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); CHECK_FOR_ERROR - ; - break;} -case 128: -#line 1745 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = yyvsp[-1].ModuleVal; + ;} + break; + + case 129: +#line 1745 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CHECK_FOR_ERROR - ; - break;} -case 129: -#line 1749 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = yyvsp[-3].ModuleVal; + ;} + break; + + case 130: +#line 1749 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); CHECK_FOR_ERROR - ; - break;} -case 130: -#line 1753 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = yyvsp[-1].ModuleVal; + ;} + break; + + case 131: +#line 1753 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CHECK_FOR_ERROR - ; - break;} -case 131: -#line 1757 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ModuleVal = CurModule.CurrentModule; + ;} + break; + + case 132: +#line 1757 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ModuleVal) = CurModule.CurrentModule; // Emit an error if there are any unresolved types left. if (!CurModule.LateResolveTypes.empty()) { const ValID &DID = CurModule.LateResolveTypes.begin()->first; @@ -3204,11 +3878,12 @@ case 131: } } CHECK_FOR_ERROR - ; - break;} -case 132: -#line 1772 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 133: +#line 1772 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: // @@ -3218,274 +3893,306 @@ case 132: // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); + ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); - if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { + if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { CHECK_FOR_ERROR // If this is a named type that is not a redefinition, add it to the slot // table. - CurModule.Types.push_back(*yyvsp[0].TypeVal); + CurModule.Types.push_back(*(yyvsp[0].TypeVal)); } - delete yyvsp[0].TypeVal; + delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 133: -#line 1794 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Function prototypes can be in const pool + ;} + break; + + case 134: +#line 1794 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Function prototypes can be in const pool CHECK_FOR_ERROR - ; - break;} -case 134: -#line 1797 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Asm blocks can be in the const pool + ;} + break; + + case 135: +#line 1797 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Asm blocks can be in the const pool CHECK_FOR_ERROR - ; - break;} -case 135: -#line 1800 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].ConstVal == 0) + ;} + break; + + case 136: +#line 1800 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant!"); - CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); + CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 136: -#line 1805 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 137: +#line 1805 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurGV = 0; - ; - break;} -case 137: -#line 1808 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); + ;} + break; + + case 138: +#line 1808 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); CHECK_FOR_ERROR - delete yyvsp[0].TypeVal; - ; - break;} -case 138: -#line 1812 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + delete (yyvsp[0].TypeVal); + ;} + break; + + case 139: +#line 1812 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurGV = 0; CHECK_FOR_ERROR - ; - break;} -case 139: -#line 1816 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); + ;} + break; + + case 140: +#line 1816 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); CHECK_FOR_ERROR - delete yyvsp[0].TypeVal; - ; - break;} -case 140: -#line 1820 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + delete (yyvsp[0].TypeVal); + ;} + break; + + case 141: +#line 1820 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurGV = 0; CHECK_FOR_ERROR - ; - break;} -case 141: -#line 1824 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 142: +#line 1824 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurGV = - ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); + ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); CHECK_FOR_ERROR - delete yyvsp[0].TypeVal; - ; - break;} -case 142: -#line 1829 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + delete (yyvsp[0].TypeVal); + ;} + break; + + case 143: +#line 1829 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurGV = 0; CHECK_FOR_ERROR - ; - break;} -case 143: -#line 1833 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 144: +#line 1833 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CHECK_FOR_ERROR - ; - break;} -case 144: -#line 1836 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 145: +#line 1836 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CHECK_FOR_ERROR - ; - break;} -case 145: -#line 1839 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - ; - break;} -case 146: -#line 1843 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 146: +#line 1839 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + ;} + break; + + case 147: +#line 1843 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); - char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); - std::string NewAsm(yyvsp[0].StrVal, EndStr); - free(yyvsp[0].StrVal); + char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); + std::string NewAsm((yyvsp[0].StrVal), EndStr); + free((yyvsp[0].StrVal)); if (AsmSoFar.empty()) CurModule.CurrentModule->setModuleInlineAsm(NewAsm); else CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); CHECK_FOR_ERROR -; - break;} -case 147: -#line 1856 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Endianness = Module::BigEndian; ; - break;} -case 148: -#line 1857 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.Endianness = Module::LittleEndian; ; - break;} -case 149: -#line 1859 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness); +;} + break; + + case 148: +#line 1856 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Endianness) = Module::BigEndian; ;} + break; + + case 149: +#line 1857 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.Endianness) = Module::LittleEndian; ;} + break; + + case 150: +#line 1859 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); CHECK_FOR_ERROR - ; - break;} -case 150: -#line 1863 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].UInt64Val == 32) + ;} + break; + + case 151: +#line 1863 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].UInt64Val) == 32) CurModule.CurrentModule->setPointerSize(Module::Pointer32); - else if (yyvsp[0].UInt64Val == 64) + else if ((yyvsp[0].UInt64Val) == 64) CurModule.CurrentModule->setPointerSize(Module::Pointer64); else - GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!"); + GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); CHECK_FOR_ERROR - ; - break;} -case 151: -#line 1872 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); - free(yyvsp[0].StrVal); + ;} + break; + + case 152: +#line 1872 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); + free((yyvsp[0].StrVal)); CHECK_FOR_ERROR - ; - break;} -case 152: -#line 1877 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); - free(yyvsp[0].StrVal); + ;} + break; + + case 153: +#line 1877 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); + free((yyvsp[0].StrVal)); CHECK_FOR_ERROR - ; - break;} -case 154: -#line 1885 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); - free(yyvsp[0].StrVal); + ;} + break; + + case 155: +#line 1885 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); + free((yyvsp[0].StrVal)); CHECK_FOR_ERROR - ; - break;} -case 155: -#line 1890 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); - free(yyvsp[0].StrVal); + ;} + break; + + case 156: +#line 1890 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); + free((yyvsp[0].StrVal)); CHECK_FOR_ERROR - ; - break;} -case 156: -#line 1895 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 157: +#line 1895 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CHECK_FOR_ERROR - ; - break;} -case 160: -#line 1905 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.StrVal = 0; ; - break;} -case 161: -#line 1907 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (*yyvsp[-1].TypeVal == Type::VoidTy) + ;} + break; + + case 161: +#line 1905 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.StrVal) = 0; ;} + break; + + case 162: +#line 1907 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (*(yyvsp[-1].TypeVal) == Type::VoidTy) GEN_ERROR("void typed arguments are invalid!"); - yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); + (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); CHECK_FOR_ERROR -; - break;} -case 162: -#line 1914 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = yyvsp[-2].ArgList; - yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal); - delete yyvsp[0].ArgVal; - CHECK_FOR_ERROR - ; - break;} -case 163: -#line 1920 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); - yyval.ArgList->push_back(*yyvsp[0].ArgVal); - delete yyvsp[0].ArgVal; - CHECK_FOR_ERROR - ; - break;} -case 164: -#line 1927 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = yyvsp[0].ArgList; +;} + break; + + case 163: +#line 1914 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = (yyvsp[-2].ArgList); + (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); + delete (yyvsp[0].ArgVal); CHECK_FOR_ERROR - ; - break;} -case 165: -#line 1931 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = yyvsp[-2].ArgList; - yyval.ArgList->push_back(std::pair<PATypeHolder*, + ;} + break; + + case 164: +#line 1920 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); + (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); + delete (yyvsp[0].ArgVal); + CHECK_FOR_ERROR + ;} + break; + + case 165: +#line 1927 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = (yyvsp[0].ArgList); + CHECK_FOR_ERROR + ;} + break; + + case 166: +#line 1931 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = (yyvsp[-2].ArgList); + (yyval.ArgList)->push_back(std::pair<PATypeHolder*, char*>(new PATypeHolder(Type::VoidTy), 0)); CHECK_FOR_ERROR - ; - break;} -case 166: -#line 1937 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); - yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); + ;} + break; + + case 167: +#line 1937 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); + (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); CHECK_FOR_ERROR - ; - break;} -case 167: -#line 1942 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ArgList = 0; + ;} + break; + + case 168: +#line 1942 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ArgList) = 0; CHECK_FOR_ERROR - ; - break;} -case 168: -#line 1948 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - UnEscapeLexed(yyvsp[-5].StrVal); - std::string FunctionName(yyvsp[-5].StrVal); - free(yyvsp[-5].StrVal); // Free strdup'd memory! + ;} + break; + + case 169: +#line 1948 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + UnEscapeLexed((yyvsp[-5].StrVal)); + std::string FunctionName((yyvsp[-5].StrVal)); + free((yyvsp[-5].StrVal)); // Free strdup'd memory! - if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy) + if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); std::vector<const Type*> ParamTypeList; - if (yyvsp[-3].ArgList) { // If there are arguments... - for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin(); - I != yyvsp[-3].ArgList->end(); ++I) + if ((yyvsp[-3].ArgList)) { // If there are arguments... + for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); + I != (yyvsp[-3].ArgList)->end(); ++I) ParamTypeList.push_back(I->first->get()); } bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg); + const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg); const PointerType *PFT = PointerType::get(FT); - delete yyvsp[-6].TypeVal; + delete (yyvsp[-6].TypeVal); ValID ID; if (!FunctionName.empty()) { @@ -3529,24 +4236,24 @@ case 168: // another function. Fn->setLinkage(CurFun.Linkage); } - Fn->setCallingConv(yyvsp[-7].UIntVal); - Fn->setAlignment(yyvsp[0].UIntVal); - if (yyvsp[-1].StrVal) { - Fn->setSection(yyvsp[-1].StrVal); - free(yyvsp[-1].StrVal); + Fn->setCallingConv((yyvsp[-7].UIntVal)); + Fn->setAlignment((yyvsp[0].UIntVal)); + if ((yyvsp[-1].StrVal)) { + Fn->setSection((yyvsp[-1].StrVal)); + free((yyvsp[-1].StrVal)); } // Add all of the arguments we parsed to the function... - if (yyvsp[-3].ArgList) { // Is null if empty... + if ((yyvsp[-3].ArgList)) { // Is null if empty... if (isVarArg) { // Nuke the last entry - assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&& + assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&& "Not a varargs marker!"); - delete yyvsp[-3].ArgList->back().first; - yyvsp[-3].ArgList->pop_back(); // Delete the last entry + delete (yyvsp[-3].ArgList)->back().first; + (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry } Function::arg_iterator ArgIt = Fn->arg_begin(); - for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin(); - I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) { + for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); + I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) { delete I->first; // Delete the typeholder... setValueName(ArgIt, I->second); // Insert arg into symtab... @@ -3554,123 +4261,140 @@ case 168: InsertValue(ArgIt); } - delete yyvsp[-3].ArgList; // We're now done with the argument list + delete (yyvsp[-3].ArgList); // We're now done with the argument list } CHECK_FOR_ERROR -; - break;} -case 171: -#line 2044 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.FunctionVal = CurFun.CurrentFunction; +;} + break; + + case 172: +#line 2044 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.FunctionVal) = CurFun.CurrentFunction; // Make sure that we keep track of the linkage type even if there was a // previous "declare". - yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage); -; - break;} -case 174: -#line 2054 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.FunctionVal = yyvsp[-1].FunctionVal; + (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); +;} + break; + + case 175: +#line 2054 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); CHECK_FOR_ERROR -; - break;} -case 176: -#line 2060 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ CurFun.Linkage = GlobalValue::DLLImportLinkage ; - break;} -case 177: -#line 2061 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ CurFun.Linkage = GlobalValue::DLLImportLinkage ; - break;} -case 178: -#line 2063 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ CurFun.isDeclare = true; ; - break;} -case 179: -#line 2063 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.FunctionVal = CurFun.CurrentFunction; +;} + break; + + case 177: +#line 2060 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} + break; + + case 178: +#line 2061 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} + break; + + case 179: +#line 2063 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { CurFun.isDeclare = true; ;} + break; + + case 180: +#line 2063 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.FunctionVal) = CurFun.CurrentFunction; CurFun.FunctionDone(); CHECK_FOR_ERROR - ; - break;} -case 180: -#line 2073 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = false; + ;} + break; + + case 181: +#line 2073 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = false; CHECK_FOR_ERROR - ; - break;} -case 181: -#line 2077 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = true; - CHECK_FOR_ERROR - ; - break;} -case 182: -#line 2082 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // A reference to a direct constant - yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); - CHECK_FOR_ERROR - ; - break;} -case 183: -#line 2086 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); - CHECK_FOR_ERROR - ; - break;} -case 184: -#line 2090 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Perhaps it's an FP constant? - yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); - CHECK_FOR_ERROR - ; - break;} -case 185: -#line 2094 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::create(ConstantBool::getTrue()); + ;} + break; + + case 182: +#line 2077 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = true; CHECK_FOR_ERROR - ; - break;} -case 186: -#line 2098 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::create(ConstantBool::getFalse()); + ;} + break; + + case 183: +#line 2082 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // A reference to a direct constant + (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); CHECK_FOR_ERROR - ; - break;} -case 187: -#line 2102 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::createNull(); + ;} + break; + + case 184: +#line 2086 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); CHECK_FOR_ERROR - ; - break;} -case 188: -#line 2106 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::createUndef(); - CHECK_FOR_ERROR - ; - break;} -case 189: -#line 2110 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // A vector zero constant. - yyval.ValIDVal = ValID::createZeroInit(); - CHECK_FOR_ERROR - ; - break;} -case 190: -#line 2114 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Nonempty unsized packed vector - const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); - int NumElements = yyvsp[-1].ConstVector->size(); + ;} + break; + + case 185: +#line 2090 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Perhaps it's an FP constant? + (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); + CHECK_FOR_ERROR + ;} + break; + + case 186: +#line 2094 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); + CHECK_FOR_ERROR + ;} + break; + + case 187: +#line 2098 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); + CHECK_FOR_ERROR + ;} + break; + + case 188: +#line 2102 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::createNull(); + CHECK_FOR_ERROR + ;} + break; + + case 189: +#line 2106 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::createUndef(); + CHECK_FOR_ERROR + ;} + break; + + case 190: +#line 2110 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // A vector zero constant. + (yyval.ValIDVal) = ValID::createZeroInit(); + CHECK_FOR_ERROR + ;} + break; + + case 191: +#line 2114 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Nonempty unsized packed vector + const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); + int NumElements = (yyvsp[-1].ConstVector)->size(); PackedType* pt = PackedType::get(ETy, NumElements); PATypeHolder* PTy = new PATypeHolder( @@ -3682,98 +4406,108 @@ case 190: ); // Verify all elements are correct type! - for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { - if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) + for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '" + - (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); + (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); } - yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector)); - delete PTy; delete yyvsp[-1].ConstVector; + (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); + delete PTy; delete (yyvsp[-1].ConstVector); CHECK_FOR_ERROR - ; - break;} -case 191: -#line 2139 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); + ;} + break; + + case 192: +#line 2139 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); CHECK_FOR_ERROR - ; - break;} -case 192: -#line 2143 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); - std::string AsmStr = std::string(yyvsp[-2].StrVal, End); - End = UnEscapeLexed(yyvsp[0].StrVal, true); - std::string Constraints = std::string(yyvsp[0].StrVal, End); - yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); - free(yyvsp[-2].StrVal); - free(yyvsp[0].StrVal); - CHECK_FOR_ERROR - ; - break;} -case 193: -#line 2157 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Is it an integer reference...? - yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); - CHECK_FOR_ERROR - ; - break;} -case 194: -#line 2161 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Is it a named reference...? - yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); - CHECK_FOR_ERROR - ; - break;} -case 197: -#line 2173 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal; + ;} + break; + + case 193: +#line 2143 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); + std::string AsmStr = std::string((yyvsp[-2].StrVal), End); + End = UnEscapeLexed((yyvsp[0].StrVal), true); + std::string Constraints = std::string((yyvsp[0].StrVal), End); + (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); + free((yyvsp[-2].StrVal)); + free((yyvsp[0].StrVal)); + CHECK_FOR_ERROR + ;} + break; + + case 194: +#line 2157 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Is it an integer reference...? + (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); CHECK_FOR_ERROR - ; - break;} -case 198: -#line 2178 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.FunctionVal = yyvsp[-1].FunctionVal; - CHECK_FOR_ERROR - ; - break;} -case 199: -#line 2182 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Do not allow functions with 0 basic blocks - yyval.FunctionVal = yyvsp[-1].FunctionVal; - CHECK_FOR_ERROR - ; - break;} -case 200: -#line 2191 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); + ;} + break; + + case 195: +#line 2161 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Is it a named reference...? + (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); CHECK_FOR_ERROR - InsertValue(yyvsp[0].TermInstVal); + ;} + break; - yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); - InsertValue(yyvsp[-2].BasicBlockVal); - yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; + case 198: +#line 2173 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 201: -#line 2202 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); - yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; + ;} + break; + + case 199: +#line 2178 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); CHECK_FOR_ERROR - ; - break;} -case 202: -#line 2207 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); + ;} + break; + + case 200: +#line 2182 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Do not allow functions with 0 basic blocks + (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + CHECK_FOR_ERROR + ;} + break; + + case 201: +#line 2191 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); + CHECK_FOR_ERROR + InsertValue((yyvsp[0].TermInstVal)); + + (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); + InsertValue((yyvsp[-2].BasicBlockVal)); + (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); + CHECK_FOR_ERROR + ;} + break; + + case 202: +#line 2202 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); + (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); + CHECK_FOR_ERROR + ;} + break; + + case 203: +#line 2207 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); CHECK_FOR_ERROR // Make sure to move the basic block to the correct location in the @@ -3781,14 +4515,15 @@ case 202: // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); + BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); CHECK_FOR_ERROR - ; - break;} -case 203: -#line 2219 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); + ;} + break; + + case 204: +#line 2219 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); CHECK_FOR_ERROR // Make sure to move the basic block to the correct location in the @@ -3796,90 +4531,97 @@ case 203: // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); - CHECK_FOR_ERROR - ; - break;} -case 204: -#line 2232 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Return with a result... - yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); - CHECK_FOR_ERROR - ; - break;} -case 205: -#line 2236 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Return with no result... - yyval.TermInstVal = new ReturnInst(); - CHECK_FOR_ERROR - ; - break;} -case 206: -#line 2240 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Unconditional Branch... - BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); - CHECK_FOR_ERROR - yyval.TermInstVal = new BranchInst(tmpBB); - ; - break;} -case 207: -#line 2245 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); - CHECK_FOR_ERROR - BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); - CHECK_FOR_ERROR - Value* tmpVal = getVal(Type::BoolTy, yyvsp[-6].ValIDVal); - CHECK_FOR_ERROR - yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); - ; - break;} -case 208: -#line 2254 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); + BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); + CHECK_FOR_ERROR + ;} + break; + + case 205: +#line 2232 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Return with a result... + (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); + ;} + break; + + case 206: +#line 2236 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Return with no result... + (yyval.TermInstVal) = new ReturnInst(); CHECK_FOR_ERROR - SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); - yyval.TermInstVal = S; + ;} + break; + + case 207: +#line 2240 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Unconditional Branch... + BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + CHECK_FOR_ERROR + (yyval.TermInstVal) = new BranchInst(tmpBB); + ;} + break; + + case 208: +#line 2245 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); + CHECK_FOR_ERROR + BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); + CHECK_FOR_ERROR + Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)); + CHECK_FOR_ERROR + (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); + ;} + break; - std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), - E = yyvsp[-1].JumpTable->end(); + case 209: +#line 2254 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); + CHECK_FOR_ERROR + BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); + CHECK_FOR_ERROR + SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); + (yyval.TermInstVal) = S; + + std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), + E = (yyvsp[-1].JumpTable)->end(); for (; I != E; ++I) { if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) S->addCase(CI, I->second); else GEN_ERROR("Switch case is constant, but not a simple integer!"); } - delete yyvsp[-1].JumpTable; + delete (yyvsp[-1].JumpTable); CHECK_FOR_ERROR - ; - break;} -case 209: -#line 2273 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); + ;} + break; + + case 210: +#line 2273 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); + BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); CHECK_FOR_ERROR SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); - yyval.TermInstVal = S; + (yyval.TermInstVal) = S; CHECK_FOR_ERROR - ; - break;} -case 210: -#line 2283 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 211: +#line 2283 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { const PointerType *PFTy; const FunctionType *Ty; - if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) || + if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) || !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector<const Type*> ParamTypes; - if (yyvsp[-7].ValueList) { - for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); + if ((yyvsp[-7].ValueList)) { + for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end(); I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -3887,27 +4629,27 @@ case 210: bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg); + Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... + Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... CHECK_FOR_ERROR - BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); + BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); CHECK_FOR_ERROR - BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); + BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR // Create the call node... - if (!yyvsp[-7].ValueList) { // Has no arguments? - yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>()); + if (!(yyvsp[-7].ValueList)) { // Has no arguments? + (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>()); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified // correctly! // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end(); + std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -3917,242 +4659,263 @@ case 210: if (I != E || (ArgI != ArgE && !Ty->isVarArg())) GEN_ERROR("Invalid number of parameters detected!"); - yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList); + (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList)); } - cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal); + cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal)); - delete yyvsp[-10].TypeVal; - delete yyvsp[-7].ValueList; + delete (yyvsp[-10].TypeVal); + delete (yyvsp[-7].ValueList); CHECK_FOR_ERROR - ; - break;} -case 211: -#line 2338 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TermInstVal = new UnwindInst(); + ;} + break; + + case 212: +#line 2338 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TermInstVal) = new UnwindInst(); CHECK_FOR_ERROR - ; - break;} -case 212: -#line 2342 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.TermInstVal = new UnreachableInst(); + ;} + break; + + case 213: +#line 2342 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.TermInstVal) = new UnreachableInst(); CHECK_FOR_ERROR - ; - break;} -case 213: -#line 2349 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.JumpTable = yyvsp[-5].JumpTable; - Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); + ;} + break; + + case 214: +#line 2349 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.JumpTable) = (yyvsp[-5].JumpTable); + Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value!"); - BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); - ; - break;} -case 214: -#line 2360 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); - Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); + (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); + ;} + break; + + case 215: +#line 2360 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); + Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value!"); - BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); - ; - break;} -case 215: -#line 2373 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); + ;} + break; + + case 216: +#line 2373 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Is this definition named?? if so, assign the name... - setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); + setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); CHECK_FOR_ERROR - InsertValue(yyvsp[0].InstVal); - yyval.InstVal = yyvsp[0].InstVal; + InsertValue((yyvsp[0].InstVal)); + (yyval.InstVal) = (yyvsp[0].InstVal); CHECK_FOR_ERROR -; - break;} -case 216: -#line 2382 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Used for PHI nodes - yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); - Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); - CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); - CHECK_FOR_ERROR - yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); - delete yyvsp[-5].TypeVal; - ; - break;} -case 217: -#line 2391 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.PHIList = yyvsp[-6].PHIList; - Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); - CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); - CHECK_FOR_ERROR - yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); - ; - break;} -case 218: -#line 2401 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ // Used for call statements, and memory insts... - yyval.ValueList = new std::vector<Value*>(); - yyval.ValueList->push_back(yyvsp[0].ValueVal); - ; - break;} -case 219: -#line 2405 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValueList = yyvsp[-2].ValueList; - yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); - CHECK_FOR_ERROR - ; - break;} -case 221: -#line 2412 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ yyval.ValueList = 0; ; - break;} -case 222: -#line 2414 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = true; +;} + break; + + case 217: +#line 2382 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Used for PHI nodes + (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); + Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); CHECK_FOR_ERROR - ; - break;} -case 223: -#line 2418 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = false; + BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); CHECK_FOR_ERROR - ; - break;} -case 224: -#line 2423 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && - !isa<PackedType>((*yyvsp[-3].TypeVal).get())) + (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); + delete (yyvsp[-5].TypeVal); + ;} + break; + + case 218: +#line 2391 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.PHIList) = (yyvsp[-6].PHIList); + Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); + CHECK_FOR_ERROR + BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); + CHECK_FOR_ERROR + (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); + ;} + break; + + case 219: +#line 2401 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { // Used for call statements, and memory insts... + (yyval.ValueList) = new std::vector<Value*>(); + (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); + ;} + break; + + case 220: +#line 2405 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValueList) = (yyvsp[-2].ValueList); + (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); + CHECK_FOR_ERROR + ;} + break; + + case 222: +#line 2412 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { (yyval.ValueList) = 0; ;} + break; + + case 223: +#line 2414 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = true; + CHECK_FOR_ERROR + ;} + break; + + case 224: +#line 2418 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = false; + CHECK_FOR_ERROR + ;} + break; + + case 225: +#line 2423 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && + !isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem) + if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal) == Instruction::Rem) GEN_ERROR("Rem not supported on packed types!"); - Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); + Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); CHECK_FOR_ERROR - Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); + Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); - if (yyval.InstVal == 0) + (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); + if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete yyvsp[-3].TypeVal; - ; - break;} -case 225: -#line 2439 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!(*yyvsp[-3].TypeVal)->isIntegral()) { - if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) || - !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral()) + delete (yyvsp[-3].TypeVal); + ;} + break; + + case 226: +#line 2439 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!(*(yyvsp[-3].TypeVal))->isIntegral()) { + if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) || + !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); + Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); + Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); - if (yyval.InstVal == 0) + (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete yyvsp[-3].TypeVal; - ; - break;} -case 226: -#line 2454 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) { + delete (yyvsp[-3].TypeVal); + ;} + break; + + case 227: +#line 2454 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) { GEN_ERROR( "PackedTypes currently not supported in setcc instructions!"); } - Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); + Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); + Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); - if (yyval.InstVal == 0) + (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete yyvsp[-3].TypeVal; - ; - break;} -case 227: -#line 2468 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + delete (yyvsp[-3].TypeVal); + ;} + break; + + case 228: +#line 2468 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { std::cerr << "WARNING: Use of eliminated 'not' instruction:" << " Replacing with 'xor'.\n"; - Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType()); + Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType()); if (Ones == 0) GEN_ERROR("Expected integral type for not instruction!"); - yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones); - if (yyval.InstVal == 0) + (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones); + if ((yyval.InstVal) == 0) GEN_ERROR("Could not create a xor instruction!"); CHECK_FOR_ERROR - ; - break;} -case 228: -#line 2481 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[0].ValueVal->getType() != Type::UByteTy) + ;} + break; + + case 229: +#line 2481 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) GEN_ERROR("Shift amount must be ubyte!"); - if (!yyvsp[-2].ValueVal->getType()->isInteger()) + if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); + (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 229: -#line 2489 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!yyvsp[0].TypeVal->get()->isFirstClassType()) + ;} + break; + + case 230: +#line 2489 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!(yyvsp[0].TypeVal)->get()->isFirstClassType()) GEN_ERROR("cast instruction to a non-primitive type: '" + - yyvsp[0].TypeVal->get()->getDescription() + "'!"); - yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); - delete yyvsp[0].TypeVal; - CHECK_FOR_ERROR - ; - break;} -case 230: -#line 2497 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (yyvsp[-4].ValueVal->getType() != Type::BoolTy) + (yyvsp[0].TypeVal)->get()->getDescription() + "'!"); + (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); + delete (yyvsp[0].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 231: +#line 2497 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) GEN_ERROR("select condition must be boolean!"); - if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) + if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) GEN_ERROR("select value types should match!"); - yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); + (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 231: -#line 2505 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 232: +#line 2505 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { NewVarArgs = true; - yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); - delete yyvsp[0].TypeVal; + (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); + delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 232: -#line 2511 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 233: +#line 2511 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { ObsoleteVarArgs = true; - const Type* ArgTy = yyvsp[-2].ValueVal->getType(); + const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); Function* NF = CurModule.CurrentModule-> getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); @@ -4163,19 +4926,20 @@ case 232: //b = vaarg foo, t AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); CurBB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); + CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); - yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal); - delete yyvsp[0].TypeVal; + (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal)); + delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 233: -#line 2531 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 234: +#line 2531 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { ObsoleteVarArgs = true; - const Type* ArgTy = yyvsp[-2].ValueVal->getType(); + const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); Function* NF = CurModule.CurrentModule-> getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); @@ -4187,73 +4951,78 @@ case 233: //b = load foo AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); CurBB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); + CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); - Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal); + Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal)); CurBB->getInstList().push_back(tmp); - yyval.InstVal = new LoadInst(foo); - delete yyvsp[0].TypeVal; + (yyval.InstVal) = new LoadInst(foo); + delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR - ; - break;} -case 234: -#line 2554 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) + ;} + break; + + case 235: +#line 2554 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid extractelement operands!"); - yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); + (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 235: -#line 2560 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) + ;} + break; + + case 236: +#line 2560 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid insertelement operands!"); - yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); + (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 236: -#line 2566 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) + ;} + break; + + case 237: +#line 2566 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid shufflevector operands!"); - yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); + (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 237: -#line 2572 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const Type *Ty = yyvsp[0].PHIList->front().first->getType(); + ;} + break; + + case 238: +#line 2572 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); if (!Ty->isFirstClassType()) GEN_ERROR("PHI node operands must be of first class type!"); - yyval.InstVal = new PHINode(Ty); - ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); - while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { - if (yyvsp[0].PHIList->front().first->getType() != Ty) + (yyval.InstVal) = new PHINode(Ty); + ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); + while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { + if ((yyvsp[0].PHIList)->front().first->getType() != Ty) GEN_ERROR("All elements of a PHI node must be of the same type!"); - cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); - yyvsp[0].PHIList->pop_front(); + cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); + (yyvsp[0].PHIList)->pop_front(); } - delete yyvsp[0].PHIList; // Free the list... + delete (yyvsp[0].PHIList); // Free the list... CHECK_FOR_ERROR - ; - break;} -case 238: -#line 2587 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ + ;} + break; + + case 239: +#line 2587 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { const PointerType *PFTy; const FunctionType *Ty; - if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) || + if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) || !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector<const Type*> ParamTypes; - if (yyvsp[-1].ValueList) { - for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); + if ((yyvsp[-1].ValueList)) { + for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end(); I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -4261,31 +5030,31 @@ case 238: bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy) + if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); - Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg); + Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling... + Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling... CHECK_FOR_ERROR // Create the call node... - if (!yyvsp[-1].ValueList) { // Has no arguments? + if (!(yyvsp[-1].ValueList)) { // Has no arguments? // Make sure no arguments is a good thing! if (Ty->getNumParams() != 0) GEN_ERROR("No arguments passed to a function that " "expects arguments!"); - yyval.InstVal = new CallInst(V, std::vector<Value*>()); + (yyval.InstVal) = new CallInst(V, std::vector<Value*>()); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified // correctly! // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end(); + std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -4295,377 +5064,442 @@ case 238: if (I != E || (ArgI != ArgE && !Ty->isVarArg())) GEN_ERROR("Invalid number of parameters detected!"); - yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList); + (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList)); } - cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal); - cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal); - delete yyvsp[-4].TypeVal; - delete yyvsp[-1].ValueList; - CHECK_FOR_ERROR - ; - break;} -case 239: -#line 2646 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.InstVal = yyvsp[0].InstVal; - CHECK_FOR_ERROR - ; - break;} -case 240: -#line 2653 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValueList = yyvsp[0].ValueList; - CHECK_FOR_ERROR - ; - break;} -case 241: -#line 2656 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.ValueList = new std::vector<Value*>(); - CHECK_FOR_ERROR - ; - break;} -case 242: -#line 2661 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = true; + cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal)); + cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal)); + delete (yyvsp[-4].TypeVal); + delete (yyvsp[-1].ValueList); CHECK_FOR_ERROR - ; - break;} -case 243: -#line 2665 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.BoolVal = false; + ;} + break; + + case 240: +#line 2646 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.InstVal) = (yyvsp[0].InstVal); CHECK_FOR_ERROR - ; - break;} -case 244: -#line 2672 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); - delete yyvsp[-1].TypeVal; + ;} + break; + + case 241: +#line 2653 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValueList) = (yyvsp[0].ValueList); CHECK_FOR_ERROR - ; - break;} -case 245: -#line 2677 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); - CHECK_FOR_ERROR - yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); - delete yyvsp[-4].TypeVal; - ; - break;} -case 246: -#line 2683 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); - delete yyvsp[-1].TypeVal; + ;} + break; + + case 242: +#line 2656 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.ValueList) = new std::vector<Value*>(); CHECK_FOR_ERROR - ; - break;} -case 247: -#line 2688 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); - CHECK_FOR_ERROR - yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); - delete yyvsp[-4].TypeVal; - ; - break;} -case 248: -#line 2694 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) + ;} + break; + + case 243: +#line 2661 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = true; + CHECK_FOR_ERROR + ;} + break; + + case 244: +#line 2665 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.BoolVal) = false; + CHECK_FOR_ERROR + ;} + break; + + case 245: +#line 2672 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); + delete (yyvsp[-1].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 246: +#line 2677 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + CHECK_FOR_ERROR + (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); + delete (yyvsp[-4].TypeVal); + ;} + break; + + case 247: +#line 2683 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); + delete (yyvsp[-1].TypeVal); + CHECK_FOR_ERROR + ;} + break; + + case 248: +#line 2688 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + CHECK_FOR_ERROR + (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); + delete (yyvsp[-4].TypeVal); + ;} + break; + + case 249: +#line 2694 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) GEN_ERROR("Trying to free nonpointer type " + - yyvsp[0].ValueVal->getType()->getDescription() + "!"); - yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); + (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); + (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); CHECK_FOR_ERROR - ; - break;} -case 249: -#line 2702 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!isa<PointerType>(yyvsp[-1].TypeVal->get())) + ;} + break; + + case 250: +#line 2702 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) GEN_ERROR("Can't load from nonpointer type: " + - (*yyvsp[-1].TypeVal)->getDescription()); - if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) + (*(yyvsp[-1].TypeVal))->getDescription()); + if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) GEN_ERROR("Can't load from pointer of non-first-class type: " + - (*yyvsp[-1].TypeVal)->getDescription()); - Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); - CHECK_FOR_ERROR - yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); - delete yyvsp[-1].TypeVal; - ; - break;} -case 250: -#line 2714 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); + (*(yyvsp[-1].TypeVal))->getDescription()); + Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); + CHECK_FOR_ERROR + (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); + delete (yyvsp[-1].TypeVal); + ;} + break; + + case 251: +#line 2714 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); if (!PT) GEN_ERROR("Can't store to a nonpointer type: " + - (*yyvsp[-1].TypeVal)->getDescription()); + (*(yyvsp[-1].TypeVal))->getDescription()); const Type *ElTy = PT->getElementType(); - if (ElTy != yyvsp[-3].ValueVal->getType()) - GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + + if (ElTy != (yyvsp[-3].ValueVal)->getType()) + GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'!"); - Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); + Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal); - delete yyvsp[-1].TypeVal; - ; - break;} -case 251: -#line 2729 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" -{ - if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) + (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); + delete (yyvsp[-1].TypeVal); + ;} + break; + + case 252: +#line 2729 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" + { + if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) GEN_ERROR("getelementptr insn requires pointer operand!"); // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct // indices to uint struct indices for compatibility. generic_gep_type_iterator<std::vector<Value*>::iterator> - GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()), - GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()); - for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) + GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()), + GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()); + for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i])) if (CUI->getType() == Type::UByteTy) - (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); + (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); - if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true)) + if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) GEN_ERROR("Invalid getelementptr indices for type '" + - (*yyvsp[-2].TypeVal)->getDescription()+ "'!"); - Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); - CHECK_FOR_ERROR - yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList); - delete yyvsp[-2].TypeVal; - delete yyvsp[0].ValueList; - ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/share/bison.simple" + (*(yyvsp[-2].TypeVal))->getDescription()+ "'!"); + Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); + CHECK_FOR_ERROR + (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); + delete (yyvsp[-2].TypeVal); + delete (yyvsp[0].ValueList); + ;} + break; + + + default: break; + } + +/* Line 1126 of yacc.c. */ +#line 5235 "llvmAsmParser.tab.c" yyvsp -= yylen; yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif + + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; -yyerrlab: /* here on detecting error */ - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + char *yymsg = 0; +# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; - if (count < 5) +#if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + + if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yymsg; + int yyi = 0; + while ((*yyp = *yyf)) { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } } - yyerror(msg); - free(msg); + yyerror (yymsg); + YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exceeded"); + { + yyerror (YY_("syntax error")); + goto yyexhaustedlab; + } } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror (YY_("syntax error")); } - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ + if (yyerrstatus == 3) { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token - after shifting the error token. */ + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; - yyerrstatus = 3; /* Each real token shifted decrements this */ - goto yyerrhandle; +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: -yyerrdefault: /* current state does not do anything special for the error token. */ + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (0) + goto yyerrorlab; -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif +yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; -yyerrpop: /* pop the current state because it cannot handle the error token */ - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ -#if YYDEBUG != 0 - if (yydebug) + for (;;) { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; + yydestruct ("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - else if (yyn == 0) - goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ #endif - } - return 0; - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + while (yyssp != yyss) { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK; } - return 1; +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; } -#line 2755 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y" + + +#line 2755 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" void llvm::GenerateError(const std::string &message, int LineNo) { @@ -4688,3 +5522,4 @@ int yyerror(const char *ErrorMsg) { GenerateError(errMsg); return 0; } + diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs index 6bfcf02ad3..83f40e181f 100644 --- a/lib/AsmParser/llvmAsmParser.h.cvs +++ b/lib/AsmParser/llvmAsmParser.h.cvs @@ -1,4 +1,256 @@ -typedef union { +/* A Bison parser, made by GNU Bison 2.1. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ESINT64VAL = 258, + EUINT64VAL = 259, + SINTVAL = 260, + UINTVAL = 261, + FPVAL = 262, + VOID = 263, + BOOL = 264, + SBYTE = 265, + UBYTE = 266, + SHORT = 267, + USHORT = 268, + INT = 269, + UINT = 270, + LONG = 271, + ULONG = 272, + FLOAT = 273, + DOUBLE = 274, + TYPE = 275, + LABEL = 276, + VAR_ID = 277, + LABELSTR = 278, + STRINGCONSTANT = 279, + IMPLEMENTATION = 280, + ZEROINITIALIZER = 281, + TRUETOK = 282, + FALSETOK = 283, + BEGINTOK = 284, + ENDTOK = 285, + DECLARE = 286, + GLOBAL = 287, + CONSTANT = 288, + SECTION = 289, + VOLATILE = 290, + TO = 291, + DOTDOTDOT = 292, + NULL_TOK = 293, + UNDEF = 294, + CONST = 295, + INTERNAL = 296, + LINKONCE = 297, + WEAK = 298, + APPENDING = 299, + DLLIMPORT = 300, + DLLEXPORT = 301, + EXTERN_WEAK = 302, + OPAQUE = 303, + NOT = 304, + EXTERNAL = 305, + TARGET = 306, + TRIPLE = 307, + ENDIAN = 308, + POINTERSIZE = 309, + LITTLE = 310, + BIG = 311, + ALIGN = 312, + DEPLIBS = 313, + CALL = 314, + TAIL = 315, + ASM_TOK = 316, + MODULE = 317, + SIDEEFFECT = 318, + CC_TOK = 319, + CCC_TOK = 320, + CSRETCC_TOK = 321, + FASTCC_TOK = 322, + COLDCC_TOK = 323, + X86_STDCALLCC_TOK = 324, + X86_FASTCALLCC_TOK = 325, + DATA = 326, + RET = 327, + BR = 328, + SWITCH = 329, + INVOKE = 330, + UNWIND = 331, + UNREACHABLE = 332, + ADD = 333, + SUB = 334, + MUL = 335, + DIV = 336, + REM = 337, + AND = 338, + OR = 339, + XOR = 340, + SETLE = 341, + SETGE = 342, + SETLT = 343, + SETGT = 344, + SETEQ = 345, + SETNE = 346, + MALLOC = 347, + ALLOCA = 348, + FREE = 349, + LOAD = 350, + STORE = 351, + GETELEMENTPTR = 352, + PHI_TOK = 353, + CAST = 354, + SELECT = 355, + SHL = 356, + SHR = 357, + VAARG = 358, + EXTRACTELEMENT = 359, + INSERTELEMENT = 360, + SHUFFLEVECTOR = 361, + VAARG_old = 362, + VANEXT_old = 363 + }; +#endif +/* Tokens. */ +#define ESINT64VAL 258 +#define EUINT64VAL 259 +#define SINTVAL 260 +#define UINTVAL 261 +#define FPVAL 262 +#define VOID 263 +#define BOOL 264 +#define SBYTE 265 +#define UBYTE 266 +#define SHORT 267 +#define USHORT 268 +#define INT 269 +#define UINT 270 +#define LONG 271 +#define ULONG 272 +#define FLOAT 273 +#define DOUBLE 274 +#define TYPE 275 +#define LABEL 276 +#define VAR_ID 277 +#define LABELSTR 278 +#define STRINGCONSTANT 279 +#define IMPLEMENTATION 280 +#define ZEROINITIALIZER 281 +#define TRUETOK 282 +#define FALSETOK 283 +#define BEGINTOK 284 +#define ENDTOK 285 +#define DECLARE 286 +#define GLOBAL 287 +#define CONSTANT 288 +#define SECTION 289 +#define VOLATILE 290 +#define TO 291 +#define DOTDOTDOT 292 +#define NULL_TOK 293 +#define UNDEF 294 +#define CONST 295 +#define INTERNAL 296 +#define LINKONCE 297 +#define WEAK 298 +#define APPENDING 299 +#define DLLIMPORT 300 +#define DLLEXPORT 301 +#define EXTERN_WEAK 302 +#define OPAQUE 303 +#define NOT 304 +#define EXTERNAL 305 +#define TARGET 306 +#define TRIPLE 307 +#define ENDIAN 308 +#define POINTERSIZE 309 +#define LITTLE 310 +#define BIG 311 +#define ALIGN 312 +#define DEPLIBS 313 +#define CALL 314 +#define TAIL 315 +#define ASM_TOK 316 +#define MODULE 317 +#define SIDEEFFECT 318 +#define CC_TOK 319 +#define CCC_TOK 320 +#define CSRETCC_TOK 321 +#define FASTCC_TOK 322 +#define COLDCC_TOK 323 +#define X86_STDCALLCC_TOK 324 +#define X86_FASTCALLCC_TOK 325 +#define DATA 326 +#define RET 327 +#define BR 328 +#define SWITCH 329 +#define INVOKE 330 +#define UNWIND 331 +#define UNREACHABLE 332 +#define ADD 333 +#define SUB 334 +#define MUL 335 +#define DIV 336 +#define REM 337 +#define AND 338 +#define OR 339 +#define XOR 340 +#define SETLE 341 +#define SETGE 342 +#define SETLT 343 +#define SETGT 344 +#define SETEQ 345 +#define SETNE 346 +#define MALLOC 347 +#define ALLOCA 348 +#define FREE 349 +#define LOAD 350 +#define STORE 351 +#define GETELEMENTPTR 352 +#define PHI_TOK 353 +#define CAST 354 +#define SELECT 355 +#define SHL 356 +#define SHR 357 +#define VAARG 358 +#define EXTRACTELEMENT 359 +#define INSERTELEMENT 360 +#define SHUFFLEVECTOR 361 +#define VAARG_old 362 +#define VANEXT_old 363 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 974 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" +typedef union YYSTYPE { llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair<llvm::PATypeHolder*, char*> *ArgVal; @@ -37,112 +289,14 @@ typedef union { llvm::Instruction::OtherOps OtherOpVal; llvm::Module::Endianness Endianness; } YYSTYPE; -#define ESINT64VAL 257 -#define EUINT64VAL 258 -#define SINTVAL 259 -#define UINTVAL 260 -#define FPVAL 261 -#define VOID 262 -#define BOOL 263 -#define SBYTE 264 -#define UBYTE 265 -#define SHORT 266 -#define USHORT 267 -#define INT 268 -#define UINT 269 -#define LONG 270 -#define ULONG 271 -#define FLOAT 272 -#define DOUBLE 273 -#define TYPE 274 -#define LABEL 275 -#define VAR_ID 276 -#define LABELSTR 277 -#define STRINGCONSTANT 278 -#define IMPLEMENTATION 279 -#define ZEROINITIALIZER 280 -#define TRUETOK 281 -#define FALSETOK 282 -#define BEGINTOK 283 -#define ENDTOK 284 -#define DECLARE 285 -#define GLOBAL 286 -#define CONSTANT 287 -#define SECTION 288 -#define VOLATILE 289 -#define TO 290 -#define DOTDOTDOT 291 -#define NULL_TOK 292 -#define UNDEF 293 -#define CONST 294 -#define INTERNAL 295 -#define LINKONCE 296 -#define WEAK 297 -#define APPENDING 298 -#define DLLIMPORT 299 -#define DLLEXPORT 300 -#define EXTERN_WEAK 301 -#define OPAQUE 302 -#define NOT 303 -#define EXTERNAL 304 -#define TARGET 305 -#define TRIPLE 306 -#define ENDIAN 307 -#define POINTERSIZE 308 -#define LITTLE 309 -#define BIG 310 -#define ALIGN 311 -#define DEPLIBS 312 -#define CALL 313 -#define TAIL 314 -#define ASM_TOK 315 -#define MODULE 316 -#define SIDEEFFECT 317 -#define CC_TOK 318 -#define CCC_TOK 319 -#define CSRETCC_TOK 320 -#define FASTCC_TOK 321 -#define COLDCC_TOK 322 -#define X86_STDCALLCC_TOK 323 -#define X86_FASTCALLCC_TOK 324 -#define DATA 325 -#define RET 326 -#define BR 327 -#define SWITCH 328 -#define INVOKE 329 -#define UNWIND 330 -#define UNREACHABLE 331 -#define ADD 332 -#define SUB 333 -#define MUL 334 -#define DIV 335 -#define REM 336 -#define AND 337 -#define OR 338 -#define XOR 339 -#define SETLE 340 -#define SETGE 341 -#define SETLT 342 -#define SETGT 343 -#define SETEQ 344 -#define SETNE 345 -#define MALLOC 346 -#define ALLOCA 347 -#define FREE 348 -#define LOAD 349 -#define STORE 350 -#define GETELEMENTPTR 351 -#define PHI_TOK 352 -#define CAST 353 -#define SELECT 354 -#define SHL 355 -#define SHR 356 -#define VAARG 357 -#define EXTRACTELEMENT 358 -#define INSERTELEMENT 359 -#define SHUFFLEVECTOR 360 -#define VAARG_old 361 -#define VANEXT_old 362 - +/* Line 1447 of yacc.c. */ +#line 294 "llvmAsmParser.tab.h" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif extern YYSTYPE llvmAsmlval; + + + diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 2842f27f1b..25c8c2fff4 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -307,25 +307,25 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { // Check to make sure that "Ty" is an integral type, and that our // value will fit into the specified type... case ValID::ConstSIntVal: // Is it a constant pool reference?? - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Signed integral constant '" + itostr(D.ConstPool64) + "' is invalid for type '" + Ty->getDescription() + "'!"); return 0; } - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); case ValID::ConstUIntVal: // Is it an unsigned const pool reference? - if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Integral constant '" + utostr(D.UConstPool64) + "' is invalid or out of range!"); return 0; } else { // This is really a signed reference. Transmogrify. - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); } } else { - return ConstantUInt::get(Ty, D.UConstPool64); + return ConstantInt::get(Ty, D.UConstPool64); } case ValID::ConstFPVal: // Is it a floating point const pool reference? @@ -1394,11 +1394,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr std::vector<Constant*> Vals; if (ETy == Type::SByteTy) { for (signed char *C = (signed char *)$3; C != (signed char *)EndStr; ++C) - Vals.push_back(ConstantSInt::get(ETy, *C)); + Vals.push_back(ConstantInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { for (unsigned char *C = (unsigned char *)$3; C != (unsigned char*)EndStr; ++C) - Vals.push_back(ConstantUInt::get(ETy, *C)); + Vals.push_back(ConstantInt::get(ETy, *C)); } else { free($3); GEN_ERROR("Cannot build string arrays of non byte sized elements!"); @@ -1561,15 +1561,15 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr }; ConstVal : SIntType EINT64VAL { // integral constants - if (!ConstantSInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantSInt::get($1, $2); + $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } | UIntType EUINT64VAL { // integral constants - if (!ConstantUInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantUInt::get($1, $2); + $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } | BOOL TRUETOK { // Boolean constants @@ -1610,7 +1610,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { GTE = gep_type_end($3->getType(), $4->begin(), $4->end()); for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*$4)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i])) if (CUI->getType() == Type::UByteTy) (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); @@ -2737,7 +2737,7 @@ MemoryInst : MALLOC Types OptCAlign { GTE = gep_type_end($2->get(), $4->begin(), $4->end()); for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*$4)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i])) if (CUI->getType() == Type::UByteTy) (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 2842f27f1b..25c8c2fff4 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -307,25 +307,25 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { // Check to make sure that "Ty" is an integral type, and that our // value will fit into the specified type... case ValID::ConstSIntVal: // Is it a constant pool reference?? - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Signed integral constant '" + itostr(D.ConstPool64) + "' is invalid for type '" + Ty->getDescription() + "'!"); return 0; } - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); case ValID::ConstUIntVal: // Is it an unsigned const pool reference? - if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { - if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { + if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Integral constant '" + utostr(D.UConstPool64) + "' is invalid or out of range!"); return 0; } else { // This is really a signed reference. Transmogrify. - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantInt::get(Ty, D.ConstPool64); } } else { - return ConstantUInt::get(Ty, D.UConstPool64); + return ConstantInt::get(Ty, D.UConstPool64); } case ValID::ConstFPVal: // Is it a floating point const pool reference? @@ -1394,11 +1394,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr std::vector<Constant*> Vals; if (ETy == Type::SByteTy) { for (signed char *C = (signed char *)$3; C != (signed char *)EndStr; ++C) - Vals.push_back(ConstantSInt::get(ETy, *C)); + Vals.push_back(ConstantInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { for (unsigned char *C = (unsigned char *)$3; C != (unsigned char*)EndStr; ++C) - Vals.push_back(ConstantUInt::get(ETy, *C)); + Vals.push_back(ConstantInt::get(ETy, *C)); } else { free($3); GEN_ERROR("Cannot build string arrays of non byte sized elements!"); @@ -1561,15 +1561,15 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr }; ConstVal : SIntType EINT64VAL { // integral constants - if (!ConstantSInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantSInt::get($1, $2); + $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } | UIntType EUINT64VAL { // integral constants - if (!ConstantUInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantUInt::get($1, $2); + $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } | BOOL TRUETOK { // Boolean constants @@ -1610,7 +1610,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { GTE = gep_type_end($3->getType(), $4->begin(), $4->end()); for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*$4)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i])) if (CUI->getType() == Type::UByteTy) (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); @@ -2737,7 +2737,7 @@ MemoryInst : MALLOC Types OptCAlign { GTE = gep_type_end($2->get(), $4->begin(), $4->end()); for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa<StructType>(*GTI)) // Only change struct indices - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*$4)[i])) + if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i])) if (CUI->getType() == Type::UByteTy) (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index ac6418d7a7..c7e99d0c94 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1010,8 +1010,9 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds, // Convert ubyte struct indices into uint struct indices. if (isa<StructType>(TopTy) && hasRestrictedGEPTypes) - if (ConstantUInt *C = dyn_cast<ConstantUInt>(Idx.back())) - Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); + if (ConstantInt *C = dyn_cast<ConstantInt>(Idx.back())) + if (C->getType() == Type::UByteTy) + Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); } @@ -1549,15 +1550,15 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { case Type::UShortTyID: case Type::UIntTyID: { unsigned Val = read_vbr_uint(); - if (!ConstantUInt::isValueValidForType(Ty, Val)) + if (!ConstantInt::isValueValidForType(Ty, uint64_t(Val))) error("Invalid unsigned byte/short/int read."); - Result = ConstantUInt::get(Ty, Val); + Result = ConstantInt::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); break; } case Type::ULongTyID: - Result = ConstantUInt::get(Ty, read_vbr_uint64()); + Result = ConstantInt::get(Ty, read_vbr_uint64()); if (Handler) Handler->handleConstantValue(Result); break; @@ -1566,9 +1567,9 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { case Type::IntTyID: case Type::LongTyID: { int64_t Val = read_vbr_int64(); - if (!ConstantSInt::isValueValidForType(Ty, Val)) + if (!ConstantInt::isValueValidForType(Ty, Val)) error("Invalid signed byte/short/int/long read."); - Result = ConstantSInt::get(Ty, Val); + Result = ConstantInt::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); break; } @@ -1699,12 +1700,9 @@ void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ read_data(Data, Data+ATy->getNumElements()); std::vector<Constant*> Elements(ATy->getNumElements()); - if (ATy->getElementType() == Type::SByteTy) - for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) - Elements[i] = ConstantSInt::get(Type::SByteTy, (signed char)Data[i]); - else - for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) - Elements[i] = ConstantUInt::get(Type::UByteTy, (unsigned char)Data[i]); + const Type* ElemType = ATy->getElementType(); + for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) + Elements[i] = ConstantInt::get(ElemType, (unsigned char)Data[i]); // Create the constant, inserting it as needed. Constant *C = ConstantArray::get(ATy, Elements); diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 48cccda8f4..d5c4840c00 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -293,7 +293,7 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { assert(CE->getNumOperands() > 0 && "ConstantExpr with 0 operands"); assert(CE->getNumOperands() != 1 || CE->getOpcode() == Instruction::Cast); output_vbr(1+CE->getNumOperands()); // flags as an expr - output_vbr(CE->getOpcode()); // flags as an expr + output_vbr(CE->getOpcode()); // Put out the CE op code for (User::const_op_iterator OI = CE->op_begin(); OI != CE->op_end(); ++OI){ int Slot = Table.getSlot(*OI); @@ -307,7 +307,7 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { output_vbr(1U); // 1 -> UndefValue constant. return; } else { - output_vbr(0U); // flag as not a ConstantExpr + output_vbr(0U); // flag as not a ConstantExpr (i.e. 0 operands) } switch (CPV->getType()->getTypeID()) { @@ -322,14 +322,14 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { case Type::UShortTyID: case Type::UIntTyID: case Type::ULongTyID: - output_vbr(cast<ConstantUInt>(CPV)->getValue()); + output_vbr(cast<ConstantInt>(CPV)->getZExtValue()); break; case Type::SByteTyID: // Signed integer types... case Type::ShortTyID: case Type::IntTyID: case Type::LongTyID: - output_vbr(cast<ConstantSInt>(CPV)->getValue()); + output_vbr(cast<ConstantInt>(CPV)->getSExtValue()); break; case Type::ArrayTyID: { @@ -881,11 +881,11 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*> // FIXME: Most slabs only have 1 or 2 entries! We should encode this much // more compactly. - // Output type header: [num entries][type id number] + // Put out type header: [num entries][type id number] // output_vbr(NC); - // Output the Type ID Number... + // Put out the Type ID Number... int Slot = Table.getSlot(Plane.front()->getType()); assert (Slot != -1 && "Type in constant pool but not in function!!"); output_typeid((unsigned)Slot); diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 90d77adfb3..09978344a7 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -393,14 +393,15 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { assert(CB->getValue()); O << "1"; - } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) - if (((CI->getValue() << 32) >> 32) == CI->getValue()) - O << CI->getValue(); - else - O << (uint64_t)CI->getValue(); - else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) - O << CI->getValue(); - else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { + } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + if (CI->getType()->isSigned()) { + if (((CI->getSExtValue() << 32) >> 32) == CI->getSExtValue()) + O << CI->getSExtValue(); + else + O << (uint64_t)CI->getSExtValue(); + } else + O << CI->getZExtValue(); + } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value, possibly // decorating it with GlobalVarAddrPrefix/Suffix or @@ -492,7 +493,7 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA, O << "\""; for (unsigned i = 0; i != LastElt; ++i) { unsigned char C = - (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue(); + (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getZExtValue(); if (C == '"') { O << "\\\""; @@ -524,7 +525,7 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA, void AsmPrinter::EmitString(const ConstantArray *CVA) const { unsigned NumElts = CVA->getNumOperands(); if (TAI->getAscizDirective() && NumElts && - cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) { + cast<ConstantInt>(CVA->getOperand(NumElts-1))->getZExtValue() == 0) { O << TAI->getAscizDirective(); printAsCString(O, CVA, NumElts-1); } else { @@ -604,7 +605,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { } } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) { if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { - uint64_t Val = CI->getRawValue(); + uint64_t Val = CI->getZExtValue(); if (TAI->getData64bitsDirective()) O << TAI->getData64bitsDirective() << Val << "\n"; diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 515752e6b7..b5a03fc54d 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -166,10 +166,10 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) { Value *Tmp1 = new ShiftInst(Instruction::Shr, V, ConstantInt::get(Type::UByteTy,24),"bswap.1", IP); Tmp3 = BinaryOperator::createAnd(Tmp3, - ConstantUInt::get(Type::UIntTy, 0xFF0000), + ConstantInt::get(Type::UIntTy, 0xFF0000), "bswap.and3", IP); Tmp2 = BinaryOperator::createAnd(Tmp2, - ConstantUInt::get(Type::UIntTy, 0xFF00), + ConstantInt::get(Type::UIntTy, 0xFF00), "bswap.and2", IP); Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP); Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP); @@ -194,23 +194,24 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) { Value *Tmp1 = new ShiftInst(Instruction::Shr, V, ConstantInt::get(Type::UByteTy,56),"bswap.1", IP); Tmp7 = BinaryOperator::createAnd(Tmp7, - ConstantUInt::get(Type::ULongTy, 0xFF000000000000ULL), - "bswap.and7", IP); + ConstantInt::get(Type::ULongTy, + 0xFF000000000000ULL), + "bswap.and7", IP); Tmp6 = BinaryOperator::createAnd(Tmp6, - ConstantUInt::get(Type::ULongTy, 0xFF0000000000ULL), - "bswap.and6", IP); + ConstantInt::get(Type::ULongTy, 0xFF0000000000ULL), + "bswap.and6", IP); Tmp5 = BinaryOperator::createAnd(Tmp5, - ConstantUInt::get(Type::ULongTy, 0xFF00000000ULL), - "bswap.and5", IP); + ConstantInt::get(Type::ULongTy, 0xFF00000000ULL), + "bswap.and5", IP); Tmp4 = BinaryOperator::createAnd(Tmp4, - ConstantUInt::get(Type::ULongTy, 0xFF000000ULL), - "bswap.and4", IP); + ConstantInt::get(Type::ULongTy, 0xFF000000ULL), + "bswap.and4", IP); Tmp3 = BinaryOperator::createAnd(Tmp3, - ConstantUInt::get(Type::ULongTy, 0xFF0000ULL), - "bswap.and3", IP); + ConstantInt::get(Type::ULongTy, 0xFF0000ULL), + "bswap.and3", IP); Tmp2 = BinaryOperator::createAnd(Tmp2, - ConstantUInt::get(Type::ULongTy, 0xFF00ULL), - "bswap.and2", IP); + ConstantInt::get(Type::ULongTy, 0xFF00ULL), + "bswap.and2", IP); Tmp8 = BinaryOperator::createOr(Tmp8, Tmp7, "bswap.or1", IP); Tmp6 = BinaryOperator::createOr(Tmp6, Tmp5, "bswap.or2", IP); Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or3", IP); @@ -247,8 +248,8 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) { unsigned BitSize = V->getType()->getPrimitiveSizeInBits(); for (unsigned i = 1, ct = 0; i != BitSize; i <<= 1, ++ct) { Value *MaskCst = - ConstantExpr::getCast(ConstantUInt::get(Type::ULongTy, - MaskValues[ct]), V->getType()); + ConstantExpr::getCast(ConstantInt::get(Type::ULongTy, MaskValues[ct]), + V->getType()); Value *LHS = BinaryOperator::createAnd(V, MaskCst, "cppop.and1", IP); Value *VShift = new ShiftInst(Instruction::Shr, V, ConstantInt::get(Type::UByteTy, i), "ctpop.sh", IP); @@ -395,7 +396,7 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::readcyclecounter: { std::cerr << "WARNING: this target does not support the llvm.readcyclecoun" << "ter intrinsic. It is being lowered to a constant 0\n"; - CI->replaceAllUsesWith(ConstantUInt::get(Type::ULongTy, 0)); + CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, 0)); break; } diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index 7ca63b0ba4..a1f4f1338b 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -120,7 +120,7 @@ static bool isGlobalVariable(Value *V) { /// getUIntOperand - Return ith operand if it is an unsigned integer. /// -static ConstantUInt *getUIntOperand(GlobalVariable *GV, unsigned i) { +static ConstantInt *getUIntOperand(GlobalVariable *GV, unsigned i) { // Make sure the GlobalVariable has an initializer. if (!GV->hasInitializer()) return NULL; @@ -133,8 +133,9 @@ static ConstantUInt *getUIntOperand(GlobalVariable *GV, unsigned i) { if (i >= N) return NULL; // Check constant. - return dyn_cast<ConstantUInt>(CI->getOperand(i)); + return dyn_cast<ConstantInt>(CI->getOperand(i)); } + //===----------------------------------------------------------------------===// /// ApplyToFields - Target the visitor to each field of the debug information @@ -192,19 +193,19 @@ public: /// virtual void Apply(int &Field) { Constant *C = CI->getOperand(I++); - Field = cast<ConstantSInt>(C)->getValue(); + Field = cast<ConstantInt>(C)->getSExtValue(); } virtual void Apply(unsigned &Field) { Constant *C = CI->getOperand(I++); - Field = cast<ConstantUInt>(C)->getValue(); + Field = cast<ConstantInt>(C)->getZExtValue(); } virtual void Apply(int64_t &Field) { Constant *C = CI->getOperand(I++); - Field = cast<ConstantSInt>(C)->getValue(); + Field = cast<ConstantInt>(C)->getSExtValue(); } virtual void Apply(uint64_t &Field) { Constant *C = CI->getOperand(I++); - Field = cast<ConstantUInt>(C)->getValue(); + Field = cast<ConstantInt>(C)->getZExtValue(); } virtual void Apply(bool &Field) { Constant *C = CI->getOperand(I++); @@ -261,16 +262,16 @@ public: /// Apply - Set the value of each of the fields. /// virtual void Apply(int &Field) { - Elements.push_back(ConstantSInt::get(Type::IntTy, Field)); + Elements.push_back(ConstantInt::get(Type::IntTy, int32_t(Field))); } virtual void Apply(unsigned &Field) { - Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); + Elements.push_back(ConstantInt::get(Type::UIntTy, uint32_t(Field))); } virtual void Apply(int64_t &Field) { - Elements.push_back(ConstantSInt::get(Type::LongTy, Field)); + Elements.push_back(ConstantInt::get(Type::LongTy, int64_t(Field))); } virtual void Apply(uint64_t &Field) { - Elements.push_back(ConstantUInt::get(Type::ULongTy, Field)); + Elements.push_back(ConstantInt::get(Type::ULongTy, uint64_t(Field))); } virtual void Apply(bool &Field) { Elements.push_back(ConstantBool::get(Field)); @@ -467,8 +468,8 @@ public: /// TagFromGlobal - Returns the tag number from a debug info descriptor /// GlobalVariable. Return DIIValid if operand is not an unsigned int. unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { - ConstantUInt *C = getUIntOperand(GV, 0); - return C ? ((unsigned)C->getValue() & ~LLVMDebugVersionMask) : + ConstantInt *C = getUIntOperand(GV, 0); + return C ? ((unsigned)C->getZExtValue() & ~LLVMDebugVersionMask) : (unsigned)DW_TAG_invalid; } @@ -476,8 +477,8 @@ unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { /// descriptor GlobalVariable. Return DIIValid if operand is not an unsigned /// int. unsigned DebugInfoDesc::VersionFromGlobal(GlobalVariable *GV) { - ConstantUInt *C = getUIntOperand(GV, 0); - return C ? ((unsigned)C->getValue() & LLVMDebugVersionMask) : + ConstantInt *C = getUIntOperand(GV, 0); + return C ? ((unsigned)C->getZExtValue() & LLVMDebugVersionMask) : (unsigned)DW_TAG_invalid; } diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 723177f97d..125e46c0ca 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3562,7 +3562,7 @@ SDOperand SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { CV.push_back(ConstantFP::get(OpNTy, V->getValue())); } else if (ConstantSDNode *V = dyn_cast<ConstantSDNode>(Node->getOperand(i))) { - CV.push_back(ConstantUInt::get(OpNTy, V->getValue())); + CV.push_back(ConstantInt::get(OpNTy, V->getValue())); } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); CV.push_back(UndefValue::get(OpNTy)); @@ -3915,7 +3915,7 @@ ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source) { SignSet, Four, Zero); uint64_t FF = 0x5f800000ULL; if (TLI.isLittleEndian()) FF <<= 32; - static Constant *FudgeFactor = ConstantUInt::get(Type::ULongTy, FF); + static Constant *FudgeFactor = ConstantInt::get(Type::ULongTy, FF); SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy()); CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset); @@ -4046,7 +4046,7 @@ SDOperand SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned, case MVT::i64: FF = 0x5F800000ULL; break; // 2^64 (as a float) } if (TLI.isLittleEndian()) FF <<= 32; - static Constant *FudgeFactor = ConstantUInt::get(Type::ULongTy, FF); + static Constant *FudgeFactor = ConstantInt::get(Type::ULongTy, FF); SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy()); CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 7cf3f5cb0d..238ed97843 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -236,21 +236,22 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli, Function::iterator BB = Fn.begin(), EB = Fn.end(); for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(AI->getArraySize())) { + if (ConstantInt *CUI = dyn_cast<ConstantInt>(AI->getArraySize())) { const Type *Ty = AI->getAllocatedType(); uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); unsigned Align = std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty), AI->getAlignment()); - // If the alignment of the value is smaller than the size of the value, - // and if the size of the value is particularly small (<= 8 bytes), - // round up to the size of the value for potentially better performance. + // If the alignment of the value is smaller than the size of the + // value, and if the size of the value is particularly small + // (<= 8 bytes), round up to the size of the value for potentially + // better performance. // // FIXME: This could be made better with a preferred alignment hook in // TargetData. It serves primarily to 8-byte align doubles for X86. if (Align < TySize && TySize <= 8) Align = TySize; - TySize *= CUI->getValue(); // Get total allocated size. + TySize *= CUI->getZExtValue(); // Get total allocated size. if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects. StaticAllocaMap[AI] = MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align); @@ -393,11 +394,13 @@ class SelectionDAGLowering { /// The comparison function for sorting Case values. struct CaseCmp { bool operator () (const Case& C1, const Case& C2) { - if (const ConstantUInt* U1 = dyn_cast<const ConstantUInt>(C1.first)) - return U1->getValue() < cast<const ConstantUInt>(C2.first)->getValue(); + if (const ConstantInt* I1 = dyn_cast<const ConstantInt>(C1.first)) + if (I1->getType()->isUnsigned()) + return I1->getZExtValue() < + cast<const ConstantInt>(C2.first)->getZExtValue(); - const ConstantSInt* S1 = dyn_cast<const ConstantSInt>(C1.first); - return S1->getValue() < cast<const ConstantSInt>(C2.first)->getValue(); + return cast<const ConstantInt>(C1.first)->getSExtValue() < + cast<const ConstantInt>(C2.first)->getSExtValue(); } }; @@ -637,7 +640,7 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { return N = DAG.getNode(ISD::VBUILD_VECTOR,MVT::Vector,&Ops[0],Ops.size()); } else { // Canonicalize all constant ints to be unsigned. - return N = DAG.getConstant(cast<ConstantIntegral>(C)->getRawValue(),VT); + return N = DAG.getConstant(cast<ConstantIntegral>(C)->getZExtValue(),VT); } } @@ -930,8 +933,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // lowering the switch to a binary tree of conditional branches. if (TLI.isOperationLegal(ISD::BRIND, TLI.getPointerTy()) && Cases.size() > 5) { - uint64_t First = cast<ConstantIntegral>(Cases.front().first)->getRawValue(); - uint64_t Last = cast<ConstantIntegral>(Cases.back().first)->getRawValue(); + uint64_t First =cast<ConstantIntegral>(Cases.front().first)->getZExtValue(); + uint64_t Last = cast<ConstantIntegral>(Cases.back().first)->getZExtValue(); double Density = (double)Cases.size() / (double)((Last - First) + 1ULL); if (Density >= 0.3125) { @@ -979,9 +982,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // the default BB. std::vector<MachineBasicBlock*> DestBBs; uint64_t TEI = First; - for (CaseItr ii = Cases.begin(), ee = Cases.end(); ii != ee; ++TEI) - if (cast<ConstantIntegral>(ii->first)->getRawValue() == TEI) { + if (cast<ConstantIntegral>(ii->first)->getZExtValue() == TEI) { DestBBs.push_back(ii->second); ++ii; } else { @@ -1055,8 +1057,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // rather than creating a leaf node for it. if ((LHSR.second - LHSR.first) == 1 && LHSR.first->first == CR.GE && - cast<ConstantIntegral>(C)->getRawValue() == - (cast<ConstantIntegral>(CR.GE)->getRawValue() + 1ULL)) { + cast<ConstantIntegral>(C)->getZExtValue() == + (cast<ConstantIntegral>(CR.GE)->getZExtValue() + 1ULL)) { LHSBB = LHSR.first->second; } else { LHSBB = new MachineBasicBlock(LLVMBB); @@ -1069,8 +1071,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // is CR.LT - 1, then we can branch directly to the target block for // the current Case Value, rather than emitting a RHS leaf node for it. if ((RHSR.second - RHSR.first) == 1 && CR.LT && - cast<ConstantIntegral>(RHSR.first->first)->getRawValue() == - (cast<ConstantIntegral>(CR.LT)->getRawValue() - 1ULL)) { + cast<ConstantIntegral>(RHSR.first->first)->getZExtValue() == + (cast<ConstantIntegral>(CR.LT)->getZExtValue() - 1ULL)) { RHSBB = RHSR.first->second; } else { RHSBB = new MachineBasicBlock(LLVMBB); @@ -1259,7 +1261,7 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) { OI != E; ++OI) { Value *Idx = *OI; if (const StructType *StTy = dyn_cast<StructType>(Ty)) { - unsigned Field = cast<ConstantUInt>(Idx)->getValue(); + unsigned Field = cast<ConstantInt>(Idx)->getZExtValue(); if (Field) { // N = N + Offset uint64_t Offset = TD->getStructLayout(StTy)->MemberOffsets[Field]; @@ -1272,13 +1274,14 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) { // If this is a constant subscript, handle it quickly. if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) { - if (CI->getRawValue() == 0) continue; - + if (CI->getZExtValue() == 0) continue; uint64_t Offs; - if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(CI)) - Offs = (int64_t)TD->getTypeSize(Ty)*CSI->getValue(); + if (CI->getType()->isSigned()) + Offs = (int64_t) + TD->getTypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue(); else - Offs = TD->getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue(); + Offs = + TD->getTypeSize(Ty)*cast<ConstantInt>(CI)->getZExtValue(); N = DAG.getNode(ISD::ADD, N.getValueType(), N, getIntPtrConstant(Offs)); continue; } @@ -2732,7 +2735,7 @@ SDOperand TargetLowering::CustomPromoteOperation(SDOperand Op, } void SelectionDAGLowering::visitFrameReturnAddress(CallInst &I, bool isFrame) { - unsigned Depth = (unsigned)cast<ConstantUInt>(I.getOperand(1))->getValue(); + unsigned Depth = (unsigned)cast<ConstantInt>(I.getOperand(1))->getZExtValue(); std::pair<SDOperand,SDOperand> Result = TLI.LowerFrameReturnAddress(isFrame, getRoot(), Depth, DAG); setValue(&I, Result.first); @@ -3126,7 +3129,7 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI, for (GetElementPtrInst::op_iterator OI = GEPI->op_begin()+1, E = GEPI->op_end(); OI != E; ++OI) { if (ConstantInt *CI = dyn_cast<ConstantInt>(*OI)) { - if (CI->getRawValue()) { + if (CI->getZExtValue()) { hasConstantIndex = true; break; } @@ -3159,7 +3162,7 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI, E = GEPI->op_end(); OI != E; ++OI) { Value *Idx = *OI; if (const StructType *StTy = dyn_cast<StructType>(Ty)) { - unsigned Field = cast<ConstantUInt>(Idx)->getValue(); + unsigned Field = cast<ConstantInt>(Idx)->getZExtValue(); if (Field) ConstantOffset += TD->getStructLayout(StTy)->MemberOffsets[Field]; Ty = StTy->getElementType(Field); @@ -3168,12 +3171,11 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI, // Handle constant subscripts. if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) { - if (CI->getRawValue() == 0) continue; - - if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(CI)) - ConstantOffset += (int64_t)TD->getTypeSize(Ty)*CSI->getValue(); + if (CI->getZExtValue() == 0) continue; + if (CI->getType()->isSigned()) + ConstantOffset += (int64_t)TD->getTypeSize(Ty)*CI->getSExtValue(); else - ConstantOffset+=TD->getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue(); + ConstantOffset += TD->getTypeSize(Ty)*CI->getZExtValue(); continue; } @@ -3185,7 +3187,7 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI, uint64_t ElementSize = TD->getTypeSize(Ty); // Mask off bits that should not be set. ElementSize &= ~0ULL >> (64-UIntPtrTy->getPrimitiveSizeInBits()); - Constant *SizeCst = ConstantUInt::get(UIntPtrTy, ElementSize); + Constant *SizeCst = ConstantInt::get(UIntPtrTy, ElementSize); // Multiply by the element size and add to the base. Idx = BinaryOperator::createMul(Idx, SizeCst, "", GEPI); @@ -3195,7 +3197,7 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI, // Make sure that the offset fits in uintptr_t. ConstantOffset &= ~0ULL >> (64-UIntPtrTy->getPrimitiveSizeInBits()); - Constant *PtrOffset = ConstantUInt::get(UIntPtrTy, ConstantOffset); + Constant *PtrOffset = ConstantInt::get(UIntPtrTy, ConstantOffset); // Okay, we have now emitted all of the variable index parts to the BB that // the GEP is defined in. Loop over all of the using instructions, inserting diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp index b60f5fc4bc..7e12cf80d6 100644 --- a/lib/Debugger/ProgramInfo.cpp +++ b/lib/Debugger/ProgramInfo.cpp @@ -114,8 +114,8 @@ SourceFileInfo::SourceFileInfo(const GlobalVariable *Desc, if (Desc && Desc->hasInitializer()) if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer())) if (CS->getNumOperands() > 4) { - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(CS->getOperand(1))) - Version = CUI->getValue(); + if (ConstantInt *CUI = dyn_cast<ConstantInt>(CS->getOperand(1))) + Version = CUI->getZExtValue(); BaseName = CS->getOperand(3)->getStringValue(); Directory = CS->getOperand(4)->getStringValue(); @@ -237,8 +237,8 @@ ProgramInfo::getSourceFile(const GlobalVariable *Desc) { if (Desc && Desc->hasInitializer()) if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer())) if (CS->getNumOperands() > 2) - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(CS->getOperand(2))) - LangID = CUI->getValue(); + if (ConstantInt *CUI = dyn_cast<ConstantInt>(CS->getOperand(2))) + LangID = CUI->getZExtValue(); const SourceLanguage &Lang = SourceLanguage::get(LangID); SourceFileInfo *New = Lang.createSourceFileInfo(Desc, *this); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 067f24de8b..f61369cd50 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -390,19 +390,19 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { } switch (C->getType()->getTypeID()) { -#define GET_CONST_VAL(TY, CTY, CLASS) \ - case Type::TY##TyID: Result.TY##Val = (CTY)cast<CLASS>(C)->getValue(); break - GET_CONST_VAL(Bool , bool , ConstantBool); - GET_CONST_VAL(UByte , unsigned char , ConstantUInt); - GET_CONST_VAL(SByte , signed char , ConstantSInt); - GET_CONST_VAL(UShort , unsigned short, ConstantUInt); - GET_CONST_VAL(Short , signed short , ConstantSInt); - GET_CONST_VAL(UInt , unsigned int , ConstantUInt); - GET_CONST_VAL(Int , signed int , ConstantSInt); - GET_CONST_VAL(ULong , uint64_t , ConstantUInt); - GET_CONST_VAL(Long , int64_t , ConstantSInt); - GET_CONST_VAL(Float , float , ConstantFP); - GET_CONST_VAL(Double , double , ConstantFP); +#define GET_CONST_VAL(TY, CTY, CLASS, GETMETH) \ + case Type::TY##TyID: Result.TY##Val = (CTY)cast<CLASS>(C)->GETMETH(); break + GET_CONST_VAL(Bool , bool , ConstantBool, getValue); + GET_CONST_VAL(UByte , unsigned char , ConstantInt, getZExtValue); + GET_CONST_VAL(SByte , signed char , ConstantInt, getSExtValue); + GET_CONST_VAL(UShort , unsigned short, ConstantInt, getZExtValue); + GET_CONST_VAL(Short , signed short , ConstantInt, getSExtValue); + GET_CONST_VAL(UInt , unsigned int , ConstantInt, getZExtValue); + GET_CONST_VAL(Int , signed int , ConstantInt, getSExtValue); + GET_CONST_VAL(ULong , uint64_t , ConstantInt, getZExtValue); + GET_CONST_VAL(Long , int64_t , ConstantInt, getSExtValue); + GET_CONST_VAL(Float , float , ConstantFP, getValue); + GET_CONST_VAL(Double , double , ConstantFP, getValue); #undef GET_CONST_VAL case Type::PointerTyID: if (isa<ConstantPointerNull>(C)) diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 4104ff3636..8c812f82d4 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -735,8 +735,8 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I, if (const StructType *STy = dyn_cast<StructType>(*I)) { const StructLayout *SLO = TD.getStructLayout(STy); - const ConstantUInt *CPU = cast<ConstantUInt>(I.getOperand()); - unsigned Index = unsigned(CPU->getValue()); + const ConstantInt *CPU = cast<ConstantInt>(I.getOperand()); + unsigned Index = unsigned(CPU->getZExtValue()); Total += (PointerTy)SLO->MemberOffsets[Index]; } else { diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 0a5423ef9d..9795eb7935 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -196,22 +196,22 @@ GenericValue JIT::runFunction(Function *F, switch (ArgTy->getTypeID()) { default: assert(0 && "Unknown argument type for function call!"); case Type::BoolTyID: C = ConstantBool::get(AV.BoolVal); break; - case Type::SByteTyID: C = ConstantSInt::get(ArgTy, AV.SByteVal); break; - case Type::UByteTyID: C = ConstantUInt::get(ArgTy, AV.UByteVal); break; - case Type::ShortTyID: C = ConstantSInt::get(ArgTy, AV.ShortVal); break; - case Type::UShortTyID: C = ConstantUInt::get(ArgTy, AV.UShortVal); break; - case Type::IntTyID: C = ConstantSInt::get(ArgTy, AV.IntVal); break; - case Type::UIntTyID: C = ConstantUInt::get(ArgTy, AV.UIntVal); break; - case Type::LongTyID: C = ConstantSInt::get(ArgTy, AV.LongVal); break; - case Type::ULongTyID: C = ConstantUInt::get(ArgTy, AV.ULongVal); break; - case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break; - case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break; + case Type::SByteTyID: C = ConstantInt::get(ArgTy, AV.SByteVal); break; + case Type::UByteTyID: C = ConstantInt::get(ArgTy, AV.UByteVal); break; + case Type::ShortTyID: C = ConstantInt::get(ArgTy, AV.ShortVal); break; + case Type::UShortTyID: C = ConstantInt::get(ArgTy, AV.UShortVal); break; + case Type::IntTyID: C = ConstantInt::get(ArgTy, AV.IntVal); break; + case Type::UIntTyID: C = ConstantInt::get(ArgTy, AV.UIntVal); break; + case Type::LongTyID: C = ConstantInt::get(ArgTy, AV.LongVal); break; + case Type::ULongTyID: C = ConstantInt::get(ArgTy, AV.ULongVal); break; + case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break; + case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break; case Type::PointerTyID: void *ArgPtr = GVTOP(AV); if (sizeof(void*) == 4) { - C = ConstantSInt::get(Type::IntTy, (int)(intptr_t)ArgPtr); + C = ConstantInt::get(Type::IntTy, (int)(intptr_t)ArgPtr); } else { - C = ConstantSInt::get(Type::LongTy, (intptr_t)ArgPtr); + C = ConstantInt::get(Type::LongTy, (intptr_t)ArgPtr); } C = ConstantExpr::getCast(C, ArgTy); // Cast the integer to pointer break; diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index beb61754fc..9e12c9343d 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -161,7 +161,7 @@ uint64_t ConstantRange::getSetSize() const { // Simply subtract the bounds... Constant *Result = ConstantExpr::getSub(Upper, Lower); - return cast<ConstantInt>(Result)->getRawValue(); + return cast<ConstantInt>(Result)->getZExtValue(); } /// contains - Return true if the specified value is in the set. @@ -288,7 +288,7 @@ ConstantRange ConstantRange::zeroExtend(const Type *Ty) const { // Change a source full set into [0, 1 << 8*numbytes) unsigned SrcTySize = getLower()->getType()->getPrimitiveSize(); return ConstantRange(Constant::getNullValue(Ty), - ConstantUInt::get(Ty, 1ULL << SrcTySize*8)); + ConstantInt::get(Ty, 1ULL << SrcTySize*8)); } Constant *Lower = getLower(); diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp index 4b197db407..cd49271e43 100644 --- a/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -810,8 +810,7 @@ bool ARMDAGToDAGISel::SelectAddrMode1(SDOperand N, case ISD::Constant: { uint32_t val = cast<ConstantSDNode>(N)->getValue(); if(!isRotInt8Immediate(val)) { - const Type *t = MVT::getTypeForValueType(MVT::i32); - Constant *C = ConstantUInt::get(t, val); + Constant *C = ConstantInt::get(Type::UIntTy, val); int alignment = 2; SDOperand Addr = CurDAG->getTargetConstantPool(C, MVT::i32, alignment); SDOperand Z = CurDAG->getTargetConstant(0, MVT::i32); diff --git a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp index b3b2461eaf..15ee143172 100644 --- a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp +++ b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp @@ -317,8 +317,7 @@ SDNode *AlphaDAGToDAGISel::Select(SDOperand Op) { break; //(zext (LDAH (LDA))) //Else use the constant pool MachineConstantPool *CP = BB->getParent()->getConstantPool(); - ConstantUInt *C = - ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , uval); + ConstantInt *C = ConstantInt::get(Type::ULongTy, uval); SDOperand CPI = CurDAG->getTargetConstantPool(C, MVT::i64); SDNode *Tmp = CurDAG->getTargetNode(Alpha::LDAHr, MVT::i64, CPI, getGlobalBaseReg()); diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 88113a0347..f31f92018b 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -460,7 +460,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) { // Do not include the last character, which we know is null for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) { - unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue(); + unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getZExtValue(); // Print it out literally if it is a printable character. The only thing // to be careful about is when the last letter output was a hex escape @@ -642,31 +642,31 @@ void CWriter::printConstant(Constant *CPV) { break; case Type::SByteTyID: case Type::ShortTyID: - Out << cast<ConstantSInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getSExtValue(); break; case Type::IntTyID: - if ((int)cast<ConstantSInt>(CPV)->getValue() == (int)0x80000000) + if ((int)cast<ConstantInt>(CPV)->getSExtValue() == (int)0x80000000) Out << "((int)0x80000000U)"; // Handle MININT specially to avoid warning else - Out << cast<ConstantSInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getSExtValue(); break; case Type::LongTyID: - if (cast<ConstantSInt>(CPV)->isMinValue()) + if (cast<ConstantInt>(CPV)->isMinValue()) Out << "(/*INT64_MIN*/(-9223372036854775807LL)-1)"; else - Out << cast<ConstantSInt>(CPV)->getValue() << "ll"; + Out << cast<ConstantInt>(CPV)->getSExtValue() << "ll"; break; case Type::UByteTyID: case Type::UShortTyID: - Out << cast<ConstantUInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getZExtValue(); break; case Type::UIntTyID: - Out << cast<ConstantUInt>(CPV)->getValue() << 'u'; + Out << cast<ConstantInt>(CPV)->getZExtValue() << 'u'; break; case Type::ULongTyID: - Out << cast<ConstantUInt>(CPV)->getValue() << "ull"; + Out << cast<ConstantInt>(CPV)->getZExtValue() << "ull"; break; case Type::FloatTyID: @@ -2002,14 +2002,14 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, // Print out the -> operator if possible... if (TmpI != E && isa<StructType>(*TmpI)) { Out << (HasImplicitAddress ? "." : "->"); - Out << "field" << cast<ConstantUInt>(TmpI.getOperand())->getValue(); + Out << "field" << cast<ConstantInt>(TmpI.getOperand())->getZExtValue(); I = ++TmpI; } } for (; I != E; ++I) if (isa<StructType>(*I)) { - Out << ".field" << cast<ConstantUInt>(I.getOperand())->getValue(); + Out << ".field" << cast<ConstantInt>(I.getOperand())->getZExtValue(); } else { Out << '['; writeOperand(I.getOperand()); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 88113a0347..f31f92018b 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -460,7 +460,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) { // Do not include the last character, which we know is null for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) { - unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue(); + unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getZExtValue(); // Print it out literally if it is a printable character. The only thing // to be careful about is when the last letter output was a hex escape @@ -642,31 +642,31 @@ void CWriter::printConstant(Constant *CPV) { break; case Type::SByteTyID: case Type::ShortTyID: - Out << cast<ConstantSInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getSExtValue(); break; case Type::IntTyID: - if ((int)cast<ConstantSInt>(CPV)->getValue() == (int)0x80000000) + if ((int)cast<ConstantInt>(CPV)->getSExtValue() == (int)0x80000000) Out << "((int)0x80000000U)"; // Handle MININT specially to avoid warning else - Out << cast<ConstantSInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getSExtValue(); break; case Type::LongTyID: - if (cast<ConstantSInt>(CPV)->isMinValue()) + if (cast<ConstantInt>(CPV)->isMinValue()) Out << "(/*INT64_MIN*/(-9223372036854775807LL)-1)"; else - Out << cast<ConstantSInt>(CPV)->getValue() << "ll"; + Out << cast<ConstantInt>(CPV)->getSExtValue() << "ll"; break; case Type::UByteTyID: case Type::UShortTyID: - Out << cast<ConstantUInt>(CPV)->getValue(); + Out << cast<ConstantInt>(CPV)->getZExtValue(); break; case Type::UIntTyID: - Out << cast<ConstantUInt>(CPV)->getValue() << 'u'; + Out << cast<ConstantInt>(CPV)->getZExtValue() << 'u'; break; case Type::ULongTyID: - Out << cast<ConstantUInt>(CPV)->getValue() << "ull"; + Out << cast<ConstantInt>(CPV)->getZExtValue() << "ull"; break; case Type::FloatTyID: @@ -2002,14 +2002,14 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, // Print out the -> operator if possible... if (TmpI != E && isa<StructType>(*TmpI)) { Out << (HasImplicitAddress ? "." : "->"); - Out << "field" << cast<ConstantUInt>(TmpI.getOperand())->getValue(); + Out << "field" << cast<ConstantInt>(TmpI.getOperand())->getZExtValue(); I = ++TmpI; } } for (; I != E; ++I) if (isa<StructType>(*I)) { - Out << ".field" << cast<ConstantUInt>(I.getOperand())->getValue(); + Out << ".field" << cast<ConstantInt>(I.getOperand())->getZExtValue(); } else { Out << '['; writeOperand(I.getOperand()); diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index cb602a6352..834177420f 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -330,7 +330,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, for (unsigned CurIDX = 0; CurIDX != Idx.size(); ++CurIDX, ++TI) { if (const StructType *STy = dyn_cast<StructType>(*TI)) { assert(Idx[CurIDX]->getType() == Type::UIntTy && "Illegal struct idx"); - unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue(); + unsigned FieldNo = cast<ConstantInt>(Idx[CurIDX])->getZExtValue(); // Get structure layout information... const StructLayout *Layout = getStructLayout(STy); @@ -346,7 +346,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Ty = cast<SequentialType>(Ty)->getElementType(); // Get the array index and the size of each array element. - int64_t arrayIdx = cast<ConstantInt>(Idx[CurIDX])->getRawValue(); + int64_t arrayIdx = cast<ConstantInt>(Idx[CurIDX])->getSExtValue(); Result += arrayIdx * (int64_t)getTypeSize(Ty); } } diff --git a/lib/Target/X86/X86IntelAsmPrinter.cpp b/lib/Target/X86/X86IntelAsmPrinter.cpp index a7d1351e7a..7a420d894e 100755 --- a/lib/Target/X86/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/X86IntelAsmPrinter.cpp @@ -474,7 +474,7 @@ void X86IntelAsmPrinter::EmitString(const ConstantArray *CVA) const { unsigned len = 0; bool inString = false; for (unsigned i = 0; i < NumElts; i++) { - int n = cast<ConstantInt>(CVA->getOperand(i))->getRawValue() & 255; + int n = cast<ConstantInt>(CVA->getOperand(i))->getZExtValue() & 255; if (len == 0) O << "\tdb "; diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 5183d43bc7..79f21b5c02 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -307,8 +307,8 @@ namespace { unsigned idx = 0; for (; idx < LHS.size() && idx < RHS.size(); ++idx) { if (LHS[idx] != RHS[idx]) { - return cast<ConstantInt>(LHS[idx])->getRawValue() < - cast<ConstantInt>(RHS[idx])->getRawValue(); + return cast<ConstantInt>(LHS[idx])->getZExtValue() < + cast<ConstantInt>(RHS[idx])->getZExtValue(); } } @@ -518,7 +518,7 @@ Function *ArgPromotion::DoPromotion(Function *F, std::string NewName = I->getName(); for (unsigned i = 0, e = Operands.size(); i != e; ++i) if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i])) - NewName += "."+itostr((int64_t)CI->getRawValue()); + NewName += "."+itostr((int64_t)CI->getZExtValue()); else NewName += ".x"; TheArg->setName(NewName+".val"); diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 5abd290527..fc39fe8ad5 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -270,7 +270,7 @@ static bool AnalyzeGlobal(Value *V, GlobalStatus &GS, static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx) { ConstantInt *CI = dyn_cast<ConstantInt>(Idx); if (!CI) return 0; - unsigned IdxV = (unsigned)CI->getRawValue(); + unsigned IdxV = CI->getZExtValue(); if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Agg)) { if (IdxV < CS->getNumOperands()) return CS->getOperand(IdxV); @@ -384,7 +384,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { NewGlobals.reserve(STy->getNumElements()); for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - ConstantUInt::get(Type::UIntTy, i)); + ConstantInt::get(Type::UIntTy, i)); assert(In && "Couldn't get element of initializer?"); GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false, GlobalVariable::InternalLinkage, @@ -406,7 +406,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { NewGlobals.reserve(NumElements); for (unsigned i = 0, e = NumElements; i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - ConstantUInt::get(Type::UIntTy, i)); + ConstantInt::get(Type::UIntTy, i)); assert(In && "Couldn't get element of initializer?"); GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false, @@ -435,8 +435,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { // Ignore the 1th operand, which has to be zero or else the program is quite // broken (undefined). Get the 2nd operand, which is the structure or array // index. - unsigned Val = - (unsigned)cast<ConstantInt>(GEP->getOperand(2))->getRawValue(); + unsigned Val = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue(); if (Val >= NewGlobals.size()) Val = 0; // Out of bound array access. Value *NewPtr = NewGlobals[Val]; @@ -673,11 +672,11 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, DEBUG(std::cerr << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " <<*MI); ConstantInt *NElements = cast<ConstantInt>(MI->getArraySize()); - if (NElements->getRawValue() != 1) { + if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. Type *NewTy = ArrayType::get(MI->getAllocatedType(), - (unsigned)NElements->getRawValue()); + NElements->getZExtValue()); MallocInst *NewMI = new MallocInst(NewTy, Constant::getNullValue(Type::UIntTy), MI->getAlignment(), MI->getName(), MI); @@ -886,11 +885,12 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr, // Otherwise, this should be: 'getelementptr Ptr, Idx, uint FieldNo ...' GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User); - assert(GEPI->getNumOperands() >= 3 && isa<ConstantUInt>(GEPI->getOperand(2)) + assert(GEPI->getNumOperands() >= 3 && isa<ConstantInt>(GEPI->getOperand(2)) + && GEPI->getOperand(2)->getType()->isUnsigned() && "Unexpected GEPI!"); // Load the pointer for this field. - unsigned FieldNo = cast<ConstantUInt>(GEPI->getOperand(2))->getValue(); + unsigned FieldNo = cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue(); if (InsertedLoadsForPtr.size() <= FieldNo) InsertedLoadsForPtr.resize(FieldNo+1); if (InsertedLoadsForPtr[FieldNo] == 0) @@ -1088,7 +1088,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, // Restrict this transformation to only working on small allocations // (2048 bytes currently), as we don't want to introduce a 16M global or // something. - if (NElements->getRawValue()* + if (NElements->getZExtValue()* TD.getTypeSize(MI->getAllocatedType()) < 2048) { GVI = OptimizeGlobalAddressOfMalloc(GV, MI); return true; @@ -1431,7 +1431,7 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) { // Init priority must be standard. ConstantInt *CI = dyn_cast<ConstantInt>(CS->getOperand(0)); - if (!CI || CI->getRawValue() != 65535) + if (!CI || CI->getZExtValue() != 65535) return 0; } else { return 0; @@ -1461,7 +1461,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, const std::vector<Function*> &Ctors) { // If we made a change, reassemble the initializer list. std::vector<Constant*> CSVals; - CSVals.push_back(ConstantSInt::get(Type::IntTy, 65535)); + CSVals.push_back(ConstantInt::get(Type::IntTy, 65535)); CSVals.push_back(0); // Create the new init list. @@ -1474,7 +1474,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, std::vector<const Type*>(), false); const PointerType *PFTy = PointerType::get(FTy); CSVals[1] = Constant::getNullValue(PFTy); - CSVals[0] = ConstantSInt::get(Type::IntTy, 2147483647); + CSVals[0] = ConstantInt::get(Type::IntTy, 2147483647); } CAList.push_back(ConstantStruct::get(CSVals)); } @@ -1575,10 +1575,9 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val, } // Replace the element that we are supposed to. - ConstantUInt *CU = cast<ConstantUInt>(Addr->getOperand(OpNo)); - assert(CU->getValue() < STy->getNumElements() && - "Struct index out of range!"); - unsigned Idx = (unsigned)CU->getValue(); + ConstantInt *CU = cast<ConstantInt>(Addr->getOperand(OpNo)); + unsigned Idx = CU->getZExtValue(); + assert(Idx < STy->getNumElements() && "Struct index out of range!"); Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1); // Return the modified struct. @@ -1603,9 +1602,9 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val, " ConstantFoldLoadThroughGEPConstantExpr"); } - assert((uint64_t)CI->getRawValue() < ATy->getNumElements()); - Elts[(uint64_t)CI->getRawValue()] = - EvaluateStoreInto(Elts[(uint64_t)CI->getRawValue()], Val, Addr, OpNo+1); + assert(CI->getZExtValue() < ATy->getNumElements()); + Elts[CI->getZExtValue()] = + EvaluateStoreInto(Elts[CI->getZExtValue()], Val, Addr, OpNo+1); return ConstantArray::get(ATy, Elts); } } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 8018553e4f..cd46718ba6 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -378,7 +378,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) CastInst* BufPtr = new CastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); new CallInst(AddSJToMap, make_vector<Value*>(GetSetJmpMap(Func), BufPtr, - ConstantUInt::get(Type::UIntTy, + ConstantInt::get(Type::UIntTy, SetJmpIDMap[Func]++), 0), "", Inst); @@ -429,7 +429,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) // Add the case for this setjmp's number... SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func)); - SVP.first->addCase(ConstantUInt::get(Type::UIntTy, SetJmpIDMap[Func] - 1), + SVP.first->addCase(ConstantInt::get(Type::UIntTy, SetJmpIDMap[Func] - 1), SetJmpContBlock); // Value coming from the handling of the exception. diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 9f9c52788b..23f3352ced 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -517,8 +517,8 @@ public: std::vector<Value*> vals; vals.push_back(gep); // destination vals.push_back(ci->getOperand(2)); // source - vals.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); // length - vals.push_back(ConstantUInt::get(Type::UIntTy,1)); // alignment + vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length + vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment new CallInst(SLC.get_memcpy(), vals, "", ci); // Finally, substitute the first operand of the strcat call for the @@ -556,38 +556,38 @@ public: // Check that the first argument to strchr is a constant array of sbyte. // If it is, get the length and data, otherwise return false. uint64_t len = 0; - ConstantArray* CA; + ConstantArray* CA = 0; if (!getConstantStringLength(ci->getOperand(1),len,&CA)) return false; - // Check that the second argument to strchr is a constant int, return false - // if it isn't - ConstantSInt* CSI = dyn_cast<ConstantSInt>(ci->getOperand(2)); - if (!CSI) { - // Just lower this to memchr since we know the length of the string as - // it is constant. + // Check that the second argument to strchr is a constant int. If it isn't + // a constant signed integer, we can try an alternate optimization + ConstantInt* CSI = dyn_cast<ConstantInt>(ci->getOperand(2)); + if (!CSI || CSI->getType()->isUnsigned() ) { + // The second operand is not constant, or not signed. Just lower this to + // memchr since we know the length of the string since it is constant. Function* f = SLC.get_memchr(); std::vector<Value*> args; args.push_back(ci->getOperand(1)); args.push_back(ci->getOperand(2)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); ci->replaceAllUsesWith( new CallInst(f,args,ci->getName(),ci)); ci->eraseFromParent(); return true; } // Get the character we're looking for - int64_t chr = CSI->getValue(); + int64_t chr = CSI->getSExtValue(); // Compute the offset uint64_t offset = 0; bool char_found = false; for (uint64_t i = 0; i < len; ++i) { - if (ConstantSInt* CI = dyn_cast<ConstantSInt>(CA->getOperand(i))) { + if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) { // Check for the null terminator if (CI->isNullValue()) break; // we found end of string - else if (CI->getValue() == chr) { + else if (CI->getSExtValue() == chr) { char_found = true; offset = i; break; @@ -599,7 +599,7 @@ public: // (if c is a constant integer and s is a constant string) if (char_found) { std::vector<Value*> indices; - indices.push_back(ConstantUInt::get(Type::ULongTy,offset)); + indices.push_back(ConstantInt::get(Type::ULongTy,offset)); GetElementPtrInst* GEP = new GetElementPtrInst(ci->getOperand(1),indices, ci->getOperand(1)->getName()+".strchr",ci); ci->replaceAllUsesWith(GEP); @@ -679,7 +679,7 @@ public: std::string str1 = A1->getAsString(); std::string str2 = A2->getAsString(); int result = strcmp(str1.c_str(), str2.c_str()); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,result)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result)); ci->eraseFromParent(); return true; } @@ -723,7 +723,7 @@ public: bool len_arg_is_const = false; if (ConstantInt* len_CI = dyn_cast<ConstantInt>(ci->getOperand(3))) { len_arg_is_const = true; - len_arg = len_CI->getRawValue(); + len_arg = len_CI->getZExtValue(); if (len_arg == 0) { // strncmp(x,y,0) -> 0 ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0)); @@ -769,7 +769,7 @@ public: std::string str1 = A1->getAsString(); std::string str2 = A2->getAsString(); int result = strncmp(str1.c_str(), str2.c_str(), len_arg); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,result)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result)); ci->eraseFromParent(); return true; } @@ -843,8 +843,8 @@ public: std::vector<Value*> vals; vals.push_back(dest); // destination vals.push_back(src); // source - vals.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); // length - vals.push_back(ConstantUInt::get(Type::UIntTy,1)); // alignment + vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length + vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment new CallInst(SLC.get_memcpy(), vals, "", ci); // Finally, substitute the first operand of the strcat call for the @@ -891,7 +891,7 @@ struct StrLenOptimization : public LibCallOptimization { if (ConstantInt* CI = dyn_cast<ConstantInt>(bop->getOperand(1))) { // Get the value the strlen result is compared to - uint64_t val = CI->getRawValue(); + uint64_t val = CI->getZExtValue(); // If its compared against length 0 with == or != if (val == 0 && @@ -902,7 +902,7 @@ struct StrLenOptimization : public LibCallOptimization { // strlen(x) == 0 -> *x == 0 LoadInst* load = new LoadInst(str,str->getName()+".first",ci); BinaryOperator* rbop = BinaryOperator::create(bop->getOpcode(), - load, ConstantSInt::get(Type::SByteTy,0), + load, ConstantInt::get(Type::SByteTy,0), bop->getName()+".strlen", ci); bop->replaceAllUsesWith(rbop); bop->eraseFromParent(); @@ -919,9 +919,9 @@ struct StrLenOptimization : public LibCallOptimization { // strlen("xyz") -> 3 (for example) const Type *Ty = SLC.getTargetData()->getIntPtrType(); if (Ty->isSigned()) - ci->replaceAllUsesWith(ConstantSInt::get(Ty, len)); + ci->replaceAllUsesWith(ConstantInt::get(Ty, len)); else - ci->replaceAllUsesWith(ConstantUInt::get(Ty, len)); + ci->replaceAllUsesWith(ConstantInt::get(Ty, len)); ci->eraseFromParent(); return true; @@ -985,7 +985,7 @@ struct memcmpOptimization : public LibCallOptimization { // Make sure we have a constant length. ConstantInt *LenC = dyn_cast<ConstantInt>(CI->getOperand(3)); if (!LenC) return false; - uint64_t Len = LenC->getRawValue(); + uint64_t Len = LenC->getZExtValue(); // If the length is zero, this returns 0. switch (Len) { @@ -1075,8 +1075,8 @@ struct LLVMMemCpyMoveOptzn : public LibCallOptimization { return false; // If the length is larger than the alignment, we can't optimize - uint64_t len = LEN->getRawValue(); - uint64_t alignment = ALIGN->getRawValue(); + uint64_t len = LEN->getZExtValue(); + uint64_t alignment = ALIGN->getZExtValue(); if (alignment == 0) alignment = 1; // Alignment 0 is identity for alignment 1 if (len > alignment) @@ -1154,8 +1154,8 @@ struct LLVMMemSetOptimization : public LibCallOptimization { return false; // Extract the length and alignment - uint64_t len = LEN->getRawValue(); - uint64_t alignment = ALIGN->getRawValue(); + uint64_t len = LEN->getZExtValue(); + uint64_t alignment = ALIGN->getZExtValue(); // Alignment 0 is identity for alignment 1 if (alignment == 0) @@ -1174,7 +1174,7 @@ struct LLVMMemSetOptimization : public LibCallOptimization { // Make sure we have a constant ubyte to work with so we can extract // the value to be filled. - ConstantUInt* FILL = dyn_cast<ConstantUInt>(ci->getOperand(2)); + ConstantInt* FILL = dyn_cast<ConstantInt>(ci->getOperand(2)); if (!FILL) return false; if (FILL->getType() != Type::UByteTy) @@ -1183,7 +1183,7 @@ struct LLVMMemSetOptimization : public LibCallOptimization { // memset(s,c,n) -> store s, c (for n=1,2,4,8) // Extract the fill character - uint64_t fill_char = FILL->getValue(); + uint64_t fill_char = FILL->getZExtValue(); uint64_t fill_value = fill_char; // Get the type we will cast to, based on size of memory area to fill, and @@ -1215,7 +1215,7 @@ struct LLVMMemSetOptimization : public LibCallOptimization { // Cast dest to the right sized primitive and then load/store CastInst* DestCast = new CastInst(dest,PointerType::get(castType),dest->getName()+".cast",ci); - new StoreInst(ConstantUInt::get(castType,fill_value),DestCast, ci); + new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci); ci->eraseFromParent(); return true; } @@ -1325,16 +1325,16 @@ public: // The first character has to be a % if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0))) - if (CI->getRawValue() != '%') + if (CI->getZExtValue() != '%') return false; // Get the second character and switch on its value ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1)); - switch (CI->getRawValue()) { + switch (CI->getZExtValue()) { case 's': { if (len != 3 || - dyn_cast<ConstantInt>(CA->getOperand(2))->getRawValue() != '\n') + dyn_cast<ConstantInt>(CA->getOperand(2))->getZExtValue() != '\n') return false; // printf("%s\n",str) -> puts(str) @@ -1344,7 +1344,7 @@ public: std::vector<Value*> args; args.push_back(CastToCStr(ci->getOperand(2), *ci)); new CallInst(puts_func,args,ci->getName(),ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len)); break; } case 'c': @@ -1359,7 +1359,7 @@ public: CastInst* cast = new CastInst(ci->getOperand(2), Type::IntTy, CI->getName()+".int", ci); new CallInst(putchar_func, cast, "", ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy, 1)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy, 1)); break; } default: @@ -1409,7 +1409,7 @@ public: for (unsigned i = 0; i < len; ++i) { if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) { // Check for the null terminator - if (CI->getRawValue() == '%') + if (CI->getZExtValue() == '%') return false; // we found end of string } else { return false; @@ -1430,11 +1430,11 @@ public: std::vector<Value*> args; args.push_back(ci->getOperand(2)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),1)); args.push_back(ci->getOperand(1)); new CallInst(fwrite_func,args,ci->getName(),ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len)); ci->eraseFromParent(); return true; } @@ -1446,12 +1446,12 @@ public: // The first character has to be a % if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0))) - if (CI->getRawValue() != '%') + if (CI->getZExtValue() != '%') return false; // Get the second character and switch on its value ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1)); - switch (CI->getRawValue()) { + switch (CI->getZExtValue()) { case 's': { uint64_t len = 0; @@ -1464,11 +1464,11 @@ public: return false; std::vector<Value*> args; args.push_back(CastToCStr(ci->getOperand(3), *ci)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),1)); args.push_back(ci->getOperand(1)); new CallInst(fwrite_func,args,ci->getName(),ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len)); } else { // fprintf(file,"%s",str) -> fputs(str,file) const Type* FILEptr_type = ci->getOperand(1)->getType(); @@ -1479,7 +1479,7 @@ public: args.push_back(CastToCStr(ci->getOperand(3), *ci)); args.push_back(ci->getOperand(1)); new CallInst(fputs_func,args,ci->getName(),ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len)); } break; } @@ -1493,7 +1493,7 @@ public: CastInst* cast = new CastInst(ci->getOperand(3), Type::IntTy, CI->getName()+".int", ci); new CallInst(fputc_func,cast,ci->getOperand(1),"",ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1)); break; } default: @@ -1537,7 +1537,7 @@ public: if (len == 0) { // If the length is 0, we just need to store a null byte new StoreInst(ConstantInt::get(Type::SByteTy,0),ci->getOperand(1),ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,0)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0)); ci->eraseFromParent(); return true; } @@ -1546,7 +1546,7 @@ public: for (unsigned i = 0; i < len; ++i) { if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) { // Check for the null terminator - if (CI->getRawValue() == '%') + if (CI->getZExtValue() == '%') return false; // we found a %, can't optimize } else { return false; // initializer is not constant int, can't optimize @@ -1563,10 +1563,10 @@ public: std::vector<Value*> args; args.push_back(ci->getOperand(1)); args.push_back(ci->getOperand(2)); - args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); - args.push_back(ConstantUInt::get(Type::UIntTy,1)); + args.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); + args.push_back(ConstantInt::get(Type::UIntTy,1)); new CallInst(memcpy_func,args,"",ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len)); ci->eraseFromParent(); return true; } @@ -1578,12 +1578,12 @@ public: // The first character has to be a % if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0))) - if (CI->getRawValue() != '%') + if (CI->getZExtValue() != '%') return false; // Get the second character and switch on its value ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1)); - switch (CI->getRawValue()) { + switch (CI->getZExtValue()) { case 's': { // sprintf(dest,"%s",str) -> llvm.memcpy(dest, str, strlen(str)+1, 1) Function* strlen_func = SLC.get_strlen(); @@ -1602,7 +1602,7 @@ public: args.push_back(CastToCStr(ci->getOperand(1), *ci)); args.push_back(CastToCStr(ci->getOperand(3), *ci)); args.push_back(Len1); - args.push_back(ConstantUInt::get(Type::UIntTy,1)); + args.push_back(ConstantInt::get(Type::UIntTy,1)); new CallInst(memcpy_func, args, "", ci); // The strlen result is the unincremented number of bytes in the string. @@ -1619,10 +1619,10 @@ public: CastInst* cast = new CastInst(ci->getOperand(3),Type::SByteTy,"char",ci); new StoreInst(cast, ci->getOperand(1), ci); GetElementPtrInst* gep = new GetElementPtrInst(ci->getOperand(1), - ConstantUInt::get(Type::UIntTy,1),ci->getOperand(1)->getName()+".end", + ConstantInt::get(Type::UIntTy,1),ci->getOperand(1)->getName()+".end", ci); new StoreInst(ConstantInt::get(Type::SByteTy,0),gep,ci); - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1)); ci->eraseFromParent(); return true; } @@ -1686,8 +1686,8 @@ public: return false; std::vector<Value*> parms; parms.push_back(ci->getOperand(1)); - parms.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); - parms.push_back(ConstantUInt::get(SLC.getIntPtrType(),1)); + parms.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); + parms.push_back(ConstantInt::get(SLC.getIntPtrType(),1)); parms.push_back(ci->getOperand(2)); new CallInst(fwrite_func,parms,"",ci); break; @@ -1716,11 +1716,11 @@ public: virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &SLC) { if (ConstantInt* CI = dyn_cast<ConstantInt>(ci->getOperand(1))) { // isdigit(c) -> 0 or 1, if 'c' is constant - uint64_t val = CI->getRawValue(); + uint64_t val = CI->getZExtValue(); if (val >= '0' && val <='9') - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1)); else - ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,0)); + ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0)); ci->eraseFromParent(); return true; } @@ -1730,10 +1730,10 @@ public: new CastInst(ci->getOperand(1),Type::UIntTy, ci->getOperand(1)->getName()+".uint",ci); BinaryOperator* sub_inst = BinaryOperator::createSub(cast, - ConstantUInt::get(Type::UIntTy,0x30), + ConstantInt::get(Type::UIntTy,0x30), ci->getOperand(1)->getName()+".sub",ci); SetCondInst* setcond_inst = new SetCondInst(Instruction::SetLE,sub_inst, - ConstantUInt::get(Type::UIntTy,9), + ConstantInt::get(Type::UIntTy,9), ci->getOperand(1)->getName()+".cmp",ci); CastInst* c2 = new CastInst(setcond_inst,Type::IntTy, @@ -1760,7 +1760,7 @@ public: Value *V = CI->getOperand(1); if (V->getType()->isSigned()) V = new CastInst(V, V->getType()->getUnsignedVersion(), V->getName(), CI); - Value *Cmp = BinaryOperator::createSetLT(V, ConstantUInt::get(V->getType(), + Value *Cmp = BinaryOperator::createSetLT(V, ConstantInt::get(V->getType(), 128), V->getName()+".isascii", CI); if (Cmp->getType() != CI->getType()) @@ -1828,7 +1828,7 @@ public: // ffs(cnst) -> bit# // ffsl(cnst) -> bit# // ffsll(cnst) -> bit# - uint64_t val = CI->getRawValue(); + uint64_t val = CI->getZExtValue(); int result = 0; if (val) { ++result; @@ -1837,7 +1837,7 @@ public: val >>= 1; } } - TheCall->replaceAllUsesWith(ConstantSInt::get(Type::IntTy, result)); + TheCall->replaceAllUsesWith(ConstantInt::get(Type::IntTy, result)); TheCall->eraseFromParent(); return true; } @@ -1861,7 +1861,7 @@ public: Value *V = new CastInst(TheCall->getOperand(1), ArgType, "tmp", TheCall); Value *V2 = new CallInst(F, V, "tmp", TheCall); V2 = new CastInst(V2, Type::IntTy, "tmp", TheCall); - V2 = BinaryOperator::createAdd(V2, ConstantSInt::get(Type::IntTy, 1), + V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::IntTy, 1), "tmp", TheCall); Value *Cond = BinaryOperator::createSetEQ(V, Constant::getNullValue(V->getType()), @@ -2048,7 +2048,7 @@ bool getConstantStringLength(Value *V, uint64_t &len, ConstantArray **CA) { // value. We'll need this later for indexing the ConstantArray. uint64_t start_idx = 0; if (ConstantInt* CI = dyn_cast<ConstantInt>(GEP->getOperand(2))) - start_idx = CI->getRawValue(); + start_idx = CI->getZExtValue(); else return false; diff --git a/lib/Transforms/Instrumentation/EmitFunctions.cpp b/lib/Transforms/Instrumentation/EmitFunctions.cpp index 05c3419e29..b4523257af 100644 --- a/lib/Transforms/Instrumentation/EmitFunctions.cpp +++ b/lib/Transforms/Instrumentation/EmitFunctions.cpp @@ -110,7 +110,7 @@ bool EmitFunctionTable::runOnModule(Module &M){ M.getGlobalList().push_back(funcArray); - ConstantInt *cnst = ConstantSInt::get(Type::IntTy, counter); + ConstantInt *cnst = ConstantInt::get(Type::IntTy, counter); GlobalVariable *fnCount = new GlobalVariable(Type::IntTy, true, GlobalValue::ExternalLinkage, cnst, "llvmFunctionCount"); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 82e7ae7ba1..4c31793f42 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -51,7 +51,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, // pass null. Args[2] = ConstantPointerNull::get(UIntPtr); } - Args[3] = ConstantUInt::get(Type::UIntTy, NumElements); + Args[3] = ConstantInt::get(Type::UIntTy, NumElements); Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos); @@ -96,7 +96,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, // Create the getelementptr constant expression std::vector<Constant*> Indices(2); Indices[0] = Constant::getNullValue(Type::IntTy); - Indices[1] = ConstantSInt::get(Type::IntTy, CounterNum); + Indices[1] = ConstantInt::get(Type::IntTy, CounterNum); Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices); // Load, increment and store the value back. diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index 54a9ef7003..5d6654d504 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -188,10 +188,10 @@ static void getBackEdges(Function& F, T& BackEdges); GlobalRandomCounter::GlobalRandomCounter(Module& M, const Type* t, uint64_t resetval) : T(t) { + ConstantInt* Init = ConstantInt::get(T, resetval); + ResetValue = Init; Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, - ConstantUInt::get(T, resetval), - "RandomSteeringCounter", &M); - ResetValue = ConstantUInt::get(T, resetval); + Init, "RandomSteeringCounter", &M); } GlobalRandomCounter::~GlobalRandomCounter() {} @@ -205,7 +205,7 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { LoadInst* l = new LoadInst(Counter, "counter", t); SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, - ConstantUInt::get(T, 0), + ConstantInt::get(T, 0), "countercc", t); Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1), "counternew", t); @@ -225,10 +225,10 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const Type* t, uint64_t resetval) : AI(0), T(t) { + ConstantInt* Init = ConstantInt::get(T, resetval); + ResetValue = Init; Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, - ConstantUInt::get(T, resetval), - "RandomSteeringCounter", &M); - ResetValue = ConstantUInt::get(T, resetval); + Init, "RandomSteeringCounter", &M); } GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {} @@ -278,7 +278,7 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { LoadInst* l = new LoadInst(AI, "counter", t); SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, - ConstantUInt::get(T, 0), + ConstantInt::get(T, 0), "countercc", t); Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1), "counternew", t); @@ -309,11 +309,11 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { CallInst* c = new CallInst(F, "rdcc", t); BinaryOperator* b = - BinaryOperator::createAnd(c, ConstantUInt::get(Type::ULongTy, rm), + BinaryOperator::createAnd(c, ConstantInt::get(Type::ULongTy, rm), "mrdcc", t); SetCondInst* s = new SetCondInst(Instruction::SetEQ, b, - ConstantUInt::get(Type::ULongTy, 0), + ConstantInt::get(Type::ULongTy, 0), "mrdccc", t); t->setCondition(s); } @@ -339,7 +339,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu // Create the getelementptr constant expression std::vector<Constant*> Indices(2); Indices[0] = Constant::getNullValue(Type::IntTy); - Indices[1] = ConstantSInt::get(Type::IntTy, CounterNum); + Indices[1] = ConstantInt::get(Type::IntTy, CounterNum); Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices); // Load, increment and store the value back. diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp index d3af056ffc..8bf6001053 100644 --- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp +++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp @@ -49,7 +49,7 @@ static void InsertInstrumentationCall (BasicBlock *BB, Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy, Type::UIntTy, (Type *)0); std::vector<Value*> Args (1); - Args[0] = ConstantUInt::get (Type::UIntTy, BBNumber); + Args[0] = ConstantInt::get (Type::UIntTy, BBNumber); // Insert the call after any alloca or PHI instructions... BasicBlock::iterator InsertPos = BB->begin(); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 4a7edbafed..c30c0c924f 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -142,7 +142,7 @@ namespace { Instruction *FoldGEPSetCC(User *GEPLHS, Value *RHS, Instruction::BinaryOps Cond, Instruction &I); Instruction *visitShiftInst(ShiftInst &I); - Instruction *FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, + Instruction *FoldShiftByConstant(Value *Op0, ConstantInt *Op1, ShiftInst &I); Instruction *visitCastInst(CastInst &CI); Instruction *FoldSelectOpOp(SelectInst &SI, Instruction *TI, @@ -576,14 +576,14 @@ static ConstantInt *SubOne(ConstantInt *C) { /// GetConstantInType - Return a ConstantInt with the specified type and value. /// static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) { - if (Ty->isUnsigned()) - return ConstantUInt::get(Ty, Val); + if (Ty->isUnsigned()) + return ConstantInt::get(Ty, Val); else if (Ty->getTypeID() == Type::BoolTyID) return ConstantBool::get(Val); int64_t SVal = Val; SVal <<= 64-Ty->getPrimitiveSizeInBits(); SVal >>= 64-Ty->getPrimitiveSizeInBits(); - return ConstantSInt::get(Ty, SVal); + return ConstantInt::get(Ty, SVal); } @@ -712,40 +712,42 @@ static void ComputeMaskedBits(Value *V, uint64_t Mask, uint64_t &KnownZero, } case Instruction::Shl: // (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0 - if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) { - Mask >>= SA->getValue(); + if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) { + uint64_t ShiftAmt = SA->getZExtValue(); + Mask >>= ShiftAmt; ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero <<= SA->getValue(); - KnownOne <<= SA->getValue(); - KnownZero |= (1ULL << SA->getValue())-1; // low bits known zero. + KnownZero <<= ShiftAmt; + KnownOne <<= ShiftAmt; + KnownZero |= (1ULL << ShiftAmt)-1; // low bits known zero. return; } break; case Instruction::Shr: // (ushr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0 - if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) { + if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) { // Compute the new bits that are at the top now. - uint64_t HighBits = (1ULL << SA->getValue())-1; - HighBits <<= I->getType()->getPrimitiveSizeInBits()-SA->getValue(); + uint64_t ShiftAmt = SA->getZExtValue(); + uint64_t HighBits = (1ULL << ShiftAmt)-1; + HighBits <<= I->getType()->getPrimitiveSizeInBits()-ShiftAmt; if (I->getType()->isUnsigned()) { // Unsigned shift right. - Mask <<= SA->getValue(); + Mask <<= ShiftAmt; ComputeMaskedBits(I->getOperand(0), Mask, KnownZero,KnownOne,Depth+1); assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); - KnownZero >>= SA->getValue(); - KnownOne >>= SA->getValue(); + KnownZero >>= ShiftAmt; + KnownOne >>= ShiftAmt; KnownZero |= HighBits; // high bits known zero. } else { - Mask <<= SA->getValue(); + Mask <<= ShiftAmt; ComputeMaskedBits(I->getOperand(0), Mask, KnownZero,KnownOne,Depth+1); assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); - KnownZero >>= SA->getValue(); - KnownOne >>= SA->getValue(); + KnownZero >>= ShiftAmt; + KnownOne >>= ShiftAmt; // Handle the sign bits. uint64_t SignBit = 1ULL << (I->getType()->getPrimitiveSizeInBits()-1); - SignBit >>= SA->getValue(); // Adjust to where it is now in the mask. + SignBit >>= ShiftAmt; // Adjust to where it is now in the mask. if (KnownZero & SignBit) { // New bits are known zero. KnownZero |= HighBits; @@ -1100,14 +1102,15 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask, break; } case Instruction::Shl: - if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) { - if (SimplifyDemandedBits(I->getOperand(0), DemandedMask >> SA->getValue(), + if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) { + uint64_t ShiftAmt = SA->getZExtValue(); + if (SimplifyDemandedBits(I->getOperand(0), DemandedMask >> ShiftAmt, KnownZero, KnownOne, Depth+1)) return true; assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero <<= SA->getValue(); - KnownOne <<= SA->getValue(); - KnownZero |= (1ULL << SA->getValue())-1; // low bits known zero. + KnownZero <<= ShiftAmt; + KnownOne <<= ShiftAmt; + KnownZero |= (1ULL << ShiftAmt) - 1; // low bits known zero. } break; case Instruction::Shr: @@ -1131,38 +1134,38 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask, return UpdateValueUsesWith(I, NewVal); } - if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) { - unsigned ShAmt = SA->getValue(); + if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) { + unsigned ShiftAmt = SA->getZExtValue(); // Compute the new bits that are at the top now. - uint64_t HighBits = (1ULL << ShAmt)-1; - HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShAmt; + uint64_t HighBits = (1ULL << ShiftAmt)-1; + HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt; uint64_t TypeMask = I->getType()->getIntegralTypeMask(); if (I->getType()->isUnsigned()) { // Unsigned shift right. if (SimplifyDemandedBits(I->getOperand(0), - (DemandedMask << ShAmt) & TypeMask, + (DemandedMask << ShiftAmt) & TypeMask, KnownZero, KnownOne, Depth+1)) return true; assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); KnownZero &= TypeMask; KnownOne &= TypeMask; - KnownZero >>= ShAmt; - KnownOne >>= ShAmt; + KnownZero >>= ShiftAmt; + KnownOne >>= ShiftAmt; KnownZero |= HighBits; // high bits known zero. } else { // Signed shift right. if (SimplifyDemandedBits(I->getOperand(0), - (DemandedMask << ShAmt) & TypeMask, + (DemandedMask << ShiftAmt) & TypeMask, KnownZero, KnownOne, Depth+1)) return true; assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); KnownZero &= TypeMask; KnownOne &= TypeMask; - KnownZero >>= SA->getValue(); - KnownOne >>= SA->getValue(); + KnownZero >>= ShiftAmt; + KnownOne >>= ShiftAmt; // Handle the sign bits. uint64_t SignBit = 1ULL << (I->getType()->getPrimitiveSizeInBits()-1); - SignBit >>= SA->getValue(); // Adjust to where it is now in the mask. + SignBit >>= ShiftAmt; // Adjust to where it is now in the mask. // If the input sign bit is known to be zero, or if none of the top bits // are demanded, turn this into an unsigned shift right. @@ -1277,7 +1280,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts, case Instruction::InsertElement: { // If this is a variable index, we don't know which element it overwrites. // demand exactly the same input as we produce. - ConstantUInt *Idx = dyn_cast<ConstantUInt>(I->getOperand(2)); + ConstantInt *Idx = dyn_cast<ConstantInt>(I->getOperand(2)); if (Idx == 0) { // Note that we can't propagate undef elt info, because we don't know // which elt is getting updated. @@ -1289,7 +1292,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts, // If this is inserting an element that isn't demanded, remove this // insertelement. - unsigned IdxNo = Idx->getValue(); + unsigned IdxNo = Idx->getZExtValue(); if (IdxNo >= VWidth || (DemandedElts & (1ULL << IdxNo)) == 0) return AddSoonDeadInstToWorklist(*I, 0); @@ -1795,14 +1798,14 @@ FoundSExt: if (Anded == CRHS) { // See if all bits from the first bit set in the Add RHS up are included // in the mask. First, get the rightmost bit. - uint64_t AddRHSV = CRHS->getRawValue(); + uint64_t AddRHSV = CRHS->getZExtValue(); // Form a mask of all bits from the lowest bit added through the top. uint64_t AddRHSHighBits = ~((AddRHSV & -AddRHSV)-1); AddRHSHighBits &= C2->getType()->getIntegralTypeMask(); // See if the and mask includes all of these bits. - uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getRawValue(); + uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getZExtValue(); if (AddRHSHighBits == AddRHSHighBitsAnd) { // Okay, the xform is safe. Insert the new add pronto. @@ -1845,7 +1848,7 @@ FoundSExt: // highest order bit set. static bool isSignBit(ConstantInt *CI) { unsigned NumBits = CI->getType()->getPrimitiveSizeInBits(); - return (CI->getRawValue() & (~0ULL >> (64-NumBits))) == (1ULL << (NumBits-1)); + return (CI->getZExtValue() & (~0ULL >> (64-NumBits))) == (1ULL << (NumBits-1)); } /// RemoveNoopCast - Strip off nonconverting casts from the value. @@ -1894,14 +1897,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { Value *NoopCastedRHS = RemoveNoopCast(Op1); if (ShiftInst *SI = dyn_cast<ShiftInst>(NoopCastedRHS)) if (SI->getOpcode() == Instruction::Shr) - if (ConstantUInt *CU = dyn_cast<ConstantUInt>(SI->getOperand(1))) { + if (ConstantInt *CU = dyn_cast<ConstantInt>(SI->getOperand(1))) { const Type *NewTy; if (SI->getType()->isSigned()) NewTy = SI->getType()->getUnsignedVersion(); else NewTy = SI->getType()->getSignedVersion(); // Check to see if we are shifting out everything but the sign bit. - if (CU->getValue() == SI->getType()->getPrimitiveSizeInBits()-1) { + if (CU->getZExtValue() == + SI->getType()->getPrimitiveSizeInBits()-1) { // Ok, the transformation is safe. Insert a cast of the incoming // value, then the new shift, then the new cast. Instruction *FirstCast = new CastInst(SI->getOperand(0), NewTy, @@ -1972,8 +1976,8 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { // 0 - (X sdiv C) -> (X sdiv -C) if (Op1I->getOpcode() == Instruction::Div) - if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0)) - if (CSI->isNullValue()) + if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0)) + if (CSI->getType()->isSigned() && CSI->isNullValue()) if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1))) return BinaryOperator::createDiv(Op1I->getOperand(0), ConstantExpr::getNeg(DivRHS)); @@ -2022,14 +2026,14 @@ static bool isSignBitCheck(unsigned Opcode, Value *LHS, ConstantInt *RHS) { return Opcode == Instruction::SetLT && RHS->isNullValue() || Opcode == Instruction::SetLE && RHS->isAllOnesValue(); } else { - ConstantUInt *RHSC = cast<ConstantUInt>(RHS); + ConstantInt *RHSC = cast<ConstantInt>(RHS); // True if source is LHS > 127 or LHS >= 128, where the constants depend on // the size of the integer type. if (Opcode == Instruction::SetGE) - return RHSC->getValue() == + return RHSC->getZExtValue() == 1ULL << (RHS->getType()->getPrimitiveSizeInBits()-1); if (Opcode == Instruction::SetGT) - return RHSC->getValue() == + return RHSC->getZExtValue() == (1ULL << (RHS->getType()->getPrimitiveSizeInBits()-1))-1; } return false; @@ -2060,11 +2064,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (CI->isAllOnesValue()) // X * -1 == 0 - X return BinaryOperator::createNeg(Op0, I.getName()); - int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue(); + int64_t Val = (int64_t)cast<ConstantInt>(CI)->getZExtValue(); if (isPowerOf2_64(Val)) { // Replace X*(2^C) with X << C uint64_t C = Log2_64(Val); return new ShiftInst(Instruction::Shl, Op0, - ConstantUInt::get(Type::UByteTy, C)); + ConstantInt::get(Type::UByteTy, C)); } } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) { if (Op1F->isNullValue()) @@ -2125,7 +2129,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (isa<ConstantInt>(SCIOp1) && isSignBitCheck(SCI->getOpcode(), SCIOp0, cast<ConstantInt>(SCIOp1))) { // Shift the X value right to turn it into "all signbits". - Constant *Amt = ConstantUInt::get(Type::UByteTy, + Constant *Amt = ConstantInt::get(Type::UByteTy, SCOpTy->getPrimitiveSizeInBits()-1); if (SCIOp0->getType()->isUnsigned()) { const Type *NewTy = SCIOp0->getType()->getSignedVersion(); @@ -2179,13 +2183,14 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) { // Check to see if this is an unsigned division with an exact power of 2, // if so, convert to a right shift. - if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS)) - if (uint64_t Val = C->getValue()) // Don't break X / 0 - if (isPowerOf2_64(Val)) { - uint64_t C = Log2_64(Val); - return new ShiftInst(Instruction::Shr, Op0, - ConstantUInt::get(Type::UByteTy, C)); - } + if (ConstantInt *C = dyn_cast<ConstantInt>(RHS)) + if (C->getType()->isUnsigned()) + if (uint64_t Val = C->getZExtValue()) // Don't break X / 0 + if (isPowerOf2_64(Val)) { + uint64_t C = Log2_64(Val); + return new ShiftInst(Instruction::Shr, Op0, + ConstantInt::get(Type::UByteTy, C)); + } // -X/C -> X/-C if (RHS->getType()->isSigned()) @@ -2235,24 +2240,25 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) { // If this is 'udiv X, (Cond ? C1, C2)' where C1&C2 are powers of two, // transform this into: '(Cond ? (udiv X, C1) : (udiv X, C2))'. - if (ConstantUInt *STO = dyn_cast<ConstantUInt>(SI->getOperand(1))) - if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) { - // STO == 0 and SFO == 0 handled above. - uint64_t TVA = STO->getValue(), FVA = SFO->getValue(); - if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) { - unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA); - Constant *TC = ConstantUInt::get(Type::UByteTy, TSA); - Instruction *TSI = new ShiftInst(Instruction::Shr, Op0, - TC, SI->getName()+".t"); - TSI = InsertNewInstBefore(TSI, I); - - Constant *FC = ConstantUInt::get(Type::UByteTy, FSA); - Instruction *FSI = new ShiftInst(Instruction::Shr, Op0, - FC, SI->getName()+".f"); - FSI = InsertNewInstBefore(FSI, I); - return new SelectInst(SI->getOperand(0), TSI, FSI); + if (ConstantInt *STO = dyn_cast<ConstantInt>(SI->getOperand(1))) + if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2))) + if (STO->getType()->isUnsigned() && SFO->getType()->isUnsigned()) { + // STO == 0 and SFO == 0 handled above. + uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue(); + if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) { + unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA); + Constant *TC = ConstantInt::get(Type::UByteTy, TSA); + Instruction *TSI = new ShiftInst(Instruction::Shr, Op0, + TC, SI->getName()+".t"); + TSI = InsertNewInstBefore(TSI, I); + + Constant *FC = ConstantInt::get(Type::UByteTy, FSA); + Instruction *FSI = new ShiftInst(Instruction::Shr, Op0, + FC, SI->getName()+".f"); + FSI = InsertNewInstBefore(FSI, I); + return new SelectInst(SI->getOperand(0), TSI, FSI); + } } - } } // 0 / X == 0, we don't need to preserve faults! @@ -2282,13 +2288,14 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) { if (Instruction *RHSI = dyn_cast<Instruction>(I.getOperand(1))) { // Turn A / (C1 << N), where C1 is "1<<C2" into A >> (N+C2) [udiv only]. if (RHSI->getOpcode() == Instruction::Shl && - isa<ConstantUInt>(RHSI->getOperand(0))) { - unsigned C1 = cast<ConstantUInt>(RHSI->getOperand(0))->getRawValue(); + isa<ConstantInt>(RHSI->getOperand(0)) && + RHSI->getOperand(0)->getType()->isUnsigned()) { + uint64_t C1 = cast<ConstantInt>(RHSI->getOperand(0))->getZExtValue(); if (isPowerOf2_64(C1)) { - unsigned C2 = Log2_64(C1); + uint64_t C2 = Log2_64(C1); Value *Add = RHSI->getOperand(1); if (C2) { - Constant *C2V = ConstantUInt::get(Add->getType(), C2); + Constant *C2V = ConstantInt::get(Add->getType(), C2); Add = InsertNewInstBefore(BinaryOperator::createAdd(Add, C2V, "tmp"), I); } @@ -2330,7 +2337,7 @@ static Constant *GetFactor(Value *V) { unsigned Zeros = CountTrailingZeros_64(RHS->getZExtValue()); if (Zeros != V->getType()->getPrimitiveSizeInBits()) return ConstantExpr::getShl(Result, - ConstantUInt::get(Type::UByteTy, Zeros)); + ConstantInt::get(Type::UByteTy, Zeros)); } } else if (I->getOpcode() == Instruction::Cast) { Value *Op = I->getOperand(0); @@ -2356,8 +2363,8 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { if (I.getType()->isSigned()) { if (Value *RHSNeg = dyn_castNegVal(Op1)) - if (!isa<ConstantSInt>(RHSNeg) || - cast<ConstantSInt>(RHSNeg)->getValue() > 0) { + if (!isa<ConstantInt>(RHSNeg) || !RHSNeg->getType()->isSigned() || + cast<ConstantInt>(RHSNeg)->getSExtValue() > 0) { // X % -Y -> X % Y AddUsesToWorkList(I); I.setOperand(1, RHSNeg); @@ -2392,9 +2399,10 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { // Check to see if this is an unsigned remainder with an exact power of 2, // if so, convert to a bitwise and. - if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS)) - if (isPowerOf2_64(C->getValue())) - return BinaryOperator::createAnd(Op0, SubOne(C)); + if (ConstantInt *C = dyn_cast<ConstantInt>(RHS)) + if (RHS->getType()->isUnsigned()) + if (isPowerOf2_64(C->getZExtValue())) + return BinaryOperator::createAnd(Op0, SubOne(C)); if (Instruction *Op0I = dyn_cast<Instruction>(Op0)) { if (SelectInst *SI = dyn_cast<SelectInst>(Op0I)) { @@ -2415,8 +2423,9 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { // Turn A % (C << N), where C is 2^k, into A & ((C << N)-1) [urem only]. if (I.getType()->isUnsigned() && RHSI->getOpcode() == Instruction::Shl && - isa<ConstantUInt>(RHSI->getOperand(0))) { - unsigned C1 = cast<ConstantUInt>(RHSI->getOperand(0))->getRawValue(); + isa<ConstantInt>(RHSI->getOperand(0)) && + RHSI->getOperand(0)->getType()->isUnsigned()) { + unsigned C1 = cast<ConstantInt>(RHSI->getOperand(0))->getZExtValue(); if (isPowerOf2_64(C1)) { Constant *N1 = ConstantInt::getAllOnesValue(I.getType()); Value *Add = InsertNewInstBefore(BinaryOperator::createAdd(RHSI, N1, @@ -2458,18 +2467,21 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { } - if (ConstantUInt *STO = dyn_cast<ConstantUInt>(SI->getOperand(1))) - if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) { - // STO == 0 and SFO == 0 handled above. - - if (isPowerOf2_64(STO->getValue()) && isPowerOf2_64(SFO->getValue())){ - Value *TrueAnd = InsertNewInstBefore(BinaryOperator::createAnd(Op0, - SubOne(STO), SI->getName()+".t"), I); - Value *FalseAnd = InsertNewInstBefore(BinaryOperator::createAnd(Op0, - SubOne(SFO), SI->getName()+".f"), I); - return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd); + if (ConstantInt *STO = dyn_cast<ConstantInt>(SI->getOperand(1))) + if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2))) + if (STO->getType()->isUnsigned() && SFO->getType()->isUnsigned()) { + // STO == 0 and SFO == 0 handled above. + if (isPowerOf2_64(STO->getZExtValue()) && + isPowerOf2_64(SFO->getZExtValue())) { + Value *TrueAnd = InsertNewInstBefore( + BinaryOperator::createAnd(Op0, SubOne(STO), SI->getName()+".t"), + I); + Value *FalseAnd = InsertNewInstBefore( + BinaryOperator::createAnd(Op0, SubOne(SFO), SI->getName()+".f"), + I); + return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd); + } } - } } } @@ -2478,46 +2490,42 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { // isMaxValueMinusOne - return true if this is Max-1 static bool isMaxValueMinusOne(const ConstantInt *C) { - if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(C)) - return CU->getValue() == C->getType()->getIntegralTypeMask()-1; - - const ConstantSInt *CS = cast<ConstantSInt>(C); + if (C->getType()->isUnsigned()) + return C->getZExtValue() == C->getType()->getIntegralTypeMask()-1; // Calculate 0111111111..11111 unsigned TypeBits = C->getType()->getPrimitiveSizeInBits(); int64_t Val = INT64_MAX; // All ones Val >>= 64-TypeBits; // Shift out unwanted 1 bits... - return CS->getValue() == Val-1; + return C->getSExtValue() == Val-1; } // isMinValuePlusOne - return true if this is Min+1 static bool isMinValuePlusOne(const ConstantInt *C) { - if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(C)) - return CU->getValue() == 1; - - const ConstantSInt *CS = cast<ConstantSInt>(C); + if (C->getType()->isUnsigned()) + return C->getZExtValue() == 1; // Calculate 1111111111000000000000 unsigned TypeBits = C->getType()->getPrimitiveSizeInBits(); int64_t Val = -1; // All ones Val <<= TypeBits-1; // Shift over to the right spot - return CS->getValue() == Val+1; + return C->getSExtValue() == Val+1; } // isOneBitSet - Return true if there is exactly one bit set in the specified // constant. static bool isOneBitSet(const ConstantInt *CI) { - uint64_t V = CI->getRawValue(); + uint64_t V = CI->getZExtValue(); return V && (V & (V-1)) == 0; } #if 0 // Currently unused // isLowOnes - Return true if the constant is of the form 0+1+. static bool isLowOnes(const ConstantInt *CI) { - uint64_t V = CI->getRawValue(); + uint64_t V = CI->getZExtValue(); // There won't be bits set in parts that the type doesn't contain. - V &= ConstantInt::getAllOnesValue(CI->getType())->getRawValue(); + V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue(); uint64_t U = V+1; // If it is low ones, this should be a power of two. return U && V && (U & V) == 0; @@ -2527,11 +2535,11 @@ static bool isLowOnes(const ConstantInt *CI) { // isHighOnes - Return true if the constant is of the form 1+0+. // This is the same as lowones(~X). static bool isHighOnes(const ConstantInt *CI) { - uint64_t V = ~CI->getRawValue(); + uint64_t V = ~CI->getZExtValue(); if (~V == 0) return false; // 0's does not match "1+" // There won't be bits set in parts that the type doesn't contain. - V &= ConstantInt::getAllOnesValue(CI->getType())->getRawValue(); + V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue(); uint64_t U = V+1; // If it is low ones, this should be a power of two. return U && V && (U & V) == 0; @@ -2656,7 +2664,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // Adding a one to a single bit bit-field should be turned into an XOR // of the bit. First thing to check is to see if this AND is with a // single bit constant. - uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getRawValue(); + uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getZExtValue(); // Clear bits that are not part of the constant. AndRHSV &= AndRHS->getType()->getIntegralTypeMask(); @@ -2666,7 +2674,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // Ok, at this point, we know that we are masking the result of the // ADD down to exactly one bit. If the constant we are adding has // no bits set below this bit, then we can eliminate the ADD. - uint64_t AddRHS = cast<ConstantInt>(OpRHS)->getRawValue(); + uint64_t AddRHS = cast<ConstantInt>(OpRHS)->getZExtValue(); // Check to see if any bits below the one bit set in AndRHSV are set. if ((AddRHS & (AndRHSV-1)) == 0) { @@ -2780,7 +2788,9 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, return new SetCondInst(Instruction::SetEQ, V, V); Hi = SubOne(cast<ConstantInt>(Hi)); - if (cast<ConstantIntegral>(Lo)->isMinValue()) // V < 0 || V >= Hi ->'V > Hi-1' + + // V < 0 || V >= Hi ->'V > Hi-1' + if (cast<ConstantIntegral>(Lo)->isMinValue()) return new SetCondInst(Instruction::SetGT, V, Hi); // Emit X-Lo > Hi-Lo-1 @@ -2800,7 +2810,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is // not, since all 1s are not contiguous. static bool isRunOfOnes(ConstantIntegral *Val, unsigned &MB, unsigned &ME) { - uint64_t V = Val->getRawValue(); + uint64_t V = Val->getZExtValue(); if (!isShiftedMask_64(V)) return false; // look for the first zero bit after the run of ones @@ -2836,7 +2846,7 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS, case Instruction::And: if (ConstantExpr::getAnd(N, Mask) == Mask) { // If the AndRHS is a power of two minus one (0+1+), this is simple. - if ((Mask->getRawValue() & Mask->getRawValue()+1) == 0) + if ((Mask->getZExtValue() & Mask->getZExtValue()+1) == 0) break; // Otherwise, if Mask is 0+1+0+, and if B is known to have the low 0+ @@ -2854,7 +2864,7 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS, case Instruction::Or: case Instruction::Xor: // If the AndRHS is a power of two minus one (0+1+), and N&Mask == 0 - if ((Mask->getRawValue() & Mask->getRawValue()+1) == 0 && + if ((Mask->getZExtValue() & Mask->getZExtValue()+1) == 0 && ConstantExpr::getAnd(N, Mask)->isNullValue()) break; return 0; @@ -3168,7 +3178,7 @@ static bool CollectBSwapParts(Value *V, std::vector<Value*> &ByteValues) { // defines a byte. We only handle unsigned types here. if (isa<ShiftInst>(I) && isa<ConstantInt>(I->getOperand(1))) { // Not shifting the entire input by N-1 bytes? - if (cast<ConstantInt>(I->getOperand(1))->getRawValue() != + if (cast<ConstantInt>(I->getOperand(1))->getZExtValue() != 8*(ByteValues.size()-1)) return true; @@ -3199,19 +3209,19 @@ static bool CollectBSwapParts(Value *V, std::vector<Value*> &ByteValues) { Instruction *SI = cast<Instruction>(Shift); // Make sure that the shift amount is by a multiple of 8 and isn't too big. - if (ShiftAmt->getRawValue() & 7 || - ShiftAmt->getRawValue() > 8*ByteValues.size()) + if (ShiftAmt->getZExtValue() & 7 || + ShiftAmt->getZExtValue() > 8*ByteValues.size()) return true; // Turn 0xFF -> 0, 0xFF00 -> 1, 0xFF0000 -> 2, etc. unsigned DestByte; for (DestByte = 0; DestByte != ByteValues.size(); ++DestByte) - if (AndAmt->getRawValue() == uint64_t(0xFF) << 8*DestByte) + if (AndAmt->getZExtValue() == uint64_t(0xFF) << 8*DestByte) break; // Unknown mask for bswap. if (DestByte == ByteValues.size()) return true; - unsigned ShiftBytes = ShiftAmt->getRawValue()/8; + unsigned ShiftBytes = ShiftAmt->getZExtValue()/8; unsigned SrcByte; if (SI->getOpcode() == Instruction::Shl) SrcByte = DestByte - ShiftBytes; @@ -3372,7 +3382,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // replace with V+N. if (C1 == ConstantExpr::getNot(C2)) { Value *V1 = 0, *V2 = 0; - if ((C2->getRawValue() & (C2->getRawValue()+1)) == 0 && // C2 == 0+1+ + if ((C2->getZExtValue() & (C2->getZExtValue()+1)) == 0 && // C2 == 0+1+ match(A, m_Add(m_Value(V1), m_Value(V2)))) { // Add commutes, try both ways. if (V1 == B && MaskedValueIsZero(V2, C2->getZExtValue())) @@ -3381,7 +3391,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { return ReplaceInstUsesWith(I, A); } // Or commutes, try both ways. - if ((C1->getRawValue() & (C1->getRawValue()+1)) == 0 && + if ((C1->getZExtValue() & (C1->getZExtValue()+1)) == 0 && match(B, m_Add(m_Value(V1), m_Value(V2)))) { // Add commutes, try both ways. if (V1 == A && MaskedValueIsZero(V2, C1->getZExtValue())) @@ -3716,7 +3726,7 @@ static bool MulWithOverflow(ConstantInt *&Result, ConstantInt *In1, } static bool isPositive(ConstantInt *C) { - return cast<ConstantSInt>(C)->getValue() >= 0; + return C->getSExtValue() >= 0; } /// AddWithOverflow - Compute Result = In1+In2, returning true if the result @@ -3726,15 +3736,15 @@ static bool AddWithOverflow(ConstantInt *&Result, ConstantInt *In1, Result = cast<ConstantInt>(ConstantExpr::getAdd(In1, In2)); if (In1->getType()->isUnsigned()) - return cast<ConstantUInt>(Result)->getValue() < - cast<ConstantUInt>(In1)->getValue(); + return cast<ConstantInt>(Result)->getZExtValue() < + cast<ConstantInt>(In1)->getZExtValue(); if (isPositive(In1) != isPositive(In2)) return false; if (isPositive(In1)) - return cast<ConstantSInt>(Result)->getValue() < - cast<ConstantSInt>(In1)->getValue(); - return cast<ConstantSInt>(Result)->getValue() > - cast<ConstantSInt>(In1)->getValue(); + return cast<ConstantInt>(Result)->getSExtValue() < + cast<ConstantInt>(In1)->getSExtValue(); + return cast<ConstantInt>(Result)->getSExtValue() > + cast<ConstantInt>(In1)->getSExtValue(); } /// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the @@ -3753,7 +3763,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i, ++GTI) { Value *Op = GEP->getOperand(i); uint64_t Size = TD.getTypeSize(GTI.getIndexedType()) & PtrSizeMask; - Constant *Scale = ConstantExpr::getCast(ConstantUInt::get(UIntPtrTy, Size), + Constant *Scale = ConstantExpr::getCast(ConstantInt::get(UIntPtrTy, Size), SIntPtrTy); if (Constant *OpC = dyn_cast<Constant>(Op)) { if (!OpC->isNullValue()) { @@ -4139,14 +4149,14 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { ConstantInt *NewCST; ConstantInt *NewCI; if (Cast->getOperand(0)->getType()->isSigned()) { - NewCST = ConstantSInt::get(Cast->getOperand(0)->getType(), + NewCST = ConstantInt::get(Cast->getOperand(0)->getType(), AndCST->getZExtValue()); - NewCI = ConstantSInt::get(Cast->getOperand(0)->getType(), + NewCI = ConstantInt::get(Cast->getOperand(0)->getType(), CI->getZExtValue()); } else { - NewCST = ConstantUInt::get(Cast->getOperand(0)->getType(), + NewCST = ConstantInt::get(Cast->getOperand(0)->getType(), AndCST->getZExtValue()); - NewCI = ConstantUInt::get(Cast->getOperand(0)->getType(), + NewCI = ConstantInt::get(Cast->getOperand(0)->getType(), CI->getZExtValue()); } Instruction *NewAnd = @@ -4172,8 +4182,8 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { Shift = dyn_cast<ShiftInst>(CI->getOperand(0)); } - ConstantUInt *ShAmt; - ShAmt = Shift ? dyn_cast<ConstantUInt>(Shift->getOperand(1)) : 0; + ConstantInt *ShAmt; + ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0; const Type *Ty = Shift ? Shift->getType() : 0; // Type of the shift. const Type *AndTy = AndCST->getType(); // Type of the and. @@ -4185,10 +4195,10 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { if (!CanFold) { // To test for the bad case of the signed shr, see if any // of the bits shifted in could be tested after the mask. - int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getValue(); + int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getZExtValue(); if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift. - Constant *OShAmt = ConstantUInt::get(Type::UByteTy, ShAmtVal); + Constant *OShAmt = ConstantInt::get(Type::UByteTy, ShAmtVal); Constant *ShVal = ConstantExpr::getShl(ConstantInt::getAllOnesValue(AndTy), OShAmt); @@ -4277,14 +4287,14 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { break; case Instruction::Shl: // (setcc (shl X, ShAmt), CI) - if (ConstantUInt *ShAmt = dyn_cast<ConstantUInt>(LHSI->getOperand(1))) { + if (ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1))) { if (I.isEquality()) { unsigned TypeBits = CI->getType()->getPrimitiveSizeInBits(); // Check that the shift amount is in range. If not, don't perform // undefined shifts. When the shift is visited it will be // simplified. - if (ShAmt->getValue() >= TypeBits) + if (ShAmt->getZExtValue() >= TypeBits) break; // If we are comparing against bits always shifted out, the @@ -4299,14 +4309,14 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { if (LHSI->hasOneUse()) { // Otherwise strength reduce the shift into an and. - unsigned ShAmtVal = (unsigned)ShAmt->getValue(); + unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue(); uint64_t Val = (1ULL << (TypeBits-ShAmtVal))-1; Constant *Mask; if (CI->getType()->isUnsigned()) { - Mask = ConstantUInt::get(CI->getType(), Val); + Mask = ConstantInt::get(CI->getType(), Val); } else if (ShAmtVal != 0) { - Mask = ConstantSInt::get(CI->getType(), Val); + Mask = ConstantInt::get(CI->getType(), Val); } else { Mask = ConstantInt::getAllOnesValue(CI->getType()); } @@ -4323,13 +4333,13 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { break; case Instruction::Shr: // (setcc (shr X, ShAmt), CI) - if (ConstantUInt *ShAmt = dyn_cast<ConstantUInt>(LHSI->getOperand(1))) { + if (ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1))) { if (I.isEquality()) { // Check that the shift amount is in range. If not, don't perform // undefined shifts. When the shift is visited it will be // simplified. unsigned TypeBits = CI->getType()->getPrimitiveSizeInBits(); - if (ShAmt->getValue() >= TypeBits) + if (ShAmt->getZExtValue() >= TypeBits) break; // If we are comparing against bits always shifted out, the @@ -4344,7 +4354,7 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { } if (LHSI->hasOneUse() || CI->isNullValue()) { - unsigned ShAmtVal = (unsigned)ShAmt->getValue(); + unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue(); // Otherwise strength reduce the shift into an and. uint64_t Val = ~0ULL; // All ones. @@ -4353,9 +4363,9 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { Constant *Mask; if (CI->getType()->isUnsigned()) { Val &= ~0ULL >> (64-TypeBits); - Mask = ConstantUInt::get(CI->getType(), Val); + Mask = ConstantInt::get(CI->getType(), Val); } else { - Mask = ConstantSInt::get(CI->getType(), Val); + Mask = ConstantInt::get(CI->getType(), Val); } Instruction *AndI = @@ -4466,22 +4476,40 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { if (I.isEquality()) { bool isSetNE = I.getOpcode() == Instruction::SetNE; - // If the first operand is (and|or|xor) with a constant, and the second - // operand is a constant, simplify a bit. + // If the first operand is (add|sub|and|or|xor|rem) with a constant, and + // the second operand is a constant, simplify a bit. if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) { switch (BO->getOpcode()) { +#if 0 + case Instruction::SRem: + // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one. + if (CI->isNullValue() && isa<ConstantInt>(BO->getOperand(1)) && + BO->hasOneUse()) { + int64_t V = cast<ConstantInt>(BO->getOperand(1))->getSExtValue(); + if (V > 1 && isPowerOf2_64(V)) { + Value *NewRem = InsertNewInstBefore( + BinaryOperator::createURem(BO->getOperand(0), + BO->getOperand(1), + BO->getName()), I); + return BinaryOperator::create( + I.getOpcode(), NewRem, + Constant::getNullValue(NewRem->getType())); + } + } + break; +#endif + case Instruction::Rem: // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one. - if (CI->isNullValue() && isa<ConstantSInt>(BO->getOperand(1)) && - BO->hasOneUse() && - cast<ConstantSInt>(BO->getOperand(1))->getValue() > 1) { - int64_t V = cast<ConstantSInt>(BO->getOperand(1))->getValue(); - if (isPowerOf2_64(V)) { + if (CI->isNullValue() && isa<ConstantInt>(BO->getOperand(1)) && + BO->hasOneUse() && BO->getOperand(1)->getType()->isSigned()) { + int64_t V = cast<ConstantInt>(BO->getOperand(1))->getSExtValue(); + if (V > 1 && isPowerOf2_64(V)) { unsigned L2 = Log2_64(V); const Type *UTy = BO->getType()->getUnsignedVersion(); Value *NewX = InsertNewInstBefore(new CastInst(BO->getOperand(0), UTy, "tmp"), I); - Constant *RHSCst = ConstantUInt::get(UTy, 1ULL << L2); + Constant *RHSCst = ConstantInt::get(UTy, 1ULL << L2); Value *NewRem =InsertNewInstBefore(BinaryOperator::createRem(NewX, RHSCst, BO->getName()), I); return BinaryOperator::create(I.getOpcode(), NewRem, @@ -4489,7 +4517,6 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { } } break; - case Instruction::Add: // Replace ((add A, B) != C) with (A != C-B) if B & C are constants. if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) { @@ -4602,21 +4629,21 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { if (I.getOpcode() == Instruction::SetLT && CI->isNullValue()) // X < 0 => x > 127 return BinaryOperator::createSetGT(CastOp, - ConstantUInt::get(SrcTy, (1ULL << (SrcTySize-1))-1)); + ConstantInt::get(SrcTy, (1ULL << (SrcTySize-1))-1)); else if (I.getOpcode() == Instruction::SetGT && - cast<ConstantSInt>(CI)->getValue() == -1) + cast<ConstantInt>(CI)->getSExtValue() == -1) // X > -1 => x < 128 return BinaryOperator::createSetLT(CastOp, - ConstantUInt::get(SrcTy, 1ULL << (SrcTySize-1))); + ConstantInt::get(SrcTy, 1ULL << (SrcTySize-1))); } else { - ConstantUInt *CUI = cast<ConstantUInt>(CI); + ConstantInt *CUI = cast<ConstantInt>(CI); if (I.getOpcode() == Instruction::SetLT && - CUI->getValue() == 1ULL << (SrcTySize-1)) + CUI->getZExtValue() == 1ULL << (SrcTySize-1)) // X < 128 => X > -1 return BinaryOperator::createSetGT(CastOp, - ConstantSInt::get(SrcTy, -1)); + ConstantInt::get(SrcTy, -1)); else if (I.getOpcode() == Instruction::SetGT && - CUI->getValue() == (1ULL << (SrcTySize-1))-1) + CUI->getZExtValue() == (1ULL << (SrcTySize-1))-1) // X > 127 => X < 0 return BinaryOperator::createSetLT(CastOp, Constant::getNullValue(SrcTy)); @@ -4815,13 +4842,13 @@ Instruction *InstCombiner::visitSetCondInstWithCastAndCast(SetCondInst &SCI) { // We're performing a signed comparison. if (isSignSrc) { // Signed extend and signed comparison. - if (cast<ConstantSInt>(CI)->getValue() < 0) // X < (small) --> false + if (cast<ConstantInt>(CI)->getSExtValue() < 0)// X < (small) --> false Result = ConstantBool::getFalse(); else - Result = ConstantBool::getTrue(); // X < (large) --> true + Result = ConstantBool::getTrue(); // X < (large) --> true } else { // Unsigned extend and signed comparison. - if (cast<ConstantSInt>(CI)->getValue() < 0) + if (cast<ConstantInt>(CI)->getSExtValue() < 0) Result = ConstantBool::getFalse(); else Result = ConstantBool::getTrue(); @@ -4885,7 +4912,7 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) { // shr int -1, X = -1 (for any arithmetic shift rights of ~0) if (!isLeftShift) - if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0)) + if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0)) if (CSI->isAllOnesValue()) return ReplaceInstUsesWith(I, CSI); @@ -4906,13 +4933,14 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) { } } - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(Op1)) - if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I)) - return Res; + if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op1)) + if (CUI->getType()->isUnsigned()) + if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I)) + return Res; return 0; } -Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, +Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, ShiftInst &I) { bool isLeftShift = I.getOpcode() == Instruction::Shl; bool isSignedShift = Op0->getType()->isSigned(); @@ -4929,11 +4957,11 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, // of a signed value. // unsigned TypeBits = Op0->getType()->getPrimitiveSizeInBits(); - if (Op1->getValue() >= TypeBits) { + if (Op1->getZExtValue() >= TypeBits) { if (isUnsignedShift || isLeftShift) return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType())); else { - I.setOperand(1, ConstantUInt::get(Type::UByteTy, TypeBits-1)); + I.setOperand(1, ConstantInt::get(Type::UByteTy, TypeBits-1)); return &I; } } @@ -5069,7 +5097,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, // operation. // if (isValid && !isLeftShift && isSignedShift) { - uint64_t Val = Op0C->getRawValue(); + uint64_t Val = Op0C->getZExtValue(); isValid = ((Val & (1 << (TypeBits-1))) != 0) == highBitSet; } @@ -5103,7 +5131,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, } } - if (ShiftOp && isa<ConstantUInt>(ShiftOp->getOperand(1))) { + if (ShiftOp && isa<ConstantInt>(ShiftOp->getOperand(1))) { // Find the operands and properties of the input shift. Note that the // signedness of the input shift may differ from the current shift if there // is a noop cast between the two. @@ -5111,10 +5139,10 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, bool isShiftOfSignedShift = ShiftOp->getType()->isSigned(); bool isShiftOfUnsignedShift = !isShiftOfSignedShift; - ConstantUInt *ShiftAmt1C = cast<ConstantUInt>(ShiftOp->getOperand(1)); + ConstantInt *ShiftAmt1C = cast<ConstantInt>(ShiftOp->getOperand(1)); - unsigned ShiftAmt1 = (unsigned)ShiftAmt1C->getValue(); - unsigned ShiftAmt2 = (unsigned)Op1->getValue(); + unsigned ShiftAmt1 = (unsigned)ShiftAmt1C->getZExtValue(); + unsigned ShiftAmt2 = (unsigned)Op1->getZExtValue(); // Check for (A << c1) << c2 and (A >> c1) >> c2. if (isLeftShift == isShiftOfLeftShift) { @@ -5132,7 +5160,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, if (isShiftOfSignedShift != isSignedShift) Op = InsertNewInstBefore(new CastInst(Op, I.getType(), "tmp"), I); return new ShiftInst(I.getOpcode(), Op, - ConstantUInt::get(Type::UByteTy, Amt)); + ConstantInt::get(Type::UByteTy, Amt)); } // Check for (A << c1) >> c2 or (A >> c1) << c2. If we are dealing with @@ -5159,7 +5187,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, return ReplaceInstUsesWith(I, Mask); // (A << c) >> c === A & c2 } else if (ShiftAmt1 < ShiftAmt2) { return new ShiftInst(I.getOpcode(), Mask, - ConstantUInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1)); + ConstantInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1)); } else if (isShiftOfUnsignedShift || isShiftOfLeftShift) { if (isShiftOfUnsignedShift && !isShiftOfLeftShift && isSignedShift) { // Make sure to emit an unsigned shift right, not a signed one. @@ -5167,12 +5195,12 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, Mask->getType()->getUnsignedVersion(), Op->getName()), I); Mask = new ShiftInst(Instruction::Shr, Mask, - ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); + ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); InsertNewInstBefore(Mask, I); return new CastInst(Mask, I.getType()); } else { return new ShiftInst(ShiftOp->getOpcode(), Mask, - ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); + ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); } } else { // (X >>s C1) << C2 where C1 > C2 === (X >>s (C1-C2)) & mask @@ -5181,7 +5209,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, Mask->getName()), I); Instruction *Shift = new ShiftInst(ShiftOp->getOpcode(), Op, - ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); + ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2)); InsertNewInstBefore(Shift, I); C = ConstantIntegral::getAllOnesValue(Shift->getType()); @@ -5221,33 +5249,37 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1, static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale, unsigned &Offset) { assert(Val->getType() == Type::UIntTy && "Unexpected allocation size type!"); - if (ConstantUInt *CI = dyn_cast<ConstantUInt>(Val)) { - Offset = CI->getValue(); - Scale = 1; - return ConstantUInt::get(Type::UIntTy, 0); + if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) { + if (CI->getType()->isUnsigned()) { + Offset = CI->getZExtValue(); + Scale = 1; + return ConstantInt::get(Type::UIntTy, 0); + } } else if (Instruction *I = dyn_cast<Instruction>(Val)) { if (I->getNumOperands() == 2) { - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(I->getOperand(1))) { - if (I->getOpcode() == Instruction::Shl) { - // This is a value scaled by '1 << the shift amt'. - Scale = 1U << CUI->getValue(); - Offset = 0; - return I->getOperand(0); - } else if (I->getOpcode() == Instruction::Mul) { - // This value is scaled by 'CUI'. - Scale = CUI->getValue(); - Offset = 0; - return I->getOperand(0); - } else if (I->getOpcode() == Instruction::Add) { - // We have X+C. Check to see if we really have (X*C2)+C1, where C1 is - // divisible by C2. - unsigned SubScale; - Value *SubVal = DecomposeSimpleLinearExpr(I->getOperand(0), SubScale, - Offset); - Offset += CUI->getValue(); - if (SubScale > 1 && (Offset % SubScale == 0)) { - Scale = SubScale; - return SubVal; + if (ConstantInt *CUI = dyn_cast<ConstantInt>(I->getOperand(1))) { + if (CUI->getType()->isUnsigned()) { + if (I->getOpcode() == Instruction::Shl) { + // This is a value scaled by '1 << the shift amt'. + Scale = 1U << CUI->getZExtValue(); + Offset = 0; + return I->getOperand(0); + } else if (I->getOpcode() == Instruction::Mul) { + // This value is scaled by 'CUI'. + Scale = CUI->getZExtValue(); + Offset = 0; + return I->getOperand(0); + } else if (I->getOpcode() == Instruction::Add) { + // We have X+C. Check to see if we really have (X*C2)+C1, + // where C1 is divisible by C2. + unsigned SubScale; + Value *SubVal = + DecomposeSimpleLinearExpr(I->getOperand(0), SubScale, Offset); + Offset += CUI->getZExtValue(); + if (SubScale > 1 && (Offset % SubScale == 0)) { + Scale = SubScale; + return SubVal; + } } } } @@ -5321,9 +5353,12 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI, if (Scale == 1) { Amt = NumElements; } else { - Amt = ConstantUInt::get(Type::UIntTy, Scale); - if (ConstantUInt *CI = dyn_cast<ConstantUInt>(NumElements)) - Amt = ConstantExpr::getMul(CI, cast<ConstantUInt>(Amt)); + // If the allocation size is constant, form a constant mul expression + Amt = ConstantInt::get(Type::UIntTy, Scale); + if (isa<ConstantInt>(NumElements) && NumElements->getType()->isUnsigned()) + Amt = ConstantExpr::getMul( + cast<ConstantInt>(NumElements), cast<ConstantInt>(Amt)); + // otherwise multiply the amount and the number of elements else if (Scale != 1) { Instruction *Tmp = BinaryOperator::createMul(Amt, NumElements, "tmp"); Amt = InsertNewInstBefore(Tmp, AI); @@ -5331,7 +5366,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI, } if (unsigned Offset = (AllocElTySize*ArrayOffset)/CastElTySize) { - Value *Off = ConstantUInt::get(Type::UIntTy, Offset); + Value *Off = ConstantInt::get(Type::UIntTy, Offset); Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp"); Amt = InsertNewInstBefore(Tmp, AI); } @@ -5467,7 +5502,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) { assert(CSrc->getType() != Type::ULongTy && "Cannot have type bigger than ulong!"); uint64_t AndValue = CSrc->getType()->getIntegralTypeMask(); - Constant *AndOp = ConstantUInt::get(A->getType()->getUnsignedVersion(), + Constant *AndOp = ConstantInt::get(A->getType()->getUnsignedVersion(), AndValue); AndOp = ConstantExpr::getCast(AndOp, A->getType()); Instruction *And = BinaryOperator::createAnd(CSrc->getOperand(0), AndOp); @@ -5595,7 +5630,8 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) { unsigned SrcBitSize = Src->getType()->getPrimitiveSizeInBits(); unsigned DestBitSize = CI.getType()->getPrimitiveSizeInBits(); assert(SrcBitSize < DestBitSize && "Not a zext?"); - Constant *C = ConstantUInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1); + Constant *C = + ConstantInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1); C = ConstantExpr::getCast(C, CI.getType()); return BinaryOperator::createAnd(Res, C); } @@ -5660,7 +5696,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) { // simplifications. if (DestBitSize < SrcBitSize && Src->getType()->isSigned() && isa<ConstantInt>(Op1)) { - unsigned ShiftAmt = cast<ConstantUInt>(Op1)->getValue(); + unsigned ShiftAmt = cast<ConstantInt>(Op1)->getZExtValue(); if (SrcBitSize > ShiftAmt && SrcBitSize-ShiftAmt >= DestBitSize) { // Convert to unsigned. Value *N1 = InsertOperandCastBefore(Op0, @@ -5941,9 +5977,9 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (ConstantInt *TrueValC = dyn_cast<ConstantInt>(TrueVal)) if (ConstantInt *FalseValC = dyn_cast<ConstantInt>(FalseVal)) { // select C, 1, 0 -> cast C to int - if (FalseValC->isNullValue() && TrueValC->getRawValue() == 1) { + if (FalseValC->isNullValue() && TrueValC->getZExtValue() == 1) { return new CastInst(CondVal, SI.getType()); - } else if (TrueValC->isNullValue() && FalseValC->getRawValue() == 1) { + } else if (TrueValC->isNullValue() && FalseValC->getZExtValue() == 1) { // select C, 0, 1 -> cast !C to int Value *NotCond = InsertNewInstBefore(BinaryOperator::createNot(CondVal, @@ -5963,7 +5999,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { IC->getOpcode() == Instruction::SetLT; else { unsigned Bits = CmpCst->getType()->getPrimitiveSizeInBits(); - CanXForm = (CmpCst->getRawValue() == ~0ULL >> (64-Bits+1)) && + CanXForm = (CmpCst->getZExtValue() == ~0ULL >> (64-Bits+1)) && IC->getOpcode() == Instruction::SetGT; } @@ -5978,7 +6014,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { // Now that X is signed, we have to make the all ones value. Do // this by inserting a new SRA. unsigned Bits = X->getType()->getPrimitiveSizeInBits(); - Constant *ShAmt = ConstantUInt::get(Type::UByteTy, Bits-1); + Constant *ShAmt = ConstantInt::get(Type::UByteTy, Bits-1); Instruction *SRA = new ShiftInst(Instruction::Shr, X, ShAmt, "ones"); InsertNewInstBefore(SRA, SI); @@ -6245,7 +6281,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (NumBytes->isNullValue()) return EraseInstFromFunction(CI); if (ConstantInt *CI = dyn_cast<ConstantInt>(NumBytes)) - if (CI->getRawValue() == 1) { + if (CI->getZExtValue() == 1) { // Replace the instruction with just byte operations. We would // transform other cases to loads/stores, but we don't know if // alignment is sufficient. @@ -6278,14 +6314,14 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { unsigned Alignment1 = GetKnownAlignment(MI->getOperand(1), TD); unsigned Alignment2 = GetKnownAlignment(MI->getOperand(2), TD); unsigned Align = std::min(Alignment1, Alignment2); - if (MI->getAlignment()->getRawValue() < Align) { - MI->setAlignment(ConstantUInt::get(Type::UIntTy, Align)); + if (MI->getAlignment()->getZExtValue() < Align) { + MI->setAlignment(ConstantInt::get(Type::UIntTy, Align)); Changed = true; } } else if (isa<MemSetInst>(MI)) { unsigned Alignment = GetKnownAlignment(MI->getDest(), TD); - if (MI->getAlignment()->getRawValue() < Alignment) { - MI->setAlignment(ConstantUInt::get(Type::UIntTy, Alignment)); + if (MI->getAlignment()->getZExtValue() < Alignment) { + MI->setAlignment(ConstantInt::get(Type::UIntTy, Alignment)); Changed = true; } } @@ -6368,7 +6404,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { for (unsigned i = 0; i != 16; ++i) { if (isa<UndefValue>(Mask->getOperand(i))) continue; - unsigned Idx =cast<ConstantInt>(Mask->getOperand(i))->getRawValue(); + unsigned Idx =cast<ConstantInt>(Mask->getOperand(i))->getZExtValue(); Idx &= 31; // Match the hardware behavior. if (ExtractedElts[Idx] == 0) { @@ -6542,14 +6578,14 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { for (unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) { const Type *ParamTy = FT->getParamType(i); const Type *ActTy = (*AI)->getType(); - ConstantSInt* c = dyn_cast<ConstantSInt>(*AI); + ConstantInt* c = dyn_cast<ConstantInt>(*AI); //Either we can cast directly, or we can upconvert the argument bool isConvertible = ActTy->isLosslesslyConvertibleTo(ParamTy) || (ParamTy->isIntegral() && ActTy->isIntegral() && ParamTy->isSigned() == ActTy->isSigned() && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) || (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() && - c->getValue() > 0); + c->getSExtValue() > 0); if (Callee->isExternal() && !isConvertible) return false; } @@ -6874,11 +6910,12 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { // If this is a constant idx, make sure to canonicalize it to be a signed // operand, otherwise CSE and other optimizations are pessimized. - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(Op)) { - GEP.setOperand(i, ConstantExpr::getCast(CUI, - CUI->getType()->getSignedVersion())); - MadeChange = true; - } + if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op)) + if (CUI->getType()->isUnsigned()) { + GEP.setOperand(i, + ConstantExpr::getCast(CUI, CUI->getType()->getSignedVersion())); + MadeChange = true; + } } if (MadeChange) return &GEP; @@ -7049,11 +7086,12 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { } else if (Instruction *Inst =dyn_cast<Instruction>(GEP.getOperand(1))){ if (Inst->getOpcode() == Instruction::Shl && isa<ConstantInt>(Inst->getOperand(1))) { - unsigned ShAmt =cast<ConstantUInt>(Inst->getOperand(1))->getValue(); + unsigned ShAmt = + cast<ConstantInt>(Inst->getOperand(1))->getZExtValue(); if (Inst->getType()->isSigned()) - Scale = ConstantSInt::get(Inst->getType(), 1ULL << ShAmt); + Scale = ConstantInt::get(Inst->getType(), 1ULL << ShAmt); else - Scale = ConstantUInt::get(Inst->getType(), 1ULL << ShAmt); + Scale = ConstantInt::get(Inst->getType(), 1ULL << ShAmt); NewIdx = Inst->getOperand(0); } else if (Inst->getOpcode() == Instruction::Mul && isa<ConstantInt>(Inst->getOperand(1))) { @@ -7064,15 +7102,11 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { // If the index will be to exactly the right offset with the scale taken // out, perform the transformation. - if (Scale && Scale->getRawValue() % ArrayEltSize == 0) { - if (ConstantSInt *C = dyn_cast<ConstantSInt>(Scale)) - Scale = ConstantSInt::get(C->getType(), - (int64_t)C->getRawValue() / - (int64_t)ArrayEltSize); - else - Scale = ConstantUInt::get(Scale->getType(), - Scale->getRawValue() / ArrayEltSize); - if (Scale->getRawValue() != 1) { + if (Scale && Scale->getZExtValue() % ArrayEltSize == 0) { + if (ConstantInt *C = dyn_cast<ConstantInt>(Scale)) + Scale = ConstantInt::get(Scale->getType(), + Scale->getZExtValue() / ArrayEltSize); + if (Scale->getZExtValue() != 1) { Constant *C = ConstantExpr::getCast(Scale, NewIdx->getType()); Instruction *Sc = BinaryOperator::createMul(NewIdx, C, "idxscale"); NewIdx = InsertNewInstBefore(Sc, GEP); @@ -7095,8 +7129,9 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { // Convert: malloc Ty, C - where C is a constant != 1 into: malloc [C x Ty], 1 if (AI.isArrayAllocation()) // Check C != 1 - if (const ConstantUInt *C = dyn_cast<ConstantUInt>(AI.getArraySize())) { - const Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getValue()); + if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) { + const Type *NewTy = + ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); AllocationInst *New = 0; // Create and insert the replacement instruction... @@ -7688,7 +7723,7 @@ static std::vector<unsigned> getShuffleMask(const ShuffleVectorInst *SVI) { if (isa<UndefValue>(CP->getOperand(i))) Result.push_back(NElts*2); // undef -> 8 else - Result.push_back(cast<ConstantUInt>(CP->getOperand(i))->getValue()); + Result.push_back(cast<ConstantInt>(CP->getOperand(i))->getZExtValue()); return Result; } @@ -7710,12 +7745,14 @@ static Value *FindScalarElement(Value *V, unsigned EltNo) { return CP->getOperand(EltNo); else if (InsertElementInst *III = dyn_cast<InsertElementInst>(V)) { // If this is an insert to a variable element, we don't know what it is. - if (!isa<ConstantUInt>(III->getOperand(2))) return 0; - unsigned IIElt = cast<ConstantUInt>(III->getOperand(2))->getValue(); + if (!isa<ConstantInt>(III->getOperand(2))) + return 0; + unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue(); // If this is an insert to the element we are looking for, return the // inserted value. - if (EltNo == IIElt) return III->getOperand(1); + if (EltNo == IIElt) + return III->getOperand(1); // Otherwise, the insertelement doesn't modify the value, recurse on its // vector input. @@ -7759,21 +7796,22 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { // If extracting a specified index from the vector, see if we can recursively // find a previously computed scalar that was inserted into the vector. - if (ConstantUInt *IdxC = dyn_cast<ConstantUInt>(EI.getOperand(1))) { + if (ConstantInt *IdxC = dyn_cast<ConstantInt>(EI.getOperand(1))) { // This instruction only demands the single element from the input vector. // If the input vector has a single use, simplify it based on this use // property. + uint64_t IndexVal = IdxC->getZExtValue(); if (EI.getOperand(0)->hasOneUse()) { uint64_t UndefElts; if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0), - 1 << IdxC->getValue(), + 1 << IndexVal, UndefElts)) { EI.setOperand(0, V); return &EI; } } - if (Value *Elt = FindScalarElement(EI.getOperand(0), IdxC->getValue())) + if (Value *Elt = FindScalarElement(EI.getOperand(0), IndexVal)) return ReplaceInstUsesWith(EI, Elt); } @@ -7819,8 +7857,8 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { } else if (ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(I)) { // If this is extracting an element from a shufflevector, figure out where // it came from and extract from the appropriate input element instead. - if (ConstantUInt *Elt = dyn_cast<ConstantUInt>(EI.getOperand(1))) { - unsigned SrcIdx = getShuffleMask(SVI)[Elt->getValue()]; + if (ConstantInt *Elt = dyn_cast<ConstantInt>(EI.getOperand(1))) { + unsigned SrcIdx = getShuffleMask(SVI)[Elt->getZExtValue()]; Value *Src; if (SrcIdx < SVI->getType()->getNumElements()) Src = SVI->getOperand(0); @@ -7851,11 +7889,11 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, return true; } else if (V == LHS) { for (unsigned i = 0; i != NumElts; ++i) - Mask.push_back(ConstantUInt::get(Type::UIntTy, i)); + Mask.push_back(ConstantInt::get(Type::UIntTy, i)); return true; } else if (V == RHS) { for (unsigned i = 0; i != NumElts; ++i) - Mask.push_back(ConstantUInt::get(Type::UIntTy, i+NumElts)); + Mask.push_back(ConstantInt::get(Type::UIntTy, i+NumElts)); return true; } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) { // If this is an insert of an extract from some other vector, include it. @@ -7865,7 +7903,7 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, if (!isa<ConstantInt>(IdxOp)) return false; - unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue(); + unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue(); if (isa<UndefValue>(ScalarOp)) { // inserting undef into vector. // Okay, we can handle this if the vector we are insertinting into is @@ -7879,7 +7917,7 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, if (isa<ConstantInt>(EI->getOperand(1)) && EI->getOperand(0)->getType() == V->getType()) { unsigned ExtractedIdx = - cast<ConstantInt>(EI->getOperand(1))->getRawValue(); + cast<ConstantInt>(EI->getOperand(1))->getZExtValue(); // This must be extracting from either LHS or RHS. if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) { @@ -7889,11 +7927,11 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, // If so, update the mask to reflect the inserted value. if (EI->getOperand(0) == LHS) { Mask[InsertedIdx & (NumElts-1)] = - ConstantUInt::get(Type::UIntTy, ExtractedIdx); + ConstantInt::get(Type::UIntTy, ExtractedIdx); } else { assert(EI->getOperand(0) == RHS); Mask[InsertedIdx & (NumElts-1)] = - ConstantUInt::get(Type::UIntTy, ExtractedIdx+NumElts); + ConstantInt::get(Type::UIntTy, ExtractedIdx+NumElts); } return true; @@ -7921,7 +7959,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask, Mask.assign(NumElts, UndefValue::get(Type::UIntTy)); return V; } else if (isa<ConstantAggregateZero>(V)) { - Mask.assign(NumElts, ConstantUInt::get(Type::UIntTy, 0)); + Mask.assign(NumElts, ConstantInt::get(Type::UIntTy, 0)); return V; } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) { // If this is an insert of an extract from some other vector, include it. @@ -7933,8 +7971,8 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask, if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) && EI->getOperand(0)->getType() == V->getType()) { unsigned ExtractedIdx = - cast<ConstantInt>(EI->getOperand(1))->getRawValue(); - unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue(); + cast<ConstantInt>(EI->getOperand(1))->getZExtValue(); + unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue(); // Either the extracted from or inserted into vector must be RHSVec, // otherwise we'd end up with a shuffle of three inputs. @@ -7942,7 +7980,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask, RHS = EI->getOperand(0); Value *V = CollectShuffleElements(VecOp, Mask, RHS); Mask[InsertedIdx & (NumElts-1)] = - ConstantUInt::get(Type::UIntTy, NumElts+ExtractedIdx); + ConstantInt::get(Type::UIntTy, NumElts+ExtractedIdx); return V; } @@ -7951,7 +7989,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask, // Everything but the extracted element is replaced with the RHS. for (unsigned i = 0; i != NumElts; ++i) { if (i != InsertedIdx) - Mask[i] = ConstantUInt::get(Type::UIntTy, NumElts+i); + Mask[i] = ConstantInt::get(Type::UIntTy, NumElts+i); } return V; } @@ -7968,7 +8006,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask, // Otherwise, can't do anything fancy. Return an identity vector. for (unsigned i = 0; i != NumElts; ++i) - Mask.push_back(ConstantUInt::get(Type::UIntTy, i)); + Mask.push_back(ConstantInt::get(Type::UIntTy, i)); return V; } @@ -7983,8 +8021,8 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) { if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) && EI->getOperand(0)->getType() == IE.getType()) { unsigned NumVectorElts = IE.getType()->getNumElements(); - unsigned ExtractedIdx=cast<ConstantInt>(EI->getOperand(1))->getRawValue(); - unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue(); + unsigned ExtractedIdx=cast<ConstantInt>(EI->getOperand(1))->getZExtValue(); + unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue(); if (ExtractedIdx >= NumVectorElts) // Out of range extract. return ReplaceInstUsesWith(IE, VecOp); @@ -8010,10 +8048,10 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) { Mask.assign(NumVectorElts, UndefValue::get(Type::UIntTy)); else { assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing"); - Mask.assign(NumVectorElts, ConstantUInt::get(Type::UIntTy, + Mask.assign(NumVectorElts, ConstantInt::get(Type::UIntTy, NumVectorElts)); } - Mask[InsertedIdx] = ConstantUInt::get(Type::UIntTy, ExtractedIdx); + Mask[InsertedIdx] = ConstantInt::get(Type::UIntTy, ExtractedIdx); return new ShuffleVectorInst(EI->getOperand(0), VecOp, ConstantPacked::get(Mask)); } @@ -8068,7 +8106,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { Mask[i] = 2*e; // Turn into undef. else Mask[i] &= (e-1); // Force to LHS. - Elts.push_back(ConstantUInt::get(Type::UIntTy, Mask[i])); + Elts.push_back(ConstantInt::get(Type::UIntTy, Mask[i])); } } SVI.setOperand(0, SVI.getOperand(1)); @@ -8123,7 +8161,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { if (NewMask[i] >= e*2) { Elts.push_back(UndefValue::get(Type::UIntTy)); } else { - Elts.push_back(ConstantUInt::get(Type::UIntTy, NewMask[i])); + Elts.push_back(ConstantInt::get(Type::UIntTy, NewMask[i])); } } return new ShuffleVectorInst(LHSSVI->getOperand(0), @@ -8193,7 +8231,7 @@ static Constant *OptimizeConstantExpr(ConstantExpr *CE, const TargetData *TD) { if (isFoldableGEP) { std::vector<Value*> Ops(CE->op_begin()+1, CE->op_end()); uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), Ops); - Constant *C = ConstantUInt::get(Type::ULongTy, Offset); + Constant *C = ConstantInt::get(Type::ULongTy, Offset); C = ConstantExpr::getCast(C, TD->getIntPtrType()); return ConstantExpr::getCast(C, CE->getType()); } diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 7f0248845d..e498860b5e 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -264,7 +264,7 @@ SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp, Loop *L) { // operand. if (const StructType *STy = dyn_cast<StructType>(*GTI)) { const StructLayout *SL = TD->getStructLayout(STy); - unsigned Idx = cast<ConstantUInt>(GEP->getOperand(i))->getValue(); + unsigned Idx = cast<ConstantInt>(GEP->getOperand(i))->getZExtValue(); uint64_t Offset = SL->MemberOffsets[Idx]; GEPVal = SCEVAddExpr::get(GEPVal, SCEVUnknown::getIntegerSCEV(Offset, UIntPtrTy)); @@ -275,7 +275,7 @@ SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp, Loop *L) { uint64_t TypeSize = TD->getTypeSize(GTI.getIndexedType()); if (TypeSize != 1) Idx = SCEVMulExpr::get(Idx, - SCEVConstant::get(ConstantUInt::get(UIntPtrTy, + SCEVConstant::get(ConstantInt::get(UIntPtrTy, TypeSize))); GEPVal = SCEVAddExpr::get(GEPVal, Idx); } @@ -861,7 +861,7 @@ RemoveCommonExpressionsFromUseBases(std::vector<BasedUser> &Uses) { /// static bool isZero(SCEVHandle &V) { if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) - return SC->getValue()->getRawValue() == 0; + return SC->getValue()->getZExtValue() == 0; return false; } diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index f1a826e127..9c59dd3de0 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -190,8 +190,8 @@ bool LoopUnroll::visitLoop(Loop *L) { ConstantInt *TripCountC = dyn_cast_or_null<ConstantInt>(L->getTripCount()); if (!TripCountC) return Changed; // Must have constant trip count! - uint64_t TripCountFull = TripCountC->getRawValue(); - if (TripCountFull != TripCountC->getRawValue() || TripCountFull == 0) + uint64_t TripCountFull = TripCountC->getZExtValue(); + if (TripCountFull != TripCountC->getZExtValue() || TripCountFull == 0) return Changed; // More than 2^32 iterations??? unsigned LoopSize = ApproximateLoopSize(L); diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp index 851009c7d6..6a07691adb 100644 --- a/lib/Transforms/Scalar/LowerGC.cpp +++ b/lib/Transforms/Scalar/LowerGC.cpp @@ -222,8 +222,8 @@ bool LowerGC::runOnFunction(Function &F) { BasicBlock::iterator IP = AI; while (isa<AllocaInst>(IP)) ++IP; - Constant *Zero = ConstantUInt::get(Type::UIntTy, 0); - Constant *One = ConstantUInt::get(Type::UIntTy, 1); + Constant *Zero = ConstantInt::get(Type::UIntTy, 0); + Constant *One = ConstantInt::get(Type::UIntTy, 1); // Get a pointer to the prev pointer. std::vector<Value*> Par; @@ -237,11 +237,11 @@ bool LowerGC::runOnFunction(Function &F) { new StoreInst(PrevPtr, PrevPtrPtr, IP); // Set the number of elements in this record. - Par[1] = ConstantUInt::get(Type::UIntTy, 1); + Par[1] = ConstantInt::get(Type::UIntTy, 1); Value *NumEltsPtr = new GetElementPtrInst(AI, Par, "numeltsptr", IP); - new StoreInst(ConstantUInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP); + new StoreInst(ConstantInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP); - Par[1] = ConstantUInt::get(Type::UIntTy, 2); + Par[1] = ConstantInt::get(Type::UIntTy, 2); Par.resize(4); const PointerType *PtrLocTy = @@ -251,7 +251,7 @@ bool LowerGC::runOnFunction(Function &F) { // Initialize all of the gcroot records now, and eliminate them as we go. for (unsigned i = 0, e = GCRoots.size(); i != e; ++i) { // Initialize the meta-data pointer. - Par[2] = ConstantUInt::get(Type::UIntTy, i); + Par[2] = ConstantInt::get(Type::UIntTy, i); Par[3] = One; Value *MetaDataPtr = new GetElementPtrInst(AI, Par, "MetaDataPtr", IP); assert(isa<Constant>(GCRoots[i]->getOperand(2)) && "Must be a constant"); diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp index 79a55ee876..5eb89115b0 100644 --- a/lib/Transforms/Scalar/LowerPacked.cpp +++ b/lib/Transforms/Scalar/LowerPacked.cpp @@ -209,7 +209,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI) if (const PackedType* PKT = dyn_cast<PackedType>(LI.getType())) { // Initialization, Idx is needed for getelementptr needed later std::vector<Value*> Idx(2); - Idx[0] = ConstantUInt::get(Type::UIntTy,0); + Idx[0] = ConstantInt::get(Type::UIntTy,0); ArrayType* AT = ArrayType::get(PKT->getContainedType(0), PKT->getNumElements()); @@ -227,7 +227,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI) for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) { // Calculate the second index we will need - Idx[1] = ConstantUInt::get(Type::UIntTy,i); + Idx[1] = ConstantInt::get(Type::UIntTy,i); // Get the pointer Value* val = new GetElementPtrInst(array, @@ -283,7 +283,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI) dyn_cast<PackedType>(SI.getOperand(0)->getType())) { // We will need this for getelementptr std::vector<Value*> Idx(2); - Idx[0] = ConstantUInt::get(Type::UIntTy,0); + Idx[0] = ConstantInt::get(Type::UIntTy,0); ArrayType* AT = ArrayType::get(PKT->getContainedType(0), PKT->getNumElements()); @@ -301,7 +301,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI) for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) { // Generate the indices for getelementptr - Idx[1] = ConstantUInt::get(Type::UIntTy,i); + Idx[1] = ConstantInt::get(Type::UIntTy,i); Value* val = new GetElementPtrInst(array, Idx, "store.ge." + @@ -346,17 +346,17 @@ void LowerPacked::visitExtractElementInst(ExtractElementInst& EI) const PackedType *PTy = cast<PackedType>(EI.getOperand(0)->getType()); Value *op1 = EI.getOperand(1); - if (ConstantUInt *C = dyn_cast<ConstantUInt>(op1)) { - EI.replaceAllUsesWith(op0Vals[C->getValue()]); + if (ConstantInt *C = dyn_cast<ConstantInt>(op1)) { + EI.replaceAllUsesWith(op0Vals[C->getZExtValue()]); } else { AllocaInst *alloca = new AllocaInst(PTy->getElementType(), - ConstantUInt::get(Type::UIntTy, PTy->getNumElements()), + ConstantInt::get(Type::UIntTy, PTy->getNumElements()), EI.getName() + ".alloca", EI.getParent()->getParent()->getEntryBlock().begin()); for (unsigned i = 0; i < PTy->getNumElements(); ++i) { GetElementPtrInst *GEP = - new GetElementPtrInst(alloca, ConstantUInt::get(Type::UIntTy, i), + new GetElementPtrInst(alloca, ConstantInt::get(Type::UIntTy, i), "store.ge", &EI); new StoreInst(op0Vals[i], GEP, &EI); } @@ -378,8 +378,8 @@ void LowerPacked::visitInsertElementInst(InsertElementInst& IE) std::vector<Value*> result; result.reserve(Vals.size()); - if (ConstantUInt *C = dyn_cast<ConstantUInt>(Idx)) { - unsigned idxVal = C->getValue(); + if (ConstantInt *C = dyn_cast<ConstantInt>(Idx)) { + unsigned idxVal = C->getZExtValue(); for (unsigned i = 0; i != Vals.size(); ++i) { result.push_back(i == idxVal ? Elt : Vals[i]); } @@ -387,7 +387,7 @@ void LowerPacked::visitInsertElementInst(InsertElementInst& IE) for (unsigned i = 0; i != Vals.size(); ++i) { SetCondInst *setcc = new SetCondInst(Instruction::SetEQ, Idx, - ConstantUInt::get(Type::UIntTy, i), + ConstantInt::get(Type::UIntTy, i), "setcc", &IE); SelectInst *select = new SelectInst(setcc, Elt, Vals[i], "select", &IE); diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 250d62b126..64b7b12a5e 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -549,7 +549,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, if (CstVal->isNullValue()) { // ... * 0 -> 0 ++NumAnnihil; return CstVal; - } else if (cast<ConstantInt>(CstVal)->getRawValue() == 1) { + } else if (cast<ConstantInt>(CstVal)->getZExtValue() == 1) { Ops.pop_back(); // ... * 1 -> ... } break; diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 87952bef5e..496449f494 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -203,7 +203,7 @@ bool SROA::performScalarRepl(Function &F) { GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User); // We now know that the GEP is of the form: GEP <ptr>, 0, <cst> unsigned Idx = - (unsigned)cast<ConstantInt>(GEPI->getOperand(2))->getRawValue(); + (unsigned)cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue(); assert(Idx < ElementAllocas.size() && "Index out of range?"); AllocaInst *AllocaToUse = ElementAllocas[Idx]; @@ -306,7 +306,7 @@ int SROA::isSafeUseOfAllocation(Instruction *User) { // Check to make sure that index falls within the array. If not, // something funny is going on, so we won't do the optimization. // - if (cast<ConstantInt>(GEPI->getOperand(2))->getRawValue() >= NumElements) + if (cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue() >= NumElements) return 0; // We cannot scalar repl this level of the array unless any array @@ -320,7 +320,7 @@ int SROA::isSafeUseOfAllocation(Instruction *User) { const ArrayType *SubArrayTy = cast<ArrayType>(*I); uint64_t NumElements = SubArrayTy->getNumElements(); if (!isa<ConstantInt>(I.getOperand())) return 0; - if (cast<ConstantInt>(I.getOperand())->getRawValue() >= NumElements) + if (cast<ConstantInt>(I.getOperand())->getZExtValue() >= NumElements) return 0; } @@ -499,7 +499,7 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) { } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) { // Check to see if this is stepping over an element: GEP Ptr, int C if (GEP->getNumOperands() == 2 && isa<ConstantInt>(GEP->getOperand(1))) { - unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getRawValue(); + unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getZExtValue(); unsigned ElSize = TD.getTypeSize(PTy->getElementType()); unsigned BitOffset = Idx*ElSize*8; if (BitOffset > 64 || !isPowerOf2_32(ElSize)) return 0; @@ -520,7 +520,7 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) { // We are stepping into an element, e.g. a structure or an array: // GEP Ptr, int 0, uint C const Type *AggTy = PTy->getElementType(); - unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getRawValue(); + unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue(); if (const ArrayType *ATy = dyn_cast<ArrayType>(AggTy)) { if (Idx >= ATy->getNumElements()) return 0; // Out of range. @@ -608,13 +608,13 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { if (const PackedType *PTy = dyn_cast<PackedType>(NV->getType())) { // Must be an element access. unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8); - NV = new ExtractElementInst(NV, ConstantUInt::get(Type::UIntTy, Elt), + NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt), "tmp", LI); } else { assert(NV->getType()->isInteger() && "Unknown promotion!"); if (Offset && Offset < TD.getTypeSize(NV->getType())*8) NV = new ShiftInst(Instruction::Shr, NV, - ConstantUInt::get(Type::UByteTy, Offset), + ConstantInt::get(Type::UByteTy, Offset), LI->getName(), LI); NV = new CastInst(NV, LI->getType(), LI->getName(), LI); } @@ -635,7 +635,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { // Must be an element insertion. unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8); SV = new InsertElementInst(Old, SV, - ConstantUInt::get(Type::UIntTy, Elt), + ConstantInt::get(Type::UIntTy, Elt), "tmp", SI); } else { // If SV is signed, convert it to unsigned, so that the next cast zero @@ -646,7 +646,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { SV = new CastInst(SV, Old->getType(), SV->getName(), SI); if (Offset && Offset < TD.getTypeSize(SV->getType())*8) SV = new ShiftInst(Instruction::Shl, SV, - ConstantUInt::get(Type::UByteTy, Offset), + ConstantInt::get(Type::UByteTy, Offset), SV->getName()+".adj", SI); // Mask out the bits we are about to insert from the old value. unsigned TotalBits = TD.getTypeSize(SV->getType())*8; @@ -657,7 +657,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { if (TotalBits != 64) Mask = Mask & ((1ULL << TotalBits)-1); Old = BinaryOperator::createAnd(Old, - ConstantUInt::get(Old->getType(), Mask), + ConstantInt::get(Old->getType(), Mask), Old->getName()+".mask", SI); SV = BinaryOperator::createOr(Old, SV, SV->getName()+".ins", SI); } @@ -688,7 +688,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { // Check to see if this is stepping over an element: GEP Ptr, int C unsigned NewOffset = Offset; if (GEP->getNumOperands() == 2) { - unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getRawValue(); + unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getZExtValue(); unsigned BitOffset = Idx*AggSizeInBits; if (TD.isLittleEndian() || isVectorInsert) @@ -698,7 +698,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { } else if (GEP->getNumOperands() == 3) { // We know that operand #2 is zero. - unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getRawValue(); + unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue(); const Type *AggTy = AggPtrTy->getElementType(); if (const SequentialType *SeqTy = dyn_cast<SequentialType>(AggTy)) { unsigned ElSizeBits = TD.getTypeSize(SeqTy->getElementType())*8; diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 8cd2511e7c..b6739f40b2 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -34,7 +34,7 @@ static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset, (i == SL->MemberOffsets.size()-1 || Offset < SL->MemberOffsets[i+1])); // Make sure to save the current index... - Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, i)); Offset = SL->MemberOffsets[i]; return STy->getContainedType(i); } @@ -73,10 +73,11 @@ const Type *llvm::getStructOffsetType(const Type *Ty, unsigned &Offset, NextType = ATy->getElementType(); unsigned ChildSize = (unsigned)TD.getTypeSize(NextType); - if (ConstantSInt::isValueValidForType(Type::IntTy, Offset/ChildSize)) - Indices.push_back(ConstantSInt::get(Type::IntTy, Offset/ChildSize)); + if (ConstantInt::isValueValidForType(Type::IntTy, + uint64_t(Offset/ChildSize))) + Indices.push_back(ConstantInt::get(Type::IntTy, Offset/ChildSize)); else - Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize)); + Indices.push_back(ConstantInt::get(Type::LongTy, Offset/ChildSize)); ThisOffset = (Offset/ChildSize)*ChildSize; } else { Offset = 0; // Return the offset that we were able to achieve diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h index 51e32c81e6..4e28904833 100644 --- a/lib/Transforms/TransformInternals.h +++ b/lib/Transforms/TransformInternals.h @@ -25,7 +25,7 @@ namespace llvm { static inline int64_t getConstantValue(const ConstantInt *CPI) { - return (int64_t)cast<ConstantInt>(CPI)->getRawValue(); + return (int64_t)cast<ConstantInt>(CPI)->getZExtValue(); } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index f264cff472..ba403450a7 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -305,7 +305,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs, if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, i)); std::string GEPname = "gep_" + inputs[i]->getName(); TerminatorInst *TI = newFunction->begin()->getTerminator(); GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI); @@ -392,7 +392,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, for (unsigned i = 0, e = inputs.size(); i != e; ++i) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, i)); GetElementPtrInst *GEP = new GetElementPtrInst(Struct, Indices, "gep_" + StructValues[i]->getName()); @@ -418,7 +418,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, FirstOut + i)); GetElementPtrInst *GEP = new GetElementPtrInst(Struct, Indices, "gep_reload_" + outputs[i]->getName()); @@ -439,7 +439,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // Now we can emit a switch statement using the call as a value. SwitchInst *TheSwitch = - new SwitchInst(ConstantUInt::getNullValue(Type::UShortTy), + new SwitchInst(ConstantInt::getNullValue(Type::UShortTy), codeReplacer, 0, codeReplacer); // Since there may be multiple exits from the original region, make the new @@ -473,14 +473,14 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, brVal = ConstantBool::get(!SuccNum); break; default: - brVal = ConstantUInt::get(Type::UShortTy, SuccNum); + brVal = ConstantInt::get(Type::UShortTy, SuccNum); break; } ReturnInst *NTRet = new ReturnInst(brVal, NewTarget); // Update the switch instruction. - TheSwitch->addCase(ConstantUInt::get(Type::UShortTy, SuccNum), + TheSwitch->addCase(ConstantInt::get(Type::UShortTy, SuccNum), OldTarget); // Restore values just before we exit @@ -519,7 +519,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out)); + Indices.push_back(ConstantInt::get(Type::UIntTy,FirstOut+out)); GetElementPtrInst *GEP = new GetElementPtrInst(OAI, Indices, "gep_" + outputs[out]->getName(), diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 3d1faff018..28864fd613 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -272,10 +272,10 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, gep_type_iterator I = gep_type_begin(CE), E = gep_type_end(CE); for (++I; I != E; ++I) if (const StructType *STy = dyn_cast<StructType>(*I)) { - ConstantUInt *CU = cast<ConstantUInt>(I.getOperand()); - assert(CU->getValue() < STy->getNumElements() && + ConstantInt *CU = cast<ConstantInt>(I.getOperand()); + assert(CU->getZExtValue() < STy->getNumElements() && "Struct index out of range!"); - unsigned El = (unsigned)CU->getValue(); + unsigned El = (unsigned)CU->getZExtValue(); if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) { C = CS->getOperand(El); } else if (isa<ConstantAggregateZero>(C)) { @@ -287,10 +287,10 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, } } else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) { if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) { - if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) + if (CI->getZExtValue() >= ATy->getNumElements()) return 0; if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) - C = CA->getOperand((unsigned)CI->getRawValue()); + C = CA->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) C = Constant::getNullValue(ATy->getElementType()); else if (isa<UndefValue>(C)) @@ -298,10 +298,10 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, else return 0; } else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) { - if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) + if (CI->getZExtValue() >= PTy->getNumElements()) return 0; if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) - C = CP->getOperand((unsigned)CI->getRawValue()); + C = CP->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) C = Constant::getNullValue(PTy->getElementType()); else if (isa<UndefValue>(C)) diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 451df70fef..d08235cd9d 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -119,14 +119,14 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { // malloc(type) becomes sbyte *malloc(size) Value *MallocArg; if (LowerMallocArgToInteger) - MallocArg = ConstantUInt::get(Type::ULongTy, TD.getTypeSize(AllocTy)); + MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy)); else MallocArg = ConstantExpr::getSizeOf(AllocTy); MallocArg = ConstantExpr::getCast(cast<Constant>(MallocArg), IntPtrTy); if (MI->isArrayAllocation()) { if (isa<ConstantInt>(MallocArg) && - cast<ConstantInt>(MallocArg)->getRawValue() == 1) { + cast<ConstantInt>(MallocArg)->getZExtValue() == 1) { MallocArg = MI->getOperand(0); // Operand * 1 = Operand } else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) { CO = ConstantExpr::getCast(CO, IntPtrTy); diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 918055722d..1816144fff 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -269,7 +269,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch) { - ConstantUInt *InvokeNoC = ConstantUInt::get(Type::UIntTy, InvokeNo); + ConstantInt *InvokeNoC = ConstantInt::get(Type::UIntTy, InvokeNo); // Insert a store of the invoke num before the invoke and store zero into the // location afterward. @@ -461,7 +461,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector<Value*> Idx; Idx.push_back(Constant::getNullValue(Type::IntTy)); - Idx.push_back(ConstantUInt::get(Type::UIntTy, 1)); + Idx.push_back(ConstantInt::get(Type::UIntTy, 1)); OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf", EntryBB->getTerminator()); @@ -500,7 +500,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(), "setjmp.cont"); - Idx[1] = ConstantUInt::get(Type::UIntTy, 0); + Idx[1] = ConstantInt::get(Type::UIntTy, 0); Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf", EntryBB->getTerminator()); Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret", @@ -550,7 +550,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Get a pointer to the jmpbuf and longjmp. std::vector<Value*> Idx; Idx.push_back(Constant::getNullValue(Type::IntTy)); - Idx.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Idx.push_back(ConstantInt::get(Type::UIntTy, 0)); Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock); Idx[1] = ConstantInt::get(Type::IntTy, 1); new CallInst(LongJmpFn, Idx, "", UnwindBlock); diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 12a32f19cb..724499d1ba 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -60,11 +60,12 @@ namespace { struct CaseCmp { bool operator () (const LowerSwitch::Case& C1, const LowerSwitch::Case& C2) { - if (const ConstantUInt* U1 = dyn_cast<const ConstantUInt>(C1.first)) - return U1->getValue() < cast<const ConstantUInt>(C2.first)->getValue(); - const ConstantSInt* S1 = dyn_cast<const ConstantSInt>(C1.first); - return S1->getValue() < cast<const ConstantSInt>(C2.first)->getValue(); + const ConstantInt* CI1 = cast<const ConstantInt>(C1.first); + const ConstantInt* CI2 = cast<const ConstantInt>(C2.first); + if (CI1->getType()->isUnsigned()) + return CI1->getZExtValue() < CI2->getZExtValue(); + return CI1->getSExtValue() < CI2->getSExtValue(); } }; @@ -129,7 +130,7 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End, Case& Pivot = *(Begin + Mid); DEBUG(std::cerr << "Pivot ==> " - << (int64_t)cast<ConstantInt>(Pivot.first)->getRawValue() + << cast<ConstantInt>(Pivot.first)->getSExtValue() << "\n"); BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val, diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 867455e3e7..de2ab0645c 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1160,7 +1160,7 @@ namespace { /// applications that sort ConstantInt's to ensure uniqueness. struct ConstantIntOrdering { bool operator()(const ConstantInt *LHS, const ConstantInt *RHS) const { - return LHS->getRawValue() < RHS->getRawValue(); + return LHS->getZExtValue() < RHS->getZExtValue(); } }; } diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index aedb2c4040..d4a43ce96c 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -422,10 +422,11 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, static std::string Indent = "\n"; if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { Out << (CB->getValue() ? "true" : "false"); - } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) { - Out << CI->getValue(); - } else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) { - Out << CI->getValue(); + } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + if (CI->getType()->isSigned()) + Out << CI->getSExtValue(); + else + Out << CI->getZExtValue(); } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) { // We would like to output the FP constant value in exponential notation, // but we cannot do this if doing so will lose precision. Check here to diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index ffc5ccaedc..ad9a33f845 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -271,14 +271,14 @@ struct VISIBILITY_HIDDEN BoolRules } DEF_CAST(Bool , ConstantBool, bool) - DEF_CAST(SByte , ConstantSInt, signed char) - DEF_CAST(UByte , ConstantUInt, unsigned char) - DEF_CAST(Short , ConstantSInt, signed short) - DEF_CAST(UShort, ConstantUInt, unsigned short) - DEF_CAST(Int , ConstantSInt, signed int) - DEF_CAST(UInt , ConstantUInt, unsigned int) - DEF_CAST(Long , ConstantSInt, int64_t) - DEF_CAST(ULong , ConstantUInt, uint64_t) + DEF_CAST(SByte , ConstantInt, signed char) + DEF_CAST(UByte , ConstantInt, unsigned char) + DEF_CAST(Short , ConstantInt, signed short) + DEF_CAST(UShort, ConstantInt, unsigned short) + DEF_CAST(Int , ConstantInt, signed int) + DEF_CAST(UInt , ConstantInt, unsigned int) + DEF_CAST(Long , ConstantInt, int64_t) + DEF_CAST(ULong , ConstantInt, uint64_t) DEF_CAST(Float , ConstantFP , float) DEF_CAST(Double, ConstantFP , double) #undef DEF_CAST @@ -303,28 +303,28 @@ struct VISIBILITY_HIDDEN NullPointerRules return ConstantBool::getFalse(); } static Constant *CastToSByte (const Constant *V) { - return ConstantSInt::get(Type::SByteTy, 0); + return ConstantInt::get(Type::SByteTy, 0); } static Constant *CastToUByte (const Constant *V) { - return ConstantUInt::get(Type::UByteTy, 0); + return ConstantInt::get(Type::UByteTy, 0); } static Constant *CastToShort (const Constant *V) { - return ConstantSInt::get(Type::ShortTy, 0); + return ConstantInt::get(Type::ShortTy, 0); } static Constant *CastToUShort(const Constant *V) { - return ConstantUInt::get(Type::UShortTy, 0); + return ConstantInt::get(Type::UShortTy, 0); } static Constant *CastToInt (const Constant *V) { - return ConstantSInt::get(Type::IntTy, 0); + return ConstantInt::get(Type::IntTy, 0); } static Constant *CastToUInt (const Constant *V) { - return ConstantUInt::get(Type::UIntTy, 0); + return ConstantInt::get(Type::UIntTy, 0); } static Constant *CastToLong (const Constant *V) { - return ConstantSInt::get(Type::LongTy, 0); + return ConstantInt::get(Type::LongTy, 0); } static Constant *CastToULong (const Constant *V) { - return ConstantUInt::get(Type::ULongTy, 0); + return ConstantInt::get(Type::ULongTy, 0); } static Constant *CastToFloat (const Constant *V) { return ConstantFP::get(Type::FloatTy, 0); @@ -428,49 +428,46 @@ struct VISIBILITY_HIDDEN GeneralPackedRules //===----------------------------------------------------------------------===// -// DirectRules Class +// DirectIntRules Class //===----------------------------------------------------------------------===// // -// DirectRules provides a concrete base classes of ConstRules for a variety of -// different types. This allows the C++ compiler to automatically generate our -// constant handling operations in a typesafe and accurate manner. +// DirectIntRules provides implementations of functions that are valid on +// integer types, but not all types in general. // namespace { -template<class ConstantClass, class BuiltinType, Type **Ty, class SuperClass> -struct VISIBILITY_HIDDEN DirectRules - : public TemplateRules<ConstantClass, SuperClass> { - static Constant *Add(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() + (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); - } +template <class BuiltinType, Type **Ty> +struct VISIBILITY_HIDDEN DirectIntRules + : public TemplateRules<ConstantInt, DirectIntRules<BuiltinType, Ty> > { - static Constant *Sub(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() - (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Add(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = (BuiltinType)V1->getZExtValue() + + (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Mul(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() * (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Sub(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = (BuiltinType)V1->getZExtValue() - + (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) { - if (V2->isNullValue()) return 0; - BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Mul(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = (BuiltinType)V1->getZExtValue() * + (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *LessThan(const ConstantClass *V1, const ConstantClass *V2) { - bool R = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue(); + static Constant *LessThan(const ConstantInt *V1, const ConstantInt *V2) { + bool R = (BuiltinType)V1->getZExtValue() < (BuiltinType)V2->getZExtValue(); return ConstantBool::get(R); } - static Constant *EqualTo(const ConstantClass *V1, const ConstantClass *V2) { - bool R = (BuiltinType)V1->getValue() == (BuiltinType)V2->getValue(); + static Constant *EqualTo(const ConstantInt *V1, const ConstantInt *V2) { + bool R = (BuiltinType)V1->getZExtValue() == (BuiltinType)V2->getZExtValue(); return ConstantBool::get(R); } - static Constant *CastToPointer(const ConstantClass *V, + static Constant *CastToPointer(const ConstantInt *V, const PointerType *PTy) { if (V->isNullValue()) // Is it a FP or Integral null value? return ConstantPointerNull::get(PTy); @@ -479,79 +476,70 @@ struct VISIBILITY_HIDDEN DirectRules // Casting operators. ick #define DEF_CAST(TYPE, CLASS, CTYPE) \ - static Constant *CastTo##TYPE (const ConstantClass *V) { \ - return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \ + static Constant *CastTo##TYPE (const ConstantInt *V) { \ + return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getZExtValue()); \ } DEF_CAST(Bool , ConstantBool, bool) - DEF_CAST(SByte , ConstantSInt, signed char) - DEF_CAST(UByte , ConstantUInt, unsigned char) - DEF_CAST(Short , ConstantSInt, signed short) - DEF_CAST(UShort, ConstantUInt, unsigned short) - DEF_CAST(Int , ConstantSInt, signed int) - DEF_CAST(UInt , ConstantUInt, unsigned int) - DEF_CAST(Long , ConstantSInt, int64_t) - DEF_CAST(ULong , ConstantUInt, uint64_t) - DEF_CAST(Float , ConstantFP , float) - DEF_CAST(Double, ConstantFP , double) + DEF_CAST(SByte , ConstantInt, signed char) + DEF_CAST(UByte , ConstantInt, unsigned char) + DEF_CAST(Short , ConstantInt, signed short) + DEF_CAST(UShort, ConstantInt, unsigned short) + DEF_CAST(Int , ConstantInt, signed int) + DEF_CAST(UInt , ConstantInt, unsigned int) + DEF_CAST(Long , ConstantInt, int64_t) + DEF_CAST(ULong , ConstantInt, uint64_t) + DEF_CAST(Float , ConstantFP , float) + DEF_CAST(Double, ConstantFP , double) #undef DEF_CAST -}; -} // end anonymous namespace - -//===----------------------------------------------------------------------===// -// DirectIntRules Class -//===----------------------------------------------------------------------===// -// -// DirectIntRules provides implementations of functions that are valid on -// integer types, but not all types in general. -// -namespace { -template <class ConstantClass, class BuiltinType, Type **Ty> -struct VISIBILITY_HIDDEN DirectIntRules - : public DirectRules<ConstantClass, BuiltinType, Ty, - DirectIntRules<ConstantClass, BuiltinType, Ty> > { - - static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) { + static Constant *Div(const ConstantInt *V1, const ConstantInt *V2) { if (V2->isNullValue()) return 0; if (V2->isAllOnesValue() && // MIN_INT / -1 - (BuiltinType)V1->getValue() == -(BuiltinType)V1->getValue()) + (BuiltinType)V1->getZExtValue() == -(BuiltinType)V1->getZExtValue()) return 0; - BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + BuiltinType R = + (BuiltinType)V1->getZExtValue() / (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Rem(const ConstantClass *V1, - const ConstantClass *V2) { + static Constant *Rem(const ConstantInt *V1, + const ConstantInt *V2) { if (V2->isNullValue()) return 0; // X / 0 if (V2->isAllOnesValue() && // MIN_INT / -1 - (BuiltinType)V1->getValue() == -(BuiltinType)V1->getValue()) + (BuiltinType)V1->getZExtValue() == -(BuiltinType)V1->getZExtValue()) return 0; - BuiltinType R = (BuiltinType)V1->getValue() % (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + BuiltinType R = + (BuiltinType)V1->getZExtValue() % (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *And(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() & (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *And(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = + (BuiltinType)V1->getZExtValue() & (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Or(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() | (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Or(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = + (BuiltinType)V1->getZExtValue() | (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Xor(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() ^ (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Xor(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = + (BuiltinType)V1->getZExtValue() ^ (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Shl(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() << (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Shl(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = + (BuiltinType)V1->getZExtValue() << (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } - static Constant *Shr(const ConstantClass *V1, const ConstantClass *V2) { - BuiltinType R = (BuiltinType)V1->getValue() >> (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + static Constant *Shr(const ConstantInt *V1, const ConstantInt *V2) { + BuiltinType R = + (BuiltinType)V1->getZExtValue() >> (BuiltinType)V2->getZExtValue(); + return ConstantInt::get(*Ty, R); } }; } // end anonymous namespace @@ -565,22 +553,74 @@ struct VISIBILITY_HIDDEN DirectIntRules /// floating point types, but not all types in general. /// namespace { -template <class ConstantClass, class BuiltinType, Type **Ty> +template <class BuiltinType, Type **Ty> struct VISIBILITY_HIDDEN DirectFPRules - : public DirectRules<ConstantClass, BuiltinType, Ty, - DirectFPRules<ConstantClass, BuiltinType, Ty> > { - static Constant *Rem(const ConstantClass *V1, const ConstantClass *V2) { + : public TemplateRules<ConstantFP, DirectFPRules<BuiltinType, Ty> > { + + static Constant *Add(const ConstantFP *V1, const ConstantFP *V2) { + BuiltinType R = (BuiltinType)V1->getValue() + + (BuiltinType)V2->getValue(); + return ConstantFP::get(*Ty, R); + } + + static Constant *Sub(const ConstantFP *V1, const ConstantFP *V2) { + BuiltinType R = (BuiltinType)V1->getValue() - (BuiltinType)V2->getValue(); + return ConstantFP::get(*Ty, R); + } + + static Constant *Mul(const ConstantFP *V1, const ConstantFP *V2) { + BuiltinType R = (BuiltinType)V1->getValue() * (BuiltinType)V2->getValue(); + return ConstantFP::get(*Ty, R); + } + + static Constant *LessThan(const ConstantFP *V1, const ConstantFP *V2) { + bool R = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue(); + return ConstantBool::get(R); + } + + static Constant *EqualTo(const ConstantFP *V1, const ConstantFP *V2) { + bool R = (BuiltinType)V1->getValue() == (BuiltinType)V2->getValue(); + return ConstantBool::get(R); + } + + static Constant *CastToPointer(const ConstantFP *V, + const PointerType *PTy) { + if (V->isNullValue()) // Is it a FP or Integral null value? + return ConstantPointerNull::get(PTy); + return 0; // Can't const prop other types of pointers + } + + // Casting operators. ick +#define DEF_CAST(TYPE, CLASS, CTYPE) \ + static Constant *CastTo##TYPE (const ConstantFP *V) { \ + return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \ + } + + DEF_CAST(Bool , ConstantBool, bool) + DEF_CAST(SByte , ConstantInt, signed char) + DEF_CAST(UByte , ConstantInt, unsigned char) + DEF_CAST(Short , ConstantInt, signed short) + DEF_CAST(UShort, ConstantInt, unsigned short) + DEF_CAST(Int , ConstantInt, signed int) + DEF_CAST(UInt , ConstantInt, unsigned int) + DEF_CAST(Long , ConstantInt, int64_t) + DEF_CAST(ULong , ConstantInt, uint64_t) + DEF_CAST(Float , ConstantFP , float) + DEF_CAST(Double, ConstantFP , double) +#undef DEF_CAST + + static Constant *Rem(const ConstantFP *V1, const ConstantFP *V2) { if (V2->isNullValue()) return 0; BuiltinType Result = std::fmod((BuiltinType)V1->getValue(), (BuiltinType)V2->getValue()); - return ConstantClass::get(*Ty, Result); + return ConstantFP::get(*Ty, Result); } - static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) { + static Constant *Div(const ConstantFP *V1, const ConstantFP *V2) { BuiltinType inf = std::numeric_limits<BuiltinType>::infinity(); - if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, inf); - if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -inf); + if (V2->isExactlyValue(0.0)) return ConstantFP::get(*Ty, inf); + if (V2->isExactlyValue(-0.0)) return ConstantFP::get(*Ty, -inf); BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue(); - return ConstantClass::get(*Ty, R); + return ConstantFP::get(*Ty, R); } }; } // end anonymous namespace @@ -590,26 +630,16 @@ static ManagedStatic<BoolRules> BoolR; static ManagedStatic<NullPointerRules> NullPointerR; static ManagedStatic<ConstantPackedRules> ConstantPackedR; static ManagedStatic<GeneralPackedRules> GeneralPackedR; -static ManagedStatic<DirectIntRules<ConstantSInt, signed char , - &Type::SByteTy> > SByteR; -static ManagedStatic<DirectIntRules<ConstantUInt, unsigned char , - &Type::UByteTy> > UByteR; -static ManagedStatic<DirectIntRules<ConstantSInt, signed short, - &Type::ShortTy> > ShortR; -static ManagedStatic<DirectIntRules<ConstantUInt, unsigned short, - &Type::UShortTy> > UShortR; -static ManagedStatic<DirectIntRules<ConstantSInt, signed int , - &Type::IntTy> > IntR; -static ManagedStatic<DirectIntRules<ConstantUInt, unsigned int , - &Type::UIntTy> > UIntR; -static ManagedStatic<DirectIntRules<ConstantSInt, int64_t , - &Type::LongTy> > LongR; -static ManagedStatic<DirectIntRules<ConstantUInt, uint64_t , - &Type::ULongTy> > ULongR; -static ManagedStatic<DirectFPRules <ConstantFP , float , - &Type::FloatTy> > FloatR; -static ManagedStatic<DirectFPRules <ConstantFP , double , - &Type::DoubleTy> > DoubleR; +static ManagedStatic<DirectIntRules<signed char , &Type::SByteTy> > SByteR; +static ManagedStatic<DirectIntRules<unsigned char , &Type::UByteTy> > UByteR; +static ManagedStatic<DirectIntRules<signed short , &Type::ShortTy> > ShortR; +static ManagedStatic<DirectIntRules<unsigned short, &Type::UShortTy> > UShortR; +static ManagedStatic<DirectIntRules<signed int , &Type::IntTy> > IntR; +static ManagedStatic<DirectIntRules<unsigned int , &Type::UIntTy> > UIntR; +static ManagedStatic<DirectIntRules<int64_t , &Type::LongTy> > LongR; +static ManagedStatic<DirectIntRules<uint64_t , &Type::ULongTy> > ULongR; +static ManagedStatic<DirectFPRules <float , &Type::FloatTy> > FloatR; +static ManagedStatic<DirectFPRules <double , &Type::DoubleTy> > DoubleR; /// ConstRules::get - This method returns the constant rules implementation that /// implements the semantics of the two specified constants. @@ -684,7 +714,7 @@ static Constant *CastConstantPacked(ConstantPacked *CP, if (DstEltTy->getTypeID() == Type::DoubleTyID) { for (unsigned i = 0; i != SrcNumElts; ++i) { double V = - BitsToDouble(cast<ConstantInt>(CP->getOperand(i))->getRawValue()); + BitsToDouble(cast<ConstantInt>(CP->getOperand(i))->getZExtValue()); Result.push_back(ConstantFP::get(Type::DoubleTy, V)); } return ConstantPacked::get(Result); @@ -692,7 +722,7 @@ static Constant *CastConstantPacked(ConstantPacked *CP, assert(DstEltTy == Type::FloatTy && "Unknown fp type!"); for (unsigned i = 0; i != SrcNumElts; ++i) { float V = - BitsToFloat(cast<ConstantInt>(CP->getOperand(i))->getRawValue()); + BitsToFloat(cast<ConstantInt>(CP->getOperand(i))->getZExtValue()); Result.push_back(ConstantFP::get(Type::FloatTy, V)); } return ConstantPacked::get(Result); @@ -705,7 +735,7 @@ static Constant *CastConstantPacked(ConstantPacked *CP, for (unsigned i = 0; i != SrcNumElts; ++i) { uint64_t V = DoubleToBits(cast<ConstantFP>(CP->getOperand(i))->getValue()); - Constant *C = ConstantUInt::get(Type::ULongTy, V); + Constant *C = ConstantInt::get(Type::ULongTy, V); Result.push_back(ConstantExpr::getCast(C, DstEltTy)); } return ConstantPacked::get(Result); @@ -713,8 +743,8 @@ static Constant *CastConstantPacked(ConstantPacked *CP, assert(SrcEltTy->getTypeID() == Type::FloatTyID); for (unsigned i = 0; i != SrcNumElts; ++i) { - unsigned V = FloatToBits(cast<ConstantFP>(CP->getOperand(i))->getValue()); - Constant *C = ConstantUInt::get(Type::UIntTy, V); + uint32_t V = FloatToBits(cast<ConstantFP>(CP->getOperand(i))->getValue()); + Constant *C = ConstantInt::get(Type::UIntTy, V); Result.push_back(ConstantExpr::getCast(C, DstEltTy)); } return ConstantPacked::get(Result); @@ -871,8 +901,8 @@ Constant *llvm::ConstantFoldExtractElementInstruction(const Constant *Val, cast<PackedType>(Val->getType())->getElementType()); if (const ConstantPacked *CVal = dyn_cast<ConstantPacked>(Val)) { - if (const ConstantUInt *CIdx = dyn_cast<ConstantUInt>(Idx)) { - return const_cast<Constant*>(CVal->getOperand(CIdx->getValue())); + if (const ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx)) { + return const_cast<Constant*>(CVal->getOperand(CIdx->getZExtValue())); } else if (isa<UndefValue>(Idx)) { // ee({w,x,y,z}, undef) -> w (an arbitrary value). return const_cast<Constant*>(CVal->getOperand(0)); @@ -884,9 +914,9 @@ Constant *llvm::ConstantFoldExtractElementInstruction(const Constant *Val, Constant *llvm::ConstantFoldInsertElementInstruction(const Constant *Val, const Constant *Elt, const Constant *Idx) { - const ConstantUInt *CIdx = dyn_cast<ConstantUInt>(Idx); + const ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx); if (!CIdx) return 0; - unsigned idxVal = CIdx->getValue(); + uint64_t idxVal = CIdx->getZExtValue(); if (const UndefValue *UVal = dyn_cast<UndefValue>(Val)) { // Insertion of scalar constant into packed undef // Optimize away insertion of undef @@ -991,7 +1021,8 @@ static int IdxCompare(Constant *C1, Constant *C2, const Type *ElTy) { // If they are really different, now that they are the same type, then we // found a difference! - if (cast<ConstantSInt>(C1)->getValue() < cast<ConstantSInt>(C2)->getValue()) + if (cast<ConstantInt>(C1)->getSExtValue() < + cast<ConstantInt>(C2)->getSExtValue()) return -1; else return 1; @@ -1324,17 +1355,17 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, case Instruction::Mul: if (V2->isNullValue()) return const_cast<Constant*>(V2); // X * 0 == 0 if (const ConstantInt *CI = dyn_cast<ConstantInt>(V2)) - if (CI->getRawValue() == 1) + if (CI->getZExtValue() == 1) return const_cast<Constant*>(V1); // X * 1 == X break; case Instruction::Div: if (const ConstantInt *CI = dyn_cast<ConstantInt>(V2)) - if (CI->getRawValue() == 1) + if (CI->getZExtValue() == 1) return const_cast<Constant*>(V1); // X / 1 == X break; case Instruction::Rem: if (const ConstantInt *CI = dyn_cast<ConstantInt>(V2)) - if (CI->getRawValue() == 1) + if (CI->getZExtValue() == 1) return Constant::getNullValue(CI->getType()); // X % 1 == 0 break; case Instruction::And: @@ -1348,7 +1379,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, // Functions are at least 4-byte aligned. If and'ing the address of a // function with a constant < 4, fold it to zero. if (const ConstantInt *CI = dyn_cast<ConstantInt>(V2)) - if (CI->getRawValue() < 4 && isa<Function>(CPR)) + if (CI->getZExtValue() < 4 && isa<Function>(CPR)) return Constant::getNullValue(CI->getType()); } break; @@ -1427,10 +1458,10 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, if (IdxList.size() == 1) { const Type *ElTy = cast<PointerType>(C->getType())->getElementType(); - if (unsigned ElSize = ElTy->getPrimitiveSize()) { + if (uint32_t ElSize = ElTy->getPrimitiveSize()) { // gep null, C is equal to C*sizeof(nullty). If nullty is a known llvm // type, we can statically fold this. - Constant *R = ConstantUInt::get(Type::UIntTy, ElSize); + Constant *R = ConstantInt::get(Type::UIntTy, ElSize); R = ConstantExpr::getCast(R, Idx0->getType()); R = ConstantExpr::getMul(R, Idx0); return ConstantExpr::getCast(R, C->getType()); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index cf8f79e96d..05b444573e 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -93,35 +93,35 @@ Constant *Constant::getNullValue(const Type *Ty) { return NullBool; } case Type::SByteTyID: { - static Constant *NullSByte = ConstantSInt::get(Type::SByteTy, 0); + static Constant *NullSByte = ConstantInt::get(Type::SByteTy, 0); return NullSByte; } case Type::UByteTyID: { - static Constant *NullUByte = ConstantUInt::get(Type::UByteTy, 0); + static Constant *NullUByte = ConstantInt::get(Type::UByteTy, 0); return NullUByte; } case Type::ShortTyID: { - static Constant *NullShort = ConstantSInt::get(Type::ShortTy, 0); + static Constant *NullShort = ConstantInt::get(Type::ShortTy, 0); return NullShort; } case Type::UShortTyID: { - static Constant *NullUShort = ConstantUInt::get(Type::UShortTy, 0); + static Constant *NullUShort = ConstantInt::get(Type::UShortTy, 0); return NullUShort; } case Type::IntTyID: { - static Constant *NullInt = ConstantSInt::get(Type::IntTy, 0); + static Constant *NullInt = ConstantInt::get(Type::IntTy, 0); return NullInt; } case Type::UIntTyID: { - static Constant *NullUInt = ConstantUInt::get(Type::UIntTy, 0); + static Constant *NullUInt = ConstantInt::get(Type::UIntTy, 0); return NullUInt; } case Type::LongTyID: { - static Constant *NullLong = ConstantSInt::get(Type::LongTy, 0); + static Constant *NullLong = ConstantInt::get(Type::LongTy, 0); return NullLong; } case Type::ULongTyID: { - static Constant *NullULong = ConstantUInt::get(Type::ULongTy, 0); + static Constant *NullULong = ConstantInt::get(Type::ULongTy, 0); return NullULong; } @@ -160,7 +160,7 @@ ConstantIntegral *ConstantIntegral::getMaxValue(const Type *Ty) { unsigned TypeBits = Ty->getPrimitiveSize()*8; int64_t Val = INT64_MAX; // All ones Val >>= 64-TypeBits; // Shift out unwanted 1 bits... - return ConstantSInt::get(Ty, Val); + return ConstantInt::get(Ty, Val); } case Type::UByteTyID: @@ -184,13 +184,13 @@ ConstantIntegral *ConstantIntegral::getMinValue(const Type *Ty) { unsigned TypeBits = Ty->getPrimitiveSize()*8; int64_t Val = -1; // All ones Val <<= TypeBits-1; // Shift over to the right spot - return ConstantSInt::get(Ty, Val); + return ConstantInt::get(Ty, Val); } case Type::UByteTyID: case Type::UShortTyID: case Type::UIntTyID: - case Type::ULongTyID: return ConstantUInt::get(Ty, 0); + case Type::ULongTyID: return ConstantInt::get(Ty, 0); default: return 0; } @@ -203,7 +203,7 @@ ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) { case Type::SByteTyID: case Type::ShortTyID: case Type::IntTyID: - case Type::LongTyID: return ConstantSInt::get(Ty, -1); + case Type::LongTyID: return ConstantInt::get(Ty, -1); case Type::UByteTyID: case Type::UShortTyID: @@ -213,20 +213,12 @@ ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) { unsigned TypeBits = Ty->getPrimitiveSize()*8; uint64_t Val = ~0ULL; // All ones Val >>= 64-TypeBits; // Shift out unwanted 1 bits... - return ConstantUInt::get(Ty, Val); + return ConstantInt::get(Ty, Val); } default: return 0; } } -bool ConstantUInt::isAllOnesValue() const { - unsigned TypeBits = getType()->getPrimitiveSize()*8; - uint64_t Val = ~0ULL; // All ones - Val >>= 64-TypeBits; // Shift out inappropriate bits - return getValue() == Val; -} - - //===----------------------------------------------------------------------===// // ConstantXXX Classes //===----------------------------------------------------------------------===// @@ -235,30 +227,15 @@ bool ConstantUInt::isAllOnesValue() const { // Normal Constructors ConstantIntegral::ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V) - : Constant(Ty, VT, 0, 0) { - Val.Unsigned = V; + : Constant(Ty, VT, 0, 0), Val(V) { } ConstantBool::ConstantBool(bool V) - : ConstantIntegral(Type::BoolTy, ConstantBoolVal, V) { -} - -ConstantInt::ConstantInt(const Type *Ty, ValueTy VT, uint64_t V) - : ConstantIntegral(Ty, VT, V) { -} - -ConstantSInt::ConstantSInt(const Type *Ty, int64_t V) - : ConstantInt(Ty, ConstantSIntVal, V) { - assert(Ty->isInteger() && Ty->isSigned() && - "Illegal type for signed integer constant!"); - assert(isValueValidForType(Ty, V) && "Value too large for type!"); + : ConstantIntegral(Type::BoolTy, ConstantBoolVal, uint64_t(V)) { } -ConstantUInt::ConstantUInt(const Type *Ty, uint64_t V) - : ConstantInt(Ty, ConstantUIntVal, V) { - assert(Ty->isInteger() && Ty->isUnsigned() && - "Illegal type for unsigned integer constant!"); - assert(isValueValidForType(Ty, V) && "Value too large for type!"); +ConstantInt::ConstantInt(const Type *Ty, uint64_t V) + : ConstantIntegral(Ty, ConstantIntVal, V) { } ConstantFP::ConstantFP(const Type *Ty, double V) @@ -611,36 +588,26 @@ getWithOperands(const std::vector<Constant*> &Ops) const { //===----------------------------------------------------------------------===// // isValueValidForType implementations -bool ConstantSInt::isValueValidForType(const Type *Ty, int64_t Val) { +bool ConstantInt::isValueValidForType(const Type *Ty, int64_t Val) { switch (Ty->getTypeID()) { default: return false; // These can't be represented as integers!!! // Signed types... case Type::SByteTyID: return (Val <= INT8_MAX && Val >= INT8_MIN); + case Type::UByteTyID: + return (Val >= 0) && (Val <= UINT8_MAX); case Type::ShortTyID: return (Val <= INT16_MAX && Val >= INT16_MIN); + case Type::UShortTyID: + return (Val >= 0) && (Val <= UINT16_MAX); case Type::IntTyID: return (Val <= int(INT32_MAX) && Val >= int(INT32_MIN)); - case Type::LongTyID: - return true; // This is the largest type... - } -} - -bool ConstantUInt::isValueValidForType(const Type *Ty, uint64_t Val) { - switch (Ty->getTypeID()) { - default: - return false; // These can't be represented as integers!!! - - // Unsigned types... - case Type::UByteTyID: - return (Val <= UINT8_MAX); - case Type::UShortTyID: - return (Val <= UINT16_MAX); case Type::UIntTyID: - return (Val <= UINT32_MAX); + return (Val >= 0) && (Val <= UINT32_MAX); + case Type::LongTyID: case Type::ULongTyID: - return true; // This is the largest type... + return true; // always true, has to fit in largest type } } @@ -756,8 +723,9 @@ public: ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { MapKey Lookup(Ty, V); typename MapTy::iterator I = Map.lower_bound(Lookup); + // Is it in the map? if (I != Map.end() && I->first == Lookup) - return static_cast<ConstantClass *>(I->second); // Is it in the map? + return static_cast<ConstantClass *>(I->second); // If no preexisting value, create one now... ConstantClass *Result = @@ -914,23 +882,19 @@ ConstantBool *ConstantBool::getFalse() { return F = new ConstantBool(false); } -//---- ConstantUInt::get() and ConstantSInt::get() implementations... +//---- ConstantInt::get() implementations... // -static ManagedStatic<ValueMap< int64_t, Type, ConstantSInt> > SIntConstants; -static ManagedStatic<ValueMap<uint64_t, Type, ConstantUInt> > UIntConstants; - -ConstantSInt *ConstantSInt::get(const Type *Ty, int64_t V) { - return SIntConstants->getOrCreate(Ty, V); -} - -ConstantUInt *ConstantUInt::get(const Type *Ty, uint64_t V) { - return UIntConstants->getOrCreate(Ty, V); -} +static ManagedStatic<ValueMap<uint64_t, Type, ConstantInt> > IntConstants; -ConstantInt *ConstantInt::get(const Type *Ty, unsigned char V) { - assert(V <= 127 && "Can only be used with very small positive constants!"); - if (Ty->isSigned()) return ConstantSInt::get(Ty, V); - return ConstantUInt::get(Ty, V); +// Get a ConstantInt from an int64_t. Note here that we canoncialize the value +// to a uint64_t value that has been zero extended down to the size of the +// integer type of the ConstantInt. This allows the getZExtValue method to +// just return the stored value while getSExtValue has to convert back to sign +// extended. getZExtValue is more common in LLVM than getSExtValue(). +ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { + unsigned Size = Ty->getPrimitiveSizeInBits(); + uint64_t ZeroExtendedCanonicalization = V & (~uint64_t(0UL) >> (64-Size)); + return IntConstants->getOrCreate(Ty, ZeroExtendedCanonicalization ); } //---- ConstantFP::get() implementation... @@ -1075,11 +1039,11 @@ void ConstantArray::destroyConstant() { Constant *ConstantArray::get(const std::string &Str, bool AddNull) { std::vector<Constant*> ElementVals; for (unsigned i = 0; i < Str.length(); ++i) - ElementVals.push_back(ConstantSInt::get(Type::SByteTy, Str[i])); + ElementVals.push_back(ConstantInt::get(Type::SByteTy, Str[i])); // Add a null terminator to the string... if (AddNull) { - ElementVals.push_back(ConstantSInt::get(Type::SByteTy, 0)); + ElementVals.push_back(ConstantInt::get(Type::SByteTy, 0)); } ArrayType *ATy = ArrayType::get(Type::SByteTy, ElementVals.size()); @@ -1109,7 +1073,7 @@ std::string ConstantArray::getAsString() const { assert(isString() && "Not a string!"); std::string Result; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - Result += (char)cast<ConstantInt>(getOperand(i))->getRawValue(); + Result += (char)cast<ConstantInt>(getOperand(i))->getZExtValue(); return Result; } @@ -1443,7 +1407,7 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { // pointer from array is implemented as: getelementptr arr ptr, 0, 0 - static std::vector<Constant*> Indices(2, ConstantUInt::get(Type::UIntTy, 0)); + static std::vector<Constant*> Indices(2, ConstantInt::get(Type::UIntTy, 0)); return ConstantExpr::getGetElementPtr(C, Indices); } @@ -1920,7 +1884,7 @@ std::string Constant::getStringValue(bool Chop, unsigned Offset) { if (CE->getNumOperands() == 3 && cast<Constant>(CE->getOperand(1))->isNullValue() && isa<ConstantInt>(CE->getOperand(2))) { - Offset += cast<ConstantInt>(CE->getOperand(2))->getRawValue(); + Offset += cast<ConstantInt>(CE->getOperand(2))->getZExtValue(); return CE->getOperand(0)->getStringValue(Chop, Offset); } } diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 60fce0e492..800eb9cd1d 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -513,7 +513,7 @@ void BranchInst::setSuccessorV(unsigned idx, BasicBlock *B) { static Value *getAISize(Value *Amt) { if (!Amt) - Amt = ConstantUInt::get(Type::UIntTy, 1); + Amt = ConstantInt::get(Type::UIntTy, 1); else { assert(!isa<BasicBlock>(Amt) && "Passed basic block into allocation size parameter! Ue other ctor"); @@ -546,8 +546,8 @@ AllocationInst::~AllocationInst() { } bool AllocationInst::isArrayAllocation() const { - if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(getOperand(0))) - return CUI->getValue() != 1; + if (ConstantInt *CUI = dyn_cast<ConstantInt>(getOperand(0))) + return CUI->getZExtValue() != 1; return true; } @@ -849,7 +849,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV, Instruction *InsertBef) : Instruction(cast<PackedType>(Val->getType())->getElementType(), ExtractElement, Ops, 2, Name, InsertBef) { - Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV); + Constant *Index = ConstantInt::get(Type::UIntTy, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Ops[0].init(Val, this); @@ -874,7 +874,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV, BasicBlock *InsertAE) : Instruction(cast<PackedType>(Val->getType())->getElementType(), ExtractElement, Ops, 2, Name, InsertAE) { - Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV); + Constant *Index = ConstantInt::get(Type::UIntTy, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); @@ -915,7 +915,7 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, Instruction *InsertBef) : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) { - Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV); + Constant *Index = ConstantInt::get(Type::UIntTy, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); Ops[0].init(Vec, this); @@ -940,7 +940,7 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) { - Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV); + Constant *Index = ConstantInt::get(Type::UIntTy, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index e87da1d6e0..fb8cf033e0 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -366,8 +366,8 @@ const std::string &Type::getDescription() const { bool StructType::indexValid(const Value *V) const { // Structure indexes require unsigned integer constants. if (V->getType() == Type::UIntTy) - if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V)) - return CU->getValue() < ContainedTys.size(); + if (const ConstantInt *CU = dyn_cast<ConstantInt>(V)) + return CU->getZExtValue() < ContainedTys.size(); return false; } @@ -376,7 +376,7 @@ bool StructType::indexValid(const Value *V) const { // const Type *StructType::getTypeAtIndex(const Value *V) const { assert(indexValid(V) && "Invalid structure index!"); - unsigned Idx = (unsigned)cast<ConstantUInt>(V)->getValue(); + unsigned Idx = (unsigned)cast<ConstantInt>(V)->getZExtValue(); return ContainedTys[Idx]; } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 57c09bb8c4..868fc67d51 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -586,7 +586,7 @@ void Verifier::visitShuffleVectorInst(ShuffleVectorInst &SV) { // Check to see if Mask is valid. if (const ConstantPacked *MV = dyn_cast<ConstantPacked>(SV.getOperand(2))) { for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) { - Assert1(isa<ConstantUInt>(MV->getOperand(i)) || + Assert1(isa<ConstantInt>(MV->getOperand(i)) || isa<UndefValue>(MV->getOperand(i)), "Invalid shufflevector shuffle mask!", &SV); } diff --git a/projects/Stacker/lib/compiler/StackerCompiler.cpp b/projects/Stacker/lib/compiler/StackerCompiler.cpp index a6d3995045..bae7c34c34 100644 --- a/projects/Stacker/lib/compiler/StackerCompiler.cpp +++ b/projects/Stacker/lib/compiler/StackerCompiler.cpp @@ -463,7 +463,7 @@ Instruction* StackerCompiler::push_integer(BasicBlock* bb, int64_t value ) { // Just push a constant integer value - return push_value( bb, ConstantSInt::get( Type::LongTy, value ) ); + return push_value( bb, ConstantInt::get( Type::LongTy, value ) ); } Instruction* @@ -721,7 +721,7 @@ StackerCompiler::handle_if( char* ifTrue, char* ifFalse ) // Compare the condition against 0 SetCondInst* cond_inst = new SetCondInst( Instruction::SetNE, cond, - ConstantSInt::get( Type::LongTy, 0) ); + ConstantInt::get( Type::LongTy, 0) ); bb->getInstList().push_back( cond_inst ); // Create an exit block @@ -805,7 +805,7 @@ StackerCompiler::handle_while( char* todo ) // Compare the condition against 0 SetCondInst* cond_inst = new SetCondInst( - Instruction::SetNE, cond, ConstantSInt::get( Type::LongTy, 0) ); + Instruction::SetNE, cond, ConstantInt::get( Type::LongTy, 0)); test->getInstList().push_back( cond_inst ); // Add the branch instruction @@ -1019,7 +1019,7 @@ StackerCompiler::handle_word( int tkn ) if (echo) bb->setName("DECR"); LoadInst* op1 = cast<LoadInst>(pop_integer(bb)); BinaryOperator* subop = BinaryOperator::create( Instruction::Sub, op1, - ConstantSInt::get( Type::LongTy, 1 ) ); + ConstantInt::get( Type::LongTy, 1 ) ); bb->getInstList().push_back( subop ); push_value( bb, subop ); break; @@ -1089,7 +1089,7 @@ StackerCompiler::handle_word( int tkn ) // bb->getInstList().push_back( negop ); // So we'll multiply by -1 (ugh) BinaryOperator* multop = BinaryOperator::create( Instruction::Mul, op1, - ConstantSInt::get( Type::LongTy, -1 ) ); + ConstantInt::get( Type::LongTy, -1 ) ); bb->getInstList().push_back( multop ); push_value( bb, multop ); break; @@ -1601,7 +1601,7 @@ StackerCompiler::handle_word( int tkn ) bb->getInstList().push_back( format_gep ); // Get the character to print (a tab) - ConstantSInt* newline = ConstantSInt::get(Type::IntTy, + ConstantInt* newline = ConstantInt::get(Type::IntTy, static_cast<int>('\t')); // Call printf @@ -1623,7 +1623,7 @@ StackerCompiler::handle_word( int tkn ) bb->getInstList().push_back( format_gep ); // Get the character to print (a space) - ConstantSInt* newline = ConstantSInt::get(Type::IntTy, + ConstantInt* newline = ConstantInt::get(Type::IntTy, static_cast<int>(' ')); // Call printf @@ -1645,7 +1645,7 @@ StackerCompiler::handle_word( int tkn ) bb->getInstList().push_back( format_gep ); // Get the character to print (a newline) - ConstantSInt* newline = ConstantSInt::get(Type::IntTy, + ConstantInt* newline = ConstantInt::get(Type::IntTy, static_cast<int>('\n')); // Call printf diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 756ef8b50d..c642dd0765 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -181,7 +181,7 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) { std::vector<Constant*> ArrayElts; for (unsigned i = 0, e = TorList.size(); i != e; ++i) { std::vector<Constant*> Elts; - Elts.push_back(ConstantSInt::get(Type::IntTy, TorList[i].second)); + Elts.push_back(ConstantInt::get(Type::IntTy, TorList[i].second)); Elts.push_back(TorList[i].first); ArrayElts.push_back(ConstantStruct::get(Elts)); } @@ -210,8 +210,8 @@ static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){ if (CS->getOperand(1)->isNullValue()) break; // Found a null terminator, stop here. - ConstantSInt *CI = dyn_cast<ConstantSInt>(CS->getOperand(0)); - int Priority = CI ? CI->getValue() : 0; + ConstantInt *CI = dyn_cast<ConstantInt>(CS->getOperand(0)); + int Priority = CI ? CI->getSExtValue() : 0; Constant *FP = CS->getOperand(1); if (ConstantExpr *CE = dyn_cast<ConstantExpr>(FP)) diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index 85c1ec7853..e69c722027 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -678,12 +678,11 @@ void CppWriter::printConstant(const Constant *CV) { if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { Out << "ConstantBool* " << constName << " = ConstantBool::get(" << (CB->getValue() ? "true" : "false") << ");"; - } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) { - Out << "ConstantSInt* " << constName << " = ConstantSInt::get(" - << typeName << ", " << CI->getValue() << ");"; - } else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) { - Out << "ConstantUInt* " << constName << " = ConstantUInt::get(" - << typeName << ", " << CI->getValue() << ");"; + } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + Out << "ConstantInt* " << constName << " = ConstantInt::get(" + << typeName << ", " + << (CV->getType()->isSigned() ? CI->getSExtValue() : CI->getZExtValue()) + << ");"; } else if (isa<ConstantAggregateZero>(CV)) { Out << "ConstantAggregateZero* " << constName << " = ConstantAggregateZero::get(" << typeName << ");"; |