OpenASIP
2.0
|
#include <CopyingDelaySlotFiller.hh>
Public Types | |
typedef std::map< TCEString, TTAProgram::TerminalImmediate * > | PendingImmediateMap |
Public Member Functions | |
CopyingDelaySlotFiller () | |
~CopyingDelaySlotFiller () | |
void | initialize (ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine) |
void | fillDelaySlots (ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine) |
void | addResourceManager (TTAProgram::BasicBlock &bbn, SimpleResourceManager &rm) |
void | bbnScheduled (BasicBlockNode &bbn) |
void | finalizeProcedure () |
Static Public Member Functions | |
static std::pair< int, TTAProgram::Move * > | findJump (TTAProgram::BasicBlock &bb, ControlFlowEdge::CFGEdgePredicate *pred=nullptr) |
static std::pair< TTAProgram::Move *, std::shared_ptr< TTAProgram::Immediate > > | findJumpImmediate (int jumpIndex, TTAProgram::Move &jumpMove, TTAProgram::InstructionReferenceManager &irm) |
Protected Member Functions | |
bool | fillDelaySlots (BasicBlockNode &jumpingBB, int delaySlots, bool fillFallThru) |
Private Types | |
enum | BBNStates { BBN_UNKNOWN = 0, BBN_SCHEDULED = 1, BBN_JUMP_FILLED = 3, BBN_FALLTHRU_FILLED = 5, BBN_BOTH_FILLED = 7, BBN_TEMPS_CLEANED = 15, BBN_ALL_DONE = 31 } |
typedef std::vector< std::list< MoveNode * > > | MoveNodeListVector |
Definition at line 71 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 105 of file CopyingDelaySlotFiller.hh.
typedef std::map<TCEString,TTAProgram::TerminalImmediate*> CopyingDelaySlotFiller::PendingImmediateMap |
Definition at line 98 of file CopyingDelaySlotFiller.hh.
|
private |
Enumerator | |
---|---|
BBN_UNKNOWN | |
BBN_SCHEDULED | |
BBN_JUMP_FILLED | |
BBN_FALLTHRU_FILLED | |
BBN_BOTH_FILLED | |
BBN_TEMPS_CLEANED | |
BBN_ALL_DONE |
Definition at line 209 of file CopyingDelaySlotFiller.hh.
CopyingDelaySlotFiller::CopyingDelaySlotFiller | ( | ) |
CopyingDelaySlotFiller::~CopyingDelaySlotFiller | ( | ) |
void CopyingDelaySlotFiller::addResourceManager | ( | TTAProgram::BasicBlock & | bbn, |
SimpleResourceManager & | rm | ||
) |
Definition at line 691 of file CopyingDelaySlotFiller.cc.
References SimpleResourceManager::setMaxCycle().
Referenced by BBSchedulerController::executeDDGPass().
|
private |
Definition at line 2013 of file CopyingDelaySlotFiller.cc.
References Operation::affectsCount(), TTAProgram::Move::destination(), Operation::hasSideEffects(), MoveNode::isDestinationOperation(), MoveNode::isSourceOperation(), MoveNode::isSourceVariable(), TTAProgram::Move::isTriggering(), TTAProgram::Move::isUnconditional(), MoveNode::move(), TTAProgram::Terminal::operation(), Operation::readsMemory(), MoveNode::sourceOperation(), ProgramOperation::triggeringMove(), and Operation::writesMemory().
|
private |
Checks if all jumps into given basic blocks are filled.
bbn | node to check for incoming filled jumps. |
Definition at line 470 of file CopyingDelaySlotFiller.cc.
References ControlFlowEdge::isJumpEdge(), and BasicBlockNode::isNormalBB().
|
private |
Checks whether all incoming jump basic blocks are scheduled.
bbn | basic block whose predecessors we are checking. |
Definition at line 498 of file CopyingDelaySlotFiller.cc.
References ControlFlowEdge::isJumpEdge(), and BasicBlockNode::isNormalBB().
|
private |
Executed after delay slots of a BB has been filled.
If both jump and fal-thru are filled, reletes the resource manager.
Definition at line 524 of file CopyingDelaySlotFiller.cc.
void CopyingDelaySlotFiller::bbnScheduled | ( | BasicBlockNode & | bbn | ) |
Report to the ds filler that a bb has been scheduled.
tries to fill some delay slots and then tries to get rid of the resource managers when no longer needed.
addResourceManager() for the BB should be called before this method.
bbn | BasicBlockNode which has been scheduled. |
Definition at line 640 of file CopyingDelaySlotFiller.cc.
References assert, BasicBlockNode::basicBlock(), and ControlFlowEdge::isCallPassEdge().
Referenced by BBSchedulerController::handleBBNode().
|
private |
Checks that no later uses of long immediates written in instructions which are being filled to previous basic block.
nextBB | The BB where to instructions are filled from |
slotsToFill | how many slots are filled |
Definition at line 1146 of file CopyingDelaySlotFiller.cc.
References TTAProgram::Immediate::destination(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::isImmediateRegister(), TTAMachine::ImmediateUnit::latency(), TTAProgram::Instruction::move(), TTAMachine::Component::name(), TTAProgram::Move::source(), Conversion::toString(), and TTAProgram::Immediate::value().
|
private |
Checks that no incoming deps prevent the filling, ie. no data hazards.
mnOld | movenode which to fill from successor bb |
blockToFillNode | block containing the jump being filled. |
firstCycleToFill | index of first instruction where to fill |
Definition at line 1228 of file CopyingDelaySlotFiller.cc.
References MoveNode::cycle(), DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, DataDependenceEdge::dependenceType(), MoveNode::guardLatency(), DataDependenceEdge::guardUse(), MoveNode::isMove(), and MoveNode::isScheduled().
|
private |
Collects are moves which are to be filled
blockToFillNode | basic block node where to fill to |
nextBBN | basic blocknode where to fill from |
moves | place to store the collected nodes. |
slotsToFill | how many delay slots to fill |
fallThru | if filling fall-thru |
removeGuards | how many first instructions need guard removed. |
jumpMove | move which is the jump that is filled |
grIndex | index of the guard register of the jump |
grFile | register file of the guard of the jump. |
skippedJump | if we can skip BB which jumps, sets the skipped jump here |
Definition at line 890 of file CopyingDelaySlotFiller.cc.
References assert, BasicBlockNode::basicBlock(), TTAProgram::Move::bus(), AssocTools::containsKey(), TTAProgram::MoveGuard::copy(), TTAProgram::CodeGenerator::createInverseGuard(), TTAProgram::Immediate::destination(), MoveNode::destinationOperation(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), MoveNode::guardLatency(), MoveNode::guardOperationPtr(), TTAProgram::Instruction::hasCall(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), ControlFlowEdge::isBackEdge(), MachineConnectivityCheck::isConnected(), TTAProgram::Move::isControlFlowMove(), MoveNode::isDestinationOperation(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediateRegister(), TTAProgram::Move::isJump(), TTAProgram::Terminal::isRA(), MoveNode::isSourceOperation(), TTAProgram::Move::isUnconditional(), TTAMachine::ImmediateUnit::latency(), TTAProgram::Instruction::move(), MoveNode::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), Operation::name(), ProgramOperation::operation(), TTAProgram::Terminal::port(), TTAProgram::Move::setGuard(), MoveNode::setGuardOperationPtr(), TTAProgram::Move::setSource(), SimpleResourceManager::smallestCycle(), TTAProgram::Move::source(), Conversion::toString(), and TTAProgram::Immediate::value().
|
protected |
Fill delay slots of given BB.
jumpingBB | BB to fill delay slots. |
delaySlots | number of delay slots in the machine. |
fillFallThru | fill from Fall-thru of jump BB? |
Definition at line 88 of file CopyingDelaySlotFiller.cc.
References assert, BasicBlockNode::basicBlock(), TTAProgram::CodeGenerator::createInverseGuard(), MoveNode::cycle(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), MoveNode::guardLatency(), TTAProgram::InstructionReferenceManager::hasReference(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), ControlFlowEdge::isBackEdge(), ControlFlowEdge::isCallPassEdge(), ControlFlowEdge::isFallThroughEdge(), BasicBlockNode::isHWLoop(), TTAProgram::Terminal::isInstructionAddress(), BasicBlockNode::isLoopScheduled(), BasicBlockNode::isNormalBB(), TTAProgram::Move::isUnconditional(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), TTAProgram::BasicBlock::skippedFirstInstructions(), SimpleResourceManager::smallestCycle(), and TTAProgram::Move::source().
void CopyingDelaySlotFiller::fillDelaySlots | ( | ControlFlowGraph & | cfg, |
DataDependenceGraph & | ddg, | ||
const TTAMachine::Machine & | machine | ||
) |
Fills all delay slots for all BB's in the CFG.
cfg | ControlFlowGraph where to fill delay slots. |
ddg | DataDependenceGraph containing data dependencies. |
Definition at line 405 of file CopyingDelaySlotFiller.cc.
References TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::delaySlots(), SimpleResourceManager::disposeRM(), UniversalMachine::instance(), BasicBlockNode::isNormalBB(), machine, BoostGraph< GraphNode, GraphEdge >::node(), and BoostGraph< GraphNode, GraphEdge >::nodeCount().
Referenced by llvm::LLVMTCEIRBuilder::compileOptimized(), and BBSchedulerController::handleProcedure().
void CopyingDelaySlotFiller::finalizeProcedure | ( | ) |
Deletes all removed basic blocks. Can be called after bigddg is deleted.
Definition at line 460 of file CopyingDelaySlotFiller.cc.
References AssocTools::deleteAllItems().
Referenced by BBSchedulerController::handleProcedure().
|
static |
Finds the jump move and the index of the instruction where it is from a basic block.
bb | basicBlock where to search the jump move |
Definition at line 1751 of file CopyingDelaySlotFiller.cc.
References ControlFlowEdge::CFLOW_EDGE_FALSE, ControlFlowEdge::CFLOW_EDGE_NORMAL, TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAProgram::Instruction::hasCall(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isJump(), TTAProgram::Move::isUnconditional(), TTAProgram::Instruction::move(), and TTAProgram::Instruction::moveCount().
Referenced by LoopPrologAndEpilogBuilder::moveJumpDestination().
|
static |
Finds the immediate which contains the jump address.
jumpIndex | index of the instruction containin the jump in the BB. |
jumpMove | the move containing the jump. |
Definition at line 705 of file CopyingDelaySlotFiller.cc.
References TTAProgram::Move::destination(), TTAProgram::InstructionReferenceManager::hasReference(), TTAProgram::Instruction::immediateCount(), TTAProgram::Instruction::immediatePtr(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isImmediateRegister(), TTAMachine::ImmediateUnit::latency(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Move::parent(), TTAProgram::Instruction::parent(), TTAProgram::Terminal::registerFile(), TTAProgram::BasicBlock::skippedFirstInstructions(), and TTAProgram::Move::source().
Referenced by LoopPrologAndEpilogBuilder::moveJumpDestination().
|
private |
Definition at line 1949 of file CopyingDelaySlotFiller.cc.
References assert, BasicBlockNode::basicBlock(), SimpleResourceManager::disposeRM(), ControlFlowEdge::isCallPassEdge(), and BasicBlockNode::isNormalBB().
|
private |
Gets a corresponding move to a given move in the next BB.
If no corresponding move created, creates one
old | Move in jump target BB. |
Definition at line 1578 of file CopyingDelaySlotFiller.cc.
References TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_DST, TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_SRC, assert, AssocTools::containsKey(), TTAProgram::MoveGuard::copy(), TTAProgram::Move::copy(), TTAProgram::Move::destination(), MoveNode::destinationOperation(), TTAProgram::Terminal::functionUnit(), TTAProgram::Move::guard(), MoveNode::isDestinationOperation(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isRA(), MoveNode::isSourceOperation(), TTAProgram::Move::isUnconditional(), TTAMachine::Component::name(), Operation::name(), ProgramOperation::operation(), TTAProgram::Terminal::operationIndex(), TTAProgram::Move::source(), and MoveNode::sourceOperation().
|
private |
Gets a corresponding MoveNode a given move in the next BB.
If no corresponding MoveNode created, creates one
old | ProgramOperation in jump target BB. |
Definition at line 1497 of file CopyingDelaySlotFiller.cc.
References MoveNode::addDestinationOperationPtr(), assert, TTAProgram::Move::bus(), AssocTools::containsKey(), MoveNode::destinationOperationCount(), MoveNode::destinationOperationPtr(), MoveNode::guardOperationPtr(), MoveNode::isDestinationOperation(), MoveNode::isGuardOperation(), MoveNode::isSourceOperation(), MoveNode::move(), MoveNode::setGuardOperationPtr(), MoveNode::setSourceOperationPtr(), and MoveNode::sourceOperationPtr().
|
private |
Gets a corresponding ProgramOperation to a given move in the next BB.
If no corresponding ProgramOperation created, creates one
old | ProgramOperation in jump target BB. |
Definition at line 1542 of file CopyingDelaySlotFiller.cc.
References assert, AssocTools::containsKey(), MoveNode::isDestinationOperation(), and MoveNode::isSourceOperation().
void CopyingDelaySlotFiller::initialize | ( | ControlFlowGraph & | cfg, |
DataDependenceGraph & | ddg, | ||
const TTAMachine::Machine & | machine | ||
) |
Initializes the delay slot filler for given procedure.
Has to be called before it can be used.
cfg | ControlFlowGraph of the procedure. @ddg ddg whole-procedure ddg of the procedure. |
machine | machine we are scheduling to. |
um | universalmachine. |
Definition at line 1937 of file CopyingDelaySlotFiller.cc.
References TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::delaySlots(), UniversalMachine::instance(), and machine.
Referenced by llvm::LLVMTCEIRBuilder::compileOptimized(), and BBSchedulerController::handleProcedure().
|
private |
Deletes MoveNodes and programOperations not put into final graph.
Loses all bookkeeping of corresponging stuff between BB's
Definition at line 1651 of file CopyingDelaySlotFiller.cc.
References assert, and MoveNode::isScheduled().
|
private |
Checks if jumps and fall-thrus into BB can be filled and fills them if it can
bbn | just destination basic block. |
Definition at line 537 of file CopyingDelaySlotFiller.cc.
References BasicBlockNode::isNormalBB(), and BasicBlockNode::originalStartAddress().
|
private |
This method may get slow with a big machine
Checks whether some of the moves in the given programOperation is copied to the given BB. If they are, also the programOperation is copied to the new BB.
po | ProgramOperation to check. @movesToCopy all the moves that are copies from one BB to another |
Definition at line 1716 of file CopyingDelaySlotFiller.cc.
|
private |
Assigns moves which have been copied to the succeeding basic block into instructions in the basic block which is being filled.
moves | moves to assign |
slotsToFill | number of instructions to fill |
firstCycleToFill | cycle where to fill first instruction |
rm | resourcemanager to the bb being filled to. |
Definition at line 1283 of file CopyingDelaySlotFiller.cc.
References assert, ResourceManager::assign(), ResourceManager::canAssign(), MoveNode::cycle(), TTAProgram::Immediate::destination(), TTAProgram::Terminal::equals(), MoveNode::guardOperationPtr(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), ResourceManager::instruction(), MoveNode::isDestinationOperation(), MoveNode::isGuardOperation(), TTAProgram::Terminal::isImmediateRegister(), MoveNode::isScheduled(), TTAProgram::Move::isUnconditional(), TTAMachine::ImmediateUnit::latency(), MoveNode::move(), TTAProgram::Move::setGuard(), TTAProgram::Move::source(), ResourceManager::unassign(), and MoveNode::unsetGuardOperation().
|
private |
Checks that all other moves of an operation can be scheduled at same relative cycles than they were in the another BB.
Definition at line 1404 of file CopyingDelaySlotFiller.cc.
References MoveNode::destinationOperation(), and MoveNode::destinationOperationCount().
|
private |
Definition at line 1418 of file CopyingDelaySlotFiller.cc.
References ProgramOperation::areInputsAssigned(), assert, ResourceManager::assign(), ResourceManager::canAssign(), MoveNode::cycle(), MoveNode::guardOperationPtr(), ProgramOperation::inputMove(), ProgramOperation::inputMoveCount(), MoveNode::isDestinationOperation(), MoveNode::isGuardOperation(), MoveNode::isScheduled(), TTAProgram::Move::isUnconditional(), MoveNode::move(), ProgramOperation::outputMove(), ProgramOperation::outputMoveCount(), TTAProgram::Move::setGuard(), and MoveNode::unsetGuardOperation().
|
private |
Tries to fill n slots from other BB.
Aborts cannot fill all of the slots
blockToFill | BB containing the delay slots. |
nextBB | block where from to copy the instructions. |
slotsToFill | how many slots tries to fill |
removeGuards | how many first instructions need guard removed. |
grIndex | index of the guard register of the jump |
grFile | register file of the guard of the jump. |
skippedJump | if we can skip BB which jumps, sets the skipped jump here |
Definition at line 817 of file CopyingDelaySlotFiller.cc.
References AssocTools::append(), BasicBlockNode::basicBlock(), TTAProgram::CodeSnippet::instructionCount(), and SimpleResourceManager::smallestCycle().
|
private |
Definition at line 2000 of file CopyingDelaySlotFiller.cc.
References assert, and SimpleResourceManager::unassign().
|
private |
Definition at line 333 of file CopyingDelaySlotFiller.cc.
References assert, BasicBlockNode::basicBlock(), ControlFlowEdge::edgePredicate(), ControlFlowEdge::edgeType(), TTAProgram::InstructionReferenceManager::hasReference(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Instruction::removeImmediate(), TTAProgram::Instruction::removeMove(), and TTAProgram::BasicBlock::skipFirstInstructions().
|
private |
Updates jump instruction jump address to the new one. Also updates CFG if it is changed due completely skipped BB.
jumpBBN | basic block whose delay slots are filled |
fillingBBN | next basic block where the instructions are taken |
fillEdge | CFG edge connecting the basic blocks. |
jumpAddress | jump address being updated to new one. |
slotsFilled | how many delay slots were filled. |
Definition at line 1796 of file CopyingDelaySlotFiller.cc.
References __func__, assert, BasicBlockNode::basicBlock(), TTAProgram::Terminal::copy(), TTAProgram::InstructionReferenceManager::createReference(), TTAProgram::InstructionReferenceManager::hasReference(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::Terminal::instructionReference(), TTAProgram::Move::isReturn(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Move::parent(), TTAProgram::Instruction::removeImmediate(), TTAProgram::Instruction::removeMove(), TTAProgram::AnnotatedInstructionElement::setAnnotation(), TTAProgram::TerminalInstructionReference::setInstructionReference(), TTAProgram::Move::setSource(), TTAProgram::Immediate::setValue(), TTAProgram::BasicBlock::skippedFirstInstructions(), TTAProgram::Move::source(), and TTAProgram::Immediate::value().
|
private |
Checks whether given move writes to given register
move | to check |
rf | RegisterFile containing the register |
registerIndex | index of the register. |
Definition at line 789 of file CopyingDelaySlotFiller.cc.
References TTAProgram::Move::destination(), TTAProgram::TerminalRegister::index(), TTAProgram::Terminal::isGPR(), and TTAProgram::TerminalRegister::registerFile().
|
mutableprivate |
Definition at line 215 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 186 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 185 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 217 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 219 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 206 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 199 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 196 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 198 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 197 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 195 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 193 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 188 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 203 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 201 of file CopyingDelaySlotFiller.hh.
|
private |
Definition at line 189 of file CopyingDelaySlotFiller.hh.