Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 if (auto *Var = llvm::dyn_cast<Variable>(Opnd)) { | 626 if (auto *Var = llvm::dyn_cast<Variable>(Opnd)) { |
| 627 Dependency[Var].push_back(&Instr); | 627 Dependency[Var].push_back(&Instr); |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 } | 634 } |
| 635 | 635 |
| 636 void Cfg::shortCircuitJumps() { | |
| 637 // Split Nodes whenever an early jump is possible. | |
| 638 // __N : | |
| 639 // a = <something> | |
| 640 // Instruction 1 without side effect | |
| 641 // ... b = <something> ... | |
| 642 // Instruction N without side effect | |
| 643 // t1 = or a b | |
| 644 // br t1 __X __Y | |
| 645 // | |
| 646 // is transformed into: | |
| 647 // __N : | |
| 648 // a = <something> | |
| 649 // br a __X __N_ext | |
| 650 // | |
| 651 // __N_ext : | |
| 652 // Instruction 1 without side effect | |
| 653 // ... b = <something> ... | |
| 654 // Instruction N without side effect | |
| 655 // br b __X __Y | |
| 656 //(Similar logic for AND, jump to false instead of true target.) | |
| 657 | |
| 658 TimerMarker T(TimerStack::TT_shortCircuit, this); | |
| 659 getVMetadata()->init(VMK_Uses); | |
| 660 auto Nodes = this->getNodes(); | |
|
Jim Stichnoth
2016/06/20 18:41:41
Cfg::getNodes() returns "const NodeList &". So I'
| |
| 661 while (!Nodes.empty()) { | |
| 662 auto Node = Nodes.back(); | |
|
John
2016/06/16 13:41:10
auto*
| |
| 663 Nodes.pop_back(); | |
| 664 auto NewNode = Node->shortCircuit(); | |
| 665 if (NewNode) | |
| 666 Nodes.push_back(NewNode); | |
|
John
2016/06/16 13:41:10
(I think) You are missing short circuiting opportu
| |
| 667 } | |
| 668 } | |
| 669 | |
| 636 void Cfg::doArgLowering() { | 670 void Cfg::doArgLowering() { |
| 637 TimerMarker T(TimerStack::TT_doArgLowering, this); | 671 TimerMarker T(TimerStack::TT_doArgLowering, this); |
| 638 getTarget()->lowerArguments(); | 672 getTarget()->lowerArguments(); |
| 639 } | 673 } |
| 640 | 674 |
| 641 void Cfg::sortAndCombineAllocas(CfgVector<Inst *> &Allocas, | 675 void Cfg::sortAndCombineAllocas(CfgVector<Inst *> &Allocas, |
| 642 uint32_t CombinedAlignment, InstList &Insts, | 676 uint32_t CombinedAlignment, InstList &Insts, |
| 643 AllocaBaseVariableType BaseVariableType) { | 677 AllocaBaseVariableType BaseVariableType) { |
| 644 if (Allocas.empty()) | 678 if (Allocas.empty()) |
| 645 return; | 679 return; |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1604 } | 1638 } |
| 1605 } | 1639 } |
| 1606 // Print each basic block | 1640 // Print each basic block |
| 1607 for (CfgNode *Node : Nodes) | 1641 for (CfgNode *Node : Nodes) |
| 1608 Node->dump(this); | 1642 Node->dump(this); |
| 1609 if (isVerbose(IceV_Instructions)) | 1643 if (isVerbose(IceV_Instructions)) |
| 1610 Str << "}\n"; | 1644 Str << "}\n"; |
| 1611 } | 1645 } |
| 1612 | 1646 |
| 1613 } // end of namespace Ice | 1647 } // end of namespace Ice |
| OLD | NEW |