mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Remove unsized array support
llvm-svn: 1461
This commit is contained in:
parent
8ab6f31913
commit
43c92f9dbd
@ -55,7 +55,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
|
|||||||
const Type *ElementType = getType(ElTyp);
|
const Type *ElementType = getType(ElTyp);
|
||||||
if (ElementType == 0) return failure(Val);
|
if (ElementType == 0) return failure(Val);
|
||||||
|
|
||||||
int NumElements;
|
unsigned NumElements;
|
||||||
if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
|
if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
|
||||||
|
|
||||||
BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
|
BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
|
||||||
@ -239,11 +239,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ArrayType *AT = cast<const ArrayType>(Ty);
|
const ArrayType *AT = cast<const ArrayType>(Ty);
|
||||||
unsigned NumElements;
|
unsigned NumElements = AT->getNumElements();
|
||||||
if (AT->isSized()) // Sized array, # elements stored in type!
|
|
||||||
NumElements = (unsigned)AT->getNumElements();
|
|
||||||
else // Unsized array, # elements stored in stream!
|
|
||||||
if (read_vbr(Buf, EndBuf, NumElements)) return failure(true);
|
|
||||||
|
|
||||||
vector<Constant*> Elements;
|
vector<Constant*> Elements;
|
||||||
while (NumElements--) { // Read all of the elements of the constant.
|
while (NumElements--) { // Read all of the elements of the constant.
|
||||||
@ -320,6 +316,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
BCR_TRACE(5, "UNKNOWN Pointer Constant Type!\n");
|
||||||
return failure(true);
|
return failure(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -123,9 +123,7 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) {
|
|||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ConstantArray *CPA = cast<const ConstantArray>(CPV);
|
const ConstantArray *CPA = cast<const ConstantArray>(CPV);
|
||||||
unsigned size = CPA->getValues().size();
|
unsigned size = CPA->getValues().size();
|
||||||
if (!((const ArrayType *)CPA->getType())->isSized())
|
assert(size == cast<ArrayType>(CPA->getType())->getNumElements() && "ConstantArray out of whack!");
|
||||||
output_vbr(size, Out); // Not for sized arrays!!!
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < size; i++) {
|
for (unsigned i = 0; i < size; i++) {
|
||||||
int Slot = Table.getValSlot(CPA->getOperand(i));
|
int Slot = Table.getValSlot(CPA->getOperand(i));
|
||||||
assert(Slot != -1 && "Constant used but not available!!");
|
assert(Slot != -1 && "Constant used but not available!!");
|
||||||
|
@ -447,8 +447,6 @@ ConstantToSize(const Constant* CV, const TargetMachine& target)
|
|||||||
ArrayType *aty = cast<ArrayType>(CPA->getType());
|
ArrayType *aty = cast<ArrayType>(CPA->getType());
|
||||||
if (ArrayTypeIsString(aty))
|
if (ArrayTypeIsString(aty))
|
||||||
return 1 + CPA->getNumOperands();
|
return 1 + CPA->getNumOperands();
|
||||||
else if (! aty->isSized())
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return target.findOptimalStorageSize(CV->getType());
|
return target.findOptimalStorageSize(CV->getType());
|
||||||
@ -477,16 +475,10 @@ SizeToAlignment(unsigned int size, const TargetMachine& target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the size of the type and then use SizeToAlignment.
|
// Get the size of the type and then use SizeToAlignment.
|
||||||
// If this is an unsized array, just return the L1 cache line size
|
|
||||||
// (viz., the default behavior for large global objects).
|
|
||||||
//
|
//
|
||||||
inline unsigned int
|
inline unsigned int
|
||||||
TypeToAlignment(const Type* type, const TargetMachine& target)
|
TypeToAlignment(const Type* type, const TargetMachine& target)
|
||||||
{
|
{
|
||||||
if (ArrayType* aty = dyn_cast<ArrayType>(type))
|
|
||||||
if (! aty->isSized())
|
|
||||||
return target.getCacheInfo().getCacheLineSize(1);
|
|
||||||
|
|
||||||
return SizeToAlignment(target.findOptimalStorageSize(type), target);
|
return SizeToAlignment(target.findOptimalStorageSize(type), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user