aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-24 13:47:36 +0000
committerChris Lattner <sabre@nondot.org>2003-08-24 13:47:36 +0000
commitd445c6b64a64ba61523b3d225463dce070d33212 (patch)
treebb56b33b20d0a62dbf4f34eb4bedbc5773446e7d /lib/Bytecode/Reader/Reader.cpp
parenta7a35a831bf7aaa63287824645bb71937652e1b9 (diff)
Allow modules to have 'any' pointer size and endianness. Luckily, we had
some space for extra flags, so we don't need to bump the revision number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 097a8d4dc7..3076f2032c 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -498,9 +498,15 @@ bool BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
if (read_vbr(Buf, EndBuf, Version)) return true;
// Unpack version number: low four bits are for flags, top bits = version
- isBigEndian = Version & 1;
- hasLongPointers = Version & 2;
- RevisionNum = Version >> 4;
+ 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;
// Default values for the current bytecode version
HasImplicitZeroInitializer = true;
@@ -515,11 +521,14 @@ bool BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
//
if (Version != 14) return true; // Unknown revision 0 flags?
HasImplicitZeroInitializer = false;
- isBigEndian = hasLongPointers = true;
+ Endianness = Module::BigEndian;
+ PointerSize = Module::Pointer64;
hasInternalMarkerOnly = true;
+ hasNoEndianness = hasNoPointerSize = false;
break;
case 1:
- // Version #1 has two bit fields: isBigEndian and hasLongPointers
+ // Version #1 has four bit fields: isBigEndian, hasLongPointers,
+ // hasNoEndianness, and hasNoPointerSize.
hasInternalMarkerOnly = true;
break;
case 2:
@@ -531,14 +540,14 @@ bool BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
return true;
}
- TheModule->setEndianness(isBigEndian ? Module::BigEndian :
- Module::LittleEndian);
- TheModule->setPointerSize(hasLongPointers ? Module::Pointer64 :
- Module::Pointer32);
+ if (hasNoEndianness) Endianness = Module::AnyEndianness;
+ if (hasNoPointerSize) PointerSize = Module::AnyPointerSize;
+ TheModule->setEndianness(Endianness);
+ TheModule->setPointerSize(PointerSize);
BCR_TRACE(1, "Bytecode Rev = " << (unsigned)RevisionNum << "\n");
- BCR_TRACE(1, "BigEndian/LongPointers = " << isBigEndian << ","
- << hasLongPointers << "\n");
+ BCR_TRACE(1, "Endianness/PointerSize = " << Endianness << ","
+ << PointerSize << "\n");
BCR_TRACE(1, "HasImplicitZeroInit = " << HasImplicitZeroInitializer << "\n");
return false;
}