OLD | NEW |
1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// | 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// |
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 // This file declares the Inst class and its target-independent | 10 // This file declares the Inst class and its target-independent |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 FakeDef, // not part of LLVM/PNaCl bitcode | 59 FakeDef, // not part of LLVM/PNaCl bitcode |
60 FakeUse, // not part of LLVM/PNaCl bitcode | 60 FakeUse, // not part of LLVM/PNaCl bitcode |
61 FakeKill, // not part of LLVM/PNaCl bitcode | 61 FakeKill, // not part of LLVM/PNaCl bitcode |
62 Target // target-specific low-level ICE | 62 Target // target-specific low-level ICE |
63 // Anything >= Target is an InstTarget subclass. | 63 // Anything >= Target is an InstTarget subclass. |
64 }; | 64 }; |
65 InstKind getKind() const { return Kind; } | 65 InstKind getKind() const { return Kind; } |
66 | 66 |
67 InstNumberT getNumber() const { return Number; } | 67 InstNumberT getNumber() const { return Number; } |
68 void renumber(Cfg *Func); | 68 void renumber(Cfg *Func); |
69 static const InstNumberT NumberDeleted = -1; | 69 enum { |
70 static const InstNumberT NumberSentinel = 0; | 70 NumberDeleted = -1, |
| 71 NumberSentinel = 0 |
| 72 }; |
71 | 73 |
72 bool isDeleted() const { return Deleted; } | 74 bool isDeleted() const { return Deleted; } |
73 void setDeleted() { Deleted = true; } | 75 void setDeleted() { Deleted = true; } |
74 void deleteIfDead(); | 76 void deleteIfDead(); |
75 | 77 |
76 bool hasSideEffects() const { return HasSideEffects; } | 78 bool hasSideEffects() const { return HasSideEffects; } |
77 | 79 |
| 80 bool isDestNonKillable() const { return IsDestNonKillable; } |
| 81 void setDestNonKillable() { IsDestNonKillable = true; } |
| 82 |
78 Variable *getDest() const { return Dest; } | 83 Variable *getDest() const { return Dest; } |
79 | 84 |
80 SizeT getSrcSize() const { return NumSrcs; } | 85 SizeT getSrcSize() const { return NumSrcs; } |
81 Operand *getSrc(SizeT I) const { | 86 Operand *getSrc(SizeT I) const { |
82 assert(I < getSrcSize()); | 87 assert(I < getSrcSize()); |
83 return Srcs[I]; | 88 return Srcs[I]; |
84 } | 89 } |
85 | 90 |
86 bool isLastUse(const Operand *Src) const; | 91 bool isLastUse(const Operand *Src) const; |
87 | 92 |
88 // Returns a list of out-edges corresponding to a terminator | 93 // Returns a list of out-edges corresponding to a terminator |
89 // instruction, which is the last instruction of the block. | 94 // instruction, which is the last instruction of the block. |
90 virtual NodeList getTerminatorEdges() const { | 95 virtual NodeList getTerminatorEdges() const { |
91 // All valid terminator instructions override this method. For | 96 // All valid terminator instructions override this method. For |
92 // the default implementation, we assert in case some CfgNode | 97 // the default implementation, we assert in case some CfgNode |
93 // is constructed without a terminator instruction at the end. | 98 // is constructed without a terminator instruction at the end. |
94 llvm_unreachable( | 99 llvm_unreachable( |
95 "getTerminatorEdges() called on a non-terminator instruction"); | 100 "getTerminatorEdges() called on a non-terminator instruction"); |
96 return NodeList(); | 101 return NodeList(); |
97 } | 102 } |
98 | 103 |
99 virtual bool isSimpleAssign() const { return false; } | 104 virtual bool isSimpleAssign() const { return false; } |
100 | 105 |
101 void livenessLightweight(Cfg *Func, llvm::BitVector &Live); | 106 void livenessLightweight(Cfg *Func, LivenessBV &Live); |
102 void liveness(InstNumberT InstNumber, llvm::BitVector &Live, | 107 void liveness(InstNumberT InstNumber, LivenessBV &Live, Liveness *Liveness, |
103 Liveness *Liveness, const CfgNode *Node); | 108 BeginEndMap *LiveBegin, BeginEndMap *LiveEnd); |
104 | 109 |
105 // Get the number of native instructions that this instruction | 110 // Get the number of native instructions that this instruction |
106 // ultimately emits. By default, high-level instructions don't | 111 // ultimately emits. By default, high-level instructions don't |
107 // result in any native instructions, and a target-specific | 112 // result in any native instructions, and a target-specific |
108 // instruction results in a single native instruction. | 113 // instruction results in a single native instruction. |
109 virtual uint32_t getEmitInstCount() const { return 0; } | 114 virtual uint32_t getEmitInstCount() const { return 0; } |
110 virtual void emit(const Cfg *Func) const = 0; | 115 virtual void emit(const Cfg *Func) const = 0; |
111 virtual void emitIAS(const Cfg *Func) const = 0; | 116 virtual void emitIAS(const Cfg *Func) const = 0; |
112 virtual void dump(const Cfg *Func) const; | 117 virtual void dump(const Cfg *Func) const; |
113 virtual void dumpExtras(const Cfg *Func) const; | 118 virtual void dumpExtras(const Cfg *Func) const; |
(...skipping 25 matching lines...) Expand all Loading... |
139 // Number is the instruction number for describing live ranges. | 144 // Number is the instruction number for describing live ranges. |
140 InstNumberT Number; | 145 InstNumberT Number; |
141 // Deleted means irrevocably deleted. | 146 // Deleted means irrevocably deleted. |
142 bool Deleted; | 147 bool Deleted; |
143 // Dead means pending deletion after liveness analysis converges. | 148 // Dead means pending deletion after liveness analysis converges. |
144 bool Dead; | 149 bool Dead; |
145 // HasSideEffects means the instruction is something like a function | 150 // HasSideEffects means the instruction is something like a function |
146 // call or a volatile load that can't be removed even if its Dest | 151 // call or a volatile load that can't be removed even if its Dest |
147 // variable is not live. | 152 // variable is not live. |
148 bool HasSideEffects; | 153 bool HasSideEffects; |
| 154 // IsDestNonKillable means that liveness analysis shouldn't consider |
| 155 // this instruction to kill the Dest variable. This is used when |
| 156 // lowering produces two assignments to the same variable. |
| 157 bool IsDestNonKillable; |
149 | 158 |
150 Variable *Dest; | 159 Variable *Dest; |
151 const SizeT MaxSrcs; // only used for assert | 160 const SizeT MaxSrcs; // only used for assert |
152 SizeT NumSrcs; | 161 SizeT NumSrcs; |
153 Operand **Srcs; | 162 Operand **Srcs; |
154 | 163 |
155 // LiveRangesEnded marks which Variables' live ranges end in this | 164 // LiveRangesEnded marks which Variables' live ranges end in this |
156 // instruction. An instruction can have an arbitrary number of | 165 // instruction. An instruction can have an arbitrary number of |
157 // source operands (e.g. a call instruction), and each source | 166 // source operands (e.g. a call instruction), and each source |
158 // operand can contain 0 or 1 Variable (and target-specific operands | 167 // operand can contain 0 or 1 Variable (and target-specific operands |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 536 |
528 // Phi instruction. For incoming edge I, the node is Labels[I] and | 537 // Phi instruction. For incoming edge I, the node is Labels[I] and |
529 // the Phi source operand is getSrc(I). | 538 // the Phi source operand is getSrc(I). |
530 class InstPhi : public InstHighLevel { | 539 class InstPhi : public InstHighLevel { |
531 public: | 540 public: |
532 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) { | 541 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) { |
533 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest); | 542 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest); |
534 } | 543 } |
535 void addArgument(Operand *Source, CfgNode *Label); | 544 void addArgument(Operand *Source, CfgNode *Label); |
536 Operand *getOperandForTarget(CfgNode *Target) const; | 545 Operand *getOperandForTarget(CfgNode *Target) const; |
537 void livenessPhiOperand(llvm::BitVector &Live, CfgNode *Target, | 546 void livenessPhiOperand(LivenessBV &Live, CfgNode *Target, |
538 Liveness *Liveness); | 547 Liveness *Liveness); |
539 Inst *lower(Cfg *Func); | 548 Inst *lower(Cfg *Func); |
540 void dump(const Cfg *Func) const override; | 549 void dump(const Cfg *Func) const override; |
541 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; } | 550 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; } |
542 | 551 |
543 private: | 552 private: |
544 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest); | 553 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest); |
545 InstPhi(const InstPhi &) = delete; | 554 InstPhi(const InstPhi &) = delete; |
546 InstPhi &operator=(const InstPhi &) = delete; | 555 InstPhi &operator=(const InstPhi &) = delete; |
547 void destroy(Cfg *Func) override { | 556 void destroy(Cfg *Func) override { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 : Inst(Func, Kind, MaxSrcs, Dest) { | 794 : Inst(Func, Kind, MaxSrcs, Dest) { |
786 assert(Kind >= Target); | 795 assert(Kind >= Target); |
787 } | 796 } |
788 void emitIAS(const Cfg *Func) const override { emit(Func); } | 797 void emitIAS(const Cfg *Func) const override { emit(Func); } |
789 ~InstTarget() override {} | 798 ~InstTarget() override {} |
790 }; | 799 }; |
791 | 800 |
792 } // end of namespace Ice | 801 } // end of namespace Ice |
793 | 802 |
794 #endif // SUBZERO_SRC_ICEINST_H | 803 #endif // SUBZERO_SRC_ICEINST_H |
OLD | NEW |