mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 20:33:15 +00:00
Eliminate std::vectors from the bcanalyzer interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33978 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4d544cd646
commit
63cf59ed3f
@ -359,13 +359,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
|
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
|
||||||
std::vector<unsigned>& Operands,
|
unsigned *Operands, unsigned NumOps,
|
||||||
Instruction *Inst,
|
Instruction *Inst,
|
||||||
unsigned Size){
|
unsigned Size){
|
||||||
if (os) {
|
if (os) {
|
||||||
*os << " INST: OpCode="
|
*os << " INST: OpCode="
|
||||||
<< Instruction::getOpcodeName(Opcode);
|
<< Instruction::getOpcodeName(Opcode);
|
||||||
for ( unsigned i = 0; i < Operands.size(); ++i )
|
for (unsigned i = 0; i != NumOps; ++i)
|
||||||
*os << " Op(" << Operands[i] << ")";
|
*os << " Op(" << Operands[i] << ")";
|
||||||
*os << *Inst;
|
*os << *Inst;
|
||||||
}
|
}
|
||||||
@ -374,15 +374,15 @@ public:
|
|||||||
bca.numValues++;
|
bca.numValues++;
|
||||||
bca.instructionSize += Size;
|
bca.instructionSize += Size;
|
||||||
if (Size > 4 ) bca.longInstructions++;
|
if (Size > 4 ) bca.longInstructions++;
|
||||||
bca.numOperands += Operands.size();
|
bca.numOperands += NumOps;
|
||||||
for (unsigned i = 0; i < Operands.size(); ++i )
|
for (unsigned i = 0; i != NumOps; ++i)
|
||||||
if (Operands[i] > bca.maxValueSlot)
|
if (Operands[i] > bca.maxValueSlot)
|
||||||
bca.maxValueSlot = Operands[i];
|
bca.maxValueSlot = Operands[i];
|
||||||
if ( currFunc ) {
|
if ( currFunc ) {
|
||||||
currFunc->numInstructions++;
|
currFunc->numInstructions++;
|
||||||
currFunc->instructionSize += Size;
|
currFunc->instructionSize += Size;
|
||||||
if (Size > 4 ) currFunc->longInstructions++;
|
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);
|
||||||
}
|
}
|
||||||
@ -397,11 +397,11 @@ public:
|
|||||||
*os << " BLOCK: GlobalConstants {\n";
|
*os << " BLOCK: GlobalConstants {\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleConstantExpression( unsigned Opcode,
|
virtual void handleConstantExpression(unsigned Opcode,
|
||||||
std::vector<Constant*> ArgVec, Constant* C ) {
|
Constant**ArgVec, unsigned NumArgs, Constant* C) {
|
||||||
if (os) {
|
if (os) {
|
||||||
*os << " EXPR: " << Instruction::getOpcodeName(Opcode) << "\n";
|
*os << " EXPR: " << Instruction::getOpcodeName(Opcode) << "\n";
|
||||||
for ( unsigned i = 0; i < ArgVec.size(); ++i ) {
|
for ( unsigned i = 0; i != NumArgs; ++i ) {
|
||||||
*os << " Arg#" << i << " "; ArgVec[i]->print(*os);
|
*os << " Arg#" << i << " "; ArgVec[i]->print(*os);
|
||||||
*os << "\n";
|
*os << "\n";
|
||||||
}
|
}
|
||||||
@ -424,14 +424,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleConstantArray( const ArrayType* AT,
|
virtual void handleConstantArray( const ArrayType* AT,
|
||||||
std::vector<Constant*>& Elements,
|
Constant**Elements, unsigned NumElts,
|
||||||
unsigned TypeSlot,
|
unsigned TypeSlot,
|
||||||
Constant* ArrayVal ) {
|
Constant* ArrayVal ) {
|
||||||
if (os) {
|
if (os) {
|
||||||
*os << " ARRAY: ";
|
*os << " ARRAY: ";
|
||||||
WriteTypeSymbolic(*os,AT,M);
|
WriteTypeSymbolic(*os,AT,M);
|
||||||
*os << " TypeSlot=" << TypeSlot << "\n";
|
*os << " TypeSlot=" << TypeSlot << "\n";
|
||||||
for ( unsigned i = 0; i < Elements.size(); ++i ) {
|
for (unsigned i = 0; i != NumElts; ++i) {
|
||||||
*os << " #" << i;
|
*os << " #" << i;
|
||||||
Elements[i]->print(*os);
|
Elements[i]->print(*os);
|
||||||
*os << "\n";
|
*os << "\n";
|
||||||
@ -447,14 +447,14 @@ public:
|
|||||||
|
|
||||||
virtual void handleConstantStruct(
|
virtual void handleConstantStruct(
|
||||||
const StructType* ST,
|
const StructType* ST,
|
||||||
std::vector<Constant*>& Elements,
|
Constant**Elements, unsigned NumElts,
|
||||||
Constant* StructVal)
|
Constant* StructVal)
|
||||||
{
|
{
|
||||||
if (os) {
|
if (os) {
|
||||||
*os << " STRUC: ";
|
*os << " STRUC: ";
|
||||||
WriteTypeSymbolic(*os,ST,M);
|
WriteTypeSymbolic(*os,ST,M);
|
||||||
*os << "\n";
|
*os << "\n";
|
||||||
for ( unsigned i = 0; i < Elements.size(); ++i ) {
|
for ( unsigned i = 0; i != NumElts; ++i) {
|
||||||
*os << " #" << i << " "; Elements[i]->print(*os);
|
*os << " #" << i << " "; Elements[i]->print(*os);
|
||||||
*os << "\n";
|
*os << "\n";
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ public:
|
|||||||
|
|
||||||
virtual void handleConstantPacked(
|
virtual void handleConstantPacked(
|
||||||
const PackedType* PT,
|
const PackedType* PT,
|
||||||
std::vector<Constant*>& Elements,
|
Constant**Elements, unsigned NumElts,
|
||||||
unsigned TypeSlot,
|
unsigned TypeSlot,
|
||||||
Constant* PackedVal)
|
Constant* PackedVal)
|
||||||
{
|
{
|
||||||
@ -476,7 +476,7 @@ public:
|
|||||||
*os << " PACKD: ";
|
*os << " PACKD: ";
|
||||||
WriteTypeSymbolic(*os,PT,M);
|
WriteTypeSymbolic(*os,PT,M);
|
||||||
*os << " TypeSlot=" << TypeSlot << "\n";
|
*os << " TypeSlot=" << TypeSlot << "\n";
|
||||||
for ( unsigned i = 0; i < Elements.size(); ++i ) {
|
for ( unsigned i = 0; i != NumElts; ++i ) {
|
||||||
*os << " #" << i;
|
*os << " #" << i;
|
||||||
Elements[i]->print(*os);
|
Elements[i]->print(*os);
|
||||||
*os << "\n";
|
*os << "\n";
|
||||||
|
@ -366,7 +366,7 @@ void BytecodeReader::insertArguments(Function* F) {
|
|||||||
/// This method parses a single instruction. The instruction is
|
/// This method parses a single instruction. The instruction is
|
||||||
/// inserted at the end of the \p BB provided. The arguments of
|
/// inserted at the end of the \p BB provided. The arguments of
|
||||||
/// the instruction are provided in the \p Oprnds vector.
|
/// the instruction are provided in the \p Oprnds vector.
|
||||||
void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
void BytecodeReader::ParseInstruction(SmallVector<unsigned, 8> &Oprnds,
|
||||||
BasicBlock* BB) {
|
BasicBlock* BB) {
|
||||||
BufPtr SaveAt = At;
|
BufPtr SaveAt = At;
|
||||||
|
|
||||||
@ -859,7 +859,8 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
|||||||
|
|
||||||
// We have enough info to inform the handler now.
|
// We have enough info to inform the handler now.
|
||||||
if (Handler)
|
if (Handler)
|
||||||
Handler->handleInstruction(Opcode, InstTy, Oprnds, Result, At-SaveAt);
|
Handler->handleInstruction(Opcode, InstTy, &Oprnds[0], Oprnds.size(),
|
||||||
|
Result, At-SaveAt);
|
||||||
|
|
||||||
insertValue(Result, TypeSlot, FunctionValues);
|
insertValue(Result, TypeSlot, FunctionValues);
|
||||||
}
|
}
|
||||||
@ -890,7 +891,7 @@ BasicBlock *BytecodeReader::getBasicBlock(unsigned ID) {
|
|||||||
/// @returns the number of basic blocks encountered.
|
/// @returns the number of basic blocks encountered.
|
||||||
unsigned BytecodeReader::ParseInstructionList(Function* F) {
|
unsigned BytecodeReader::ParseInstructionList(Function* F) {
|
||||||
unsigned BlockNo = 0;
|
unsigned BlockNo = 0;
|
||||||
std::vector<unsigned> Args;
|
SmallVector<unsigned, 8> Args;
|
||||||
|
|
||||||
while (moreInBlock()) {
|
while (moreInBlock()) {
|
||||||
if (Handler) Handler->handleBasicBlockBegin(BlockNo);
|
if (Handler) Handler->handleBasicBlockBegin(BlockNo);
|
||||||
@ -941,7 +942,7 @@ void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
|
|||||||
if (Handler) Handler->handleValueSymbolTableBegin(CurrentFunction,VST);
|
if (Handler) Handler->handleValueSymbolTableBegin(CurrentFunction,VST);
|
||||||
|
|
||||||
// Allow efficient basic block lookup by number.
|
// Allow efficient basic block lookup by number.
|
||||||
std::vector<BasicBlock*> BBMap;
|
SmallVector<BasicBlock*, 32> BBMap;
|
||||||
if (CurrentFunction)
|
if (CurrentFunction)
|
||||||
for (Function::iterator I = CurrentFunction->begin(),
|
for (Function::iterator I = CurrentFunction->begin(),
|
||||||
E = CurrentFunction->end(); I != E; ++I)
|
E = CurrentFunction->end(); I != E; ++I)
|
||||||
@ -1166,26 +1167,30 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
|
|
||||||
Constant *Result = ConstantExpr::getCast(Opcode, ArgVec[0],
|
Constant *Result = ConstantExpr::getCast(Opcode, ArgVec[0],
|
||||||
getType(TypeID));
|
getType(TypeID));
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr
|
} else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr
|
||||||
Constant *Result = ConstantExpr::getGetElementPtr(ArgVec[0], &ArgVec[1],
|
Constant *Result = ConstantExpr::getGetElementPtr(ArgVec[0], &ArgVec[1],
|
||||||
ArgVec.size()-1);
|
ArgVec.size()-1);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::Select) {
|
} else if (Opcode == Instruction::Select) {
|
||||||
if (ArgVec.size() != 3)
|
if (ArgVec.size() != 3)
|
||||||
error("Select instruction must have three arguments.");
|
error("Select instruction must have three arguments.");
|
||||||
Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1],
|
Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1],
|
||||||
ArgVec[2]);
|
ArgVec[2]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::ExtractElement) {
|
} else if (Opcode == Instruction::ExtractElement) {
|
||||||
if (ArgVec.size() != 2 ||
|
if (ArgVec.size() != 2 ||
|
||||||
!ExtractElementInst::isValidOperands(ArgVec[0], ArgVec[1]))
|
!ExtractElementInst::isValidOperands(ArgVec[0], ArgVec[1]))
|
||||||
error("Invalid extractelement constand expr arguments");
|
error("Invalid extractelement constand expr arguments");
|
||||||
Constant* Result = ConstantExpr::getExtractElement(ArgVec[0], ArgVec[1]);
|
Constant* Result = ConstantExpr::getExtractElement(ArgVec[0], ArgVec[1]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::InsertElement) {
|
} else if (Opcode == Instruction::InsertElement) {
|
||||||
if (ArgVec.size() != 3 ||
|
if (ArgVec.size() != 3 ||
|
||||||
@ -1194,7 +1199,8 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
|
|
||||||
Constant *Result =
|
Constant *Result =
|
||||||
ConstantExpr::getInsertElement(ArgVec[0], ArgVec[1], ArgVec[2]);
|
ConstantExpr::getInsertElement(ArgVec[0], ArgVec[1], ArgVec[2]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::ShuffleVector) {
|
} else if (Opcode == Instruction::ShuffleVector) {
|
||||||
if (ArgVec.size() != 3 ||
|
if (ArgVec.size() != 3 ||
|
||||||
@ -1202,25 +1208,29 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
error("Invalid shufflevector constant expr arguments.");
|
error("Invalid shufflevector constant expr arguments.");
|
||||||
Constant *Result =
|
Constant *Result =
|
||||||
ConstantExpr::getShuffleVector(ArgVec[0], ArgVec[1], ArgVec[2]);
|
ConstantExpr::getShuffleVector(ArgVec[0], ArgVec[1], ArgVec[2]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::ICmp) {
|
} else if (Opcode == Instruction::ICmp) {
|
||||||
if (ArgVec.size() != 2)
|
if (ArgVec.size() != 2)
|
||||||
error("Invalid ICmp constant expr arguments.");
|
error("Invalid ICmp constant expr arguments.");
|
||||||
unsigned predicate = read_vbr_uint();
|
unsigned predicate = read_vbr_uint();
|
||||||
Constant *Result = ConstantExpr::getICmp(predicate, ArgVec[0], ArgVec[1]);
|
Constant *Result = ConstantExpr::getICmp(predicate, ArgVec[0], ArgVec[1]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else if (Opcode == Instruction::FCmp) {
|
} else if (Opcode == Instruction::FCmp) {
|
||||||
if (ArgVec.size() != 2)
|
if (ArgVec.size() != 2)
|
||||||
error("Invalid FCmp constant expr arguments.");
|
error("Invalid FCmp constant expr arguments.");
|
||||||
unsigned predicate = read_vbr_uint();
|
unsigned predicate = read_vbr_uint();
|
||||||
Constant *Result = ConstantExpr::getFCmp(predicate, ArgVec[0], ArgVec[1]);
|
Constant *Result = ConstantExpr::getFCmp(predicate, ArgVec[0], ArgVec[1]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
} else { // All other 2-operand expressions
|
} else { // All other 2-operand expressions
|
||||||
Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]);
|
Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]);
|
||||||
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
|
if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
|
||||||
|
ArgVec.size(), Result);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1273,7 +1283,8 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
Elements.push_back(getConstantValue(TypeSlot,
|
Elements.push_back(getConstantValue(TypeSlot,
|
||||||
read_vbr_uint()));
|
read_vbr_uint()));
|
||||||
Result = ConstantArray::get(AT, Elements);
|
Result = ConstantArray::get(AT, Elements);
|
||||||
if (Handler) Handler->handleConstantArray(AT, Elements, TypeSlot, Result);
|
if (Handler) Handler->handleConstantArray(AT, &Elements[0], Elements.size(),
|
||||||
|
TypeSlot, Result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1287,7 +1298,8 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
read_vbr_uint()));
|
read_vbr_uint()));
|
||||||
|
|
||||||
Result = ConstantStruct::get(ST, Elements);
|
Result = ConstantStruct::get(ST, Elements);
|
||||||
if (Handler) Handler->handleConstantStruct(ST, Elements, Result);
|
if (Handler) Handler->handleConstantStruct(ST, &Elements[0],Elements.size(),
|
||||||
|
Result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1301,7 +1313,8 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
|
|||||||
Elements.push_back(getConstantValue(TypeSlot,
|
Elements.push_back(getConstantValue(TypeSlot,
|
||||||
read_vbr_uint()));
|
read_vbr_uint()));
|
||||||
Result = ConstantPacked::get(PT, Elements);
|
Result = ConstantPacked::get(PT, Elements);
|
||||||
if (Handler) Handler->handleConstantPacked(PT, Elements, TypeSlot, Result);
|
if (Handler) Handler->handleConstantPacked(PT, &Elements[0],Elements.size(),
|
||||||
|
TypeSlot, Result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/ModuleProvider.h"
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/Bytecode/Analyzer.h"
|
#include "llvm/Bytecode/Analyzer.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <map>
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -228,7 +228,7 @@ protected:
|
|||||||
|
|
||||||
/// @brief Parse a single instruction.
|
/// @brief Parse a single instruction.
|
||||||
void ParseInstruction(
|
void ParseInstruction(
|
||||||
std::vector<unsigned>& Args, ///< The arguments to be filled in
|
SmallVector <unsigned, 8>& Args, ///< The arguments to be filled in
|
||||||
BasicBlock* BB ///< The BB the instruction goes in
|
BasicBlock* BB ///< The BB the instruction goes in
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user