}
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
- std::vector<unsigned>& Operands,
+ unsigned *Operands, unsigned NumOps,
Instruction *Inst,
unsigned Size){
if (os) {
*os << " INST: OpCode="
<< Instruction::getOpcodeName(Opcode);
- for ( unsigned i = 0; i < Operands.size(); ++i )
+ for (unsigned i = 0; i != NumOps; ++i)
*os << " Op(" << Operands[i] << ")";
*os << *Inst;
}
bca.numValues++;
bca.instructionSize += Size;
if (Size > 4 ) bca.longInstructions++;
- bca.numOperands += Operands.size();
- for (unsigned i = 0; i < Operands.size(); ++i )
+ bca.numOperands += NumOps;
+ for (unsigned i = 0; i != NumOps; ++i)
if (Operands[i] > bca.maxValueSlot)
bca.maxValueSlot = Operands[i];
if ( currFunc ) {
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);
}
*os << " BLOCK: GlobalConstants {\n";
}
- virtual void handleConstantExpression( unsigned Opcode,
- std::vector<Constant*> ArgVec, Constant* C ) {
+ virtual void handleConstantExpression(unsigned Opcode,
+ Constant**ArgVec, unsigned NumArgs, Constant* C) {
if (os) {
*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 << "\n";
}
}
virtual void handleConstantArray( const ArrayType* AT,
- std::vector<Constant*>& Elements,
+ Constant**Elements, unsigned NumElts,
unsigned TypeSlot,
Constant* ArrayVal ) {
if (os) {
*os << " ARRAY: ";
WriteTypeSymbolic(*os,AT,M);
*os << " TypeSlot=" << TypeSlot << "\n";
- for ( unsigned i = 0; i < Elements.size(); ++i ) {
+ for (unsigned i = 0; i != NumElts; ++i) {
*os << " #" << i;
Elements[i]->print(*os);
*os << "\n";
virtual void handleConstantStruct(
const StructType* ST,
- std::vector<Constant*>& Elements,
+ Constant**Elements, unsigned NumElts,
Constant* StructVal)
{
if (os) {
*os << " STRUC: ";
WriteTypeSymbolic(*os,ST,M);
*os << "\n";
- for ( unsigned i = 0; i < Elements.size(); ++i ) {
+ for ( unsigned i = 0; i != NumElts; ++i) {
*os << " #" << i << " "; Elements[i]->print(*os);
*os << "\n";
}
virtual void handleConstantPacked(
const PackedType* PT,
- std::vector<Constant*>& Elements,
+ Constant**Elements, unsigned NumElts,
unsigned TypeSlot,
Constant* PackedVal)
{
*os << " PACKD: ";
WriteTypeSymbolic(*os,PT,M);
*os << " TypeSlot=" << TypeSlot << "\n";
- for ( unsigned i = 0; i < Elements.size(); ++i ) {
+ for ( unsigned i = 0; i != NumElts; ++i ) {
*os << " #" << i;
Elements[i]->print(*os);
*os << "\n";
/// This method parses a single instruction. The instruction is
/// inserted at the end of the \p BB provided. The arguments of
/// 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) {
BufPtr SaveAt = At;
// We have enough info to inform the handler now.
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);
}
/// @returns the number of basic blocks encountered.
unsigned BytecodeReader::ParseInstructionList(Function* F) {
unsigned BlockNo = 0;
- std::vector<unsigned> Args;
+ SmallVector<unsigned, 8> Args;
while (moreInBlock()) {
if (Handler) Handler->handleBasicBlockBegin(BlockNo);
if (Handler) Handler->handleValueSymbolTableBegin(CurrentFunction,VST);
// Allow efficient basic block lookup by number.
- std::vector<BasicBlock*> BBMap;
+ SmallVector<BasicBlock*, 32> BBMap;
if (CurrentFunction)
for (Function::iterator I = CurrentFunction->begin(),
E = CurrentFunction->end(); I != E; ++I)
Constant *Result = ConstantExpr::getCast(Opcode, ArgVec[0],
getType(TypeID));
- if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
+ if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
+ ArgVec.size(), Result);
return Result;
} else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr
Constant *Result = ConstantExpr::getGetElementPtr(ArgVec[0], &ArgVec[1],
ArgVec.size()-1);
- if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
+ if (Handler) Handler->handleConstantExpression(Opcode, &ArgVec[0],
+ ArgVec.size(), Result);
return Result;
} else if (Opcode == Instruction::Select) {
if (ArgVec.size() != 3)
error("Select instruction must have three arguments.");
Constant* Result = ConstantExpr::getSelect(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;
} else if (Opcode == Instruction::ExtractElement) {
if (ArgVec.size() != 2 ||
!ExtractElementInst::isValidOperands(ArgVec[0], ArgVec[1]))
error("Invalid extractelement constand expr arguments");
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;
} else if (Opcode == Instruction::InsertElement) {
if (ArgVec.size() != 3 ||
Constant *Result =
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;
} else if (Opcode == Instruction::ShuffleVector) {
if (ArgVec.size() != 3 ||
error("Invalid shufflevector constant expr arguments.");
Constant *Result =
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;
} else if (Opcode == Instruction::ICmp) {
if (ArgVec.size() != 2)
error("Invalid ICmp constant expr arguments.");
unsigned predicate = read_vbr_uint();
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;
} else if (Opcode == Instruction::FCmp) {
if (ArgVec.size() != 2)
error("Invalid FCmp constant expr arguments.");
unsigned predicate = read_vbr_uint();
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;
} else { // All other 2-operand expressions
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;
}
}
Elements.push_back(getConstantValue(TypeSlot,
read_vbr_uint()));
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;
}
read_vbr_uint()));
Result = ConstantStruct::get(ST, Elements);
- if (Handler) Handler->handleConstantStruct(ST, Elements, Result);
+ if (Handler) Handler->handleConstantStruct(ST, &Elements[0],Elements.size(),
+ Result);
break;
}
Elements.push_back(getConstantValue(TypeSlot,
read_vbr_uint()));
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;
}