Go to the documentation of this file.
34 codeGenerator_(new
TTAProgram::CodeGenerator(targetMachine)),
35 irm_(NULL), mach_(targetMachine) {}
49 for (
auto e: iEdges) {
50 if (e->isFallThroughEdge()) {
56 if (loopBegin == NULL || preLoop == NULL) {
62 for (
auto e: oEdges) {
63 if (e->isFallThroughEdge()) {
66 if (&cfg.
headNode(*e) != loopBegin) {
72 if (afterLoop == NULL) {
90 return BBNodes(preLoop, loopBegin, &bbn, afterLoop);
109 for (
int i = 0; i < cfg.
nodeCount(); i++) {
138 loopEdge->edgePredicate(),
142 exitEdge->edgePredicate(),
146 loopEdge->setBackEdge();
175 std::map<ProgramOperationPtr,ProgramOperationPtr> poMapping;
182 for (
int i = 0; i < ins.
moveCount(); i++) {
184 auto moveCopy = move.
copy();
187 if (moveCopy->source().isFUPort()) {
196 newPO->addOutputNode(*newMN);
200 if (moveCopy->destination().isFUPort()) {
203 moveCopy->destination()),
207 if (newMN ==
nullptr)
209 newPO->addInputNode(*newMN);
215 if (moveCopy->isJump() && newJumpDest !=
nullptr) {
216 if (!moveCopy->isUnconditional()) {
220 if (!(moveCopy->guard().guard().parentBus() ==
nullptr
230 std::map<std::string, std::string> branchNegations =
231 {{
"BZ",
"BNZ"}, {
"BNZ",
"BZ"},
232 {
"BZ1",
"BNZ1"}, {
"BNZ1",
"BZ1"},
233 {
"BEQ",
"BNE"}, {
"BNE",
"BEQ"},
234 {
"BGT",
"BLE"}, {
"BLE",
"BGT"},
235 {
"BGTU",
"BLEU"}, {
"BLEU",
"BGTU"},
236 {
"BLT",
"BGE"}, {
"BGE",
"BLT"},
237 {
"BLTU",
"BGEU"}, {
"BGEU",
"BLTU"}
240 &moveCopy->destination());
242 TCEString jumpName = dest->hintOperation().name();
243 if (branchNegations.count(jumpName) > 0) {
245 std::string negatedOpName = branchNegations[jumpName];
251 "Cannot neg unknown conditional jump instr");
270 std::map<TCEString, TCEString> negateOps;
271 negateOps[
"eq"] =
"ne";
272 negateOps[
"ne"] =
"eq";
273 negateOps[
"le"] =
"gt";
274 negateOps[
"gt"] =
"le";
275 negateOps[
"lt"] =
"ge";
276 negateOps[
"ge"] =
"lt";
277 negateOps[
"leu"] =
"gtu";
278 negateOps[
"gtu"] =
"leu";
279 negateOps[
"ltu"] =
"geu";
280 negateOps[
"geu"] =
"ltu";
283 std::cerr <<
"negating op: " << op.
name() << std::endl;
284 auto i = negateOps.find(op.
name());
285 if (i == negateOps.end()) {
286 std::cerr <<
"negated op for: " << op.
name() <<
" not found!" << std::endl;
289 std::cerr <<
"negated opname: " << i->second << std::endl;
296 po->setOperation(negatedOp);
std::shared_ptr< Move > copy() const
TTAProgram::InstructionReferenceManager * irm_
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)
virtual Edge & outEdge(const Node &node, const int index) const
void addMove(std::shared_ptr< Move > move)
Operation & operation(const char *name)
BasicBlockNode * postLoop
virtual Node & tailNode(const Edge &edge) const
static ProgramOperationPtr fixTerminalPO(TTAProgram::TerminalFUPort &terminal, std::map< ProgramOperationPtr, ProgramOperationPtr > &poMapping)
virtual Node & headNode(const Edge &edge) const
Node & node(const int index) const
static bool supportsOperation(const TTAMachine::Machine &mach, TCEString operation)
BasicBlockNode * beginLoop
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
virtual void moveOutEdge(const Node &source, const Node &destination, Edge &edge, const Node *head=NULL, bool childs=false)
virtual TCEString name() const
bool negateOp(ProgramOperationPtr po)
std::shared_ptr< ProgramOperation > ProgramOperationPtr
virtual int outDegree(const Node &node) const
virtual void disconnectNodes(const Node &nTail, const Node &nHead)
void setSourceOperationPtr(ProgramOperationPtr po)
TTAProgram::BasicBlock & basicBlock()
#define assert(condition)
Peel2BBLoops(InterPassData &data, const TTAMachine::Machine &targetMachine)
void addDestinationOperationPtr(ProgramOperationPtr po)
virtual int instructionCount() const
virtual void add(Instruction *ins)
virtual Edge & inEdge(const Node &node, const int index) const
void updateCFG(ControlFlowGraph &cfg, BBNodes &bbns)
void peel2BBLoop(ControlFlowGraph &cfg, BBNodes &bbns)
bool isFallThroughEdge() const
virtual int inDegree(const Node &node) const
virtual EdgeSet inEdges(const Node &node) const
EdgeSet connectingEdges(const Node &nTail, const Node &nHead) const
virtual EdgeSet outEdges(const Node &node) const
ProgramOperation & destinationOperation(unsigned int index=0) const
void appendBB(const TTAProgram::BasicBlock &src, TTAProgram::BasicBlock &dest, BasicBlockNode *newJumpDest)
TTAProgram::CodeGenerator * codeGenerator_
void setOperation(const Operation &op)
static bool removeJump(TTAProgram::BasicBlock &bb)
void handleControlFlowGraph(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine) override
virtual Instruction & instructionAtIndex(int index) const
BBNodes testIf2BBLoop(ControlFlowGraph &cfg, BasicBlockNode &bbn)
static TTAProgram::MoveGuard * createInverseGuard(const TTAProgram::MoveGuard &mg, const TTAMachine::Bus *bus=NULL)
void deleteNodeAndRefs(BasicBlockNode &node)
const TTAMachine::Machine & mach_
void performCodeMotion(BBNodes &bbns)