OpenASIP  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BFShareOperand Class Reference

#include <BFShareOperand.hh>

Inheritance diagram for BFShareOperand:
Inheritance graph
Collaboration diagram for BFShareOperand:
Collaboration graph

Public Member Functions

 BFShareOperand (BF2Scheduler &sched, MoveNode &removed, MoveNode &shared)
 
virtual bool operator() ()
 
virtual ~BFShareOperand ()
 
- Public Member Functions inherited from BFOptimization
 BFOptimization (BF2Scheduler &sched)
 
virtual bool isFinishFront ()
 
virtual void mightBeReady (MoveNode &mn)
 
- Public Member Functions inherited from Reversible
virtual void undo ()
 
virtual ~Reversible ()
 
void deleteChildren (std::stack< Reversible * > &children)
 
int id ()
 
 Reversible ()
 

Protected Member Functions

virtual void undoOnlyMe ()
 
- Protected Member Functions inherited from BFOptimization
DataDependenceGraphddg ()
 
DataDependenceGraphrootDDG ()
 
const DataDependenceGraphddg () const
 
DataDependenceGraphprologDDG ()
 
SimpleResourceManagerrm () const
 
SimpleResourceManagerprologRM () const
 
BUMoveNodeSelectorselector ()
 
const TTAMachine::MachinetargetMachine () const
 
unsigned int ii () const
 
MoveNodeDuplicatorduplicator () const
 
virtual bool assign (int cycle, MoveNode &, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU_=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGuardWriteCycle=false)
 
virtual void unassign (MoveNode &mn, bool disposePrologCopy=true)
 
virtual int rmEC (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1)
 
virtual int rmLC (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1)
 
virtual bool canAssign (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGWN=false)
 
bool putAlsoToPrologEpilog (int cycle, MoveNode &mn)
 
void setPrologSrcFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setPrologDstFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setJumpGuard (MoveNode &mn)
 
void unsetJumpGuard (MoveNode &mn)
 
bool needJumpGuard (const MoveNode &mn, int cycle)
 
int jumpGuardAvailableCycle (const MoveNode &mn)
 
bool canBeSpeculated (const Operation &op)
 
bool canBeSpeculated (const MoveNode &mn)
 
bool usePrologMove (const MoveNode &mn)
 
bool canBeScheduled (const MoveNode &mn)
 
const TTAMachine::RegisterFileRFReadPortCountPreventsScheduling (const MoveNode &mn)
 
bool immCountPreventsScheduling (const MoveNode &mn)
 
- Protected Member Functions inherited from Reversible
bool runPreChild (Reversible *preChild)
 
bool runPostChild (Reversible *preChild)
 
bool runChild (std::stack< Reversible * > &children, Reversible *child)
 
bool runChild (Reversible *child, bool pre)
 
void undoAndRemovePreChildren ()
 
void undoAndRemovePostChildren ()
 
void undoAndRemoveChildren (std::stack< Reversible * > &children)
 

Protected Attributes

MoveNoderemoved_
 
MoveNodeshared_
 
std::vector< ProgramOperationPtrops_
 
std::set< ProgramOperationPtrcreatedPrologPOs_
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 43 of file BFShareOperand.hh.

Constructor & Destructor Documentation

◆ BFShareOperand()

BFShareOperand::BFShareOperand ( BF2Scheduler sched,
MoveNode removed,
MoveNode shared 
)
inline

Definition at line 45 of file BFShareOperand.hh.

46  :
47  BFOptimization(sched), removed_(removed), shared_(shared) {}

◆ ~BFShareOperand()

virtual BFShareOperand::~BFShareOperand ( )
inlinevirtual

Definition at line 49 of file BFShareOperand.hh.

49 {}

Member Function Documentation

◆ operator()()

bool BFShareOperand::operator() ( )
virtual

This performs the operation. Returns true if success, false if fail.

Implements Reversible.

Reimplemented in BFShareOperandLate, and BFShareOperandWithScheduled.

Definition at line 43 of file BFShareOperand.cc.

43  {
46  return false;
47  }
51  op->removeInputNode(removed_);
52 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
53  std::cerr << "\t\t\t\t\tRemoved: " << removed_.toString()
54  << " from: " << op->toString() << std::endl;
55 #endif
56 
58  op->addInputNode(shared_);
59 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
60  std::cerr << "\t\t\t\t\tAdded: " << shared_.toString()
61  << " to: " << op->toString() << std::endl;
62 #endif
63 
64  // update also prolog movenodes.
65  if (ii()) {
66  MoveNode* prologMNOfRemoved = duplicator().getMoveNode(removed_);
67  ProgramOperationPtr prologPO;
68  if (prologMNOfRemoved) {
69  prologPO = prologMNOfRemoved->destinationOperationPtr(0);
70  prologMNOfRemoved->removeDestinationOperation(&*prologPO);
71  prologPO->removeInputNode(*prologMNOfRemoved);
72  } else {
73  prologPO = duplicator().getProgramOperation(op);
74  }
75 
76  MoveNode* prologMNOfShared = duplicator().getMoveNode(shared_);
77  if (prologMNOfShared) {
78  if (prologPO == nullptr) {
80  createdPrologPOs_.insert(prologPO);
81  }
82  prologMNOfShared->addDestinationOperationPtr(prologPO);
83  prologPO->addInputNode(*prologMNOfShared);
84  }
85  }
86  ops_.push_back(op);
87  }
88  return true;
89 }

References MoveNode::addDestinationOperationPtr(), createdPrologPOs_, TTAProgram::Move::destination(), MoveNode::destinationOperationCount(), MoveNode::destinationOperationPtr(), MoveNodeDuplicator::duplicateProgramOperationPtr(), BFOptimization::duplicator(), MoveNodeDuplicator::getMoveNode(), MoveNodeDuplicator::getProgramOperation(), BFOptimization::ii(), MoveNode::move(), TTAProgram::Terminal::operationIndex(), ops_, removed_, MoveNode::removeDestinationOperation(), shared_, and MoveNode::toString().

Here is the call graph for this function:

◆ undoOnlyMe()

void BFShareOperand::undoOnlyMe ( )
protectedvirtual

Undoes the operations done by this class but not children. This method should be overloaded by most derived classes.

Reimplemented from Reversible.

Reimplemented in BFShareOperandLate, and BFShareOperandWithScheduled.

Definition at line 92 of file BFShareOperand.cc.

92  {
93 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
94  std::cerr << "\t\t\t\tBFShareOperand undoing itseld, shared: "
95  << shared_.toString() << std::endl;
96 #endif
97  while(ops_.size()) {
98  ProgramOperationPtr op = *ops_.rbegin();
99 
100  if (ii()) {
101  ProgramOperationPtr prologPO =
103 
104  MoveNode* prologMNOfShared = duplicator().getMoveNode(shared_);
105  MoveNode* prologMNOfRemoved = duplicator().getMoveNode(removed_);
106 
107  if (prologMNOfShared) {
108  // if the mn is duplicated, also the PO should be duplicated
109  assert(prologPO != nullptr);
110  prologPO->removeInputNode(*prologMNOfShared);
111  prologMNOfShared->removeDestinationOperation(&*prologPO);
112  }
113 
114  if (prologMNOfRemoved) {
115  // if the mn is duplicated, also the PO should be duplicated
116  assert(prologPO != nullptr);
117  prologPO->addInputNode(*prologMNOfRemoved);
118  prologMNOfRemoved->addDestinationOperationPtr(prologPO);
119  }
120  }
121 
122 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
123  std::cerr << "\t\t\t\t\t\tRestoring, op: "
124  << op->toString() << std::endl;
125 #endif
126  op->removeInputNode(shared_);
128  op->addInputNode(removed_);
130 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
131  std::cerr << "\t\t\t\t\t\tRestored: " << removed_.toString()
132  << " to: " << op->toString() << std::endl;
133 #endif
134  ops_.pop_back();
135  }
136 }

References MoveNode::addDestinationOperationPtr(), assert, BFOptimization::duplicator(), MoveNodeDuplicator::getMoveNode(), MoveNodeDuplicator::getProgramOperation(), BFOptimization::ii(), ops_, removed_, MoveNode::removeDestinationOperation(), shared_, and MoveNode::toString().

Referenced by BFShareOperandLate::operator()(), BFShareOperandWithScheduled::undoOnlyMe(), and BFShareOperandLate::undoOnlyMe().

Here is the call graph for this function:

Member Data Documentation

◆ createdPrologPOs_

std::set<ProgramOperationPtr> BFShareOperand::createdPrologPOs_
protected

Definition at line 55 of file BFShareOperand.hh.

Referenced by operator()().

◆ ops_

std::vector<ProgramOperationPtr> BFShareOperand::ops_
protected

Definition at line 54 of file BFShareOperand.hh.

Referenced by operator()(), and undoOnlyMe().

◆ removed_

MoveNode& BFShareOperand::removed_
protected

◆ shared_

MoveNode& BFShareOperand::shared_
protected

The documentation for this class was generated from the following files:
BFShareOperand::removed_
MoveNode & removed_
Definition: BFShareOperand.hh:52
BFOptimization::duplicator
MoveNodeDuplicator & duplicator() const
Definition: BFOptimization.cc:87
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
MoveNode
Definition: MoveNode.hh:65
MoveNodeDuplicator::duplicateProgramOperationPtr
ProgramOperationPtr duplicateProgramOperationPtr(ProgramOperationPtr old)
Definition: MoveNodeDuplicator.cc:173
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
assert
#define assert(condition)
Definition: Application.hh:86
TTAProgram::Terminal::operationIndex
virtual int operationIndex() const
Definition: Terminal.cc:364
MoveNode::addDestinationOperationPtr
void addDestinationOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:533
BFShareOperand::createdPrologPOs_
std::set< ProgramOperationPtr > createdPrologPOs_
Definition: BFShareOperand.hh:55
MoveNode::destinationOperationCount
unsigned int destinationOperationCount() const
MoveNodeDuplicator::getProgramOperation
ProgramOperationPtr getProgramOperation(ProgramOperationPtr old)
Definition: MoveNodeDuplicator.cc:188
BFOptimization::BFOptimization
BFOptimization(BF2Scheduler &sched)
Definition: BFOptimization.hh:75
BFShareOperand::shared_
MoveNode & shared_
Definition: BFShareOperand.hh:53
MoveNodeDuplicator::getMoveNode
MoveNode * getMoveNode(MoveNode &mn)
Definition: MoveNodeDuplicator.cc:85
MoveNode::destinationOperationPtr
ProgramOperationPtr destinationOperationPtr(unsigned int index=0) const
MoveNode::move
TTAProgram::Move & move()
MoveNode::removeDestinationOperation
void removeDestinationOperation(const ProgramOperation *po)
Definition: MoveNode.cc:741
BFShareOperand::ops_
std::vector< ProgramOperationPtr > ops_
Definition: BFShareOperand.hh:54