OpenASIP
2.0
|
#include <CodeSnippet.hh>
Public Member Functions | |
CodeSnippet () | |
CodeSnippet (const TTAProgram::Address &start) | |
virtual | ~CodeSnippet () |
virtual void | clear () |
virtual void | removeLastInstruction () |
virtual int | instructionCount () const |
virtual Program & | parent () const |
virtual void | setParent (Program &prog) |
virtual bool | isInProgram () const |
virtual Address | address (const Instruction &ins) const |
virtual Address | startAddress () const |
virtual void | setStartAddress (Address start) |
virtual Address | endAddress () const |
virtual void | setEndAddress (Address end) |
virtual Instruction & | firstInstruction () const |
virtual Instruction & | instructionAt (UIntWord address) const |
virtual Instruction & | instructionAtIndex (int index) const |
virtual Instruction & | operator[] (size_t index) const |
virtual bool | hasNextInstruction (const Instruction &ins) const |
virtual Instruction & | nextInstruction (const Instruction &ins) const |
virtual Instruction & | previousInstruction (const Instruction &ins) const |
virtual Instruction & | lastInstruction () const |
virtual void | addFront (Instruction *ins) |
virtual void | add (Instruction *ins) |
virtual void | insertAfter (const Instruction &pos, Instruction *ins) |
virtual void | insertBefore (const Instruction &pos, Instruction *ins) |
virtual void | remove (Instruction &ins) |
virtual void | deleteInstructionAt (InstructionAddress address) |
virtual CodeSnippet * | copy () const |
virtual void | prepend (const CodeSnippet &cs) |
virtual void | prepend (CodeSnippet *cs) |
virtual void | append (const CodeSnippet &cs) |
virtual void | append (CodeSnippet *cs) |
virtual void | insertBefore (const Instruction &pos, const CodeSnippet &cs) |
virtual void | insertBefore (const Instruction &pos, CodeSnippet *cs) |
virtual void | insertAfter (const Instruction &pos, const CodeSnippet &cs) |
virtual void | insertAfter (const Instruction &pos, CodeSnippet *cs) |
bool | hasReturn () const |
virtual std::string | disassembly () const |
virtual std::string | toString () const |
Protected Types | |
typedef std::vector< Instruction * > | InsList |
List of instructions. More... | |
typedef InsList::iterator | InsIter |
Iterator for the instruction list. More... | |
Protected Attributes | |
InsList | instructions_ |
The instructions in this procedure. More... | |
Program * | parent_ |
The parent program of the procedure. More... | |
Address | startAddr_ |
The start (lowest) address of the procedure. More... | |
Address | endAddr_ |
The highest address of the procedure. More... | |
A code snippet is an ordered sequence of adjacent instructions.
It is a helper class for representing pieces of code that are not necessarily full procedures, for example basic blocks. Code snippet doesn't care, whether the sequence of instructions in it makes sense or not. That's the responsibility of the client that created the snippet.
Definition at line 59 of file CodeSnippet.hh.
|
protected |
Iterator for the instruction list.
Definition at line 123 of file CodeSnippet.hh.
|
protected |
List of instructions.
Definition at line 121 of file CodeSnippet.hh.
TTAProgram::CodeSnippet::CodeSnippet | ( | ) |
TTAProgram::CodeSnippet::CodeSnippet | ( | const TTAProgram::Address & | start | ) |
Constructor.
Definition at line 65 of file CodeSnippet.cc.
|
virtual |
The destructor.
Definition at line 73 of file CodeSnippet.cc.
References TTAProgram::NullInstruction::instance(), and instructions_.
|
virtual |
Adds an instruction as the last instruction in the code snippet.
The ownership of the instruction will be passed to the code snippet.
ins | The instruction to add. |
IllegalRegistration | if the instruction is already registered in another code snippet. |
Reimplemented in TTAProgram::Procedure.
Definition at line 432 of file CodeSnippet.cc.
References __func__, POMDisassembler::disassemble(), disassembly(), instructions_, TTAProgram::Instruction::isInProcedure(), TTAProgram::Instruction::parent(), and TTAProgram::Instruction::setParent().
Referenced by TTAProgram::CodeGenerator::addAnnotatedMoveToProcedure(), LoopPrologAndEpilogBuilder::addEpilogFromRM(), SimpleIfConverter::addJump(), TTAProgram::CodeGenerator::addMoveToProcedure(), append(), Peel2BBLoops::appendBB(), SimpleIfConverter::appendBB(), LoopPrologAndEpilogBuilder::build(), TTAProgram::BasicBlock::copy(), copy(), InlineAsmParser::copyInstructions(), BasicBlockPass::copyRMToBB(), SequentialScheduler::createBasicBlocks(), ControlFlowGraph::createBlock(), ProgramDependenceGraph::createJump(), llvm::LLVMTCEBuilder::emitComparisonForBranch(), llvm::LLVMTCEBuilder::emitGlobalXXtructorCalls(), llvm::LLVMTCEBuilder::emitInstruction(), llvm::LLVMTCEPOMBuilder::emitMove(), llvm::LLVMTCEBuilder::emitMove(), llvm::LLVMTCEBuilder::emitOperationMacro(), llvm::LLVMTCEBuilder::emitRemaingingBrach(), llvm::LLVMTCEBuilder::emitReturn(), llvm::LLVMTCEBuilder::emitSelect(), llvm::LLVMTCEBuilder::emitSetjmp(), llvm::LLVMTCEBuilder::emitSPInitialization(), insertAfter(), ControlFlowGraph::mergeNodes(), ProgramDependenceGraph::processLoopClose(), ProgramDependenceGraph::processPredicate(), ProgramDependenceGraph::processRegion(), ControlFlowGraph::splitBasicBlockAtIndex(), and ControlFlowGraph::splitBB().
|
virtual |
Adds an instruction as the first instruction in the code snippet.
The ownership of the instruction will be passed to the code snippet.
ins | The instruction to add. |
IllegalRegistration | if the instruction is already registered in another code snippet. |
Reimplemented in TTAProgram::Procedure.
Definition at line 406 of file CodeSnippet.cc.
References instructions_, TTAProgram::Instruction::isInProcedure(), and TTAProgram::Instruction::setParent().
Referenced by prepend().
|
virtual |
Returns the address of the given instruction.
IllegalRegistration | if the instruction does not belong to this code snippet. |
Reimplemented in TTAProgram::Procedure, and TTAProgram::NullProcedure.
Definition at line 163 of file CodeSnippet.cc.
References __func__, TTAProgram::Instruction::address(), TTAProgram::Instruction::hasFinalAddress(), instructions_, TTAProgram::Address::location(), TTAProgram::Address::space(), and startAddr_.
Referenced by TTAProgram::Instruction::address(), deleteInstructionAt(), and instructionAt().
|
virtual |
Inserts a whole code snippet at the end of this code snippet.
This function moves the ownership of instructions from the old code snippet into the new one, and deletes the given code snippet.
@TODO: This routine is O(n^2). Optimize!
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 730 of file CodeSnippet.cc.
References add(), instructionAtIndex(), instructionCount(), and remove().
|
virtual |
Inserts a whole code snippet at end of this code snippet.
This function does not remove the instruction references from the code snippet.
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 711 of file CodeSnippet.cc.
References add(), TTAProgram::Instruction::copy(), instructionAtIndex(), and instructionCount().
Referenced by llvm::LLVMTCEBuilder::emitSPInitialization().
|
virtual |
Clears the code snippet.
Removes all instruction references inside the snippet and deletes the instructions.
Reimplemented in TTAProgram::BasicBlock, and TTAProgram::Procedure.
Definition at line 89 of file CodeSnippet.cc.
References TTAProgram::NullInstruction::instance(), and instructions_.
Referenced by TTAProgram::Procedure::clear(), and TTAProgram::BasicBlock::clear().
|
virtual |
Make a complete copy of the code snippet.
The copy is identical, except that it is not registered to the program of the original code snippet.
Reimplemented in TTAProgram::BasicBlock, and TTAProgram::Procedure.
Definition at line 608 of file CodeSnippet.cc.
References add(), CodeSnippet(), TTAProgram::Instruction::copy(), firstInstruction(), TTAProgram::NullInstruction::instance(), instructionCount(), nextInstruction(), and startAddr_.
|
virtual |
Remove instruction from the code snippet at the given address and delete it.
All instructions following the removed code snippet are relocated appropriately. All code labels attached to the removed instruction are deleted from the Program.
address | Index of the instruction to remove. |
IllegalRegistration | If instruction does not belong to the code snippet. |
Definition at line 593 of file CodeSnippet.cc.
References address(), instructionAt(), and remove().
|
virtual |
Returns the disassembly of the basic block as string.
Definition at line 820 of file CodeSnippet.cc.
References POMDisassembler::disassemble(), instructionAtIndex(), and instructionCount().
Referenced by add(), LoopPrologAndEpilogBuilder::addEpilogFromRM(), LoopPrologAndEpilogBuilder::addPrologFromRM(), LoopPrologAndEpilogBuilder::build(), SimpleIfConverter::canConvert(), and toString().
|
virtual |
Returns the first address that is outside of the code snippet.
Reimplemented in TTAProgram::NullProcedure.
Definition at line 788 of file CodeSnippet.cc.
References endAddr_, instructions_, isInProgram(), TTAProgram::Address::location(), parent(), TTAProgram::Address::space(), and startAddr_.
Referenced by ControlFlowGraph::buildFrom(), ProgramDependenceGraph::disassemble(), DisassembleCommand::execute(), TTASimulationController::findProgramExitPoints(), SimulatorFrontend::finishSimulation(), SimControlLanguageCommand::parseInstructionAddressExpression(), SimulatorFrontend::programLocationDescription(), and TTAProgram::Program::removeProcedure().
|
virtual |
Returns the first instruction in the code snippet.
InstanceNotFound | if there are no instructions in the code snippet. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 216 of file CodeSnippet.cc.
References __func__, and instructions_.
Referenced by SimpleIfConverter::addJump(), ControlFlowGraph::computeLeadersFromRefManager(), ControlFlowGraph::convertBBRefsToInstRefs(), TTAProgram::Program::convertSymbolRef(), copy(), SequentialScheduler::copyBasicBlocksToProcedure(), BasicBlockPass::copyRMToBB(), ControlFlowGraph::copyToProcedure(), ControlFlowGraph::createBBEdges(), ProgramDependenceGraph::createJump(), llvm::LLVMTCEBuilder::emitSPInitialization(), TTAProgram::TerminalBasicBlockReference::equals(), TTAProgram::TerminalInstructionReference::equals(), TTAProgram::Program::finalize(), TTASimulationController::findProgramExitPoints(), TTAProgram::Program::firstInstruction(), CallsToJumps::handleControlFlowGraph(), TTAProgram::CodeLabel::instructionReference(), ControlFlowGraph::jumpToBBN(), ControlFlowGraph::optimizeBBOrdering(), TTAProgram::Procedure::remove(), BasicBlockNode::updateReferencesFromProcToCfg(), TTAProgram::InstructionReferenceManager::validate(), and llvm::LLVMTCEIRBuilder::writeMachineFunction().
|
virtual |
Tells whether the given instruction is the last instruction of the code snippet or not.
ins | The instruction to compare. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 303 of file CodeSnippet.cc.
References TTAProgram::NullInstruction::instance(), and nextInstruction().
Referenced by insertAfter().
bool TTAProgram::CodeSnippet::hasReturn | ( | ) | const |
Returns true in case there is at least one procedure return in the code snippet.
Definition at line 804 of file CodeSnippet.cc.
References instructionAtIndex(), and instructionCount().
|
virtual |
Inserts a whole code snippet into this code snippet just after specified instruction.
This function moves the ownership of the moves and deletes the another code snippet.
ins | The succeeding the place where to insert he instructions. |
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 690 of file CodeSnippet.cc.
References insertAfter(), instructionAtIndex(), instructionCount(), and remove().
|
virtual |
Inserts a whole code snippet into this code snippet just after specified instruction.
This function does not remove the instruction references from the code snippet.
ins | The succeeding the place where to insert he instructions. |
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 671 of file CodeSnippet.cc.
References TTAProgram::Instruction::copy(), insertAfter(), instructionAtIndex(), and instructionCount().
|
virtual |
Insert the given instruction after the given position.
Instructions from pos are relocated to make room for the new instruction.
pos | The position. |
ins | The instruction to insert. |
IllegalRegistration | if pos does not belong to the code snippet or ins already belongs to a code snippet. |
Reimplemented in TTAProgram::Procedure.
Definition at line 462 of file CodeSnippet.cc.
References add(), assert, hasNextInstruction(), instructions_, TTAProgram::Instruction::isInProcedure(), nextInstruction(), and TTAProgram::Instruction::setParent().
Referenced by insertAfter(), and PreOptimizer::tryToRemoveGuardInversingOp().
|
virtual |
Inserts a whole code snippet into this code snippet just before specified instruction. This function moves the ownership of the moves and deletes the another code snippet.
ins | The succeeding the place where to insert he instructions. |
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 650 of file CodeSnippet.cc.
References insertBefore(), instructionAtIndex(), instructionCount(), and remove().
|
virtual |
Inserts a whole code snippet into this code snippet just before specified instruction.
This function does not remove the instruction references from the code snippet.
ins | The succeeding the place where to insert he instructions. |
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 632 of file CodeSnippet.cc.
References TTAProgram::Instruction::copy(), insertBefore(), instructionAtIndex(), and instructionCount().
|
virtual |
Insert the given instruction before the given position.
Instructions from and including pos are relocated to make room for the new instruction.
pos | The position. |
ins | The instruction to insert. |
IllegalRegistration | if pos does not belong to the code snippet or ins already belongs to a code snippet. |
Reimplemented in TTAProgram::Procedure.
Definition at line 514 of file CodeSnippet.cc.
References assert, instructions_, TTAProgram::Instruction::isInProcedure(), and TTAProgram::Instruction::setParent().
Referenced by llvm::LLVMTCEBuilder::emitSPInitialization(), CallsToJumps::handleControlFlowGraph(), and insertBefore().
|
virtual |
Returns the explicit instruction at a given address.
The address space of the address is implied, since there is only one address space for instructions. In case there are multiple instructions at the given address, only one of them is considered explicit, others implicit. The implicit instructions are detected by having a size of 0.
address | The instruction address. |
KeyNotFound | if given address is illegal. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 241 of file CodeSnippet.cc.
References __func__, address(), TTAProgram::Instruction::address(), TTAProgram::NullInstruction::instance(), instructions_, isInProgram(), TTAProgram::Address::location(), parent(), TTAProgram::Instruction::size(), startAddr_, and Conversion::toString().
Referenced by ControlFlowGraph::computeLeadersFromRelocations(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::createAllBlocks(), deleteInstructionAt(), and ControlFlowGraph::splitBasicBlocksWithCallsAndRefs().
|
virtual |
Returns the instruction at a given index in the container of instructions.
This method is for quickly traversing through all the instructions within time critical loops.
index | The instruction index in the list of instructions. |
Definition at line 285 of file CodeSnippet.cc.
References instructions_.
Referenced by SimpleICOptimizer::addConnections(), InlineAsmParser::addDebugInfoToInlineAsmBB(), append(), Peel2BBLoops::appendBB(), SimpleIfConverter::appendBB(), CodeCompressorPlugin::bemBits(), LoopPrologAndEpilogBuilder::build(), MoveNodeGroupBuilder::build(), SimProgramBuilder::build(), ControlFlowGraph::buildMBBFromBB(), CopyingDelaySlotFiller::checkImmediatesAfter(), CopyingDelaySlotFiller::collectMoves(), ControlFlowGraph::computeLeadersFromJumpSuccessors(), DataDependenceGraphBuilder::constructIndividualBB(), ControlFlowGraph::convertBBRefsToInstRefs(), TTAProgram::Program::convertSymbolRefsToInsRefs(), TTAProgram::Procedure::copy(), TTAProgram::BasicBlock::copy(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), TTAProgram::Program::copyFrom(), BasicBlockPass::copyRMToBB(), ControlFlowGraph::copyToProcedure(), SequentialScheduler::createBasicBlocks(), ControlFlowGraph::createBBEdges(), ControlFlowGraph::createBlock(), TTAProgram::ProgramWriter::createCodeSection(), ControlFlowGraph::createJumps(), ControlFlowGraph::directJump(), ProgramDependenceGraph::disassemble(), POMDisassembler::disassembleProcedure(), disassembly(), llvm::LLVMTCEBuilder::emitInlineAsm(), llvm::LLVMTCEBuilder::emitLongjmp(), llvm::LLVMTCEBuilder::emitSetjmp(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::findJump(), CopyingDelaySlotFiller::findJumpImmediate(), BasicBlockNode::findJumps(), ControlFlowGraph::findNextIndex(), TTASimulationController::findProgramExitPoints(), DataDependenceGraphBuilder::findStaticRegisters(), TTAProgram::Program::fixInstructionReferences(), DataDependenceGraph::fixInterBBAntiEdges(), CompiledSimCodeGenerator::generateProcedureCode(), PostpassOperandSharer::handleBasicBlock(), CallsToJumps::handleControlFlowGraph(), AbsoluteToRelativeJumps::handleProcedure(), SimpleIfConverter::hasConditionals(), hasReturn(), ControlFlowGraph::indirectJump(), insertAfter(), insertBefore(), ControlDependenceNode::instruction(), TTAProgram::Program::instructionVector(), main(), ControlFlowGraph::mergeNodes(), LoopPrologAndEpilogBuilder::moveJumpDestination(), ControlFlowGraph::optimizeBBOrdering(), LoopPrologAndEpilogBuilder::optimizeEpilog(), LoopPrologAndEpilogBuilder::optimizeProlog(), prepend(), ControlFlowGraph::removeJumpToTarget(), ControlFlowGraph::removeUnreachableNodes(), TTAProgram::Program::replaceUniversalAddressSpaces(), ControlFlowGraph::splitBasicBlockAtIndex(), TTAProgram::BasicBlock::statistics(), BasicBlockNode::toString(), PostpassOperandSharer::tryRemoveOperandWrite(), CopyingDelaySlotFiller::updateFTBBAndCfg(), BasicBlockNode::updateHWloopLength(), CopyingDelaySlotFiller::updateJumpsAndCfg(), ControlFlowGraph::updateReferencesFromProcToCfg(), and SimpleIfConverter::writesRegister().
|
virtual |
Returns the number of instructions in this code snippet.
Reimplemented in TTAProgram::NullProcedure.
Definition at line 205 of file CodeSnippet.cc.
References instructions_.
Referenced by SimpleICOptimizer::addConnections(), InlineAsmParser::addDebugInfoToInlineAsmBB(), LoopAnalyzer::analyze(), append(), Peel2BBLoops::appendBB(), SimpleIfConverter::appendBB(), CodeCompressorPlugin::bemBits(), MoveNodeGroupBuilder::build(), SimProgramBuilder::build(), ControlFlowGraph::buildMBBFromBB(), llvm::LLVMTCEIRBuilder::buildTCECFG(), SimpleIfConverter::canConvert(), CopyingDelaySlotFiller::checkImmediatesAfter(), TTAProgram::Procedure::clear(), CopyingDelaySlotFiller::collectMoves(), SimpleIfConverter::combineBlocks(), ControlFlowGraph::computeLeadersFromJumpSuccessors(), DataDependenceGraphBuilder::constructIndividualBB(), ControlFlowGraph::convertBBRefsToInstRefs(), TTAProgram::Program::convertSymbolRef(), TTAProgram::Program::convertSymbolRefsToInsRefs(), TTAProgram::Procedure::copy(), TTAProgram::BasicBlock::copy(), copy(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), TTAProgram::Program::copyFrom(), InlineAsmParser::copyInstructions(), BasicBlockPass::copyRMToBB(), ControlFlowGraph::copyToProcedure(), SequentialScheduler::createBasicBlocks(), ControlFlowGraph::createBBEdges(), TTAProgram::ProgramWriter::createCodeSection(), SimpleIfConverter::detectDiamond(), SimpleIfConverter::detectTriangleViaFt(), SimpleIfConverter::detectTriangleViaJump(), ControlFlowGraph::directJump(), ProgramDependenceGraph::disassemble(), POMDisassembler::disassembleProcedure(), disassembly(), llvm::LLVMTCEBuilder::emitInlineAsm(), llvm::LLVMTCEBuilder::emitLongjmp(), llvm::LLVMTCEBuilder::emitSetjmp(), llvm::LLVMTCEBuilder::emitSPInitialization(), BasicBlockPass::executeDDGPass(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::findJump(), BasicBlockNode::findJumps(), ControlFlowGraph::findLimmWrite(), ControlFlowGraph::findNextIndex(), TTASimulationController::findProgramExitPoints(), DataDependenceGraphBuilder::findStaticRegisters(), TTAProgram::Program::fixInstructionReferences(), DataDependenceGraph::fixInterBBAntiEdges(), CompiledSimCodeGenerator::generateProcedureCode(), PostpassOperandSharer::handleBasicBlock(), BasicBlockPass::handleBasicBlock(), SequentialScheduler::handleBasicBlock(), BBSchedulerController::handleBasicBlock(), CallsToJumps::handleControlFlowGraph(), AbsoluteToRelativeJumps::handleProcedure(), PreOptimizer::handleProcedure(), BBSchedulerController::handleProcedure(), SimpleIfConverter::hasConditionals(), hasReturn(), ControlFlowGraph::indirectJump(), insertAfter(), insertBefore(), POMDisassembler::instructionCount(), ControlDependenceNode::instructionCount(), TTAProgram::Program::instructionCount(), TTAProgram::CodeLabel::instructionReference(), TTAProgram::Program::instructionVector(), TTAProgram::BasicBlock::isEmpty(), main(), BasicBlockNode::maximumSize(), ScheduleEstimator::maximumSizeOfBB(), ControlFlowGraph::mergeNodes(), ControlFlowGraph::optimizeBBOrdering(), LoopPrologAndEpilogBuilder::optimizeEpilog(), LoopPrologAndEpilogBuilder::optimizeProlog(), prepend(), SimpleIfConverter::removeJump(), ControlFlowGraph::removeJumpToTarget(), ControlFlowGraph::removeUnreachableNodes(), TTAProgram::Program::replaceUniversalAddressSpaces(), ControlFlowGraph::splitBasicBlockAtIndex(), ControlFlowGraph::splitBasicBlocksWithCallsAndRefs(), ControlFlowGraph::splitBB(), TTAProgram::BasicBlock::statistics(), SimpleIfConverter::successors(), BasicBlockNode::toString(), CopyingDelaySlotFiller::tryToFillSlots(), CopyingDelaySlotFiller::updateFTBBAndCfg(), BasicBlockNode::updateHWloopLength(), BasicBlockNode::updateReferencesFromProcToCfg(), ControlFlowGraph::updateReferencesFromProcToCfg(), llvm::LLVMTCEIRBuilder::writeMachineFunction(), and SimpleIfConverter::writesRegister().
|
virtual |
Tells whether the code snippet belongs to a program.
Reimplemented in TTAProgram::NullProcedure.
Definition at line 151 of file CodeSnippet.cc.
References TTAProgram::NullProgram::instance(), and parent_.
Referenced by TTAProgram::Program::addProcedure(), TTAProgram::Procedure::address(), ControlFlowGraph::buildFrom(), ControlFlowGraph::computeLeadersFromRefManager(), ControlFlowGraph::computeLeadersFromRelocations(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), ControlFlowGraph::createBBEdges(), POMDisassembler::createMove(), ProgramDependenceGraph::disassemble(), POMDisassembler::disassemble(), endAddress(), instructionAt(), nextInstruction(), TTAProgram::Program::nextInstruction(), TTAProgram::Program::nextProcedure(), previousInstruction(), and TTAProgram::InstructionReferenceManager::validate().
|
virtual |
Returns the last instruction in the code snippet.
IllegalRegistration | if there are no instructions in the code snippet. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 387 of file CodeSnippet.cc.
References instructions_.
Referenced by SimpleIfConverter::canConvert(), SimpleIfConverter::combineBlocks(), ControlFlowGraph::createAllBlocks(), ProgramDependenceGraph::createJump(), llvm::LLVMTCEBuilder::emitGlobalXXtructorCalls(), llvm::LLVMTCEBuilder::emitReadSP(), llvm::LLVMTCEBuilder::emitReturnTo(), llvm::LLVMTCEBuilder::emitWriteSP(), DisassembleCommand::execute(), TTAProgram::Program::finalize(), BBSchedulerController::handleBasicBlock(), llvm::LLVMTCEBuilder::handleMemoryCategoryInfo(), TTAProgram::Program::lastInstruction(), SimpleIfConverter::removeJump(), ControlFlowGraph::splitBasicBlocksWithCallsAndRefs(), SimpleIfConverter::successors(), and BasicBlockNode::toString().
|
virtual |
Returns the next instruction in the instruction stream.
IllegalRegistration | If given instruction does not belong to the code snippet. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 318 of file CodeSnippet.cc.
References TTAProgram::Instruction::address(), TTAProgram::NullInstruction::instance(), instructions_, isInProgram(), TTAProgram::Address::location(), parent(), TTAProgram::Instruction::parent(), and startAddr_.
Referenced by copy(), TTAProgram::CodeGenerator::createSchedYieldProcedure(), llvm::LLVMTCEBuilder::emitReadSP(), llvm::LLVMTCEBuilder::emitReturnTo(), llvm::LLVMTCEBuilder::emitWriteSP(), llvm::LLVMTCEBuilder::handleMemoryCategoryInfo(), hasNextInstruction(), insertAfter(), and TTAProgram::Program::nextInstruction().
|
virtual |
Definition at line 290 of file CodeSnippet.cc.
References instructions_.
|
virtual |
Return the parent program that contains the code snippet.
IllegalRegistration | If the code snippet is not registered anywhere. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 118 of file CodeSnippet.cc.
References __func__, and parent_.
Referenced by TTAProgram::Procedure::address(), ControlFlowGraph::buildFrom(), TTAProgram::CodeLabel::CodeLabel(), ControlFlowGraph::computeLeadersFromRefManager(), ControlFlowGraph::computeLeadersFromRelocations(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), SequentialScheduler::createBasicBlocks(), POMDisassembler::createMove(), POMDisassembler::destinationLabels(), POMDisassembler::disassemble(), endAddress(), AbsoluteToRelativeJumps::handleProcedure(), SimpleIfConverter::handleProcedure(), SequentialScheduler::handleProcedure(), instructionAt(), TTAProgram::CodeLabel::instructionReference(), nextInstruction(), TTAProgram::Program::nextInstruction(), TTAProgram::Program::nextProcedure(), previousInstruction(), TTAProgram::Procedure::remove(), and TTAProgram::Program::removeProcedure().
|
virtual |
Inserts a whole code snippet at the beginning of this code snippet.
This function moves the ownership of instructions from the old code snippet into the new one, and deletes the given code snippet.
@TODO: This routine is O(n^2). Optimize!
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 765 of file CodeSnippet.cc.
References addFront(), instructionAtIndex(), instructionCount(), and remove().
|
virtual |
Inserts a whole code snippet at the beginning of this code snippet.
This function does not remove the instruction references from the code snippet.
cs | CodeSnippet containing the instructions being inserted. |
Definition at line 748 of file CodeSnippet.cc.
References addFront(), TTAProgram::Instruction::copy(), instructionAtIndex(), and instructionCount().
|
virtual |
Return the previous instruction in the instruction stream.
IllegalRegistration | If given instruction does not belong to the code snippet. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 352 of file CodeSnippet.cc.
References __func__, TTAProgram::Instruction::address(), TTAProgram::NullInstruction::instance(), instructions_, isInProgram(), TTAProgram::Address::location(), parent(), TTAProgram::Instruction::parent(), and startAddr_.
Referenced by SimpleIfConverter::canConvert(), ControlFlowGraph::createJumps(), and SimpleIfConverter::successors().
|
virtual |
Remove instruction from the code snippet.
The instruction becomes independent (it is not deleted). All instructions following the removed code snippet are relocated appropriately.
The instructions should not have code labels attached to them.
ins | Instruction to remove. |
IllegalRegistration | If instruction does not belong to the code snippet. |
Reimplemented in TTAProgram::Procedure.
Definition at line 558 of file CodeSnippet.cc.
References __func__, TTAProgram::NullProcedure::instance(), instructions_, TTAProgram::Instruction::isInProcedure(), TTAProgram::Instruction::parent(), and TTAProgram::Instruction::setParent().
Referenced by append(), deleteInstructionAt(), CallsToJumps::handleControlFlowGraph(), insertAfter(), insertBefore(), ControlFlowGraph::mergeNodes(), LoopPrologAndEpilogBuilder::optimizeEpilog(), LoopPrologAndEpilogBuilder::optimizeProlog(), prepend(), ControlFlowGraph::splitBasicBlockAtIndex(), ControlFlowGraph::splitBB(), PreOptimizer::tryToPrecalcConstantAdd(), and PreOptimizer::tryToRemoveGuardInversingOp().
|
virtual |
Remove one instruction from the end of the code snippet.
Nothing happens if the code snippet is empty.
Definition at line 104 of file CodeSnippet.cc.
References instructions_.
|
virtual |
Definition at line 195 of file CodeSnippet.cc.
References endAddr_.
Referenced by TTAProgram::Program::finalize().
|
virtual |
Sets the parent program of the code snippet.
prog | The new parent program. |
Reimplemented in TTAProgram::NullProcedure.
Definition at line 136 of file CodeSnippet.cc.
References TTAProgram::NullProgram::instance(), and parent_.
Referenced by TTAProgram::Program::addProcedure(), and TTAProgram::Program::removeProcedure().
|
virtual |
Sets the start address of the code snippet.
Reimplemented in TTAProgram::NullProcedure.
Definition at line 190 of file CodeSnippet.cc.
References startAddr_.
Referenced by TTAProgram::Program::addProcedure(), TTAProgram::Program::finalize(), and TTAProgram::Program::moveProcedure().
|
virtual |
Returns the start address of the code snippet.
Reimplemented in TTAProgram::NullProcedure.
Definition at line 780 of file CodeSnippet.cc.
References startAddr_.
Referenced by TTAProgram::CodeLabel::address(), TTAProgram::Instruction::address(), ControlFlowGraph::buildFrom(), TTAProgram::CodeLabel::CodeLabel(), TTAProgram::Program::copyFrom(), ControlFlowGraph::createBBEdges(), TTAProgram::ProgramWriter::createBinary(), ControlFlowGraph::createBlock(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), POMDisassembler::destinationLabels(), ControlFlowGraph::directJump(), ProgramDependenceGraph::disassemble(), SimulatorFrontend::disassembleInstruction(), POMDisassembler::disassembleProcedure(), DisassembleCommand::execute(), TTASimulationController::findProgramExitPoints(), SimulatorFrontend::finishSimulation(), TTAProgram::Program::fixInstructionReferences(), ControlFlowGraph::indirectJump(), TTAProgram::Program::instructionCount(), TTAProgram::Program::moveProcedure(), SimControlLanguageCommand::parseInstructionAddressExpression(), SimulatorFrontend::programLocationDescription(), TTAProgram::Program::removeProcedure(), and TTAProgram::TerminalBasicBlockReference::value().
|
inlinevirtual |
Definition at line 117 of file CodeSnippet.hh.
References disassembly().
Referenced by ControlFlowGraph::buildMBBFromBB(), ControlFlowGraph::copyToProcedure(), llvm::LLVMTCEIRBuilder::createMBBReference(), CallsToJumps::handleControlFlowGraph(), and InlineAsmParser::parse().
|
protected |
The highest address of the procedure.
Definition at line 132 of file CodeSnippet.hh.
Referenced by endAddress(), and setEndAddress().
|
protected |
The instructions in this procedure.
Definition at line 126 of file CodeSnippet.hh.
Referenced by TTAProgram::Procedure::add(), add(), addFront(), TTAProgram::Procedure::address(), address(), clear(), endAddress(), firstInstruction(), TTAProgram::Procedure::insertAfter(), insertAfter(), TTAProgram::Procedure::insertBefore(), insertBefore(), instructionAt(), instructionAtIndex(), instructionCount(), lastInstruction(), nextInstruction(), operator[](), previousInstruction(), TTAProgram::Procedure::remove(), remove(), removeLastInstruction(), and ~CodeSnippet().
|
protected |
The parent program of the procedure.
Definition at line 128 of file CodeSnippet.hh.
Referenced by TTAProgram::Procedure::add(), TTAProgram::Procedure::clear(), TTAProgram::Procedure::insertAfter(), TTAProgram::Procedure::insertBefore(), isInProgram(), parent(), TTAProgram::Procedure::remove(), and setParent().
|
protected |
The start (lowest) address of the procedure.
Definition at line 130 of file CodeSnippet.hh.
Referenced by TTAProgram::Procedure::address(), address(), TTAProgram::Procedure::copy(), TTAProgram::BasicBlock::copy(), copy(), endAddress(), instructionAt(), nextInstruction(), previousInstruction(), TTAProgram::Procedure::remove(), setStartAddress(), and startAddress().