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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
696 } | 696 } |
697 } | 697 } |
698 | 698 |
699 SizeT NodeIndex = 0; | 699 SizeT NodeIndex = 0; |
700 for (auto *Node : NewList) { | 700 for (auto *Node : NewList) { |
701 Node->resetIndex(NodeIndex++); | 701 Node->resetIndex(NodeIndex++); |
702 } | 702 } |
703 Nodes = NewList; | 703 Nodes = NewList; |
704 } | 704 } |
705 | 705 |
706 void Cfg::invertICMP() { | |
707 for (auto *Node : getNodes()) { | |
708 for (auto &Inst : Node->getInsts()) { | |
709 | |
710 if (auto *ICMP = llvm::dyn_cast<InstIcmp>(&Inst)) { | |
John
2016/07/07 21:20:56
optional: Icmp instead of ICMP
manasijm
2016/07/07 22:43:35
Done.
| |
711 auto *Const0 = llvm::dyn_cast<Constant>(ICMP->getSrc(0)); | |
712 auto *Const1 = llvm::dyn_cast<Constant>(ICMP->getSrc(1)); | |
713 if (Const0 || Const1) | |
Eric Holk
2016/07/07 21:46:48
Should this be (Const0 != nullptr || Const1 != nul
manasijm
2016/07/07 22:43:35
Acknowledged.
| |
714 continue; | |
715 auto *Var0 = llvm::dyn_cast<Variable>(ICMP->getSrc(0)); | |
716 auto *Var1 = llvm::dyn_cast<Variable>(ICMP->getSrc(1)); | |
717 if (!Var0) | |
Eric Holk
2016/07/07 21:46:48
Here too, Var0 == nullptr.
manasijm
2016/07/07 22:43:35
Done.
| |
718 continue; | |
719 if (!getVMetadata()->isTracked(Var0)) | |
720 continue; | |
721 auto Op0Def = getVMetadata()->getFirstDefinitionSingleBlock(Var0); | |
John
2016/07/07 21:20:56
are you missing a * here?
manasijm
2016/07/07 22:43:35
Done.
| |
722 if (!Op0Def || !llvm::isa<InstLoad>(Op0Def)) | |
John
2016/07/07 21:20:55
Op0Def == nullptr
manasijm
2016/07/07 22:43:35
Done.
| |
723 continue; | |
724 if (getVMetadata()->getLocalUseNode(Var0) != Node) | |
725 continue; | |
726 | |
John
2016/07/07 21:20:55
optional: define Var1 here, closer to where it is
manasijm
2016/07/07 22:43:35
Done.
| |
727 if (Var1 && getVMetadata()->isTracked(Var1)) { | |
728 auto Op1Def = getVMetadata()->getFirstDefinitionSingleBlock(Var1); | |
John
2016/07/07 21:20:55
are you missing a * here?
manasijm
2016/07/07 22:43:35
Done.
| |
729 if (Op1Def && !getVMetadata()->isMultiBlock(Var1) && | |
730 llvm::isa<InstLoad>(Op1Def)) { | |
731 continue; // Both are loads | |
732 } | |
733 } | |
734 auto Cond = ICMP->getCondition(); | |
735 switch (Cond) { | |
John
2016/07/07 21:20:56
I would either add a "swap" field to the ICEINSTIC
manasijm
2016/07/07 22:43:35
Added a function to InstIcmp
| |
736 case InstIcmp::ICond::Eq: | |
737 break; | |
738 case InstIcmp::ICond::Ne: | |
739 break; | |
740 case InstIcmp::ICond::Sge: | |
741 Cond = InstIcmp::ICond::Sle; | |
742 break; | |
743 case InstIcmp::ICond::Sgt: | |
744 Cond = InstIcmp::ICond::Slt; | |
745 break; | |
746 case InstIcmp::ICond::Sle: | |
747 Cond = InstIcmp::ICond::Sge; | |
748 break; | |
749 case InstIcmp::ICond::Slt: | |
750 Cond = InstIcmp::ICond::Sgt; | |
751 break; | |
752 case InstIcmp::ICond::Uge: | |
753 Cond = InstIcmp::ICond::Ule; | |
754 break; | |
755 case InstIcmp::ICond::Ugt: | |
756 Cond = InstIcmp::ICond::Ult; | |
757 break; | |
758 case InstIcmp::ICond::Ule: | |
759 Cond = InstIcmp::ICond::Uge; | |
760 break; | |
761 case InstIcmp::ICond::Ult: | |
762 Cond = InstIcmp::ICond::Ugt; | |
763 break; | |
764 default: | |
765 continue; | |
766 } | |
767 ICMP->setCondition(Cond); | |
768 auto *TempOp = ICMP->getSrc(0); | |
769 ICMP->replaceSource(0, ICMP->getSrc(1)); | |
770 ICMP->replaceSource(1, TempOp); | |
771 } | |
772 } | |
773 } | |
774 } | |
775 | |
706 void Cfg::doArgLowering() { | 776 void Cfg::doArgLowering() { |
707 TimerMarker T(TimerStack::TT_doArgLowering, this); | 777 TimerMarker T(TimerStack::TT_doArgLowering, this); |
708 getTarget()->lowerArguments(); | 778 getTarget()->lowerArguments(); |
709 } | 779 } |
710 | 780 |
711 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, | 781 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, |
712 uint32_t CombinedAlignment, InstList &Insts, | 782 uint32_t CombinedAlignment, InstList &Insts, |
713 AllocaBaseVariableType BaseVariableType) { | 783 AllocaBaseVariableType BaseVariableType) { |
714 if (Allocas.empty()) | 784 if (Allocas.empty()) |
715 return; | 785 return; |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1683 } | 1753 } |
1684 } | 1754 } |
1685 // Print each basic block | 1755 // Print each basic block |
1686 for (CfgNode *Node : Nodes) | 1756 for (CfgNode *Node : Nodes) |
1687 Node->dump(this); | 1757 Node->dump(this); |
1688 if (isVerbose(IceV_Instructions)) | 1758 if (isVerbose(IceV_Instructions)) |
1689 Str << "}\n"; | 1759 Str << "}\n"; |
1690 } | 1760 } |
1691 | 1761 |
1692 } // end of namespace Ice | 1762 } // end of namespace Ice |
OLD | NEW |