OpenASIP  2.0
BFCopyRegWithOp.cc
Go to the documentation of this file.
1 #include "BFCopyRegWithOp.hh"
2 #include "ProgramOperation.hh"
3 #include "OperationPool.hh"
4 #include "Operation.hh"
5 #include "Move.hh"
6 #include "CodeGenerator.hh"
7 #include "TerminalFUPort.hh"
8 #include "FunctionUnit.hh"
9 #include "DataDependenceGraph.hh"
10 
11 #include <iostream>
12 
14 
17  OperationPool opPool;
18  auto& op = opPool.operation("COPY");
19  pop_ = std::make_shared<ProgramOperation>(op);
20 
21  mn_.move().setSource(cGen.createTerminalFUPort("COPY",2));
23  pop_->addInputNode(*regCopy_);
24  pop_->addOutputNode(mn_);
27 
28  for (auto fu : candidateFUs_) {
29  TTAProgram::ProgramAnnotation srcCandidate(
31  fu->name());
32  mn_.move().addAnnotation(srcCandidate);
33 
34  TTAProgram::ProgramAnnotation dstCandidate(
36  fu->name());
37  regCopy_->move().addAnnotation(dstCandidate);
38  }
39 
40  // move RAW in edges...
41  for (int i = ddg().rootGraph()->inDegree(mn_)-1; i >= 0; i--) {
42  auto& e = ddg().rootGraph()->inEdge(mn_,i);
43  if (e.isRAW() && !e.headPseudo()) {
44  ddg().rootGraph()->moveInEdge(mn_, *regCopy_, e);
45  }
46  }
47 
48  // move antidep edges.
49  for (int i = ddg().rootGraph()->outDegree(mn_)-1; i >= 0; i--) {
50  auto& e = ddg().rootGraph()->outEdge(mn_,i);
51  if (e.isRegisterOrRA() && !e.isRAW() && !e.tailPseudo()) {
53  }
54  }
55 
56 
58  *(new DataDependenceEdge(
61  TCEString("COPY"))));
62  return true;
63 }
64 
66 
69 
70  // restore antidep edges.
71  for (int i = ddg().rootGraph()->outDegree(*regCopy_)-1; i >= 0; i--) {
72  auto& e = ddg().rootGraph()->outEdge(*regCopy_,i);
73  if (e.isRegisterOrRA() && !e.isRAW() && !e.tailPseudo()) {
75  }
76  }
77 
78  // restore raw edges
79  for (int i = ddg().rootGraph()->inDegree(*regCopy_)-1; i >= 0; i--) {
80  auto& e = ddg().rootGraph()->inEdge(*regCopy_,i);
81  if (e.isRAW() && !e.headPseudo()) {
82  ddg().rootGraph()->moveInEdge(*regCopy_, mn_, e);
83  }
84  }
85 
86 
87  pop_->removeOutputNode(mn_);
88  pop_->removeInputNode(*regCopy_);
92  pop_ = ProgramOperationPtr(); // this should delete the obj.
93 
95 }
BoostGraph::connectNodes
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)
BoostGraph::outEdge
virtual Edge & outEdge(const Node &node, const int index) const
OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
TTAProgram::CodeGenerator::createTerminalFUPort
TTAProgram::TerminalFUPort * createTerminalFUPort(const TCEString &opName, int operand)
Definition: CodeGenerator.cc:94
BFCopyRegWithOp::pop_
ProgramOperationPtr pop_
Definition: BFCopyRegWithOp.hh:17
DataDependenceGraph.hh
BoostGraph::moveOutEdge
virtual void moveOutEdge(const Node &source, const Node &destination, Edge &edge, const Node *head=NULL, bool childs=false)
BFOptimization::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: BFOptimization.cc:81
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
BFCopyRegWithOp::splitMove
bool splitMove(BasicBlockNode &bbn)
Definition: BFCopyRegWithOp.cc:15
BoostGraph::moveInEdge
virtual void moveInEdge(const Node &source, const Node &destination, Edge &edge, const Node *tail=NULL, bool childs=false)
BoostGraph::disconnectNodes
virtual void disconnectNodes(const Node &nTail, const Node &nHead)
MoveNode::setSourceOperationPtr
void setSourceOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:541
DataDependenceEdge::DEP_UNKNOWN
@ DEP_UNKNOWN
Definition: DataDependenceEdge.hh:46
TTAProgram::Move::setDestination
void setDestination(Terminal *dst)
Definition: Move.cc:333
TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_SRC
@ ANN_CONN_CANDIDATE_UNIT_SRC
Src. unit candidate.
Definition: ProgramAnnotation.hh:115
BoostGraph::rootGraph
BoostGraph * rootGraph()
MoveNode::addDestinationOperationPtr
void addDestinationOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:533
BoostGraph::inEdge
virtual Edge & inEdge(const Node &node, const int index) const
DataDependenceEdge::EDGE_OPERATION
@ EDGE_OPERATION
Definition: DataDependenceEdge.hh:56
BasicBlockNode
Definition: BasicBlockNode.hh:64
Operation.hh
MoveNode::unsetSourceOperation
void unsetSourceOperation()
Definition: MoveNode.cc:760
TerminalFUPort.hh
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
BFRegCopy::regCopy_
MoveNode * regCopy_
Definition: BFRegCopy.hh:70
ProgramOperation.hh
BFCopyRegWithOp::undoSplit
void undoSplit()
Definition: BFCopyRegWithOp.cc:65
TTAProgram::AnnotatedInstructionElement::addAnnotation
void addAnnotation(const ProgramAnnotation &annotation)
Definition: AnnotatedInstructionElement.cc:63
MoveNode::move
TTAProgram::Move & move()
CodeGenerator.hh
BFRegCopy::mn_
MoveNode & mn_
Definition: BFRegCopy.hh:69
BFCopyRegWithOp.hh
MoveNode::removeDestinationOperation
void removeDestinationOperation(const ProgramOperation *po)
Definition: MoveNode.cc:741
BFCopyRegWithOp::candidateFUs_
MachineConnectivityCheck::FUSet candidateFUs_
Definition: BFCopyRegWithOp.hh:18
TCEString
Definition: TCEString.hh:53
TTAProgram::Terminal::copy
virtual Terminal * copy() const =0
TTAProgram::CodeGenerator
Definition: CodeGenerator.hh:53
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
TTAProgram::ProgramAnnotation
Definition: ProgramAnnotation.hh:49
TTAProgram::AnnotatedInstructionElement::removeAnnotations
void removeAnnotations(ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID)
Definition: AnnotatedInstructionElement.cc:146
OperationPool
Definition: OperationPool.hh:52
Move.hh
OperationPool.hh
TTAProgram::Move::setSource
void setSource(Terminal *src)
Definition: Move.cc:312
FunctionUnit.hh
TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_DST
@ ANN_CONN_CANDIDATE_UNIT_DST
Dst. unit candidate.
Definition: ProgramAnnotation.hh:116