mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
For PR950:
Change signed integer type names to unsigned equivalents. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c2e86a8d0
commit
79e21d338c
@ -87,7 +87,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 = ConstantInt::get(Type::ULongTy, V);
|
||||
Constant *C = ConstantInt::get(Type::Int64Ty, V);
|
||||
Result.push_back(ConstantExpr::getBitCast(C, DstEltTy ));
|
||||
}
|
||||
return ConstantPacked::get(Result);
|
||||
@ -96,7 +96,7 @@ static Constant *CastConstantPacked(ConstantPacked *CP,
|
||||
assert(SrcEltTy->getTypeID() == Type::FloatTyID);
|
||||
for (unsigned i = 0; i != SrcNumElts; ++i) {
|
||||
uint32_t V = FloatToBits(cast<ConstantFP>(CP->getOperand(i))->getValue());
|
||||
Constant *C = ConstantInt::get(Type::UIntTy, V);
|
||||
Constant *C = ConstantInt::get(Type::Int32Ty, V);
|
||||
Result.push_back(ConstantExpr::getBitCast(C, DstEltTy));
|
||||
}
|
||||
return ConstantPacked::get(Result);
|
||||
@ -132,7 +132,7 @@ foldConstantCastPair(
|
||||
|
||||
// Let CastInst::isEliminableCastPair do the heavy lifting.
|
||||
return CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy, DstTy,
|
||||
Type::ULongTy);
|
||||
Type::Int64Ty);
|
||||
}
|
||||
|
||||
Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
@ -217,13 +217,13 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
if (const PointerType *PTy = dyn_cast<PointerType>(V->getType()))
|
||||
if (const PointerType *DPTy = dyn_cast<PointerType>(DestTy)) {
|
||||
std::vector<Value*> IdxList;
|
||||
IdxList.push_back(Constant::getNullValue(Type::IntTy));
|
||||
IdxList.push_back(Constant::getNullValue(Type::Int32Ty));
|
||||
const Type *ElTy = PTy->getElementType();
|
||||
while (ElTy != DPTy->getElementType()) {
|
||||
if (const StructType *STy = dyn_cast<StructType>(ElTy)) {
|
||||
if (STy->getNumElements() == 0) break;
|
||||
ElTy = STy->getElementType(0);
|
||||
IdxList.push_back(Constant::getNullValue(Type::UIntTy));
|
||||
IdxList.push_back(Constant::getNullValue(Type::Int32Ty));
|
||||
} else if (const SequentialType *STy =
|
||||
dyn_cast<SequentialType>(ElTy)) {
|
||||
if (isa<PointerType>(ElTy)) break; // Can't index into pointers!
|
||||
@ -296,10 +296,10 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
|
||||
// FP -> Integral.
|
||||
if (DestTy->isIntegral()) {
|
||||
if (DestTy == Type::IntTy || DestTy == Type::UIntTy)
|
||||
if (DestTy == Type::Int32Ty)
|
||||
return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
|
||||
assert((DestTy == Type::LongTy || DestTy == Type::ULongTy)
|
||||
&& "Incorrect integer type for bitcast!");
|
||||
assert(DestTy == Type::Int64Ty &&
|
||||
"Incorrect integer type for bitcast!");
|
||||
return ConstantInt::get(DestTy, DoubleToBits(FP->getValue()));
|
||||
}
|
||||
}
|
||||
@ -712,16 +712,13 @@ static int IdxCompare(Constant *C1, Constant *C2, const Type *ElTy) {
|
||||
|
||||
// Ok, we have two differing integer indices. Sign extend them to be the same
|
||||
// type. Long is always big enough, so we use it.
|
||||
if (C1->getType() != Type::LongTy && C1->getType() != Type::ULongTy)
|
||||
C1 = ConstantExpr::getSExt(C1, Type::LongTy);
|
||||
else
|
||||
C1 = ConstantExpr::getBitCast(C1, Type::LongTy);
|
||||
if (C2->getType() != Type::LongTy && C1->getType() != Type::ULongTy)
|
||||
C2 = ConstantExpr::getSExt(C2, Type::LongTy);
|
||||
else
|
||||
C2 = ConstantExpr::getBitCast(C2, Type::LongTy);
|
||||
if (C1->getType() != Type::Int64Ty)
|
||||
C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
|
||||
|
||||
if (C1 == C2) return 0; // Are they just differing types?
|
||||
if (C2->getType() != Type::Int64Ty)
|
||||
C1 = ConstantExpr::getSExt(C2, Type::Int64Ty);
|
||||
|
||||
if (C1 == C2) return 0; // They are equal
|
||||
|
||||
// If the type being indexed over is really just a zero sized type, there is
|
||||
// no pointer difference being made here.
|
||||
@ -1324,7 +1321,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C,
|
||||
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 = ConstantInt::get(Type::UIntTy, ElSize);
|
||||
Constant *R = ConstantInt::get(Type::Int32Ty, ElSize);
|
||||
// We know R is unsigned, Idx0 is signed because it must be an index
|
||||
// through a sequential type (gep pointer operand) which is always
|
||||
// signed.
|
||||
@ -1360,9 +1357,9 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C,
|
||||
if (!Idx0->isNullValue()) {
|
||||
const Type *IdxTy = Combined->getType();
|
||||
if (IdxTy != Idx0->getType()) {
|
||||
Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::LongTy);
|
||||
Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty);
|
||||
Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined,
|
||||
Type::LongTy);
|
||||
Type::Int64Ty);
|
||||
Combined = ConstantExpr::get(Instruction::Add, C1, C2);
|
||||
} else {
|
||||
Combined =
|
||||
|
@ -96,39 +96,22 @@ Constant *Constant::getNullValue(const Type *Ty) {
|
||||
static Constant *NullBool = ConstantBool::get(false);
|
||||
return NullBool;
|
||||
}
|
||||
case Type::SByteTyID: {
|
||||
static Constant *NullSByte = ConstantInt::get(Type::SByteTy, 0);
|
||||
return NullSByte;
|
||||
case Type::Int8TyID: {
|
||||
static Constant *NullInt8 = ConstantInt::get(Type::Int8Ty, 0);
|
||||
return NullInt8;
|
||||
}
|
||||
case Type::UByteTyID: {
|
||||
static Constant *NullUByte = ConstantInt::get(Type::UByteTy, 0);
|
||||
return NullUByte;
|
||||
case Type::Int16TyID: {
|
||||
static Constant *NullInt16 = ConstantInt::get(Type::Int16Ty, 0);
|
||||
return NullInt16;
|
||||
}
|
||||
case Type::ShortTyID: {
|
||||
static Constant *NullShort = ConstantInt::get(Type::ShortTy, 0);
|
||||
return NullShort;
|
||||
case Type::Int32TyID: {
|
||||
static Constant *NullInt32 = ConstantInt::get(Type::Int32Ty, 0);
|
||||
return NullInt32;
|
||||
}
|
||||
case Type::UShortTyID: {
|
||||
static Constant *NullUShort = ConstantInt::get(Type::UShortTy, 0);
|
||||
return NullUShort;
|
||||
case Type::Int64TyID: {
|
||||
static Constant *NullInt64 = ConstantInt::get(Type::Int64Ty, 0);
|
||||
return NullInt64;
|
||||
}
|
||||
case Type::IntTyID: {
|
||||
static Constant *NullInt = ConstantInt::get(Type::IntTy, 0);
|
||||
return NullInt;
|
||||
}
|
||||
case Type::UIntTyID: {
|
||||
static Constant *NullUInt = ConstantInt::get(Type::UIntTy, 0);
|
||||
return NullUInt;
|
||||
}
|
||||
case Type::LongTyID: {
|
||||
static Constant *NullLong = ConstantInt::get(Type::LongTy, 0);
|
||||
return NullLong;
|
||||
}
|
||||
case Type::ULongTyID: {
|
||||
static Constant *NullULong = ConstantInt::get(Type::ULongTy, 0);
|
||||
return NullULong;
|
||||
}
|
||||
|
||||
case Type::FloatTyID: {
|
||||
static Constant *NullFloat = ConstantFP::get(Type::FloatTy, 0);
|
||||
return NullFloat;
|
||||
@ -137,10 +120,8 @@ Constant *Constant::getNullValue(const Type *Ty) {
|
||||
static Constant *NullDouble = ConstantFP::get(Type::DoubleTy, 0);
|
||||
return NullDouble;
|
||||
}
|
||||
|
||||
case Type::PointerTyID:
|
||||
return ConstantPointerNull::get(cast<PointerType>(Ty));
|
||||
|
||||
case Type::StructTyID:
|
||||
case Type::ArrayTyID:
|
||||
case Type::PackedTyID:
|
||||
@ -157,21 +138,10 @@ Constant *Constant::getNullValue(const Type *Ty) {
|
||||
ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) {
|
||||
switch (Ty->getTypeID()) {
|
||||
case Type::BoolTyID: return ConstantBool::getTrue();
|
||||
case Type::SByteTyID:
|
||||
case Type::ShortTyID:
|
||||
case Type::IntTyID:
|
||||
case Type::LongTyID: return ConstantInt::get(Ty, -1);
|
||||
|
||||
case Type::UByteTyID:
|
||||
case Type::UShortTyID:
|
||||
case Type::UIntTyID:
|
||||
case Type::ULongTyID: {
|
||||
// Calculate ~0 of the right type...
|
||||
unsigned TypeBits = Ty->getPrimitiveSize()*8;
|
||||
uint64_t Val = ~0ULL; // All ones
|
||||
Val >>= 64-TypeBits; // Shift out unwanted 1 bits...
|
||||
return ConstantInt::get(Ty, Val);
|
||||
}
|
||||
case Type::Int8TyID:
|
||||
case Type::Int16TyID:
|
||||
case Type::Int32TyID:
|
||||
case Type::Int64TyID: return ConstantInt::get(Ty, int64_t(-1));
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
@ -573,28 +543,20 @@ getWithOperands(const std::vector<Constant*> &Ops) const {
|
||||
bool ConstantInt::isValueValidForType(const Type *Ty, uint64_t Val) {
|
||||
switch (Ty->getTypeID()) {
|
||||
default: return false; // These can't be represented as integers!
|
||||
case Type::SByteTyID:
|
||||
case Type::UByteTyID: return Val <= UINT8_MAX;
|
||||
case Type::ShortTyID:
|
||||
case Type::UShortTyID:return Val <= UINT16_MAX;
|
||||
case Type::IntTyID:
|
||||
case Type::UIntTyID: return Val <= UINT32_MAX;
|
||||
case Type::LongTyID:
|
||||
case Type::ULongTyID: return true; // always true, has to fit in largest type
|
||||
case Type::Int8TyID: return Val <= UINT8_MAX;
|
||||
case Type::Int16TyID: return Val <= UINT16_MAX;
|
||||
case Type::Int32TyID: return Val <= UINT32_MAX;
|
||||
case Type::Int64TyID: return true; // always true, has to fit in largest type
|
||||
}
|
||||
}
|
||||
|
||||
bool ConstantInt::isValueValidForType(const Type *Ty, int64_t Val) {
|
||||
switch (Ty->getTypeID()) {
|
||||
default: return false; // These can't be represented as integers!
|
||||
case Type::SByteTyID:
|
||||
case Type::UByteTyID: return (Val >= INT8_MIN && Val <= INT8_MAX);
|
||||
case Type::ShortTyID:
|
||||
case Type::UShortTyID:return (Val >= INT16_MIN && Val <= UINT16_MAX);
|
||||
case Type::IntTyID:
|
||||
case Type::UIntTyID: return (Val >= INT32_MIN && Val <= UINT32_MAX);
|
||||
case Type::LongTyID:
|
||||
case Type::ULongTyID: return true; // always true, has to fit in largest type
|
||||
case Type::Int8TyID: return (Val >= INT8_MIN && Val <= INT8_MAX);
|
||||
case Type::Int16TyID: return (Val >= INT16_MIN && Val <= UINT16_MAX);
|
||||
case Type::Int32TyID: return (Val >= INT32_MIN && Val <= UINT32_MAX);
|
||||
case Type::Int64TyID: return true; // always true, has to fit in largest type
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,14 +991,14 @@ 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(ConstantInt::get(Type::SByteTy, Str[i]));
|
||||
ElementVals.push_back(ConstantInt::get(Type::Int8Ty, Str[i]));
|
||||
|
||||
// Add a null terminator to the string...
|
||||
if (AddNull) {
|
||||
ElementVals.push_back(ConstantInt::get(Type::SByteTy, 0));
|
||||
ElementVals.push_back(ConstantInt::get(Type::Int8Ty, 0));
|
||||
}
|
||||
|
||||
ArrayType *ATy = ArrayType::get(Type::SByteTy, ElementVals.size());
|
||||
ArrayType *ATy = ArrayType::get(Type::Int8Ty, ElementVals.size());
|
||||
return ConstantArray::get(ATy, ElementVals);
|
||||
}
|
||||
|
||||
@ -1044,8 +1006,7 @@ Constant *ConstantArray::get(const std::string &Str, bool AddNull) {
|
||||
/// ubyte, and if the elements of the array are all ConstantInt's.
|
||||
bool ConstantArray::isString() const {
|
||||
// Check the element type for sbyte or ubyte...
|
||||
if (getType()->getElementType() != Type::UByteTy &&
|
||||
getType()->getElementType() != Type::SByteTy)
|
||||
if (getType()->getElementType() != Type::Int8Ty)
|
||||
return false;
|
||||
// Check the elements to make sure they are all integers, not constant
|
||||
// expressions.
|
||||
@ -1060,8 +1021,7 @@ bool ConstantArray::isString() const {
|
||||
/// null bytes except its terminator.
|
||||
bool ConstantArray::isCString() const {
|
||||
// Check the element type for sbyte or ubyte...
|
||||
if (getType()->getElementType() != Type::UByteTy &&
|
||||
getType()->getElementType() != Type::SByteTy)
|
||||
if (getType()->getElementType() != Type::Int8Ty)
|
||||
return false;
|
||||
Constant *Zero = Constant::getNullValue(getOperand(0)->getType());
|
||||
// Last element must be a null.
|
||||
@ -1292,6 +1252,7 @@ void UndefValue::destroyConstant() {
|
||||
|
||||
//---- ConstantExpr::get() implementations...
|
||||
//
|
||||
|
||||
struct ExprMapKeyType {
|
||||
explicit ExprMapKeyType(unsigned opc, std::vector<Constant*> ops,
|
||||
unsigned short pred = 0) : opcode(opc), predicate(pred), operands(ops) { }
|
||||
@ -1612,12 +1573,12 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) {
|
||||
// sizeof is implemented as: (ulong) gep (Ty*)null, 1
|
||||
return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue(
|
||||
PointerType::get(Ty)), std::vector<Constant*>(1,
|
||||
ConstantInt::get(Type::UIntTy, 1))), Type::ULongTy);
|
||||
ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty);
|
||||
}
|
||||
|
||||
Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) {
|
||||
// pointer from array is implemented as: getelementptr arr ptr, 0, 0
|
||||
static std::vector<Constant*> Indices(2, ConstantInt::get(Type::UIntTy, 0));
|
||||
static std::vector<Constant*> Indices(2, ConstantInt::get(Type::Int32Ty, 0));
|
||||
|
||||
return ConstantExpr::getGetElementPtr(C, Indices);
|
||||
}
|
||||
@ -1710,7 +1671,7 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
|
||||
case Instruction::Shl:
|
||||
case Instruction::LShr:
|
||||
case Instruction::AShr:
|
||||
assert(C2->getType() == Type::UByteTy && "Shift should be by ubyte!");
|
||||
assert(C2->getType() == Type::Int8Ty && "Shift should be by ubyte!");
|
||||
assert(C1->getType()->isInteger() &&
|
||||
"Tried to create a shift operation on a non-integer type!");
|
||||
break;
|
||||
@ -1753,7 +1714,7 @@ Constant *ConstantExpr::getShiftTy(const Type *ReqTy, unsigned Opcode,
|
||||
Opcode == Instruction::LShr ||
|
||||
Opcode == Instruction::AShr) &&
|
||||
"Invalid opcode in binary constant expression");
|
||||
assert(C1->getType()->isIntegral() && C2->getType() == Type::UByteTy &&
|
||||
assert(C1->getType()->isIntegral() && C2->getType() == Type::Int8Ty &&
|
||||
"Invalid operand types for Shift constant expr!");
|
||||
|
||||
if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2))
|
||||
@ -1854,7 +1815,7 @@ Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val,
|
||||
Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) {
|
||||
assert(isa<PackedType>(Val->getType()) &&
|
||||
"Tried to create extractelement operation on non-packed type!");
|
||||
assert(Idx->getType() == Type::UIntTy &&
|
||||
assert(Idx->getType() == Type::Int32Ty &&
|
||||
"Extractelement index must be uint type!");
|
||||
return getExtractElementTy(cast<PackedType>(Val->getType())->getElementType(),
|
||||
Val, Idx);
|
||||
@ -1878,7 +1839,7 @@ Constant *ConstantExpr::getInsertElement(Constant *Val, Constant *Elt,
|
||||
"Tried to create insertelement operation on non-packed type!");
|
||||
assert(Elt->getType() == cast<PackedType>(Val->getType())->getElementType()
|
||||
&& "Insertelement types must match!");
|
||||
assert(Idx->getType() == Type::UIntTy &&
|
||||
assert(Idx->getType() == Type::Int32Ty &&
|
||||
"Insertelement index must be uint type!");
|
||||
return getInsertElementTy(cast<PackedType>(Val->getType())->getElementType(),
|
||||
Val, Elt, Idx);
|
||||
|
@ -32,7 +32,7 @@ iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
|
||||
}
|
||||
|
||||
Argument *ilist_traits<Argument>::createSentinel() {
|
||||
Argument *Ret = new Argument(Type::IntTy);
|
||||
Argument *Ret = new Argument(Type::Int32Ty);
|
||||
// This should not be garbage monitored.
|
||||
LeakDetector::removeGarbageObject(Ret);
|
||||
return Ret;
|
||||
|
@ -513,11 +513,11 @@ void BranchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
|
||||
|
||||
static Value *getAISize(Value *Amt) {
|
||||
if (!Amt)
|
||||
Amt = ConstantInt::get(Type::UIntTy, 1);
|
||||
Amt = ConstantInt::get(Type::Int32Ty, 1);
|
||||
else {
|
||||
assert(!isa<BasicBlock>(Amt) &&
|
||||
"Passed basic block into allocation size parameter! Ue other ctor");
|
||||
assert(Amt->getType() == Type::UIntTy &&
|
||||
assert(Amt->getType() == Type::Int32Ty &&
|
||||
"Malloc/Allocation array size != UIntTy!");
|
||||
}
|
||||
return Amt;
|
||||
@ -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 = ConstantInt::get(Type::UIntTy, IndexV);
|
||||
Constant *Index = ConstantInt::get(Type::Int32Ty, 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 = ConstantInt::get(Type::UIntTy, IndexV);
|
||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||
assert(isValidOperands(Val, Index) &&
|
||||
"Invalid extractelement instruction operands!");
|
||||
|
||||
@ -884,7 +884,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
|
||||
|
||||
|
||||
bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
|
||||
if (!isa<PackedType>(Val->getType()) || Index->getType() != Type::UIntTy)
|
||||
if (!isa<PackedType>(Val->getType()) || Index->getType() != Type::Int32Ty)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -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 = ConstantInt::get(Type::UIntTy, IndexV);
|
||||
Constant *Index = ConstantInt::get(Type::Int32Ty, 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 = ConstantInt::get(Type::UIntTy, IndexV);
|
||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||
assert(isValidOperands(Vec, Elt, Index) &&
|
||||
"Invalid insertelement instruction operands!");
|
||||
|
||||
@ -957,7 +957,7 @@ bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt,
|
||||
if (Elt->getType() != cast<PackedType>(Vec->getType())->getElementType())
|
||||
return false;// Second operand of insertelement must be packed element type.
|
||||
|
||||
if (Index->getType() != Type::UIntTy)
|
||||
if (Index->getType() != Type::Int32Ty)
|
||||
return false; // Third operand of insertelement must be uint.
|
||||
return true;
|
||||
}
|
||||
@ -1002,7 +1002,7 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||
if (!isa<PackedType>(V1->getType())) return false;
|
||||
if (V1->getType() != V2->getType()) return false;
|
||||
if (!isa<PackedType>(Mask->getType()) ||
|
||||
cast<PackedType>(Mask->getType())->getElementType() != Type::UIntTy ||
|
||||
cast<PackedType>(Mask->getType())->getElementType() != Type::Int32Ty ||
|
||||
cast<PackedType>(Mask->getType())->getNumElements() !=
|
||||
cast<PackedType>(V1->getType())->getNumElements())
|
||||
return false;
|
||||
@ -1233,23 +1233,9 @@ bool CastInst::isLosslessCast() const {
|
||||
if (SrcTy == DstTy)
|
||||
return true;
|
||||
|
||||
// The remaining possibilities are lossless if the typeID of the source type
|
||||
// matches the type ID of the destination in size and fundamental type. This
|
||||
// prevents things like int -> ptr, int -> float, packed -> int, mismatched
|
||||
// packed types of the same size, and etc.
|
||||
switch (SrcTy->getTypeID()) {
|
||||
case Type::UByteTyID: return DstTy == Type::SByteTy;
|
||||
case Type::SByteTyID: return DstTy == Type::UByteTy;
|
||||
case Type::UShortTyID: return DstTy == Type::ShortTy;
|
||||
case Type::ShortTyID: return DstTy == Type::UShortTy;
|
||||
case Type::UIntTyID: return DstTy == Type::IntTy;
|
||||
case Type::IntTyID: return DstTy == Type::UIntTy;
|
||||
case Type::ULongTyID: return DstTy == Type::LongTy;
|
||||
case Type::LongTyID: return DstTy == Type::ULongTy;
|
||||
case Type::PointerTyID: return isa<PointerType>(DstTy);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Pointer to pointer is always lossless.
|
||||
if (isa<PointerType>(SrcTy))
|
||||
return isa<PointerType>(DstTy);
|
||||
return false; // Other types have no identity values
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,15 @@ using namespace llvm;
|
||||
|
||||
Function *ilist_traits<Function>::createSentinel() {
|
||||
FunctionType *FTy =
|
||||
FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
|
||||
FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false,
|
||||
std::vector<FunctionType::ParameterAttributes>() );
|
||||
Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage);
|
||||
// This should not be garbage monitored.
|
||||
LeakDetector::removeGarbageObject(Ret);
|
||||
return Ret;
|
||||
}
|
||||
GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
|
||||
GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false,
|
||||
GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false,
|
||||
GlobalValue::ExternalLinkage);
|
||||
// This should not be garbage monitored.
|
||||
LeakDetector::removeGarbageObject(Ret);
|
||||
@ -206,7 +207,7 @@ Function *Module::getMainFunction() {
|
||||
std::vector<const Type*> Params;
|
||||
|
||||
// int main(void)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::IntTy,
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
@ -215,10 +216,10 @@ Function *Module::getMainFunction() {
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
Params.push_back(Type::IntTy);
|
||||
Params.push_back(Type::Int32Ty);
|
||||
|
||||
// int main(int argc)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::IntTy,
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
@ -228,10 +229,10 @@ Function *Module::getMainFunction() {
|
||||
return F;
|
||||
|
||||
for (unsigned i = 0; i != 2; ++i) { // Check argv and envp
|
||||
Params.push_back(PointerType::get(PointerType::get(Type::SByteTy)));
|
||||
Params.push_back(PointerType::get(PointerType::get(Type::Int8Ty)));
|
||||
|
||||
// int main(int argc, char **argv)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::IntTy,
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
|
@ -88,10 +88,10 @@ const Type *MVT::getTypeForValueType(MVT::ValueType VT) {
|
||||
default: assert(0 && "ValueType does not correspond to LLVM type!");
|
||||
case MVT::isVoid:return Type::VoidTy;
|
||||
case MVT::i1: return Type::BoolTy;
|
||||
case MVT::i8: return Type::UByteTy;
|
||||
case MVT::i16: return Type::UShortTy;
|
||||
case MVT::i32: return Type::UIntTy;
|
||||
case MVT::i64: return Type::ULongTy;
|
||||
case MVT::i8: return Type::Int8Ty;
|
||||
case MVT::i16: return Type::Int16Ty;
|
||||
case MVT::i32: return Type::Int32Ty;
|
||||
case MVT::i64: return Type::Int64Ty;
|
||||
case MVT::f32: return Type::FloatTy;
|
||||
case MVT::f64: return Type::DoubleTy;
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ void Verifier::visitShiftInst(ShiftInst &SI) {
|
||||
"Shift must return an integer result!", &SI);
|
||||
Assert1(SI.getType() == SI.getOperand(0)->getType(),
|
||||
"Shift return type must be same as first operand!", &SI);
|
||||
Assert1(SI.getOperand(1)->getType() == Type::UByteTy,
|
||||
Assert1(SI.getOperand(1)->getType() == Type::Int8Ty,
|
||||
"Second operand to shift must be ubyte type!", &SI);
|
||||
visitInstruction(SI);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user