mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-05 01:31:05 +00:00
For PR950:
This patch implements the first increment for the Signless Types feature. All changes pertain to removing the ConstantSInt and ConstantUInt classes in favor of just using ConstantInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6e7dd9db6b
commit
b83eb6447b
@ -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.
|
||||
|
@ -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>
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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; }
|
||||
/// @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;
|
||||
}
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// 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; }
|
||||
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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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])) {
|
||||
|
@ -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();
|
||||
|
@ -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()) ||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 ";
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 *Add(const ConstantInt *V1, const ConstantInt *V2) {
|
||||
BuiltinType R = (BuiltinType)V1->getZExtValue() +
|
||||
(BuiltinType)V2->getZExtValue();
|
||||
return ConstantInt::get(*Ty, R);
|
||||
}
|
||||
|
||||
static Constant *Sub(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 *Mul(const ConstantClass *V1, const ConstantClass *V2) {
|
||||
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 *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 *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());
|
||||
|
@ -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) {
|
||||
: ConstantIntegral(Type::BoolTy, ConstantBoolVal, uint64_t(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!");
|
||||
}
|
||||
|
||||
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;
|
||||
static ManagedStatic<ValueMap<uint64_t, Type, ConstantInt> > IntConstants;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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!");
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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 << ");";
|
||||
|
Loading…
x
Reference in New Issue
Block a user