Go to the documentation of this file.
70 std::pair<int, TTAProgram::Move*> jumpData =
73 std::pair<TTAProgram::Move*, std::shared_ptr<TTAProgram::Immediate> >
77 int jumpIndex = jumpData.first;
79 if (jumpMove == NULL) {
91 jumpIndex, *jumpMove, irm);
92 if (jumpAddressData.first == NULL &&
93 jumpAddressData.second == NULL) {
98 if (jumpAddressData.first != NULL) {
99 jumpAddressData.first->setSource(
102 jumpAddressData.second->setValue(
125 std::cerr <<
"adding prolog into cfg" << std::endl;
130 for (
int i = 0; i < cfg.
inDegree(loopBBN); i++) {
133 if (&tail != &loopBBN) {
138 std::cerr <<
"\tmoving jump into loop into prolog"
173 for (
int i = 0; i < cfg.
outDegree(loopBBN); i++) {
179 cfg.
moveInEdge(succNode, epilogBBN, loopExitEdge);
188 assert(
false&&
"Loop exit fall-thru not in ddg!");
200 std::cerr <<
"rm.smallestCycle: " << rm.
smallestCycle() << std::endl;
201 std::cerr <<
"end cycle: " << endCycle << std::endl;
212 if (endCycle != -1) {
219 if (overlap_count > 0) {
222 <<
"Building prolog and epilog..... "
223 <<
" Overlapcount: " << overlap_count << std::endl;
243 for (
int i = 0; i < overlap_count * ii; i++) {
252 for (
int j = 0; j < overlap_count; j++) {
253 for (
int i = 0; i < ii; i++) {
265 int newZero = endCycle + 1 - (ii * (1 + overlap_count));
266 for (
int i = 0 ; i < overlap_count; i++) {
267 for (
int j = 0; j < ddg.
nodeCount(); j++) {
272 jumpMove = &n.
move();
277 if (endCycle != -1) {
278 cycle = n.
cycle() - newZero;
282 int round = cycle / ii;
283 int place = cycle % ii;
286 if (createEpilog || round == 0) {
290 if (endCycle != -1) {
291 nodeCopy->
setCycle(place + newZero);
298 <<
"Node cycle: " << cycle
299 <<
" round: " << round
300 <<
" place: " << place <<
" "
332 rootDDG->
addNode(*nodeCopy, *prologNode);
343 rootDDG->
addNode(*nodeCopy, *epilogNode);
354 <<
"Disassembly of prolog" << std::endl <<
358 <<
"Disassembly of epilog" << std::endl <<
366 <<
"Disassembly of optimized prolog" << std::endl <<
375 <<
"Prolog optimized."
382 <<
"Disassembly of optimized epilog" << std::endl <<
391 <<
"Epilog optimized."
398 <<
"No overlapping instructions.No need for prolog or epilog."
399 <<
"Should have used normal scheduler."
404 return overlap_count;
420 <<
"Copying prolog rm to bb" << prologNode->
toString()
421 <<
" Start cycle: " << startCycle << std::endl;
434 <<
"Prolog added to cfg" << prologNode->
toString() << std::endl
435 <<
"Disassembly of prolog" << std::endl <<
441 <<
"Empty prolog, not added to cfg" << std::endl;
457 <<
"Copying epilog rm to bb" << epilogNode->
toString()
466 epilogBB->
add(newInstruction);
473 <<
"epilog added to cfg" << epilogNode->
toString() << std::endl;
476 <<
"Disassembly of epilog" << std::endl <<
482 <<
"epilog empty, not added to cfg." << std::endl;
502 bool overwritten =
false;
507 for (
int k = i + immu.
latency() ;
509 !used && !overwritten; k++) {
513 if (immu.
latency() == 0 && k > i) {
525 for (
int l = 0; l < ins2.
moveCount(); l++) {
548 if (!used && overwritten) {
virtual Edge & outEdge(const Node &node, const int index) const
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)
void addMove(std::shared_ptr< Move > move)
virtual Node & tailNode(const Edge &edge) const
virtual int largestCycle() const override
std::string toString() const
virtual int index() const
virtual bool isInstructionAddress() const
virtual Node & headNode(const Edge &edge) const
Node & node(const int index) const
std::shared_ptr< TTAProgram::Move > movePtr()
virtual int smallestCycle() const override
virtual int build(DataDependenceGraph &ddg, SimpleResourceManager &rm, ControlFlowGraph &cfg, BasicBlockNode &loopBBN, int endCycle=-1, bool createEpilog=true)
static std::pair< int, TTAProgram::Move * > findJump(TTAProgram::BasicBlock &bb, ControlFlowEdge::CFGEdgePredicate *pred=nullptr)
virtual void remove(Instruction &ins)
InstructionReference createReference(Instruction &ins)
void removeImmediate(Immediate &imm)
virtual ~LoopPrologAndEpilogBuilder()
void setGuard(MoveGuard *guard)
BasicBlockNode * addPrologFromRM(SimpleResourceManager &prologRM, SimpleResourceManager &loopRM, ControlFlowGraph &cfg, BasicBlockNode &loopBBN)
static int verboseLevel()
static std::ostream & logStream()
virtual void addNode(Node &node)
void moveJumpDestination(TTAProgram::InstructionReferenceManager &irm, BasicBlockNode &tail, BasicBlockNode &dst, ControlFlowEdge &jumpEdge)
virtual unsigned initiationInterval() const
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
virtual std::string disassembly() const
virtual int outDegree(const Node &node) const
virtual void moveInEdge(const Node &source, const Node &destination, Edge &edge, const Node *tail=NULL, bool childs=false)
TTAProgram::BasicBlock & basicBlock()
#define assert(condition)
virtual bool isImmediateRegister() const
int skippedFirstInstructions() const
#define abortWithError(message)
bool isControlFlowMove() const
bool optimizeEpilog(TTAProgram::BasicBlock &epilog)
virtual int instructionCount() const
virtual void add(Instruction *ins)
void copyExternalOutEdges(MoveNode &nodeCopy, const MoveNode &source)
void addPrologIntoCfg(ControlFlowGraph &cfg, BasicBlockNode &prologBBN, BasicBlockNode &loopBBN)
virtual Edge & inEdge(const Node &node, const int index) const
BasicBlockNode * addEpilogFromRM(SimpleResourceManager &prologEpilogRM, int ii, ControlFlowGraph &cfg, BasicBlockNode &loopBBN)
bool optimizeProlog(TTAProgram::BasicBlock &prolog)
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
void addEpilogIntoCfg(ControlFlowGraph &cfg, BasicBlockNode &epilogBBN, BasicBlockNode &loopBBN)
LoopPrologAndEpilogBuilder()
bool isFallThroughEdge() const
virtual int inDegree(const Node &node) const
static std::pair< TTAProgram::Move *, std::shared_ptr< TTAProgram::Immediate > > findJumpImmediate(int jumpIndex, TTAProgram::Move &jumpMove, TTAProgram::InstructionReferenceManager &irm)
static void copyRMToBB(SimpleResourceManager &rm, TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, int lastCycle=-1)
Immediate & immediate(int i) const
static const int PROLOG_CYCLE_BIAS
CFGEdgePredicate edgePredicate() const
void addNode(MoveNode &moveNode)
void setScheduled(bool state=true)
TTAProgram::Move & move()
void setCycle(const int newcycle)
const TTAMachine::Machine & machine() const
int immediateCount() const
virtual void loseInstructionOwnership(int cycle)
virtual Instruction & instructionAtIndex(int index) const
Terminal & source() const
virtual void setInstructionReference(InstructionReference ref)
void copyExternalInEdges(MoveNode &nodeCopy, const MoveNode &source)
InstructionAddress originalStartAddress() const
void addImmediate(std::shared_ptr< Immediate > imm)
std::string toString() const
virtual TTAProgram::Instruction * instruction(int cycle) const override