aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/Analyzer.cpp168
-rw-r--r--lib/Bytecode/Reader/Reader.cpp228
-rw-r--r--lib/Bytecode/Reader/Reader.h56
-rw-r--r--lib/Bytecode/Reader/ReaderWrappers.cpp30
4 files changed, 241 insertions, 241 deletions
diff --git a/lib/Bytecode/Reader/Analyzer.cpp b/lib/Bytecode/Reader/Analyzer.cpp
index 5738f1a733..63fdfb9a8f 100644
--- a/lib/Bytecode/Reader/Analyzer.cpp
+++ b/lib/Bytecode/Reader/Analyzer.cpp
@@ -1,10 +1,10 @@
//===-- Analyzer.cpp - Analysis and Dumping of Bytecode 000000---*- C++ -*-===//
-//
+//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Reid Spencer and is distributed under the
+// This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements the AnalyzerHandler class and PrintBytecodeAnalysis
@@ -35,7 +35,7 @@ class AnalyzerHandler : public BytecodeHandler {
BytecodeAnalysis& bca; ///< The structure in which data is recorded
std::ostream* os; ///< A convenience for osing data.
/// @brief Keeps track of current function
- BytecodeAnalysis::BytecodeFunctionInfo* currFunc;
+ BytecodeAnalysis::BytecodeFunctionInfo* currFunc;
Module* M; ///< Keeps track of current module
/// @name Constructor
@@ -44,8 +44,8 @@ public:
/// The only way to construct an AnalyzerHandler. All that is needed is a
/// reference to the BytecodeAnalysis structure where the output will be
/// placed.
- AnalyzerHandler(BytecodeAnalysis& TheBca, std::ostream* output)
- : bca(TheBca)
+ AnalyzerHandler(BytecodeAnalysis& TheBca, std::ostream* output)
+ : bca(TheBca)
, os(output)
, currFunc(0)
{ }
@@ -54,7 +54,7 @@ public:
/// @name BytecodeHandler Implementations
/// @{
public:
- virtual void handleError(const std::string& str ) {
+ virtual void handleError(const std::string& str ) {
if (os)
*os << "ERROR: " << str << "\n";
}
@@ -104,16 +104,16 @@ public:
virtual void handleFinish() {
if (os)
- *os << "} End Bytecode\n";
+ *os << "} End Bytecode\n";
bca.fileDensity = double(bca.byteSize) / double( bca.numTypes + bca.numValues );
double globalSize = 0.0;
globalSize += double(bca.BlockSizes[BytecodeFormat::ConstantPoolBlockID]);
globalSize += double(bca.BlockSizes[BytecodeFormat::ModuleGlobalInfoBlockID]);
globalSize += double(bca.BlockSizes[BytecodeFormat::GlobalTypePlaneBlockID]);
- bca.globalsDensity = globalSize / double( bca.numTypes + bca.numConstants +
+ bca.globalsDensity = globalSize / double( bca.numTypes + bca.numConstants +
bca.numGlobalVars );
- bca.functionDensity = double(bca.BlockSizes[BytecodeFormat::FunctionBlockID]) /
+ bca.functionDensity = double(bca.BlockSizes[BytecodeFormat::FunctionBlockID]) /
double(bca.numFunctions);
if ( bca.progressiveVerify ) {
@@ -131,7 +131,7 @@ public:
bca.ModuleId = id;
}
- virtual void handleModuleEnd(const std::string& id) {
+ virtual void handleModuleEnd(const std::string& id) {
if (os)
*os << " } End Module " << id << "\n";
if ( bca.progressiveVerify ) {
@@ -147,22 +147,22 @@ public:
unsigned char RevisionNum, ///< Byte code revision number
Module::Endianness Endianness, ///< Endianness indicator
Module::PointerSize PointerSize ///< PointerSize indicator
- ) {
+ ) {
if (os)
- *os << " RevisionNum: " << int(RevisionNum)
+ *os << " RevisionNum: " << int(RevisionNum)
<< " Endianness: " << Endianness
<< " PointerSize: " << PointerSize << "\n";
bca.version = RevisionNum;
}
- virtual void handleModuleGlobalsBegin() {
+ virtual void handleModuleGlobalsBegin() {
if (os)
*os << " BLOCK: ModuleGlobalInfo {\n";
}
- virtual void handleGlobalVariable(
- const Type* ElemType,
- bool isConstant,
+ virtual void handleGlobalVariable(
+ const Type* ElemType,
+ bool isConstant,
GlobalValue::LinkageTypes Linkage,
unsigned SlotNum,
unsigned initSlot
@@ -173,7 +173,7 @@ public:
<< ( isConstant? "Constant, " : "Variable, ")
<< " Linkage=" << Linkage << " Type=";
WriteTypeSymbolic(*os, ElemType, M);
- *os << " Slot=" << SlotNum << " InitSlot=" << initSlot
+ *os << " Slot=" << SlotNum << " InitSlot=" << initSlot
<< "\n";
}
@@ -190,8 +190,8 @@ public:
bca.maxTypeSlot = numEntries - 1;
}
- virtual void handleType( const Type* Ty ) {
- bca.numTypes++;
+ virtual void handleType( const Type* Ty ) {
+ bca.numTypes++;
if (os) {
*os << " Type: ";
WriteTypeSymbolic(*os,Ty,M);
@@ -199,7 +199,7 @@ public:
}
}
- virtual void handleFunctionDeclaration(
+ virtual void handleFunctionDeclaration(
Function* Func ///< The function
) {
bca.numFunctions++;
@@ -228,7 +228,7 @@ public:
*os << " Library: '" << libName << "'\n";
}
- virtual void handleModuleGlobalsEnd() {
+ virtual void handleModuleGlobalsEnd() {
if (os)
*os << " } END BLOCK: ModuleGlobalInfo\n";
if ( bca.progressiveVerify ) {
@@ -240,7 +240,7 @@ public:
}
}
- virtual void handleCompactionTableBegin() {
+ virtual void handleCompactionTableBegin() {
if (os)
*os << " BLOCK: CompactionTable {\n";
bca.numCmpctnTables++;
@@ -251,53 +251,53 @@ public:
*os << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n";
}
- virtual void handleCompactionTableType( unsigned i, unsigned TypSlot,
+ virtual void handleCompactionTableType( unsigned i, unsigned TypSlot,
const Type* Ty ) {
if (os) {
*os << " Type: " << i << " Slot:" << TypSlot << " is ";
WriteTypeSymbolic(*os,Ty,M);
- *os << "\n";
+ *os << "\n";
}
}
virtual void handleCompactionTableValue(unsigned i, unsigned TypSlot,
- unsigned ValSlot) {
+ unsigned ValSlot) {
if (os)
- *os << " Value: " << i << " TypSlot: " << TypSlot
+ *os << " Value: " << i << " TypSlot: " << TypSlot
<< " ValSlot:" << ValSlot << "\n";
if (ValSlot > bca.maxValueSlot)
bca.maxValueSlot = ValSlot;
}
- virtual void handleCompactionTableEnd() {
+ virtual void handleCompactionTableEnd() {
if (os)
*os << " } END BLOCK: CompactionTable\n";
}
- virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) {
- bca.numSymTab++;
+ virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) {
+ bca.numSymTab++;
if (os)
*os << " BLOCK: SymbolTable {\n";
}
- virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries,
- const Type* Typ) {
+ virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries,
+ const Type* Typ) {
if (os) {
*os << " Plane: Ty=" << Ty << " Size=" << NumEntries << " Type: ";
WriteTypeSymbolic(*os,Typ,M);
- *os << "\n";
+ *os << "\n";
}
}
- virtual void handleSymbolTableType(unsigned i, unsigned TypSlot,
- const std::string& name ) {
+ virtual void handleSymbolTableType(unsigned i, unsigned TypSlot,
+ const std::string& name ) {
if (os)
*os << " Type " << i << " Slot=" << TypSlot
- << " Name: " << name << "\n";
+ << " Name: " << name << "\n";
}
- virtual void handleSymbolTableValue(unsigned i, unsigned ValSlot,
- const std::string& name ) {
+ virtual void handleSymbolTableValue(unsigned i, unsigned ValSlot,
+ const std::string& name ) {
if (os)
*os << " Value " << i << " Slot=" << ValSlot
<< " Name: " << name << "\n";
@@ -305,7 +305,7 @@ public:
bca.maxValueSlot = ValSlot;
}
- virtual void handleSymbolTableEnd() {
+ virtual void handleSymbolTableEnd() {
if (os)
*os << " } END BLOCK: SymbolTable\n";
}
@@ -314,7 +314,7 @@ public:
if (os) {
*os << " BLOCK: Function {\n"
<< " Linkage: " << Func->getLinkage() << "\n"
- << " Type: ";
+ << " Type: ";
WriteTypeSymbolic(*os,Func->getType(),M);
*os << "\n";
}
@@ -362,14 +362,14 @@ public:
if ( currFunc ) currFunc->numBasicBlocks++;
}
- virtual bool handleInstruction( unsigned Opcode, const Type* iType,
+ virtual bool handleInstruction( unsigned Opcode, const Type* iType,
std::vector<unsigned>& Operands, unsigned Size){
if (os) {
- *os << " INST: OpCode="
+ *os << " INST: OpCode="
<< Instruction::getOpcodeName(Opcode) << " Type=\"";
WriteTypeSymbolic(*os,iType,M);
*os << "\"";
- for ( unsigned i = 0; i < Operands.size(); ++i )
+ for ( unsigned i = 0; i < Operands.size(); ++i )
*os << " Op(" << i << ")=Slot(" << Operands[i] << ")";
*os << "\n";
}
@@ -388,25 +388,25 @@ public:
if (Size > 4 ) currFunc->longInstructions++;
if ( Opcode == Instruction::PHI ) currFunc->numPhis++;
}
- return Instruction::isTerminator(Opcode);
+ return Instruction::isTerminator(Opcode);
}
- virtual void handleBasicBlockEnd(unsigned blocknum) {
+ virtual void handleBasicBlockEnd(unsigned blocknum) {
if (os)
*os << " } END BLOCK: BasicBlock #" << blocknum << "{\n";
}
- virtual void handleGlobalConstantsBegin() {
+ virtual void handleGlobalConstantsBegin() {
if (os)
*os << " BLOCK: GlobalConstants {\n";
}
- virtual void handleConstantExpression( unsigned Opcode,
+ virtual void handleConstantExpression( unsigned Opcode,
std::vector<Constant*> ArgVec, Constant* C ) {
if (os) {
*os << " EXPR: " << Instruction::getOpcodeName(Opcode) << "\n";
for ( unsigned i = 0; i < ArgVec.size(); ++i ) {
- *os << " Arg#" << i << " "; ArgVec[i]->print(*os);
+ *os << " Arg#" << i << " "; ArgVec[i]->print(*os);
*os << "\n";
}
*os << " Value=";
@@ -427,13 +427,13 @@ public:
bca.numValues++;
}
- virtual void handleConstantArray( const ArrayType* AT,
+ virtual void handleConstantArray( const ArrayType* AT,
std::vector<Constant*>& Elements,
unsigned TypeSlot,
Constant* ArrayVal ) {
if (os) {
*os << " ARRAY: ";
- WriteTypeSymbolic(*os,AT,M);
+ WriteTypeSymbolic(*os,AT,M);
*os << " TypeSlot=" << TypeSlot << "\n";
for ( unsigned i = 0; i < Elements.size(); ++i ) {
*os << " #" << i;
@@ -459,7 +459,7 @@ public:
WriteTypeSymbolic(*os,ST,M);
*os << "\n";
for ( unsigned i = 0; i < Elements.size(); ++i ) {
- *os << " #" << i << " "; Elements[i]->print(*os);
+ *os << " #" << i << " "; Elements[i]->print(*os);
*os << "\n";
}
*os << " Value=";
@@ -470,11 +470,11 @@ public:
bca.numValues++;
}
- virtual void handleConstantPacked(
- const PackedType* PT,
+ virtual void handleConstantPacked(
+ const PackedType* PT,
std::vector<Constant*>& Elements,
- unsigned TypeSlot,
- Constant* PackedVal)
+ unsigned TypeSlot,
+ Constant* PackedVal)
{
if (os) {
*os << " PACKD: ";
@@ -494,7 +494,7 @@ public:
bca.numValues++;
}
- virtual void handleConstantPointer( const PointerType* PT,
+ virtual void handleConstantPointer( const PointerType* PT,
unsigned Slot, GlobalValue* GV ) {
if (os) {
*os << " PNTR: ";
@@ -510,14 +510,14 @@ public:
virtual void handleConstantString( const ConstantArray* CA ) {
if (os) {
*os << " STRNG: ";
- CA->print(*os);
+ CA->print(*os);
*os << "\n";
}
bca.numConstants++;
bca.numValues++;
}
- virtual void handleGlobalConstantsEnd() {
+ virtual void handleGlobalConstantsEnd() {
if (os)
*os << " } END BLOCK: GlobalConstants\n";
@@ -574,38 +574,38 @@ public:
/// @brief Utility for printing a titled unsigned value with
/// an aligned colon.
-inline static void print(std::ostream& Out, const char*title,
+inline static void print(std::ostream& Out, const char*title,
unsigned val, bool nl = true ) {
- Out << std::setw(30) << std::right << title
+ Out << std::setw(30) << std::right << title
<< std::setw(0) << ": "
<< std::setw(9) << val << "\n";
}
/// @brief Utility for printing a titled double value with an
/// aligned colon
-inline static void print(std::ostream&Out, const char*title,
+inline static void print(std::ostream&Out, const char*title,
double val ) {
- Out << std::setw(30) << std::right << title
+ Out << std::setw(30) << std::right << title
<< std::setw(0) << ": "
<< std::setw(9) << std::setprecision(6) << val << "\n" ;
}
/// @brief Utility for printing a titled double value with a
/// percentage and aligned colon.
-inline static void print(std::ostream&Out, const char*title,
+inline static void print(std::ostream&Out, const char*title,
double top, double bot ) {
- Out << std::setw(30) << std::right << title
+ Out << std::setw(30) << std::right << title
<< std::setw(0) << ": "
- << std::setw(9) << std::setprecision(6) << top
- << " (" << std::left << std::setw(0) << std::setprecision(4)
+ << std::setw(9) << std::setprecision(6) << top
+ << " (" << std::left << std::setw(0) << std::setprecision(4)
<< (top/bot)*100.0 << "%)\n";
}
/// @brief Utility for printing a titled string value with
/// an aligned colon.
-inline static void print(std::ostream&Out, const char*title,
+inline static void print(std::ostream&Out, const char*title,
std::string val, bool nl = true) {
- Out << std::setw(30) << std::right << title
+ Out << std::setw(30) << std::right << title
<< std::setw(0) << ": "
<< std::left << val << (nl ? "\n" : "");
}
@@ -626,33 +626,33 @@ void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
print(Out, "Module Bytes",
double(bca.BlockSizes[BytecodeFormat::ModuleBlockID]),
double(bca.byteSize));
- print(Out, "Function Bytes",
+ print(Out, "Function Bytes",
double(bca.BlockSizes[BytecodeFormat::FunctionBlockID]),
double(bca.byteSize));
- print(Out, "Global Types Bytes",
+ print(Out, "Global Types Bytes",
double(bca.BlockSizes[BytecodeFormat::GlobalTypePlaneBlockID]),
double(bca.byteSize));
- print(Out, "Constant Pool Bytes",
+ print(Out, "Constant Pool Bytes",
double(bca.BlockSizes[BytecodeFormat::ConstantPoolBlockID]),
double(bca.byteSize));
- print(Out, "Module Globals Bytes",
+ print(Out, "Module Globals Bytes",
double(bca.BlockSizes[BytecodeFormat::ModuleGlobalInfoBlockID]),
double(bca.byteSize));
- print(Out, "Instruction List Bytes",
+ print(Out, "Instruction List Bytes",
double(bca.BlockSizes[BytecodeFormat::InstructionListBlockID]),
double(bca.byteSize));
- print(Out, "Compaction Table Bytes",
+ print(Out, "Compaction Table Bytes",
double(bca.BlockSizes[BytecodeFormat::CompactionTableBlockID]),
double(bca.byteSize));
- print(Out, "Symbol Table Bytes",
+ print(Out, "Symbol Table Bytes",
double(bca.BlockSizes[BytecodeFormat::SymbolTableBlockID]),
double(bca.byteSize));
- print(Out, "Alignment Bytes",
+ print(Out, "Alignment Bytes",
double(bca.numAlignment), double(bca.byteSize));
- print(Out, "Block Header Bytes",
+ print(Out, "Block Header Bytes",
double(bca.BlockSizes[BytecodeFormat::Reserved_DoNotUse]),
double(bca.byteSize));
- print(Out, "Dependent Libraries Bytes", double(bca.libSize),
+ print(Out, "Dependent Libraries Bytes", double(bca.libSize),
double(bca.byteSize));
print(Out, "Number Of Bytecode Blocks", bca.numBlocks);
print(Out, "Number Of Functions", bca.numFunctions);
@@ -668,7 +668,7 @@ void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
print(Out, "Number Of Symbol Tables", bca.numSymTab);
print(Out, "Number Of Dependent Libs", bca.numLibraries);
print(Out, "Total Instruction Size", bca.instructionSize);
- print(Out, "Average Instruction Size",
+ print(Out, "Average Instruction Size",
double(bca.instructionSize)/double(bca.numInstructions));
print(Out, "Maximum Type Slot Number", bca.maxTypeSlot);
@@ -680,16 +680,16 @@ void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
print(Out, "# of VBR 64-bit Integers", bca.vbrCount64);
print(Out, "# of VBR Compressed Bytes", bca.vbrCompBytes);
print(Out, "# of VBR Expanded Bytes", bca.vbrExpdBytes);
- print(Out, "Bytes Saved With VBR",
+ print(Out, "Bytes Saved With VBR",
double(bca.vbrExpdBytes)-double(bca.vbrCompBytes),
double(bca.vbrExpdBytes));
if (bca.detailedResults) {
Out << "\nDetailed Analysis Of " << bca.ModuleId << " Functions:\n";
- std::map<const Function*,BytecodeAnalysis::BytecodeFunctionInfo>::iterator I =
+ std::map<const Function*,BytecodeAnalysis::BytecodeFunctionInfo>::iterator I =
bca.FunctionInfo.begin();
- std::map<const Function*,BytecodeAnalysis::BytecodeFunctionInfo>::iterator E =
+ std::map<const Function*,BytecodeAnalysis::BytecodeFunctionInfo>::iterator E =
bca.FunctionInfo.end();
while ( I != E ) {
@@ -704,14 +704,14 @@ void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
print(Out, "Long Instructions", I->second.longInstructions);
print(Out, "Operands", I->second.numOperands);
print(Out, "Instruction Size", I->second.instructionSize);
- print(Out, "Average Instruction Size",
+ print(Out, "Average Instruction Size",
double(I->second.instructionSize) / I->second.numInstructions);
print(Out, "Bytes Per Instruction", I->second.density);
print(Out, "# of VBR 32-bit Integers", I->second.vbrCount32);
print(Out, "# of VBR 64-bit Integers", I->second.vbrCount64);
print(Out, "# of VBR Compressed Bytes", I->second.vbrCompBytes);
print(Out, "# of VBR Expanded Bytes", I->second.vbrExpdBytes);
- print(Out, "Bytes Saved With VBR",
+ print(Out, "Bytes Saved With VBR",
double(I->second.vbrExpdBytes) - I->second.vbrCompBytes),
double(I->second.vbrExpdBytes);
}
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 974a3263aa..398ecfc372 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -1,15 +1,15 @@
//===- Reader.cpp - Code to read bytecode files ---------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This library implements the functionality defined in llvm/Bytecode/Reader.h
//
-// Note that this library should be as fast as possible, reentrant, and
+// Note that this library should be as fast as possible, reentrant, and
// threadsafe!!
//
// TODO: Allow passing in an option to ignore the symbol table
@@ -39,7 +39,7 @@ namespace {
void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
public:
Use Op;
- ConstantPlaceHolder(const Type *Ty)
+ ConstantPlaceHolder(const Type *Ty)
: ConstantExpr(Ty, Instruction::UserOp1, &Op, 1),
Op(UndefValue::get(Type::IntTy), this) {
}
@@ -77,16 +77,16 @@ inline void BytecodeReader::align32() {
if (hasAlignment) {
BufPtr Save = At;
At = (const unsigned char *)((unsigned long)(At+3) & (~3UL));
- if (At > Save)
+ if (At > Save)
if (Handler) Handler->handleAlignment(At - Save);
- if (At > BlockEnd)
+ if (At > BlockEnd)
error("Ran out of data while aligning!");
}
}
/// Read a whole unsigned integer
inline unsigned BytecodeReader::read_uint() {
- if (At+4 > BlockEnd)
+ if (At+4 > BlockEnd)
error("Ran out of data reading uint!");
At += 4;
return At[-4] | (At[-3] << 8) | (At[-2] << 16) | (At[-1] << 24);
@@ -97,9 +97,9 @@ inline unsigned BytecodeReader::read_vbr_uint() {
unsigned Shift = 0;
unsigned Result = 0;
BufPtr Save = At;
-
+
do {
- if (At == BlockEnd)
+ if (At == BlockEnd)
error("Ran out of data reading vbr_uint!");
Result |= (unsigned)((*At++) & 0x7F) << Shift;
Shift += 7;
@@ -113,9 +113,9 @@ inline uint64_t BytecodeReader::read_vbr_uint64() {
unsigned Shift = 0;
uint64_t Result = 0;
BufPtr Save = At;
-
+
do {
- if (At == BlockEnd)
+ if (At == BlockEnd)
error("Ran out of data reading vbr_uint64!");
Result |= (uint64_t)((*At++) & 0x7F) << Shift;
Shift += 7;
@@ -151,7 +151,7 @@ inline std::string BytecodeReader::read_str() {
inline void BytecodeReader::read_data(void *Ptr, void *End) {
unsigned char *Start = (unsigned char *)Ptr;
unsigned Amount = (unsigned char *)End - Start;
- if (At+Amount > BlockEnd)
+ if (At+Amount > BlockEnd)
error("Ran out of data!");
std::copy(At, At+Amount, Start);
At += Amount;
@@ -178,9 +178,9 @@ inline void BytecodeReader::read_double(double& DoubleVal) {
double d;
uint64_t i;
} DoubleUnion;
- DoubleUnion.i = (uint64_t(At[0]) << 0) | (uint64_t(At[1]) << 8) |
+ DoubleUnion.i = (uint64_t(At[0]) << 0) | (uint64_t(At[1]) << 8) |
(uint64_t(At[2]) << 16) | (uint64_t(At[3]) << 24) |
- (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) |
+ (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) |
(uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56);
At+=sizeof(uint64_t);
DoubleVal = DoubleUnion.d;
@@ -192,10 +192,10 @@ inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) {
Type = read_uint();
Size = read_uint();
switch (Type) {
- case BytecodeFormat::Reserved_DoNotUse :
+ case BytecodeFormat::Reserved_DoNotUse :
error("Reserved_DoNotUse used as Module Type?");
Type = BytecodeFormat::ModuleBlockID; break;
- case BytecodeFormat::Module:
+ case BytecodeFormat::Module:
Type = BytecodeFormat::ModuleBlockID; break;
case BytecodeFormat::Function:
Type = BytecodeFormat::FunctionBlockID; break;
@@ -238,8 +238,8 @@ inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) {
/// 1.3 this changed so that Type does not derive from Value. Consequently,
/// the BytecodeReader's containers for Values can't contain Types because
/// there's no inheritance relationship. This means that the "Type Type"
-/// plane is defunct along with the Type::TypeTyID TypeID. In LLVM 1.3
-/// whenever a bytecode construct must have both types and values together,
+/// plane is defunct along with the Type::TypeTyID TypeID. In LLVM 1.3
+/// whenever a bytecode construct must have both types and values together,
/// the types are always read/written first and then the Values. Furthermore
/// since Type::TypeTyID no longer exists, its value (12) now corresponds to
/// Type::LabelTyID. In order to overcome this we must "sanitize" all the
@@ -249,7 +249,7 @@ inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) {
/// larger than 12 (Type::LabelTyID). If the value is exactly 12, then this
/// function returns true, otherwise false. This helps detect situations
/// where the pre 1.3 bytecode is indicating that what follows is a type.
-/// @returns true iff type id corresponds to pre 1.3 "type type"
+/// @returns true iff type id corresponds to pre 1.3 "type type"
inline bool BytecodeReader::sanitizeTypeId(unsigned &TypeId) {
if (hasTypeDerivedFromValue) { /// do nothing if 1.3 or later
if (TypeId == Type::LabelTyID) {
@@ -342,7 +342,7 @@ unsigned BytecodeReader::getTypeSlot(const Type *Ty) {
if (!CompactionTypes.empty()) {
for (unsigned i = 0, e = CompactionTypes.size(); i != e; ++i)
if (CompactionTypes[i].first == Ty)
- return Type::FirstDerivedTyID + i;
+ return Type::FirstDerivedTyID + i;
error("Couldn't find type specified in compaction table!");
}
@@ -352,7 +352,7 @@ unsigned BytecodeReader::getTypeSlot(const Type *Ty) {
FunctionTypes.end(), Ty);
if (I != FunctionTypes.end())
- return Type::FirstDerivedTyID + ModuleTypes.size() +
+ return Type::FirstDerivedTyID + ModuleTypes.size() +
(&*I - &FunctionTypes[0]);
// Check the module level types now...
@@ -390,8 +390,8 @@ unsigned BytecodeReader::getGlobalTableTypeSlot(const Type *Ty) {
return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]);
}
-/// Retrieve a value of a given type and slot number, possibly creating
-/// it if it doesn't already exist.
+/// Retrieve a value of a given type and slot number, possibly creating
+/// it if it doesn't already exist.
Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
assert(type != Type::LabelTyID && "getValue() cannot get blocks!");
unsigned Num = oNum;
@@ -424,8 +424,8 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
}
}
- if (FunctionValues.size() > type &&
- FunctionValues[type] &&
+ if (FunctionValues.size() > type &&
+ FunctionValues[type] &&
Num < FunctionValues[type]->size())
return FunctionValues[type]->getOperand(Num);
@@ -447,8 +447,8 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
throw "Can't create placeholder for value of type slot #" + utostr(type);
}
-/// This is just like getValue, but when a compaction table is in use, it
-/// is ignored. Also, no forward references or other fancy features are
+/// This is just like getValue, but when a compaction table is in use, it
+/// is ignored. Also, no forward references or other fancy features are
/// supported.
Value* BytecodeReader::getGlobalTableValue(unsigned TyID, unsigned SlotNo) {
if (SlotNo == 0)
@@ -467,11 +467,11 @@ Value* BytecodeReader::getGlobalTableValue(unsigned TyID, unsigned SlotNo) {
SlotNo >= ModuleValues[TyID]->size()) {
if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0)
error("Corrupt compaction table entry!"
- + utostr(TyID) + ", " + utostr(SlotNo) + ": "
+ + utostr(TyID) + ", " + utostr(SlotNo) + ": "
+ utostr(ModuleValues.size()));
- else
+ else
error("Corrupt compaction table entry!"
- + utostr(TyID) + ", " + utostr(SlotNo) + ": "
+ + utostr(TyID) + ", " + utostr(SlotNo) + ": "
+ utostr(ModuleValues.size()) + ", "
+ utohexstr(reinterpret_cast<uint64_t>(((void*)ModuleValues[TyID])))
+ ", "
@@ -483,14 +483,14 @@ Value* BytecodeReader::getGlobalTableValue(unsigned TyID, unsigned SlotNo) {
/// Just like getValue, except that it returns a null pointer
/// only on error. It always returns a constant (meaning that if the value is
/// defined, but is not a constant, that is an error). If the specified
-/// constant hasn't been parsed yet, a placeholder is defined and used.
+/// constant hasn't been parsed yet, a placeholder is defined and used.
/// Later, after the real value is parsed, the placeholder is eliminated.
Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) {
if (Value *V = getValue(TypeSlot, Slot, false))
if (Constant *C = dyn_cast<Constant>(V))
return C; // If we already have the value parsed, just return it
else
- error("Value for slot " + utostr(Slot) +
+ error("Value for slot " + utostr(Slot) +
" is expected to be a constant!");
std::pair<unsigned, unsigned> Key(TypeSlot, Slot);
@@ -502,7 +502,7 @@ Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) {
// Create a placeholder for the constant reference and
// keep track of the fact that we have a forward ref to recycle it
Constant *C = new ConstantPlaceHolder(getType(TypeSlot));
-
+
// Keep track of the fact that we have a forward ref to recycle it
ConstantFwdRefs.insert(I, std::make_pair(Key, C));
return C;
@@ -516,7 +516,7 @@ Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) {
/// As values are created, they are inserted into the appropriate place
/// with this method. The ValueTable argument must be one of ModuleValues
/// or FunctionValues data members of this class.
-unsigned BytecodeReader::insertValue(Value *Val, unsigned type,
+unsigned BytecodeReader::insertValue(Value *Val, unsigned type,
ValueTable &ValueTab) {
assert((!isa<Constant>(Val) || !cast<Constant>(Val)->isNullValue()) ||
!hasImplicitNull(type) &&
@@ -584,7 +584,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
// --------------------------
// 15-08: Resulting type plane
// 23-16: Operand #1
- // 31-24: Operand #2
+ // 31-24: Operand #2
//
iType = (Op >> 8) & 255;
Oprnds[0] = (Op >> 16) & 255;
@@ -646,20 +646,20 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
getValue(iType, Oprnds[1]));
switch (Opcode) {
- default:
- if (Result == 0)
+ default:
+ if (Result == 0)
error("Illegal instruction read!");
break;
case Instruction::VAArg:
- Result = new VAArgInst(getValue(iType, Oprnds[0]),
+ Result = new VAArgInst(getValue(iType, Oprnds[0]),
getSanitizedType(Oprnds[1]));
break;
case Instruction::VANext:
- Result = new VANextInst(getValue(iType, Oprnds[0]),
+ Result = new VANextInst(getValue(iType, Oprnds[0]),
getSanitizedType(Oprnds[1]));
break;
case Instruction::Cast:
- Result = new CastInst(getValue(iType, Oprnds[0]),
+ Result = new CastInst(getValue(iType, Oprnds[0]),
getSanitizedType(Oprnds[1]));
break;
case Instruction::Select:
@@ -698,7 +698,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
if (Oprnds.size() == 1)
Result = new BranchInst(getBasicBlock(Oprnds[0]));
else if (Oprnds.size() == 3)
- Result = new BranchInst(getBasicBlock(Oprnds[0]),
+ Result = new BranchInst(getBasicBlock(Oprnds[0]),
getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2]));
else
error("Invalid number of operands for a 'br' instruction!");
@@ -750,13 +750,13 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
// Read all of the fixed arguments
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Oprnds[i]));
-
+
FirstVariableOperand = FTy->getNumParams();
- if ((Oprnds.size()-FirstVariableOperand) & 1)
+ if ((Oprnds.size()-FirstVariableOperand) & 1)
error("Invalid call instruction!"); // Must be pairs of type/value
-
- for (unsigned i = FirstVariableOperand, e = Oprnds.size();
+
+ for (unsigned i = FirstVariableOperand, e = Oprnds.size();
i != e; i += 2)
Params.push_back(getValue(Oprnds[i], Oprnds[i+1]));
}
@@ -765,16 +765,16 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
break;
}
case Instruction::Invoke: {
- if (Oprnds.size() < 3)
+ if (Oprnds.size() < 3)
error("Invalid invoke instruction!");
Value *F = getValue(iType, Oprnds[0]);
// Check to make sure we have a pointer to function type
const PointerType *PTy = dyn_cast<PointerType>(F->getType());
- if (PTy == 0)
+ if (PTy == 0)
error("Invoke to non function pointer value!");
const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType());
- if (FTy == 0)
+ if (FTy == 0)
error("Invoke to non function pointer value!");
std::vector<Value *> Params;
@@ -797,12 +797,12 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
Normal = getBasicBlock(Oprnds[0]);
Except = getBasicBlock(Oprnds[1]);
-
+
unsigned FirstVariableArgument = FTy->getNumParams()+2;
for (unsigned i = 2; i != FirstVariableArgument; ++i)
Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)),
Oprnds[i]));
-
+
if (Oprnds.size()-FirstVariableArgument & 1) // Must be type/value pairs
error("Invalid invoke instruction!");
@@ -814,7 +814,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
break;
}
case Instruction::Malloc:
- if (Oprnds.size() > 2)
+ if (Oprnds.size() > 2)
error("Invalid malloc instruction!");
if (!isa<PointerType>(InstTy))
error("Invalid malloc instruction!");
@@ -825,13 +825,13 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
break;
case Instruction::Alloca:
- if (Oprnds.size() > 2)
+ if (Oprnds.size() > 2)
error("Invalid alloca instruction!");
if (!isa<PointerType>(InstTy))
error("Invalid alloca instruction!");
Result = new AllocaInst(cast<PointerType>(InstTy)->getElementType(),
- Oprnds.size() ? getValue(Type::UIntTyID,
+ Oprnds.size() ? getValue(Type::UIntTyID,
Oprnds[0]) :0);
break;
case Instruction::Free:
@@ -848,8 +848,8 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
const Type *NextTy = InstTy;
for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) {
const CompositeType *TopTy = dyn_cast_or_null<CompositeType>(NextTy);
- if (!TopTy)
- error("Invalid getelementptr instruction!");
+ if (!TopTy)
+ error("Invalid getelementptr instruction!");
unsigned ValIdx = Oprnds[i];
unsigned IdxTy = 0;
@@ -894,7 +894,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62);
break;
- case 63: // volatile store
+ case 63: // volatile store
case Instruction::Store: {
if (!isa<PointerType>(InstTy) || Oprnds.size() != 2)
error("Invalid store instruction!");
@@ -913,7 +913,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
if (Oprnds.size() != 0) error("Invalid unreachable instruction!");
Result = new UnreachableInst();
break;
- } // end switch(Opcode)
+ } // end switch(Opcode)
unsigned TypeSlot;
if (Result->getType() == InstTy)
@@ -945,7 +945,7 @@ BasicBlock *BytecodeReader::getBasicBlock(unsigned ID) {
return ParsedBasicBlocks[ID] = new BasicBlock();
}
-/// In LLVM 1.0 bytecode files, we used to output one basicblock at a time.
+/// In LLVM 1.0 bytecode files, we used to output one basicblock at a time.
/// This method reads in one of the basicblock packets. This method is not used
/// for bytecode files after LLVM 1.0
/// @returns The basic block constructed.
@@ -970,7 +970,7 @@ BasicBlock *BytecodeReader::ParseBasicBlock(unsigned BlockNo) {
}
/// Parse all of the BasicBlock's & Instruction's in the body of a function.
-/// In post 1.0 bytecode files, we no longer emit basic block individually,
+/// In