forked from OSchip/llvm-project
For PR761:
Remove the Endianness and PointerSize fields from the ModuleHeader and replace it with the DataLayout field. llvm-svn: 33529
This commit is contained in:
parent
6a8d4eab6a
commit
675fb2301f
|
@ -142,14 +142,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleVersionInfo(
|
virtual void handleVersionInfo(
|
||||||
unsigned char RevisionNum, ///< Byte code revision number
|
unsigned char RevisionNum ///< Byte code revision number
|
||||||
Module::Endianness Endianness, ///< Endianness indicator
|
|
||||||
Module::PointerSize PointerSize ///< PointerSize indicator
|
|
||||||
) {
|
) {
|
||||||
if (os)
|
if (os)
|
||||||
*os << " RevisionNum: " << int(RevisionNum)
|
*os << " RevisionNum: " << int(RevisionNum) << "\n";
|
||||||
<< " Endianness: " << Endianness
|
|
||||||
<< " PointerSize: " << PointerSize << "\n";
|
|
||||||
bca.version = RevisionNum;
|
bca.version = RevisionNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2014,6 +2014,13 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||||
if (Handler)
|
if (Handler)
|
||||||
Handler->handleTargetTriple(triple);
|
Handler->handleTargetTriple(triple);
|
||||||
|
|
||||||
|
// Read the data layout string and place into the module.
|
||||||
|
std::string datalayout = read_str();
|
||||||
|
TheModule->setDataLayout(datalayout);
|
||||||
|
// FIXME: Implement
|
||||||
|
// if (Handler)
|
||||||
|
// Handler->handleDataLayout(datalayout);
|
||||||
|
|
||||||
if (At != BlockEnd) {
|
if (At != BlockEnd) {
|
||||||
// If the file has section info in it, read the section names now.
|
// If the file has section info in it, read the section names now.
|
||||||
unsigned NumSections = read_vbr_uint();
|
unsigned NumSections = read_vbr_uint();
|
||||||
|
@ -2045,31 +2052,14 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||||
/// Parse the version information and decode it by setting flags on the
|
/// Parse the version information and decode it by setting flags on the
|
||||||
/// Reader that enable backward compatibility of the reader.
|
/// Reader that enable backward compatibility of the reader.
|
||||||
void BytecodeReader::ParseVersionInfo() {
|
void BytecodeReader::ParseVersionInfo() {
|
||||||
unsigned Version = read_vbr_uint();
|
unsigned RevisionNum = read_vbr_uint();
|
||||||
|
|
||||||
// Unpack version number: low four bits are for flags, top bits = version
|
|
||||||
Module::Endianness Endianness;
|
|
||||||
Module::PointerSize PointerSize;
|
|
||||||
Endianness = (Version & 1) ? Module::BigEndian : Module::LittleEndian;
|
|
||||||
PointerSize = (Version & 2) ? Module::Pointer64 : Module::Pointer32;
|
|
||||||
|
|
||||||
bool hasNoEndianness = Version & 4;
|
|
||||||
bool hasNoPointerSize = Version & 8;
|
|
||||||
|
|
||||||
RevisionNum = Version >> 4;
|
|
||||||
|
|
||||||
// We don't provide backwards compatibility in the Reader any more. To
|
// We don't provide backwards compatibility in the Reader any more. To
|
||||||
// upgrade, the user should use llvm-upgrade.
|
// upgrade, the user should use llvm-upgrade.
|
||||||
if (RevisionNum < 7)
|
if (RevisionNum < 7)
|
||||||
error("Bytecode formats < 7 are no longer supported. Use llvm-upgrade.");
|
error("Bytecode formats < 7 are no longer supported. Use llvm-upgrade.");
|
||||||
|
|
||||||
if (hasNoEndianness) Endianness = Module::AnyEndianness;
|
if (Handler) Handler->handleVersionInfo(RevisionNum);
|
||||||
if (hasNoPointerSize) PointerSize = Module::AnyPointerSize;
|
|
||||||
|
|
||||||
TheModule->setEndianness(Endianness);
|
|
||||||
TheModule->setPointerSize(PointerSize);
|
|
||||||
|
|
||||||
if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a whole module.
|
/// Parse a whole module.
|
||||||
|
|
|
@ -813,17 +813,8 @@ BytecodeWriter::BytecodeWriter(std::vector<unsigned char> &o, const Module *M)
|
||||||
// Emit the top level CLASS block.
|
// Emit the top level CLASS block.
|
||||||
BytecodeBlock ModuleBlock(BytecodeFormat::ModuleBlockID, *this, false, true);
|
BytecodeBlock ModuleBlock(BytecodeFormat::ModuleBlockID, *this, false, true);
|
||||||
|
|
||||||
bool isBigEndian = M->getEndianness() == Module::BigEndian;
|
// Output the version identifier
|
||||||
bool hasLongPointers = M->getPointerSize() == Module::Pointer64;
|
output_vbr(BCVersionNum);
|
||||||
bool hasNoEndianness = M->getEndianness() == Module::AnyEndianness;
|
|
||||||
bool hasNoPointerSize = M->getPointerSize() == Module::AnyPointerSize;
|
|
||||||
|
|
||||||
// Output the version identifier and other information.
|
|
||||||
unsigned Version = (BCVersionNum << 4) |
|
|
||||||
(unsigned)isBigEndian | (hasLongPointers << 1) |
|
|
||||||
(hasNoEndianness << 2) |
|
|
||||||
(hasNoPointerSize << 3);
|
|
||||||
output_vbr(Version);
|
|
||||||
|
|
||||||
// The Global type plane comes first
|
// The Global type plane comes first
|
||||||
{
|
{
|
||||||
|
@ -1090,6 +1081,9 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
|
||||||
|
|
||||||
// Output the target triple from the module
|
// Output the target triple from the module
|
||||||
output(M->getTargetTriple());
|
output(M->getTargetTriple());
|
||||||
|
|
||||||
|
// Output the data layout from the module
|
||||||
|
output(M->getDataLayout());
|
||||||
|
|
||||||
// Emit the table of section names.
|
// Emit the table of section names.
|
||||||
output_vbr((unsigned)SectionNames.size());
|
output_vbr((unsigned)SectionNames.size());
|
||||||
|
|
Loading…
Reference in New Issue