OLD | NEW |
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// | 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering 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 28 matching lines...) Expand all Loading... |
39 End = getNode()->getInsts().end(); | 39 End = getNode()->getInsts().end(); |
40 rewind(); | 40 rewind(); |
41 advanceForward(Next); | 41 advanceForward(Next); |
42 } | 42 } |
43 | 43 |
44 void LoweringContext::rewind() { | 44 void LoweringContext::rewind() { |
45 Begin = getNode()->getInsts().begin(); | 45 Begin = getNode()->getInsts().begin(); |
46 Cur = Begin; | 46 Cur = Begin; |
47 skipDeleted(Cur); | 47 skipDeleted(Cur); |
48 Next = Cur; | 48 Next = Cur; |
| 49 availabilityReset(); |
49 } | 50 } |
50 | 51 |
51 void LoweringContext::insert(Inst *Inst) { | 52 void LoweringContext::insert(Inst *Inst) { |
52 getNode()->getInsts().insert(Next, Inst); | 53 getNode()->getInsts().insert(Next, Inst); |
53 LastInserted = Inst; | 54 LastInserted = Inst; |
54 } | 55 } |
55 | 56 |
56 void LoweringContext::skipDeleted(InstList::iterator &I) const { | 57 void LoweringContext::skipDeleted(InstList::iterator &I) const { |
57 while (I != End && I->isDeleted()) | 58 while (I != End && I->isDeleted()) |
58 ++I; | 59 ++I; |
59 } | 60 } |
60 | 61 |
61 void LoweringContext::advanceForward(InstList::iterator &I) const { | 62 void LoweringContext::advanceForward(InstList::iterator &I) const { |
62 if (I != End) { | 63 if (I != End) { |
63 ++I; | 64 ++I; |
64 skipDeleted(I); | 65 skipDeleted(I); |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 Inst *LoweringContext::getLastInserted() const { | 69 Inst *LoweringContext::getLastInserted() const { |
69 assert(LastInserted); | 70 assert(LastInserted); |
70 return LastInserted; | 71 return LastInserted; |
71 } | 72 } |
72 | 73 |
| 74 void LoweringContext::availabilityReset() { |
| 75 LastDest = nullptr; |
| 76 LastSrc = nullptr; |
| 77 } |
| 78 |
| 79 void LoweringContext::availabilityUpdate() { |
| 80 availabilityReset(); |
| 81 Inst *Instr = LastInserted; |
| 82 if (Instr == nullptr) |
| 83 return; |
| 84 if (!Instr->isSimpleAssign()) |
| 85 return; |
| 86 if (auto *SrcVar = llvm::dyn_cast<Variable>(Instr->getSrc(0))) { |
| 87 LastDest = Instr->getDest(); |
| 88 LastSrc = SrcVar; |
| 89 } |
| 90 } |
| 91 |
| 92 Variable *LoweringContext::availabilityGet(Operand *Src) const { |
| 93 assert(Src); |
| 94 if (Src == LastDest) |
| 95 return LastSrc; |
| 96 return nullptr; |
| 97 } |
| 98 |
73 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { | 99 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { |
74 #define SUBZERO_TARGET(X) \ | 100 #define SUBZERO_TARGET(X) \ |
75 if (Target == Target_##X) \ | 101 if (Target == Target_##X) \ |
76 return Target##X::create(Func); | 102 return Target##X::create(Func); |
77 #include "llvm/Config/SZTargets.def" | 103 #include "llvm/Config/SZTargets.def" |
78 | 104 |
79 Func->setError("Unsupported target"); | 105 Func->setError("Unsupported target"); |
80 return nullptr; | 106 return nullptr; |
81 } | 107 } |
82 | 108 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 if (Target == Target_##X) \ | 620 if (Target == Target_##X) \ |
595 return TargetHeader##X::create(Ctx); | 621 return TargetHeader##X::create(Ctx); |
596 #include "llvm/Config/SZTargets.def" | 622 #include "llvm/Config/SZTargets.def" |
597 | 623 |
598 llvm::report_fatal_error("Unsupported target header lowering"); | 624 llvm::report_fatal_error("Unsupported target header lowering"); |
599 } | 625 } |
600 | 626 |
601 TargetHeaderLowering::~TargetHeaderLowering() = default; | 627 TargetHeaderLowering::~TargetHeaderLowering() = default; |
602 | 628 |
603 } // end of namespace Ice | 629 } // end of namespace Ice |
OLD | NEW |