mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Implement tracking of bytecode instruction size and the number of long
instructions generated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14154 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f6d023312f
commit
1cf5024de1
@ -55,6 +55,8 @@ struct BytecodeAnalysis {
|
|||||||
///< the file is more sparse.
|
///< the file is more sparse.
|
||||||
double globalsDensity; ///< density of global defs (bytes/definition)
|
double globalsDensity; ///< density of global defs (bytes/definition)
|
||||||
double functionDensity; ///< Average density of functions (bytes/function)
|
double functionDensity; ///< Average density of functions (bytes/function)
|
||||||
|
unsigned instructionSize; ///< Size of instructions in bytes
|
||||||
|
unsigned longInstructions;///< Number of instructions > 4 bytes
|
||||||
unsigned vbrCount32; ///< Number of 32-bit vbr values
|
unsigned vbrCount32; ///< Number of 32-bit vbr values
|
||||||
unsigned vbrCount64; ///< Number of 64-bit vbr values
|
unsigned vbrCount64; ///< Number of 64-bit vbr values
|
||||||
unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
|
unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
|
||||||
@ -67,13 +69,15 @@ struct BytecodeAnalysis {
|
|||||||
/// an analysis of a single function.
|
/// an analysis of a single function.
|
||||||
struct BytecodeFunctionInfo {
|
struct BytecodeFunctionInfo {
|
||||||
std::string description; ///< Function type description
|
std::string description; ///< Function type description
|
||||||
std::string name; ///< Name of function if it has one
|
std::string name; ///< Name of function if it has one
|
||||||
unsigned byteSize; ///< The size of the function in bytecode bytes
|
unsigned byteSize; ///< The size of the function in bytecode bytes
|
||||||
unsigned numInstructions; ///< The number of instructions in the function
|
unsigned numInstructions; ///< The number of instructions in the function
|
||||||
unsigned numBasicBlocks; ///< The number of basic blocks in the function
|
unsigned numBasicBlocks; ///< The number of basic blocks in the function
|
||||||
unsigned numPhis; ///< Number of Phi Nodes in Instructions
|
unsigned numPhis; ///< Number of Phi Nodes in Instructions
|
||||||
unsigned numOperands; ///< The number of operands in the function
|
unsigned numOperands; ///< The number of operands in the function
|
||||||
double density; ///< Density of function
|
double density; ///< Density of function
|
||||||
|
unsigned instructionSize; ///< Size of instructions in bytes
|
||||||
|
unsigned longInstructions;///< Number of instructions > 4 bytes
|
||||||
unsigned vbrCount32; ///< Number of 32-bit vbr values
|
unsigned vbrCount32; ///< Number of 32-bit vbr values
|
||||||
unsigned vbrCount64; ///< Number of 64-bit vbr values
|
unsigned vbrCount64; ///< Number of 64-bit vbr values
|
||||||
unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
|
unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
bca.fileDensity = 0.0;
|
bca.fileDensity = 0.0;
|
||||||
bca.globalsDensity = 0.0;
|
bca.globalsDensity = 0.0;
|
||||||
bca.functionDensity = 0.0;
|
bca.functionDensity = 0.0;
|
||||||
|
bca.instructionSize = 0;
|
||||||
|
bca.longInstructions = 0;
|
||||||
bca.vbrCount32 = 0;
|
bca.vbrCount32 = 0;
|
||||||
bca.vbrCount64 = 0;
|
bca.vbrCount64 = 0;
|
||||||
bca.vbrCompBytes = 0;
|
bca.vbrCompBytes = 0;
|
||||||
@ -167,6 +169,8 @@ public:
|
|||||||
currFunc->numPhis = 0;
|
currFunc->numPhis = 0;
|
||||||
currFunc->numOperands = 0;
|
currFunc->numOperands = 0;
|
||||||
currFunc->density = 0.0;
|
currFunc->density = 0.0;
|
||||||
|
currFunc->instructionSize = 0;
|
||||||
|
currFunc->longInstructions = 0;
|
||||||
currFunc->vbrCount32 = 0;
|
currFunc->vbrCount32 = 0;
|
||||||
currFunc->vbrCount64 = 0;
|
currFunc->vbrCount64 = 0;
|
||||||
currFunc->vbrCompBytes = 0;
|
currFunc->vbrCompBytes = 0;
|
||||||
@ -188,9 +192,13 @@ public:
|
|||||||
std::vector<unsigned>& Operands, unsigned Size) {
|
std::vector<unsigned>& Operands, unsigned Size) {
|
||||||
bca.numInstructions++;
|
bca.numInstructions++;
|
||||||
bca.numValues++;
|
bca.numValues++;
|
||||||
|
bca.instructionSize += Size;
|
||||||
|
if (Size > 4 ) bca.longInstructions++;
|
||||||
bca.numOperands += Operands.size();
|
bca.numOperands += Operands.size();
|
||||||
if ( currFunc ) {
|
if ( currFunc ) {
|
||||||
currFunc->numInstructions++;
|
currFunc->numInstructions++;
|
||||||
|
currFunc->instructionSize += Size;
|
||||||
|
if (Size > 4 ) currFunc->longInstructions++;
|
||||||
if ( Opcode == Instruction::PHI ) currFunc->numPhis++;
|
if ( Opcode == Instruction::PHI ) currFunc->numPhis++;
|
||||||
}
|
}
|
||||||
return Instruction::isTerminator(Opcode);
|
return Instruction::isTerminator(Opcode);
|
||||||
|
@ -249,6 +249,10 @@ void llvm::PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
|
|||||||
print(Out, "Number Of Operands", bca.numOperands);
|
print(Out, "Number Of Operands", bca.numOperands);
|
||||||
print(Out, "Number Of Compaction Tables", bca.numCmpctnTables);
|
print(Out, "Number Of Compaction Tables", bca.numCmpctnTables);
|
||||||
print(Out, "Number Of Symbol Tables", bca.numSymTab);
|
print(Out, "Number Of Symbol Tables", bca.numSymTab);
|
||||||
|
print(Out, "Long Instructions", bca.longInstructions);
|
||||||
|
print(Out, "Instruction Size", bca.instructionSize);
|
||||||
|
print(Out, "Average Instruction Size",
|
||||||
|
double(bca.instructionSize)/double(bca.numInstructions));
|
||||||
print(Out, "Maximum Type Slot Number", bca.maxTypeSlot);
|
print(Out, "Maximum Type Slot Number", bca.maxTypeSlot);
|
||||||
print(Out, "Maximum Value Slot Number", bca.maxValueSlot);
|
print(Out, "Maximum Value Slot Number", bca.maxValueSlot);
|
||||||
print(Out, "Bytes Thrown To Alignment", double(bca.numAlignment),
|
print(Out, "Bytes Thrown To Alignment", double(bca.numAlignment),
|
||||||
@ -304,6 +308,10 @@ void llvm::PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
|
|||||||
print(Out, "Type:", I->second.description);
|
print(Out, "Type:", I->second.description);
|
||||||
print(Out, "Byte Size", I->second.byteSize);
|
print(Out, "Byte Size", I->second.byteSize);
|
||||||
print(Out, "Instructions", I->second.numInstructions);
|
print(Out, "Instructions", I->second.numInstructions);
|
||||||
|
print(Out, "Long Instructions", I->second.longInstructions);
|
||||||
|
print(Out, "Instruction Size", I->second.instructionSize);
|
||||||
|
print(Out, "Average Instruction Size",
|
||||||
|
double(I->second.instructionSize)/double(I->second.numInstructions));
|
||||||
print(Out, "Basic Blocks", I->second.numBasicBlocks);
|
print(Out, "Basic Blocks", I->second.numBasicBlocks);
|
||||||
print(Out, "Operand", I->second.numOperands);
|
print(Out, "Operand", I->second.numOperands);
|
||||||
print(Out, "Function Density", I->second.density);
|
print(Out, "Function Density", I->second.density);
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
bca.fileDensity = 0.0;
|
bca.fileDensity = 0.0;
|
||||||
bca.globalsDensity = 0.0;
|
bca.globalsDensity = 0.0;
|
||||||
bca.functionDensity = 0.0;
|
bca.functionDensity = 0.0;
|
||||||
|
bca.instructionSize = 0;
|
||||||
|
bca.longInstructions = 0;
|
||||||
bca.vbrCount32 = 0;
|
bca.vbrCount32 = 0;
|
||||||
bca.vbrCount64 = 0;
|
bca.vbrCount64 = 0;
|
||||||
bca.vbrCompBytes = 0;
|
bca.vbrCompBytes = 0;
|
||||||
@ -167,6 +169,8 @@ public:
|
|||||||
currFunc->numPhis = 0;
|
currFunc->numPhis = 0;
|
||||||
currFunc->numOperands = 0;
|
currFunc->numOperands = 0;
|
||||||
currFunc->density = 0.0;
|
currFunc->density = 0.0;
|
||||||
|
currFunc->instructionSize = 0;
|
||||||
|
currFunc->longInstructions = 0;
|
||||||
currFunc->vbrCount32 = 0;
|
currFunc->vbrCount32 = 0;
|
||||||
currFunc->vbrCount64 = 0;
|
currFunc->vbrCount64 = 0;
|
||||||
currFunc->vbrCompBytes = 0;
|
currFunc->vbrCompBytes = 0;
|
||||||
@ -188,9 +192,13 @@ public:
|
|||||||
std::vector<unsigned>& Operands, unsigned Size) {
|
std::vector<unsigned>& Operands, unsigned Size) {
|
||||||
bca.numInstructions++;
|
bca.numInstructions++;
|
||||||
bca.numValues++;
|
bca.numValues++;
|
||||||
|
bca.instructionSize += Size;
|
||||||
|
if (Size > 4 ) bca.longInstructions++;
|
||||||
bca.numOperands += Operands.size();
|
bca.numOperands += Operands.size();
|
||||||
if ( currFunc ) {
|
if ( currFunc ) {
|
||||||
currFunc->numInstructions++;
|
currFunc->numInstructions++;
|
||||||
|
currFunc->instructionSize += Size;
|
||||||
|
if (Size > 4 ) currFunc->longInstructions++;
|
||||||
if ( Opcode == Instruction::PHI ) currFunc->numPhis++;
|
if ( Opcode == Instruction::PHI ) currFunc->numPhis++;
|
||||||
}
|
}
|
||||||
return Instruction::isTerminator(Opcode);
|
return Instruction::isTerminator(Opcode);
|
||||||
|
@ -249,6 +249,10 @@ void llvm::PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
|
|||||||
print(Out, "Number Of Operands", bca.numOperands);
|
print(Out, "Number Of Operands", bca.numOperands);
|
||||||
print(Out, "Number Of Compaction Tables", bca.numCmpctnTables);
|
print(Out, "Number Of Compaction Tables", bca.numCmpctnTables);
|
||||||
print(Out, "Number Of Symbol Tables", bca.numSymTab);
|
print(Out, "Number Of Symbol Tables", bca.numSymTab);
|
||||||
|
print(Out, "Long Instructions", bca.longInstructions);
|
||||||
|
print(Out, "Instruction Size", bca.instructionSize);
|
||||||
|
print(Out, "Average Instruction Size",
|
||||||
|
double(bca.instructionSize)/double(bca.numInstructions));
|
||||||
print(Out, "Maximum Type Slot Number", bca.maxTypeSlot);
|
print(Out, "Maximum Type Slot Number", bca.maxTypeSlot);
|
||||||
print(Out, "Maximum Value Slot Number", bca.maxValueSlot);
|
print(Out, "Maximum Value Slot Number", bca.maxValueSlot);
|
||||||
print(Out, "Bytes Thrown To Alignment", double(bca.numAlignment),
|
print(Out, "Bytes Thrown To Alignment", double(bca.numAlignment),
|
||||||
@ -304,6 +308,10 @@ void llvm::PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
|
|||||||
print(Out, "Type:", I->second.description);
|
print(Out, "Type:", I->second.description);
|
||||||
print(Out, "Byte Size", I->second.byteSize);
|
print(Out, "Byte Size", I->second.byteSize);
|
||||||
print(Out, "Instructions", I->second.numInstructions);
|
print(Out, "Instructions", I->second.numInstructions);
|
||||||
|
print(Out, "Long Instructions", I->second.longInstructions);
|
||||||
|
print(Out, "Instruction Size", I->second.instructionSize);
|
||||||
|
print(Out, "Average Instruction Size",
|
||||||
|
double(I->second.instructionSize)/double(I->second.numInstructions));
|
||||||
print(Out, "Basic Blocks", I->second.numBasicBlocks);
|
print(Out, "Basic Blocks", I->second.numBasicBlocks);
|
||||||
print(Out, "Operand", I->second.numOperands);
|
print(Out, "Operand", I->second.numOperands);
|
||||||
print(Out, "Function Density", I->second.density);
|
print(Out, "Function Density", I->second.density);
|
||||||
|
Loading…
Reference in New Issue
Block a user