From 43c92f9dbd381e15521ef7c7681c54e81de2d802 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 14 Dec 2001 16:30:51 +0000 Subject: [PATCH] Remove unsized array support llvm-svn: 1461 --- lib/Bytecode/Reader/ConstantReader.cpp | 9 +++------ lib/Bytecode/Writer/ConstantWriter.cpp | 4 +--- lib/Target/Sparc/EmitAssembly.cpp | 8 -------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 671afd2066e..78da567f012 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -55,7 +55,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, const Type *ElementType = getType(ElTyp); if (ElementType == 0) return failure(Val); - int NumElements; + unsigned NumElements; if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val); BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size=" @@ -239,11 +239,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, case Type::ArrayTyID: { const ArrayType *AT = cast(Ty); - unsigned NumElements; - 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); + unsigned NumElements = AT->getNumElements(); vector Elements; while (NumElements--) { // Read all of the elements of the constant. @@ -320,6 +316,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, break; } default: + BCR_TRACE(5, "UNKNOWN Pointer Constant Type!\n"); return failure(true); } break; diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index 0700a2e63e7..bcfa9765731 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -123,9 +123,7 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) { case Type::ArrayTyID: { const ConstantArray *CPA = cast(CPV); unsigned size = CPA->getValues().size(); - if (!((const ArrayType *)CPA->getType())->isSized()) - output_vbr(size, Out); // Not for sized arrays!!! - + assert(size == cast(CPA->getType())->getNumElements() && "ConstantArray out of whack!"); for (unsigned i = 0; i < size; i++) { int Slot = Table.getValSlot(CPA->getOperand(i)); assert(Slot != -1 && "Constant used but not available!!"); diff --git a/lib/Target/Sparc/EmitAssembly.cpp b/lib/Target/Sparc/EmitAssembly.cpp index 032faf12d65..fb2888b05d8 100644 --- a/lib/Target/Sparc/EmitAssembly.cpp +++ b/lib/Target/Sparc/EmitAssembly.cpp @@ -447,8 +447,6 @@ ConstantToSize(const Constant* CV, const TargetMachine& target) ArrayType *aty = cast(CPA->getType()); if (ArrayTypeIsString(aty)) return 1 + CPA->getNumOperands(); - else if (! aty->isSized()) - return 0; } 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. -// If this is an unsized array, just return the L1 cache line size -// (viz., the default behavior for large global objects). // inline unsigned int TypeToAlignment(const Type* type, const TargetMachine& target) { - if (ArrayType* aty = dyn_cast(type)) - if (! aty->isSized()) - return target.getCacheInfo().getCacheLineSize(1); - return SizeToAlignment(target.findOptimalStorageSize(type), target); }