mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Adjust to the changed StructType interface. In particular, getElementTypes() is gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -241,7 +241,7 @@ namespace {
|
|||||||
StackState &SS = Stack.back();
|
StackState &SS = Stack.back();
|
||||||
if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
|
if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
|
||||||
++SS.Idx;
|
++SS.Idx;
|
||||||
if (SS.Idx != ST->getElementTypes().size()) {
|
if (SS.Idx != ST->getNumElements()) {
|
||||||
const StructLayout *SL = TD.getStructLayout(ST);
|
const StructLayout *SL = TD.getStructLayout(ST);
|
||||||
SS.Offset += SL->MemberOffsets[SS.Idx]-SL->MemberOffsets[SS.Idx-1];
|
SS.Offset += SL->MemberOffsets[SS.Idx]-SL->MemberOffsets[SS.Idx-1];
|
||||||
return;
|
return;
|
||||||
@ -266,14 +266,14 @@ namespace {
|
|||||||
while (!Stack.empty() && !Stack.back().Ty->isFirstClassType()) {
|
while (!Stack.empty() && !Stack.back().Ty->isFirstClassType()) {
|
||||||
StackState &SS = Stack.back();
|
StackState &SS = Stack.back();
|
||||||
if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
|
if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
|
||||||
if (ST->getElementTypes().empty()) {
|
if (ST->getNumElements() == 0) {
|
||||||
assert(SS.Idx == 0);
|
assert(SS.Idx == 0);
|
||||||
PopStackAndAdvance();
|
PopStackAndAdvance();
|
||||||
} else {
|
} else {
|
||||||
// Step into the structure...
|
// Step into the structure...
|
||||||
assert(SS.Idx < ST->getElementTypes().size());
|
assert(SS.Idx < ST->getNumElements());
|
||||||
const StructLayout *SL = TD.getStructLayout(ST);
|
const StructLayout *SL = TD.getStructLayout(ST);
|
||||||
Stack.push_back(StackState(ST->getElementTypes()[SS.Idx],
|
Stack.push_back(StackState(ST->getElementType(SS.Idx),
|
||||||
SS.Offset+SL->MemberOffsets[SS.Idx]));
|
SS.Offset+SL->MemberOffsets[SS.Idx]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -443,7 +443,7 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
|
|||||||
/* empty */;
|
/* empty */;
|
||||||
|
|
||||||
// The offset we are looking for must be in the i'th element...
|
// The offset we are looking for must be in the i'th element...
|
||||||
SubType = STy->getElementTypes()[i];
|
SubType = STy->getElementType(i);
|
||||||
O += SL.MemberOffsets[i];
|
O += SL.MemberOffsets[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
|
|||||||
NextPadSize = SL.MemberOffsets[1];
|
NextPadSize = SL.MemberOffsets[1];
|
||||||
else
|
else
|
||||||
NextPadSize = SubTypeSize;
|
NextPadSize = SubTypeSize;
|
||||||
NextSubType = STy->getElementTypes()[0];
|
NextSubType = STy->getElementType(0);
|
||||||
NextSubTypeSize = TD.getTypeSize(NextSubType);
|
NextSubTypeSize = TD.getTypeSize(NextSubType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1085,9 +1085,9 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
|
|||||||
|
|
||||||
// Check to ensure that constants are compatible with the type initializer!
|
// Check to ensure that constants are compatible with the type initializer!
|
||||||
for (unsigned i = 0, e = $3->size(); i != e; ++i)
|
for (unsigned i = 0, e = $3->size(); i != e; ++i)
|
||||||
if ((*$3)[i]->getType() != STy->getElementTypes()[i])
|
if ((*$3)[i]->getType() != STy->getElementType(i))
|
||||||
ThrowException("Expected type '" +
|
ThrowException("Expected type '" +
|
||||||
STy->getElementTypes()[i]->getDescription() +
|
STy->getElementType(i)->getDescription() +
|
||||||
"' for element #" + utostr(i) +
|
"' for element #" + utostr(i) +
|
||||||
" of structure initializer!");
|
" of structure initializer!");
|
||||||
|
|
||||||
|
@ -233,12 +233,12 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
|
|||||||
|
|
||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
const StructType *ST = cast<StructType>(Ty);
|
const StructType *ST = cast<StructType>(Ty);
|
||||||
const StructType::ElementTypes &ET = ST->getElementTypes();
|
|
||||||
|
|
||||||
std::vector<Constant *> Elements;
|
std::vector<Constant *> Elements;
|
||||||
Elements.reserve(ET.size());
|
Elements.reserve(ST->getNumElements());
|
||||||
for (unsigned i = 0; i != ET.size(); ++i)
|
for (unsigned i = 0; i != ST->getNumElements(); ++i)
|
||||||
Elements.push_back(getConstantValue(ET[i], read_vbr_uint(Buf, EndBuf)));
|
Elements.push_back(getConstantValue(ST->getElementType(i),
|
||||||
|
read_vbr_uint(Buf, EndBuf)));
|
||||||
|
|
||||||
return ConstantStruct::get(ST, Elements);
|
return ConstantStruct::get(ST, Elements);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ void BytecodeWriter::outputType(const Type *T) {
|
|||||||
const StructType *ST = cast<StructType>(T);
|
const StructType *ST = cast<StructType>(T);
|
||||||
|
|
||||||
// Output all of the element types...
|
// Output all of the element types...
|
||||||
StructType::ElementTypes::const_iterator I = ST->getElementTypes().begin();
|
for (StructType::element_iterator I = ST->element_begin(),
|
||||||
for (; I != ST->getElementTypes().end(); ++I) {
|
E = ST->element_end(); I != E; ++I) {
|
||||||
int Slot = Table.getSlot(*I);
|
int Slot = Table.getSlot(*I);
|
||||||
assert(Slot != -1 && "Type used but not available!!");
|
assert(Slot != -1 && "Type used but not available!!");
|
||||||
output_vbr((unsigned)Slot, Out);
|
output_vbr((unsigned)Slot, Out);
|
||||||
|
@ -222,9 +222,8 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
|
|||||||
const StructType *STy = cast<StructType>(Ty);
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
Out << NameSoFar + " {\n";
|
Out << NameSoFar + " {\n";
|
||||||
unsigned Idx = 0;
|
unsigned Idx = 0;
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printType(Out, *I, "field" + utostr(Idx++));
|
printType(Out, *I, "field" + utostr(Idx++));
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
@ -888,9 +887,8 @@ void CWriter::printContainedStructs(const Type *Ty,
|
|||||||
//Check to see if we have already printed this struct
|
//Check to see if we have already printed this struct
|
||||||
if (StructPrinted.count(STy) == 0) {
|
if (StructPrinted.count(STy) == 0) {
|
||||||
// Print all contained types first...
|
// Print all contained types first...
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
|
||||||
const Type *Ty1 = I->get();
|
const Type *Ty1 = I->get();
|
||||||
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
|
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
|
||||||
printContainedStructs(*I, StructPrinted);
|
printContainedStructs(*I, StructPrinted);
|
||||||
|
@ -222,9 +222,8 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
|
|||||||
const StructType *STy = cast<StructType>(Ty);
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
Out << NameSoFar + " {\n";
|
Out << NameSoFar + " {\n";
|
||||||
unsigned Idx = 0;
|
unsigned Idx = 0;
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printType(Out, *I, "field" + utostr(Idx++));
|
printType(Out, *I, "field" + utostr(Idx++));
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
@ -888,9 +887,8 @@ void CWriter::printContainedStructs(const Type *Ty,
|
|||||||
//Check to see if we have already printed this struct
|
//Check to see if we have already printed this struct
|
||||||
if (StructPrinted.count(STy) == 0) {
|
if (StructPrinted.count(STy) == 0) {
|
||||||
// Print all contained types first...
|
// Print all contained types first...
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
|
||||||
const Type *Ty1 = I->get();
|
const Type *Ty1 = I->get();
|
||||||
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
|
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
|
||||||
printContainedStructs(*I, StructPrinted);
|
printContainedStructs(*I, StructPrinted);
|
||||||
|
@ -42,9 +42,8 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD)
|
|||||||
StructSize = 0;
|
StructSize = 0;
|
||||||
|
|
||||||
// Loop over each of the elements, placing them in memory...
|
// Loop over each of the elements, placing them in memory...
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator TI = ST->element_begin(),
|
||||||
TI = ST->getElementTypes().begin(),
|
TE = ST->element_end(); TI != TE; ++TI) {
|
||||||
TE = ST->getElementTypes().end(); TI != TE; ++TI) {
|
|
||||||
const Type *Ty = *TI;
|
const Type *Ty = *TI;
|
||||||
unsigned char A;
|
unsigned char A;
|
||||||
unsigned TyAlign;
|
unsigned TyAlign;
|
||||||
@ -227,7 +226,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
|
|||||||
Result += Layout->MemberOffsets[FieldNo];
|
Result += Layout->MemberOffsets[FieldNo];
|
||||||
|
|
||||||
// Update Ty to refer to current element
|
// Update Ty to refer to current element
|
||||||
Ty = STy->getElementTypes()[FieldNo];
|
Ty = STy->getElementType(FieldNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2103,7 +2103,7 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
}
|
}
|
||||||
// The next type is the member of the structure selected by the
|
// The next type is the member of the structure selected by the
|
||||||
// index.
|
// index.
|
||||||
Ty = StTy->getElementTypes()[idxValue];
|
Ty = StTy->getElementType(idxValue);
|
||||||
} else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
|
} else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
|
||||||
// It's an array or pointer access: [ArraySize x ElementType].
|
// It's an array or pointer access: [ArraySize x ElementType].
|
||||||
|
|
||||||
|
@ -2103,7 +2103,7 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
}
|
}
|
||||||
// The next type is the member of the structure selected by the
|
// The next type is the member of the structure selected by the
|
||||||
// index.
|
// index.
|
||||||
Ty = StTy->getElementTypes()[idxValue];
|
Ty = StTy->getElementType(idxValue);
|
||||||
} else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
|
} else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
|
||||||
// It's an array or pointer access: [ArraySize x ElementType].
|
// It's an array or pointer access: [ArraySize x ElementType].
|
||||||
|
|
||||||
|
@ -69,11 +69,10 @@ const Type *MutateStructTypes::ConvertType(const Type *Ty) {
|
|||||||
}
|
}
|
||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
const StructType *ST = cast<StructType>(Ty);
|
const StructType *ST = cast<StructType>(Ty);
|
||||||
const StructType::ElementTypes &El = ST->getElementTypes();
|
|
||||||
std::vector<const Type *> Types;
|
std::vector<const Type *> Types;
|
||||||
|
|
||||||
for (StructType::ElementTypes::const_iterator I = El.begin(), E = El.end();
|
for (StructType::element_iterator I = ST->element_begin(),
|
||||||
I != E; ++I)
|
E = ST->element_end(); I != E; ++I)
|
||||||
Types.push_back(ConvertType(*I));
|
Types.push_back(ConvertType(*I));
|
||||||
DestTy = StructType::get(Types);
|
DestTy = StructType::get(Types);
|
||||||
break;
|
break;
|
||||||
@ -115,7 +114,7 @@ void MutateStructTypes::AdjustIndices(const CompositeType *OldTy,
|
|||||||
if (const StructType *OldST = dyn_cast<StructType>(OldTy)) {
|
if (const StructType *OldST = dyn_cast<StructType>(OldTy)) {
|
||||||
// Figure out what the current index is...
|
// Figure out what the current index is...
|
||||||
unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue();
|
unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue();
|
||||||
assert(ElNum < OldST->getElementTypes().size());
|
assert(ElNum < OldST->getNumElements());
|
||||||
|
|
||||||
std::map<const StructType*, TransformType>::iterator
|
std::map<const StructType*, TransformType>::iterator
|
||||||
I = Transforms.find(OldST);
|
I = Transforms.find(OldST);
|
||||||
@ -198,7 +197,7 @@ void MutateStructTypes::setTransforms(const TransformsType &XForm) {
|
|||||||
const StructType *OldTy = I->first;
|
const StructType *OldTy = I->first;
|
||||||
const std::vector<int> &InVec = I->second;
|
const std::vector<int> &InVec = I->second;
|
||||||
|
|
||||||
assert(OldTy->getElementTypes().size() == InVec.size() &&
|
assert(OldTy->getNumElements() == InVec.size() &&
|
||||||
"Action not specified for every element of structure type!");
|
"Action not specified for every element of structure type!");
|
||||||
|
|
||||||
std::vector<const Type *> NewType;
|
std::vector<const Type *> NewType;
|
||||||
|
@ -109,7 +109,7 @@ static unsigned getIndex(const std::vector<std::pair<unsigned, unsigned> > &Vec,
|
|||||||
static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
||||||
std::vector<int> &Transform,
|
std::vector<int> &Transform,
|
||||||
enum SimpleStructMutation::Transform XForm) {
|
enum SimpleStructMutation::Transform XForm) {
|
||||||
unsigned NumElements = ST->getElementTypes().size();
|
unsigned NumElements = ST->getNumElements();
|
||||||
Transform.reserve(NumElements);
|
Transform.reserve(NumElements);
|
||||||
|
|
||||||
switch (XForm) {
|
switch (XForm) {
|
||||||
@ -124,8 +124,7 @@ static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
|||||||
|
|
||||||
// Build mapping from index to size
|
// Build mapping from index to size
|
||||||
for (unsigned i = 0; i < NumElements; ++i)
|
for (unsigned i = 0; i < NumElements; ++i)
|
||||||
ElList.push_back(
|
ElList.push_back(std::make_pair(i,TD.getTypeSize(ST->getElementType(i))));
|
||||||
std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
|
|
||||||
|
|
||||||
sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
|
sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
|
||||||
|
|
||||||
|
@ -375,12 +375,12 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
|||||||
const Type *IdxType;
|
const Type *IdxType;
|
||||||
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
|
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
|
||||||
// Check for a zero element struct type... if we have one, bail.
|
// Check for a zero element struct type... if we have one, bail.
|
||||||
if (CurSTy->getElementTypes().size() == 0) break;
|
if (CurSTy->getNumElements() == 0) break;
|
||||||
|
|
||||||
// Grab the first element of the struct type, which must lie at
|
// Grab the first element of the struct type, which must lie at
|
||||||
// offset zero in the struct.
|
// offset zero in the struct.
|
||||||
//
|
//
|
||||||
ElTy = CurSTy->getElementTypes()[0];
|
ElTy = CurSTy->getElementType(0);
|
||||||
IdxType = Type::UByteTy; // FIXME when PR82 is fixed.
|
IdxType = Type::UByteTy; // FIXME when PR82 is fixed.
|
||||||
} else {
|
} else {
|
||||||
ElTy = cast<ArrayType>(CurCTy)->getElementType();
|
ElTy = cast<ArrayType>(CurCTy)->getElementType();
|
||||||
|
@ -62,7 +62,7 @@ const Type *llvm::getStructOffsetType(const Type *Ty, unsigned &Offset,
|
|||||||
uint64_t ThisOffset;
|
uint64_t ThisOffset;
|
||||||
const Type *NextType;
|
const Type *NextType;
|
||||||
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
||||||
if (STy->getElementTypes().empty()) {
|
if (STy->getNumElements()) {
|
||||||
Offset = 0;
|
Offset = 0;
|
||||||
return STy;
|
return STy;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +169,9 @@ static std::string calcTypeName(const Type *Ty,
|
|||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
const StructType *STy = cast<StructType>(Ty);
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
Result = "{ ";
|
Result = "{ ";
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
if (I != STy->element_begin())
|
||||||
if (I != STy->getElementTypes().begin())
|
|
||||||
Result += ", ";
|
Result += ", ";
|
||||||
Result += calcTypeName(*I, TypeStack, TypeNames);
|
Result += calcTypeName(*I, TypeStack, TypeNames);
|
||||||
}
|
}
|
||||||
@ -529,10 +528,9 @@ std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
|
|||||||
Out << ")";
|
Out << ")";
|
||||||
} else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
} else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
||||||
Out << "{ ";
|
Out << "{ ";
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
if (I != STy->element_begin())
|
||||||
if (I != STy->getElementTypes().begin())
|
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
printType(*I);
|
printType(*I);
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,10 @@ Constant *Constant::getNullValue(const Type *Ty) {
|
|||||||
|
|
||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
const StructType *ST = cast<StructType>(Ty);
|
const StructType *ST = cast<StructType>(Ty);
|
||||||
const StructType::ElementTypes &ETs = ST->getElementTypes();
|
|
||||||
std::vector<Constant*> Elements;
|
std::vector<Constant*> Elements;
|
||||||
Elements.resize(ETs.size());
|
Elements.resize(ST->getNumElements());
|
||||||
for (unsigned i = 0, e = ETs.size(); i != e; ++i)
|
for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i)
|
||||||
Elements[i] = Constant::getNullValue(ETs[i]);
|
Elements[i] = Constant::getNullValue(ST->getElementType(i));
|
||||||
return ConstantStruct::get(ST, Elements);
|
return ConstantStruct::get(ST, Elements);
|
||||||
}
|
}
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
@ -263,14 +262,15 @@ ConstantArray::ConstantArray(const ArrayType *T,
|
|||||||
|
|
||||||
ConstantStruct::ConstantStruct(const StructType *T,
|
ConstantStruct::ConstantStruct(const StructType *T,
|
||||||
const std::vector<Constant*> &V) : Constant(T) {
|
const std::vector<Constant*> &V) : Constant(T) {
|
||||||
const StructType::ElementTypes &ETypes = T->getElementTypes();
|
assert(V.size() == T->getNumElements() &&
|
||||||
assert(V.size() == ETypes.size() &&
|
|
||||||
"Invalid initializer vector for constant structure");
|
"Invalid initializer vector for constant structure");
|
||||||
Operands.reserve(V.size());
|
Operands.reserve(V.size());
|
||||||
for (unsigned i = 0, e = V.size(); i != e; ++i) {
|
for (unsigned i = 0, e = V.size(); i != e; ++i) {
|
||||||
assert((V[i]->getType() == ETypes[i] ||
|
assert((V[i]->getType() == T->getElementType(i) ||
|
||||||
((ETypes[i]->isAbstract() || V[i]->getType()->isAbstract()) &&
|
((T->getElementType(i)->isAbstract() ||
|
||||||
ETypes[i]->getPrimitiveID()==V[i]->getType()->getPrimitiveID())) &&
|
V[i]->getType()->isAbstract()) &&
|
||||||
|
T->getElementType(i)->getPrimitiveID() ==
|
||||||
|
V[i]->getType()->getPrimitiveID())) &&
|
||||||
"Initializer for struct element doesn't match struct element type!");
|
"Initializer for struct element doesn't match struct element type!");
|
||||||
Operands.push_back(Use(V[i], this));
|
Operands.push_back(Use(V[i], this));
|
||||||
}
|
}
|
||||||
|
@ -206,10 +206,9 @@ static std::string getTypeDescription(const Type *Ty,
|
|||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
const StructType *STy = cast<StructType>(Ty);
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
Result = "{ ";
|
Result = "{ ";
|
||||||
for (StructType::ElementTypes::const_iterator
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
I = STy->getElementTypes().begin(),
|
E = STy->element_end(); I != E; ++I) {
|
||||||
E = STy->getElementTypes().end(); I != E; ++I) {
|
if (I != STy->element_begin())
|
||||||
if (I != STy->getElementTypes().begin())
|
|
||||||
Result += ", ";
|
Result += ", ";
|
||||||
Result += getTypeDescription(*I, TypeStack);
|
Result += getTypeDescription(*I, TypeStack);
|
||||||
}
|
}
|
||||||
@ -512,12 +511,10 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2,
|
|||||||
return TypesEqual(PTy->getElementType(),
|
return TypesEqual(PTy->getElementType(),
|
||||||
cast<PointerType>(Ty2)->getElementType(), EqTypes);
|
cast<PointerType>(Ty2)->getElementType(), EqTypes);
|
||||||
} else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
} else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
||||||
const StructType::ElementTypes &STyE = STy->getElementTypes();
|
const StructType *STy2 = cast<StructType>(Ty2);
|
||||||
const StructType::ElementTypes &STyE2 =
|
if (STy->getNumElements() != STy2->getNumElements()) return false;
|
||||||
cast<StructType>(Ty2)->getElementTypes();
|
for (unsigned i = 0, e = STy2->getNumElements(); i != e; ++i)
|
||||||
if (STyE.size() != STyE2.size()) return false;
|
if (!TypesEqual(STy->getElementType(i), STy2->getElementType(i), EqTypes))
|
||||||
for (unsigned i = 0, e = STyE.size(); i != e; ++i)
|
|
||||||
if (!TypesEqual(STyE[i], STyE2[i], EqTypes))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
} else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
} else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
||||||
@ -815,9 +812,9 @@ public:
|
|||||||
|
|
||||||
static StructValType get(const StructType *ST) {
|
static StructValType get(const StructType *ST) {
|
||||||
std::vector<const Type *> ElTypes;
|
std::vector<const Type *> ElTypes;
|
||||||
ElTypes.reserve(ST->getElementTypes().size());
|
ElTypes.reserve(ST->getNumElements());
|
||||||
for (unsigned i = 0, e = ST->getElementTypes().size(); i != e; ++i)
|
for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i)
|
||||||
ElTypes.push_back(ST->getElementTypes()[i]);
|
ElTypes.push_back(ST->getElementType(i));
|
||||||
|
|
||||||
return StructValType(ElTypes);
|
return StructValType(ElTypes);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user