77 if (cfgPass != NULL) {
81 "must overload handleProcedure method!");
91 int insCountDelta = 0;
96 PlaceHolders placeHolders;
99 std::set<TTAProgram::Instruction*> originalInstr;
104 for (
int bbIndex = 0; bbIndex < cfg.
nodeCount(); ++bbIndex) {
111 "Cannot replace a basic block without original address.");
115 for (
int bbIndex = 0; bbIndex < cfg.
nodeCount(); ++bbIndex) {
121 PlaceHolders::iterator placeHolderIter = placeHolders.find(&bb);
123 placeHolders.erase(placeHolderIter);
128 const int originalBBSize =
131 for (
int i = 1; i < originalBBSize; ++i) {
134 originalInstr.erase(&ins);
135 procedure.CodeSnippet::remove(ins);
149 "Skipped ins has a ref");
161 *lastNewInstruction, newInstruction);
164 irm.
replace(instrToCopy,*newInstruction);
166 lastNewInstruction = newInstruction;
167 if (firstNewInstruction == NULL)
168 firstNewInstruction = newInstruction;
175 assert(firstNewInstruction != NULL);
177 placeHolder, *firstNewInstruction);
181 originalInstr.erase(&placeHolder);
184 procedure.
remove(placeHolder);
194 for(std::set<TTAProgram::Instruction*>::iterator i =
195 originalInstr.begin(); i != originalInstr.end(); i++) {
198 procedure.CodeSnippet::remove(*ins);
204 if (insCountDelta != 0) {
220 for (
int j = 0; j < ins.
moveCount(); j++) {
237 int nextIndex = gcu == NULL ?
246 if (&targetIns == &nextIns) {
#define abortWithError(message)
#define assert(condition)
TTAProgram::BasicBlock & basicBlock()
InstructionAddress originalEndAddress() const
InstructionAddress originalStartAddress() const
bool hasOriginalAddress() const
Node & node(const int index) const
virtual void handleControlFlowGraph(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine)
virtual void handleProcedure(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine)
static void copyCfgToProcedure(TTAProgram::Procedure &procedure, ControlFlowGraph &cfg)
ProcedurePass(InterPassData &data)
static void executeControlFlowGraphPass(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetmachine, ControlFlowGraphPass &cfgp)
InstructionAddress location() const
int skippedFirstInstructions() const
virtual bool isInProgram() const
virtual int instructionCount() const
virtual Instruction & instructionAt(UIntWord address) const
virtual Program & parent() const
virtual Instruction & instructionAtIndex(int index) const
void replace(Instruction &insA, Instruction &insB)
bool hasReference(Instruction &ins) const
Instruction & instruction() const
Instruction * copy() const
void removeMove(Move &move)
Terminal & source() const
Terminal & destination() const
void remove(Instruction &ins)
void insertAfter(const Instruction &pos, Instruction *ins)
void moveProcedure(Procedure &proc, int howMuch)
Procedure & nextProcedure(const Procedure &proc) const
InstructionReferenceManager & instructionReferenceManager() const
Procedure & lastProcedure() const
virtual const TTAMachine::FunctionUnit & functionUnit() const
virtual const InstructionReference & instructionReference() const
virtual bool isInstructionAddress() const