llvm.org GIT mirror llvm / aacc35a
For PR761: Remove the Endianness and PointerSize fields from the ModuleHeader and replace it with the DataLayout field. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33529 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 13 years ago
3 changed file(s) with 16 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
141141 }
142142
143143 virtual void handleVersionInfo(
144 unsigned char RevisionNum, ///< Byte code revision number
145 Module::Endianness Endianness, ///< Endianness indicator
146 Module::PointerSize PointerSize ///< PointerSize indicator
144 unsigned char RevisionNum ///< Byte code revision number
147145 ) {
148146 if (os)
149 *os << " RevisionNum: " << int(RevisionNum)
150 << " Endianness: " << Endianness
151 << " PointerSize: " << PointerSize << "\n";
147 *os << " RevisionNum: " << int(RevisionNum) << "\n";
152148 bca.version = RevisionNum;
153149 }
154150
20132013 if (Handler)
20142014 Handler->handleTargetTriple(triple);
20152015
2016 // Read the data layout string and place into the module.
2017 std::string datalayout = read_str();
2018 TheModule->setDataLayout(datalayout);
2019 // FIXME: Implement
2020 // if (Handler)
2021 // Handler->handleDataLayout(datalayout);
2022
20162023 if (At != BlockEnd) {
20172024 // If the file has section info in it, read the section names now.
20182025 unsigned NumSections = read_vbr_uint();
20442051 /// Parse the version information and decode it by setting flags on the
20452052 /// Reader that enable backward compatibility of the reader.
20462053 void BytecodeReader::ParseVersionInfo() {
2047 unsigned Version = read_vbr_uint();
2048
2049 // Unpack version number: low four bits are for flags, top bits = version
2050 Module::Endianness Endianness;
2051 Module::PointerSize PointerSize;
2052 Endianness = (Version & 1) ? Module::BigEndian : Module::LittleEndian;
2053 PointerSize = (Version & 2) ? Module::Pointer64 : Module::Pointer32;
2054
2055 bool hasNoEndianness = Version & 4;
2056 bool hasNoPointerSize = Version & 8;
2057
2058 RevisionNum = Version >> 4;
2054 unsigned RevisionNum = read_vbr_uint();
20592055
20602056 // We don't provide backwards compatibility in the Reader any more. To
20612057 // upgrade, the user should use llvm-upgrade.
20622058 if (RevisionNum < 7)
20632059 error("Bytecode formats < 7 are no longer supported. Use llvm-upgrade.");
20642060
2065 if (hasNoEndianness) Endianness = Module::AnyEndianness;
2066 if (hasNoPointerSize) PointerSize = Module::AnyPointerSize;
2067
2068 TheModule->setEndianness(Endianness);
2069 TheModule->setPointerSize(PointerSize);
2070
2071 if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize);
2061 if (Handler) Handler->handleVersionInfo(RevisionNum);
20722062 }
20732063
20742064 /// Parse a whole module.
812812 // Emit the top level CLASS block.
813813 BytecodeBlock ModuleBlock(BytecodeFormat::ModuleBlockID, *this, false, true);
814814
815 bool isBigEndian = M->getEndianness() == Module::BigEndian;
816 bool hasLongPointers = M->getPointerSize() == Module::Pointer64;
817 bool hasNoEndianness = M->getEndianness() == Module::AnyEndianness;
818 bool hasNoPointerSize = M->getPointerSize() == Module::AnyPointerSize;
819
820 // Output the version identifier and other information.
821 unsigned Version = (BCVersionNum << 4) |
822 (unsigned)isBigEndian | (hasLongPointers << 1) |
823 (hasNoEndianness << 2) |
824 (hasNoPointerSize << 3);
825 output_vbr(Version);
815 // Output the version identifier
816 output_vbr(BCVersionNum);
826817
827818 // The Global type plane comes first
828819 {
10891080
10901081 // Output the target triple from the module
10911082 output(M->getTargetTriple());
1083
1084 // Output the data layout from the module
1085 output(M->getDataLayout());
10921086
10931087 // Emit the table of section names.
10941088 output_vbr((unsigned)SectionNames.size());