OpenASIP
2.0
|
#include <SimpleIfConverter.hh>
Classes | |
struct | CandidateBlocks |
Public Member Functions | |
SimpleIfConverter (InterPassData &data, const TTAMachine::Machine &targetMachine) | |
virtual void | handleControlFlowGraph (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine) |
virtual void | handleProcedure (TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine) |
virtual void | handleProgram (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine) |
virtual std::string | shortDescription () const |
Public Member Functions inherited from ControlFlowGraphPass | |
ControlFlowGraphPass (InterPassData &data) | |
virtual | ~ControlFlowGraphPass () |
void | executeBasicBlockPass (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine, BasicBlockPass &bbPass) |
Public Member Functions inherited from SchedulerPass | |
SchedulerPass (InterPassData &data) | |
virtual | ~SchedulerPass () |
InterPassData & | interPassData () |
virtual std::string | longDescription () const |
Static Public Member Functions | |
static bool | removeJump (TTAProgram::BasicBlock &bb) |
static ProgramOperationPtr | fixTerminalPO (TTAProgram::TerminalFUPort &terminal, std::map< ProgramOperationPtr, ProgramOperationPtr > &poMapping) |
Private Attributes | |
TTAProgram::CodeGenerator * | codeGenerator_ |
TTAProgram::InstructionReferenceManager * | irm_ |
int | diamonds_ |
int | diamonds2_ |
int | triangles1_ |
int | triangles2_ |
int | grAborts_ |
int | grDefAborts_ |
int | grUseAborts_ |
int | loopAborts_ |
int | uncondAborts_ |
int | sizeAborts_ |
int | succAborts_ |
int | diamondSizeLimit_ |
int | triangleSizeLimit1_ |
int | triangleSizeLimit2_ |
Additional Inherited Members | |
Static Private Member Functions inherited from ProcedurePass | |
static void | copyCfgToProcedure (TTAProgram::Procedure &procedure, ControlFlowGraph &cfg) |
static void | executeControlFlowGraphPass (TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetmachine, ControlFlowGraphPass &cfgp) |
Static Private Member Functions inherited from ProgramPass | |
static void | executeProcedurePass (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine, ProcedurePass &procedurePass) |
Definition at line 40 of file SimpleIfConverter.hh.
SimpleIfConverter::SimpleIfConverter | ( | InterPassData & | data, |
const TTAMachine::Machine & | targetMachine | ||
) |
Constructor
InterPassData | InterPassData. Not used. |
dsLimit | diamond-shape size limit |
tsLimit1 | triangle-shape size limit(convert fall-thru) |
tsLimit2 | triangle-shape size limit(convert jump) |
Definition at line 60 of file SimpleIfConverter.cc.
References MachineAnalysis::averageILP(), MachineAnalysis::busILP(), MachineAnalysis::bypassedRfILP(), Application::cmdLineOptions(), TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::delaySlots(), diamondSizeLimit_, MachineAnalysis::fuILP(), SchedulerCmdLineOptions::ifConversionThreshold(), Application::logStream(), triangleSizeLimit1_, triangleSizeLimit2_, and Application::verboseLevel().
|
private |
Adds a jump at the end of a basic block.
This may create an dangling instr reference?
bb | basicBlock add the jump at end of this basic block. |
dest | destination of the jump. |
Definition at line 704 of file SimpleIfConverter.cc.
References TTAProgram::CodeSnippet::add(), TTAProgram::Instruction::addMove(), BasicBlockNode::basicBlock(), codeGenerator_, TTAProgram::CodeGenerator::createJump(), TTAProgram::InstructionReferenceManager::createReference(), TTAProgram::CodeSnippet::firstInstruction(), and irm_.
Referenced by combineBlocks().
|
private |
Definition at line 587 of file SimpleIfConverter.cc.
References TTAProgram::CodeSnippet::add(), MoveNode::addDestinationOperationPtr(), TTAProgram::Instruction::addMove(), TTAProgram::MoveGuard::copy(), TTAProgram::Move::copy(), fixTerminalPO(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isJump(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), and MoveNode::setSourceOperationPtr().
Referenced by combineBlocks().
|
private |
Checks whether if conversion is possible for given basic blocks.
candidates | Data about area being converted. |
Definition at line 289 of file SimpleIfConverter.cc.
References assert, codeGenerator_, TTAProgram::MoveGuard::copy(), TTAProgram::CodeGenerator::createInverseGuard(), TTAProgram::CodeSnippet::disassembly(), SimpleIfConverter::CandidateBlocks::fallThruBB_, SimpleIfConverter::CandidateBlocks::fallThruNode_, SimpleIfConverter::CandidateBlocks::firstBB_, SimpleIfConverter::CandidateBlocks::firstNode_, grAborts_, grDefAborts_, SimpleIfConverter::CandidateBlocks::grFile_, SimpleIfConverter::CandidateBlocks::grIndex_, grUseAborts_, TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), SimpleIfConverter::CandidateBlocks::guard_, hasConditionals(), BoostGraph< GraphNode, GraphEdge >::headNode(), TTAProgram::CodeSnippet::instructionCount(), SimpleIfConverter::CandidateBlocks::invg_, TTAProgram::Terminal::isBasicBlockReference(), TTAProgram::Terminal::isInstructionAddress(), TTAProgram::Move::isUnconditional(), SimpleIfConverter::CandidateBlocks::joinBB_, SimpleIfConverter::CandidateBlocks::joinNode_, SimpleIfConverter::CandidateBlocks::jumpDestBB_, SimpleIfConverter::CandidateBlocks::jumpDestNode_, TTAProgram::CodeSnippet::lastInstruction(), SimpleIfConverter::CandidateBlocks::lastNode_, Application::logStream(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), GraphNode::nodeID(), BoostGraph< GraphNode, GraphEdge >::outEdges(), TTAMachine::Guard::parentBus(), TTAProgram::CodeSnippet::previousInstruction(), PRINT_VAR, TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), TTAProgram::Move::source(), SimpleIfConverter::CandidateBlocks::succNode1_, uncondAborts_, and writesRegister().
Referenced by searchCandidate().
|
private |
Combines many basic blocks into one and sets the guards accordingly.
bblocks | All the data needed for the operation |
Definition at line 492 of file SimpleIfConverter.cc.
References addJump(), appendBB(), assert, SimpleIfConverter::CandidateBlocks::createJump_, SimpleIfConverter::CandidateBlocks::fallThruBB_, SimpleIfConverter::CandidateBlocks::fallThruNode_, SimpleIfConverter::CandidateBlocks::firstBB_, SimpleIfConverter::CandidateBlocks::guard_, TTAProgram::CodeSnippet::instructionCount(), SimpleIfConverter::CandidateBlocks::invg_, TTAProgram::Move::isJump(), BasicBlockNode::isNormalBB(), TTAProgram::Move::isUnconditional(), SimpleIfConverter::CandidateBlocks::joinBB_, SimpleIfConverter::CandidateBlocks::jumpDestBB_, SimpleIfConverter::CandidateBlocks::jumpDestNode_, SimpleIfConverter::CandidateBlocks::lastBB_, TTAProgram::CodeSnippet::lastInstruction(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), SimpleIfConverter::CandidateBlocks::removeJoin_, removeJump(), SimpleIfConverter::CandidateBlocks::succNode1_, and SimpleIfConverter::CandidateBlocks::succNode2_.
Referenced by convert().
|
private |
Do the if conversion for given area. All checks are already done, this must not fail.
bblocks | The data about blocks being merged |
cfg | ControlFlowGraph. |
Definition at line 405 of file SimpleIfConverter.cc.
References combineBlocks(), and updateCfg().
Referenced by handleControlFlowGraph().
|
private |
Definition at line 781 of file SimpleIfConverter.cc.
References BasicBlockNode::basicBlock(), ControlFlowEdge::CFLOW_EDGE_JUMP, ControlFlowEdge::CFLOW_EDGE_NORMAL, diamondSizeLimit_, ControlFlowEdge::edgePredicate(), ControlFlowEdge::edgeType(), BoostGraph< GraphNode, GraphEdge >::headNode(), BoostGraph< GraphNode, GraphEdge >::inDegree(), TTAProgram::CodeSnippet::instructionCount(), ControlFlowEdge::isBackEdge(), ControlFlowEdge::isCallPassEdge(), BasicBlockNode::isNormalBB(), loopAborts_, GraphNode::nodeID(), BoostGraph< GraphNode, GraphEdge >::outDegree(), BoostGraph< GraphNode, GraphEdge >::outEdge(), BoostGraph< GraphNode, GraphEdge >::outEdges(), sizeAborts_, succAborts_, and successors().
Referenced by searchCandidate().
|
private |
Definition at line 932 of file SimpleIfConverter.cc.
References BasicBlockNode::basicBlock(), BoostGraph< GraphNode, GraphEdge >::headNode(), BoostGraph< GraphNode, GraphEdge >::inDegree(), TTAProgram::CodeSnippet::instructionCount(), ControlFlowEdge::isBackEdge(), ControlFlowEdge::isCallPassEdge(), ControlFlowGraph::jumpSuccessor(), GraphNode::nodeID(), BoostGraph< GraphNode, GraphEdge >::outDegree(), BoostGraph< GraphNode, GraphEdge >::outEdge(), sizeAborts_, successors(), and triangleSizeLimit1_.
Referenced by searchCandidate().
|
private |
Definition at line 873 of file SimpleIfConverter.cc.
References BasicBlockNode::basicBlock(), BoostGraph< GraphNode, GraphEdge >::headNode(), BoostGraph< GraphNode, GraphEdge >::inDegree(), TTAProgram::CodeSnippet::instructionCount(), ControlFlowEdge::isBackEdge(), GraphNode::nodeID(), BoostGraph< GraphNode, GraphEdge >::outDegree(), BoostGraph< GraphNode, GraphEdge >::outEdge(), sizeAborts_, successors(), and triangleSizeLimit2_.
Referenced by searchCandidate().
|
static |
Definition at line 563 of file SimpleIfConverter.cc.
References TTAProgram::TerminalFUPort::hintOperation(), TTAProgram::TerminalFUPort::programOperation(), and TTAProgram::TerminalFUPort::setProgramOperation().
Referenced by Peel2BBLoops::appendBB(), and appendBB().
|
virtual |
Handles a cfg. Does if conversion for the cfg.
cfg | cfg to be if-converted. |
Reimplemented from ControlFlowGraphPass.
Definition at line 135 of file SimpleIfConverter.cc.
References Application::cmdLineOptions(), codeGenerator_, convert(), diamonds2_, diamonds_, SchedulerCmdLineOptions::dumpIfConversionCFGs(), grDefAborts_, grUseAborts_, ControlFlowGraph::instructionReferenceManager(), irm_, Application::logStream(), loopAborts_, BoostGraph< GraphNode, GraphEdge >::name(), searchCandidate(), sizeAborts_, succAborts_, triangles1_, triangles2_, uncondAborts_, Application::verboseLevel(), and GraphBase< GraphNode, GraphEdge >::writeToDotFile().
Referenced by llvm::LLVMTCEIRBuilder::compileOptimized(), and handleProcedure().
|
virtual |
Handles a procedure. Does if conversion for the procedure.
procedure | procedure to be if-converted. |
targetMachine | machine for which to be compiled. |
Reimplemented from ProcedurePass.
Definition at line 190 of file SimpleIfConverter.cc.
References ControlFlowGraph::copyToProcedure(), handleControlFlowGraph(), TTAProgram::Program::instructionReferenceManager(), irm_, TTAProgram::CodeSnippet::parent(), and ControlFlowGraph::updateReferencesFromProcToCfg().
|
virtual |
Handles a program. Does if conversion for the whole program.
program | program to be if-converted. |
targetMachine | machine for which to be compiled. |
Reimplemented from ProgramPass.
Definition at line 210 of file SimpleIfConverter.cc.
References codeGenerator_, ProgramPass::executeProcedurePass(), and program.
|
private |
Checks whether there exists any conditional moves in given BB.
bb | BasicBlock where to check for conditional moves. |
Definition at line 550 of file SimpleIfConverter.cc.
References TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isUnconditional(), TTAProgram::Instruction::move(), and TTAProgram::Instruction::moveCount().
Referenced by canConvert().
|
static |
Tries to remove a jump from the end of a basic block.
bb | basic block where to remove the jump from |
Definition at line 679 of file SimpleIfConverter.cc.
References TTAProgram::Instruction::hasJump(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::CodeSnippet::lastInstruction(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), and TTAProgram::Instruction::removeMove().
Referenced by combineBlocks(), and Peel2BBLoops::performCodeMotion().
|
private |
Searches a single area of basic blocs to be converted at once.
Conversion should always be possible for blocks this returns, All checks are done here.
This always returnsa the first area of blocks that can be converted. If actual conversion is not done/cfg is not changed, returns the same are again and again.
cfg | ControlFlowGraph. |
Definition at line 234 of file SimpleIfConverter.cc.
References canConvert(), detectDiamond(), detectTriangleViaFt(), detectTriangleViaJump(), diamonds_, BasicBlockNode::isNormalBB(), BoostGraph< GraphNode, GraphEdge >::node(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), BoostGraph< GraphNode, GraphEdge >::outDegree(), successors(), triangles1_, and triangles2_.
Referenced by handleControlFlowGraph().
|
virtual |
Tells what this scheduler pass does
Implements SchedulerPass.
Definition at line 125 of file SimpleIfConverter.cc.
|
private |
Returns 2 successors blocks of given block in specified order.
First contains the unconditional successor. Second contains the jumo target of conditional jump if exists, or null. If cannot analyze, returns both nulls.
node | Node whose successors to check |
cfg | cfg where the successors are searched. |
Definition at line 728 of file SimpleIfConverter.cc.
References assert, BasicBlockNode::basicBlock(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), BoostGraph< GraphNode, GraphEdge >::headNode(), TTAProgram::NullInstruction::instance(), TTAProgram::CodeSnippet::instructionCount(), TTAMachine::Guard::isInverted(), TTAProgram::Move::isJump(), ControlFlowEdge::isTrueEdge(), TTAProgram::Move::isUnconditional(), TTAProgram::CodeSnippet::lastInstruction(), Application::logStream(), TTAProgram::Instruction::move(), BoostGraph< GraphNode, GraphEdge >::outEdge(), TTAProgram::CodeSnippet::previousInstruction(), BoostGraph< GraphNode, GraphEdge >::successors(), BasicBlockNode::toString(), uncondAborts_, and GraphBase< GraphNode, GraphEdge >::writeToDotFile().
Referenced by detectDiamond(), detectTriangleViaFt(), detectTriangleViaJump(), and searchCandidate().
|
private |
Updates CFG after if conversion
bblocks | The data about blocks being merged |
cfg | The cfg to update |
Definition at line 421 of file SimpleIfConverter.cc.
References ControlFlowEdge::CFLOW_EDGE_JUMP, BoostGraph< GraphNode, GraphEdge >::connectNodes(), SimpleIfConverter::CandidateBlocks::createJump_, ControlFlowGraph::deleteNodeAndRefs(), BoostGraph< GraphNode, GraphEdge >::disconnectNodes(), SimpleIfConverter::CandidateBlocks::fallThruNode_, SimpleIfConverter::CandidateBlocks::firstNode_, BoostGraph< GraphNode, GraphEdge >::headNode(), ControlFlowEdge::isBackEdge(), SimpleIfConverter::CandidateBlocks::joinNode_, SimpleIfConverter::CandidateBlocks::jumpDestNode_, SimpleIfConverter::CandidateBlocks::lastNode_, BoostGraph< GraphNode, GraphEdge >::outEdges(), BoostGraph< GraphNode, GraphEdge >::removeEdge(), SimpleIfConverter::CandidateBlocks::removeFt_, SimpleIfConverter::CandidateBlocks::removeJd_, SimpleIfConverter::CandidateBlocks::removeJoin_, ControlFlowEdge::setBackEdge(), and SimpleIfConverter::CandidateBlocks::succNode1_.
Referenced by convert().
|
private |
Checks whether a given register is written in given BB.
bb | BasicBlock where to check for register writes |
index | index of the register in a registerfile |
rf | register file of the register |
Definition at line 644 of file SimpleIfConverter.cc.
References TTAProgram::Move::destination(), TTAProgram::TerminalRegister::index(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::isGPR(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), and TTAProgram::TerminalRegister::registerFile().
Referenced by canConvert().
|
private |
Definition at line 146 of file SimpleIfConverter.hh.
Referenced by addJump(), canConvert(), handleControlFlowGraph(), and handleProgram().
|
private |
Definition at line 150 of file SimpleIfConverter.hh.
Referenced by handleControlFlowGraph().
|
private |
Definition at line 149 of file SimpleIfConverter.hh.
Referenced by handleControlFlowGraph(), and searchCandidate().
|
private |
Definition at line 162 of file SimpleIfConverter.hh.
Referenced by detectDiamond(), and SimpleIfConverter().
|
private |
Definition at line 154 of file SimpleIfConverter.hh.
Referenced by canConvert().
|
private |
Definition at line 155 of file SimpleIfConverter.hh.
Referenced by canConvert(), and handleControlFlowGraph().
|
private |
Definition at line 156 of file SimpleIfConverter.hh.
Referenced by canConvert(), and handleControlFlowGraph().
|
private |
Definition at line 147 of file SimpleIfConverter.hh.
Referenced by addJump(), handleControlFlowGraph(), and handleProcedure().
|
private |
Definition at line 157 of file SimpleIfConverter.hh.
Referenced by detectDiamond(), and handleControlFlowGraph().
|
private |
Definition at line 159 of file SimpleIfConverter.hh.
Referenced by detectDiamond(), detectTriangleViaFt(), detectTriangleViaJump(), and handleControlFlowGraph().
|
private |
Definition at line 160 of file SimpleIfConverter.hh.
Referenced by detectDiamond(), and handleControlFlowGraph().
|
private |
Definition at line 151 of file SimpleIfConverter.hh.
Referenced by handleControlFlowGraph(), and searchCandidate().
|
private |
Definition at line 152 of file SimpleIfConverter.hh.
Referenced by handleControlFlowGraph(), and searchCandidate().
|
private |
Definition at line 163 of file SimpleIfConverter.hh.
Referenced by detectTriangleViaFt(), and SimpleIfConverter().
|
private |
Definition at line 164 of file SimpleIfConverter.hh.
Referenced by detectTriangleViaJump(), and SimpleIfConverter().
|
private |
Definition at line 158 of file SimpleIfConverter.hh.
Referenced by canConvert(), handleControlFlowGraph(), and successors().