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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 // 1.0. When t0 does not get a register, introducing an extra assignment | 821 // 1.0. When t0 does not get a register, introducing an extra assignment |
822 // statement does not make sense. The relevant portion is marked below. | 822 // statement does not make sense. The relevant portion is marked below. |
823 | 823 |
824 TimerMarker _(TimerStack::TT_floatConstantCse, this); | 824 TimerMarker _(TimerStack::TT_floatConstantCse, this); |
825 for (CfgNode *Node : getNodes()) { | 825 for (CfgNode *Node : getNodes()) { |
826 | 826 |
827 CfgUnorderedMap<Constant *, Variable *> ConstCache; | 827 CfgUnorderedMap<Constant *, Variable *> ConstCache; |
828 auto Current = Node->getInsts().begin(); | 828 auto Current = Node->getInsts().begin(); |
829 auto End = Node->getInsts().end(); | 829 auto End = Node->getInsts().end(); |
830 while (Current != End) { | 830 while (Current != End) { |
831 CfgUnorderedMap<Constant *, CfgVector<Inst *>> FloatUses; | 831 CfgUnorderedMap<Constant *, CfgVector<InstList::iterator>> FloatUses; |
832 if (llvm::isa<InstCall>(iteratorToInst(Current))) { | 832 if (llvm::isa<InstCall>(iteratorToInst(Current))) { |
833 ++Current; | 833 ++Current; |
834 assert(Current != End); | 834 assert(Current != End); |
835 // Block should not end with a call | 835 // Block should not end with a call |
836 } | 836 } |
837 while (Current != End && !llvm::isa<InstCall>(iteratorToInst(Current))) { | 837 while (Current != End && !llvm::isa<InstCall>(iteratorToInst(Current))) { |
838 for (SizeT i = 0; i < Current->getSrcSize(); ++i) { | 838 for (SizeT i = 0; i < Current->getSrcSize(); ++i) { |
839 if (auto *Const = llvm::dyn_cast<Constant>(Current->getSrc(i))) { | 839 if (auto *Const = llvm::dyn_cast<Constant>(Current->getSrc(i))) { |
840 if (Const->getType() == IceType_f32 || | 840 if (Const->getType() == IceType_f32 || |
841 Const->getType() == IceType_f64) { | 841 Const->getType() == IceType_f64) { |
(...skipping 19 matching lines...) Expand all Loading... |
861 Insts.insert(Pair.second[0], Assign); | 861 Insts.insert(Pair.second[0], Assign); |
862 ConstCache[Pair.first] = NewVar; | 862 ConstCache[Pair.first] = NewVar; |
863 } | 863 } |
864 | 864 |
865 auto *NewVar = makeVariable(Pair.first->getType()); | 865 auto *NewVar = makeVariable(Pair.first->getType()); |
866 NewVar->setLinkedTo(ConstCache[Pair.first]); | 866 NewVar->setLinkedTo(ConstCache[Pair.first]); |
867 auto *Assign = | 867 auto *Assign = |
868 InstAssign::create(Node->getCfg(), NewVar, ConstCache[Pair.first]); | 868 InstAssign::create(Node->getCfg(), NewVar, ConstCache[Pair.first]); |
869 | 869 |
870 Insts.insert(Pair.second[0], Assign); | 870 Insts.insert(Pair.second[0], Assign); |
871 for (auto *InstUse : Pair.second) { | 871 for (auto InstUse : Pair.second) { |
872 for (SizeT i = 0; i < InstUse->getSrcSize(); ++i) { | 872 for (SizeT i = 0; i < InstUse->getSrcSize(); ++i) { |
873 if (auto *Const = llvm::dyn_cast<Constant>(InstUse->getSrc(i))) { | 873 if (auto *Const = llvm::dyn_cast<Constant>(InstUse->getSrc(i))) { |
874 if (Const == Pair.first) { | 874 if (Const == Pair.first) { |
875 InstUse->replaceSource(i, NewVar); | 875 InstUse->replaceSource(i, NewVar); |
876 } | 876 } |
877 } | 877 } |
878 } | 878 } |
879 } | 879 } |
880 } | 880 } |
881 } | 881 } |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 } | 1861 } |
1862 } | 1862 } |
1863 // Print each basic block | 1863 // Print each basic block |
1864 for (CfgNode *Node : Nodes) | 1864 for (CfgNode *Node : Nodes) |
1865 Node->dump(this); | 1865 Node->dump(this); |
1866 if (isVerbose(IceV_Instructions)) | 1866 if (isVerbose(IceV_Instructions)) |
1867 Str << "}\n"; | 1867 Str << "}\n"; |
1868 } | 1868 } |
1869 | 1869 |
1870 } // end of namespace Ice | 1870 } // end of namespace Ice |
OLD | NEW |