Go to the documentation of this file.
35 #ifndef TTA_CONTROL_FLOW_GRAPH_HH
36 #define TTA_CONTROL_FLOW_GRAPH_HH
45 #include <boost/graph/reverse_graph.hpp>
46 #include <boost/graph/depth_first_search.hpp>
69 class InstructionReferenceManager;
70 class POMRelocBookkeeper;
82 class MachineFunction;
83 class MachineBasicBlock;
88 using boost::reverse_graph;
129 llvm::MachineFunction& mf,
159 llvm::MachineBasicBlock&
getMBB(
160 llvm::MachineFunction& mf,
192 typedef hash_map<InstructionAddress, const TTAProgram::Instruction*>
200 typedef std::pair<InstructionAddress, ControlFlowEdge::CFGEdgePredicate>
208 template <
typename EdgeDescriptor,
typename Graph >
273 int jumpInsIndex,
int jumpMoveIndex);
308 const llvm::MCInstrDesc&
313 llvm::MachineBasicBlock& mbb,
326 hash_map<InstructionAddress, BasicBlockNode*>
blocks_;
329 typedef hash_map<TTAProgram::Instruction*,TTAProgram::Instruction*>
346 mutable std::map<const TTAProgram::BasicBlock*, llvm::MachineBasicBlock*>
351 mutable std::set<std::pair<ProgramOperationPtr, llvm::MCSymbol*> >
tpos_;
354 mutable std::map<ProgramOperation*, llvm::MachineInstr*>
void buildMBBFromBB(llvm::MachineBasicBlock &mbb, const TTAProgram::BasicBlock &bb) const
TTAProgram::Program * program() const
void reverseGuardOnOutEdges(const BasicBlockNode &bbn)
unsigned int findNextIndex(const TTAProgram::Procedure &proc, int jumpInsIndex, int jumpMoveIndex)
TTAProgram::Address endAddress_
UInt32 InstructionAddress
virtual ~ControlFlowGraph()
bool jumpToBBN(const TTAProgram::Terminal &jumpAddr, const BasicBlockNode &bbn) const
void splitBasicBlocksWithCallsAndRefs()
std::vector< InstructionAddress > InstructionAddressVector
ReturnSourceSet returnSources_
@ JUMP_REMOVED
nothing removed
void copyToProcedure(TTAProgram::Procedure &proc, TTAProgram::InstructionReferenceManager *irm=NULL)
Node & node(const int index) const
TTAProgram::Immediate * findLimmWrite(TTAProgram::Move &move, BasicBlockNode &bb, int moveIndex)
ControlFlowEdge * incomingFTEdge(const BasicBlockNode &bbn) const
ReversedGraph & reversedGraph() const
RemovedJumpData removeJumpToTarget(TTAProgram::CodeSnippet &cs, const TTAProgram::Instruction &target, int idx, DataDependenceGraph *ddg=NULL)
void buildFrom(const TTAProgram::Procedure &procedure)
std::set< BasicBlockNode *, typename BasicBlockNode ::Comparator > NodeSet
TCEString printStatistics()
#define IGNORE_CLANG_WARNING(X)
void createAllBlocks(InstructionAddressMap &leaders, const TTAProgram::Procedure &procedure)
TTAProgram::Address startAddress_
bool hasMultipleUnconditionalSuccessors(const BasicBlockNode &node) const
void updateReferencesFromProcToCfg()
void computeLeadersFromRefManager(InstructionAddressMap &leaders, const TTAProgram::Procedure &procedure)
TTAProgram::InstructionReferenceManager * irm_
BasicBlockNode & createBlock(TTAProgram::Instruction &leader, const TTAProgram::Instruction &endBlock)
ControlFlowGraph(const TCEString name, TTAProgram::Program *program=NULL)
std::pair< InstructionAddress, ControlFlowEdge::CFGEdgePredicate > ReturnSource
BasicBlockNode * splitBasicBlockAtIndex(BasicBlockNode &bbn, int index)
std::map< ProgramOperation *, llvm::MachineInstr * > programOperationToMIMap_
For LLVM conversion: mapping of created MachineInstructions to TCE ProgramOperations.
void back_edge(EdgeDescriptor e, const Graph &g) const
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
InsMap originalToCfgInstructions_
void indirectJump(InstructionAddressMap &leaders, const InstructionAddress &leaderAddr, InstructionAddressMap &dataCodeRellocations, int insIndex, int moveIndex, const TTAProgram::Procedure &procedure)
void directJump(InstructionAddressMap &leaders, const InstructionAddress &leaderAddr, int insIndex, int moveIndex, const TTAProgram::Instruction &instructionTarget, const TTAProgram::Procedure &procedure)
BoostGraph< BasicBlockNode, ControlFlowEdge >::NodeDescriptor NodeDescriptor
DFS visitor which when finding back edge marks such edge as back edge.
void createJumps(InstructionAddressMap &leaders, const InstructionAddress &leaderAddr, InstructionAddressMap &dataCodeRellocations, const TTAProgram::Procedure &procedure, int insIndex, int moveIndex)
std::map< const TTAProgram::BasicBlock *, llvm::MachineBasicBlock * > bbMap_
void removeEntryExitEdge()
NodeSet findUnreachableNodes(const NodeSet &reachableNodes)
TTAProgram::Terminal * findJumpAddress(BasicBlockNode &src, ControlFlowEdge &e)
reverse_graph< ControlFlowGraph::Graph > ReversedGraph
hash_map< InstructionAddress, const TTAProgram::Instruction * > InstructionAddressMap
std::set< ControlFlowEdge *, typename ControlFlowEdge ::Comparator > EdgeSet
EdgeDescriptor connectingEdge(const Node &nTail, const Node &nHead) const
bool hasInstructionAnotherJump(const TTAProgram::Instruction &ins, int moveIndex)
int findRelJumpDistance(const BasicBlockNode &src, const TTAProgram::Terminal &jumpAddr, const TTAMachine::Machine &mach) const
std::set< ReturnSource > ReturnSourceSet
bool computeLeadersFromJumpSuccessors(InstructionAddressMap &leaders, const TTAProgram::Procedure &procedure)
BasicBlockNode * fallThroughPredecessor(const BasicBlockNode &bbn) const
hash_map< InstructionAddress, BasicBlockNode * > blocks_
BasicBlockNode & firstNormalNode() const
BasicBlockNode * jumpSuccessor(BasicBlockNode &bbn)
boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS, Node *, Edge * > Graph
Internal graph type, providing actual graph-like operations. This type definition relies on bundled p...
bool isSingleBBLoop(const BasicBlockNode &node) const
GraphTraits::edge_descriptor EdgeDescriptor
Type with which edges of the graph are seen internally.
bool allScheduledInBetween(const BasicBlockNode &src, const BasicBlockNode &dst) const
void convertBBRefsToInstRefs()
InsMap cfgToOriginalInstructions_
InterPassData * passData_
BasicBlockNode & exitNode() const
void computeLeadersFromRelocations(InstructionAddressMap &leaderSet, InstructionAddressMap &dataCodeRellocations, const TTAProgram::Procedure &procedure)
const llvm::MCInstrDesc & findLLVMTargetInstrDesc(TCEString name, const llvm::MCInstrInfo &tii) const
llvm::MachineBasicBlock & getMBB(llvm::MachineFunction &mf, const TTAProgram::BasicBlock &bb) const
NodeSet findReachableNodes()
#define IGNORE_COMPILER_WARNING(X)
void setInstructionReferenceManager(TTAProgram::InstructionReferenceManager &irm)
bool hasIncomingExternalJumps(const BasicBlockNode &bbn) const
void copyToLLVMMachineFunction(llvm::MachineFunction &mf, TTAProgram::InstructionReferenceManager *irm=NULL)
std::set< std::pair< ProgramOperationPtr, llvm::MCSymbol * > > tpos_
For LLVM conversion: the dummy label instructions for SPU should be created for with the given MCSymb...
hash_map< TTAProgram::Instruction *, TTAProgram::Instruction * > InsMap
const CFGStatistics & statistics()
BasicBlockNode * fallThruSuccessor(const BasicBlockNode &bbn) const
#define POP_COMPILER_DIAGS
BasicBlockNode & entryNode() const
void optimizeBBOrdering(bool removeDeadCode, TTAProgram::InstructionReferenceManager &irm, DataDependenceGraph *ddg)
TCEString procedureName() const
@ LAST_ELEMENT_REMOVED
jump removed, other things remain in BB
ControlFlowEdge & createControlFlowEdge(const TTAProgram::Instruction &iTail, const TTAProgram::Instruction &iHead, ControlFlowEdge::CFGEdgePredicate edgePredicate=ControlFlowEdge::CFLOW_EDGE_NORMAL, ControlFlowEdge::CFGEdgeType edgeType=ControlFlowEdge::CFLOW_EDGE_JUMP)
void mergeNodes(BasicBlockNode &node1, BasicBlockNode &node2, DataDependenceGraph *ddg, const ControlFlowEdge &connectingEdge)
void addExitFromSinkNodes(BasicBlockNode *exitNode)
virtual const TCEString & name() const
BasicBlockNode * splitBB(BasicBlockNode &n, int remainingSize)
const TTAProgram::Procedure * procedure_
void deleteNodeAndRefs(BasicBlockNode &node)
TTAProgram::Program * program_
EdgeSet incomingJumpEdges(const BasicBlockNode &bbn) const
void createBBEdges(const TTAProgram::Procedure &procedure, InstructionAddressMap &leaders, InstructionAddressMap &dataCodeRellocations)
void removeUnreachableNodes(const NodeSet &unreachableNodes, DataDependenceGraph *ddg)
bool hasFallThruPredecessor(const BasicBlockNode &bbn)