Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: src/IceOperand.h

Issue 656123003: Subzero: Class definition cleanup. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===// 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- 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 Operand class and its target-independent 10 // This file declares the Operand class and its target-independent
11 // subclasses. The main classes are Variable, which represents an 11 // subclasses. The main classes are Variable, which represents an
12 // LLVM variable that is either register- or stack-allocated, and the 12 // LLVM variable that is either register- or stack-allocated, and the
13 // Constant hierarchy, which represents integer, floating-point, 13 // Constant hierarchy, which represents integer, floating-point,
14 // and/or symbolic constants. 14 // and/or symbolic constants.
15 // 15 //
16 //===----------------------------------------------------------------------===// 16 //===----------------------------------------------------------------------===//
17 17
18 #ifndef SUBZERO_SRC_ICEOPERAND_H 18 #ifndef SUBZERO_SRC_ICEOPERAND_H
19 #define SUBZERO_SRC_ICEOPERAND_H 19 #define SUBZERO_SRC_ICEOPERAND_H
20 20
21 #include "IceCfg.h" 21 #include "IceCfg.h"
22 #include "IceDefs.h" 22 #include "IceDefs.h"
23 #include "IceGlobalContext.h" 23 #include "IceGlobalContext.h"
24 #include "IceTypes.h" 24 #include "IceTypes.h"
25 25
26 namespace Ice { 26 namespace Ice {
27 27
28 class Operand { 28 class Operand {
29 Operand(const Operand &) = delete;
30 Operand &operator=(const Operand &) = delete;
31
29 public: 32 public:
30 static const size_t MaxTargetKinds = 10; 33 static const size_t MaxTargetKinds = 10;
31 enum OperandKind { 34 enum OperandKind {
32 kConst_Base, 35 kConst_Base,
33 kConstInteger32, 36 kConstInteger32,
34 kConstInteger64, 37 kConstInteger64,
35 kConstFloat, 38 kConstFloat,
36 kConstDouble, 39 kConstDouble,
37 kConstRelocatable, 40 kConstRelocatable,
38 kConstUndef, 41 kConstUndef,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 protected: 82 protected:
80 Operand(OperandKind Kind, Type Ty) 83 Operand(OperandKind Kind, Type Ty)
81 : Ty(Ty), Kind(Kind), NumVars(0), Vars(NULL) {} 84 : Ty(Ty), Kind(Kind), NumVars(0), Vars(NULL) {}
82 Operand(Operand &&O) = default; 85 Operand(Operand &&O) = default;
83 86
84 const Type Ty; 87 const Type Ty;
85 const OperandKind Kind; 88 const OperandKind Kind;
86 // Vars and NumVars are initialized by the derived class. 89 // Vars and NumVars are initialized by the derived class.
87 SizeT NumVars; 90 SizeT NumVars;
88 Variable **Vars; 91 Variable **Vars;
89
90 private:
91 Operand(const Operand &) = delete;
92 Operand &operator=(const Operand &) = delete;
93 }; 92 };
94 93
95 template<class StreamType> 94 template<class StreamType>
96 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { 95 inline StreamType &operator<<(StreamType &Str, const Operand &Op) {
97 Op.dump(Str); 96 Op.dump(Str);
98 return Str; 97 return Str;
99 } 98 }
100 99
101 // Constant is the abstract base class for constants. All 100 // Constant is the abstract base class for constants. All
102 // constants are allocated from a global arena and are pooled. 101 // constants are allocated from a global arena and are pooled.
103 class Constant : public Operand { 102 class Constant : public Operand {
103 Constant(const Constant &) = delete;
104 Constant &operator=(const Constant &) = delete;
105
104 public: 106 public:
105 uint32_t getPoolEntryID() const { return PoolEntryID; } 107 uint32_t getPoolEntryID() const { return PoolEntryID; }
106 using Operand::dump; 108 using Operand::dump;
107 void emit(const Cfg *Func) const override { emit(Func->getContext()); } 109 void emit(const Cfg *Func) const override { emit(Func->getContext()); }
108 virtual void emit(GlobalContext *Ctx) const = 0; 110 virtual void emit(GlobalContext *Ctx) const = 0;
109 void dump(const Cfg *Func, Ostream &Str) const = 0; 111 void dump(const Cfg *Func, Ostream &Str) const = 0;
110 112
111 static bool classof(const Operand *Operand) { 113 static bool classof(const Operand *Operand) {
112 OperandKind Kind = Operand->getKind(); 114 OperandKind Kind = Operand->getKind();
113 return Kind >= kConst_Base && Kind <= kConst_Num; 115 return Kind >= kConst_Base && Kind <= kConst_Num;
114 } 116 }
115 117
116 protected: 118 protected:
117 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) 119 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID)
118 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { 120 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) {
119 Vars = NULL; 121 Vars = NULL;
120 NumVars = 0; 122 NumVars = 0;
121 } 123 }
122 ~Constant() override {} 124 ~Constant() override {}
123 // PoolEntryID is an integer that uniquely identifies the constant 125 // PoolEntryID is an integer that uniquely identifies the constant
124 // within its constant pool. It is used for building the constant 126 // within its constant pool. It is used for building the constant
125 // pool in the object code and for referencing its entries. 127 // pool in the object code and for referencing its entries.
126 const uint32_t PoolEntryID; 128 const uint32_t PoolEntryID;
127
128 private:
129 Constant(const Constant &) = delete;
130 Constant &operator=(const Constant &) = delete;
131 }; 129 };
132 130
133 // ConstantPrimitive<> wraps a primitive type. 131 // ConstantPrimitive<> wraps a primitive type.
134 template <typename T, Operand::OperandKind K> 132 template <typename T, Operand::OperandKind K>
135 class ConstantPrimitive : public Constant { 133 class ConstantPrimitive : public Constant {
134 ConstantPrimitive(const ConstantPrimitive &) = delete;
135 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete;
136
136 public: 137 public:
137 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, 138 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value,
138 uint32_t PoolEntryID) { 139 uint32_t PoolEntryID) {
139 return new (Ctx->allocate<ConstantPrimitive>()) 140 return new (Ctx->allocate<ConstantPrimitive>())
140 ConstantPrimitive(Ty, Value, PoolEntryID); 141 ConstantPrimitive(Ty, Value, PoolEntryID);
141 } 142 }
142 T getValue() const { return Value; } 143 T getValue() const { return Value; }
143 using Constant::emit; 144 using Constant::emit;
144 // The target needs to implement this for each ConstantPrimitive 145 // The target needs to implement this for each ConstantPrimitive
145 // specialization. 146 // specialization.
146 void emit(GlobalContext *Ctx) const override; 147 void emit(GlobalContext *Ctx) const override;
147 using Constant::dump; 148 using Constant::dump;
148 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); } 149 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); }
149 150
150 static bool classof(const Operand *Operand) { 151 static bool classof(const Operand *Operand) {
151 return Operand->getKind() == K; 152 return Operand->getKind() == K;
152 } 153 }
153 154
154 private: 155 private:
155 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) 156 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID)
156 : Constant(K, Ty, PoolEntryID), Value(Value) {} 157 : Constant(K, Ty, PoolEntryID), Value(Value) {}
157 ConstantPrimitive(const ConstantPrimitive &) = delete;
158 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete;
159 ~ConstantPrimitive() override {} 158 ~ConstantPrimitive() override {}
160 const T Value; 159 const T Value;
161 }; 160 };
162 161
163 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; 162 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32;
164 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; 163 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64;
165 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; 164 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
166 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; 165 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
167 166
168 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { 167 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
169 if (getType() == IceType_i1) 168 if (getType() == IceType_i1)
170 Str << (getValue() ? "true" : "false"); 169 Str << (getValue() ? "true" : "false");
171 else 170 else
172 Str << static_cast<int32_t>(getValue()); 171 Str << static_cast<int32_t>(getValue());
173 } 172 }
174 173
175 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { 174 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
176 assert(getType() == IceType_i64); 175 assert(getType() == IceType_i64);
177 Str << static_cast<int64_t>(getValue()); 176 Str << static_cast<int64_t>(getValue());
178 } 177 }
179 178
180 // RelocatableTuple bundles the parameters that are used to 179 // RelocatableTuple bundles the parameters that are used to
181 // construct an ConstantRelocatable. It is done this way so that 180 // construct an ConstantRelocatable. It is done this way so that
182 // ConstantRelocatable can fit into the global constant pool 181 // ConstantRelocatable can fit into the global constant pool
183 // template mechanism. 182 // template mechanism.
184 class RelocatableTuple { 183 class RelocatableTuple {
185 RelocatableTuple &operator=(const RelocatableTuple &) = delete; 184 RelocatableTuple &operator=(const RelocatableTuple &) = delete;
Karl 2014/10/15 19:59:12 What about the default constructor (or at least a
Jim Stichnoth 2014/10/15 20:23:43 It is actually explicitly defined in the public: s
186 185
187 public: 186 public:
188 RelocatableTuple(const RelocOffsetT Offset, const IceString &Name, 187 RelocatableTuple(const RelocOffsetT Offset, const IceString &Name,
189 bool SuppressMangling) 188 bool SuppressMangling)
190 : Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {} 189 : Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {}
191 RelocatableTuple(const RelocatableTuple &Other) 190 RelocatableTuple(const RelocatableTuple &Other)
192 : Offset(Other.Offset), Name(Other.Name), 191 : Offset(Other.Offset), Name(Other.Name),
193 SuppressMangling(Other.SuppressMangling) {} 192 SuppressMangling(Other.SuppressMangling) {}
194 193
195 const RelocOffsetT Offset; 194 const RelocOffsetT Offset;
196 const IceString Name; 195 const IceString Name;
197 bool SuppressMangling; 196 bool SuppressMangling;
198 }; 197 };
199 198
200 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B); 199 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B);
201 200
202 // ConstantRelocatable represents a symbolic constant combined with 201 // ConstantRelocatable represents a symbolic constant combined with
203 // a fixed offset. 202 // a fixed offset.
204 class ConstantRelocatable : public Constant { 203 class ConstantRelocatable : public Constant {
204 ConstantRelocatable(const ConstantRelocatable &) = delete;
205 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete;
206
205 public: 207 public:
206 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, 208 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty,
207 const RelocatableTuple &Tuple, 209 const RelocatableTuple &Tuple,
208 uint32_t PoolEntryID) { 210 uint32_t PoolEntryID) {
209 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( 211 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable(
210 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); 212 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID);
211 } 213 }
212 214
213 RelocOffsetT getOffset() const { return Offset; } 215 RelocOffsetT getOffset() const { return Offset; }
214 IceString getName() const { return Name; } 216 IceString getName() const { return Name; }
215 void setSuppressMangling(bool Value) { SuppressMangling = Value; } 217 void setSuppressMangling(bool Value) { SuppressMangling = Value; }
216 bool getSuppressMangling() const { return SuppressMangling; } 218 bool getSuppressMangling() const { return SuppressMangling; }
217 using Constant::emit; 219 using Constant::emit;
218 using Constant::dump; 220 using Constant::dump;
219 void emit(GlobalContext *Ctx) const override; 221 void emit(GlobalContext *Ctx) const override;
220 void dump(const Cfg *Func, Ostream &Str) const override; 222 void dump(const Cfg *Func, Ostream &Str) const override;
221 223
222 static bool classof(const Operand *Operand) { 224 static bool classof(const Operand *Operand) {
223 OperandKind Kind = Operand->getKind(); 225 OperandKind Kind = Operand->getKind();
224 return Kind == kConstRelocatable; 226 return Kind == kConstRelocatable;
225 } 227 }
226 228
227 private: 229 private:
228 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, 230 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name,
229 bool SuppressMangling, uint32_t PoolEntryID) 231 bool SuppressMangling, uint32_t PoolEntryID)
230 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), 232 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset),
231 Name(Name), SuppressMangling(SuppressMangling) {} 233 Name(Name), SuppressMangling(SuppressMangling) {}
232 ConstantRelocatable(const ConstantRelocatable &) = delete;
233 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete;
234 ~ConstantRelocatable() override {} 234 ~ConstantRelocatable() override {}
235 const RelocOffsetT Offset; // fixed offset to add 235 const RelocOffsetT Offset; // fixed offset to add
236 const IceString Name; // optional for debug/dump 236 const IceString Name; // optional for debug/dump
237 bool SuppressMangling; 237 bool SuppressMangling;
238 }; 238 };
239 239
240 // ConstantUndef represents an unspecified bit pattern. Although it is 240 // ConstantUndef represents an unspecified bit pattern. Although it is
241 // legal to lower ConstantUndef to any value, backends should try to 241 // legal to lower ConstantUndef to any value, backends should try to
242 // make code generation deterministic by lowering ConstantUndefs to 0. 242 // make code generation deterministic by lowering ConstantUndefs to 0.
243 class ConstantUndef : public Constant { 243 class ConstantUndef : public Constant {
244 ConstantUndef(const ConstantUndef &) = delete;
245 ConstantUndef &operator=(const ConstantUndef &) = delete;
246
244 public: 247 public:
245 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, 248 static ConstantUndef *create(GlobalContext *Ctx, Type Ty,
246 uint32_t PoolEntryID) { 249 uint32_t PoolEntryID) {
247 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); 250 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID);
248 } 251 }
249 252
250 using Constant::emit; 253 using Constant::emit;
251 using Constant::dump; 254 using Constant::dump;
252 // The target needs to implement this. 255 // The target needs to implement this.
253 void emit(GlobalContext *Ctx) const override; 256 void emit(GlobalContext *Ctx) const override;
254 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; } 257 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; }
255 258
256 static bool classof(const Operand *Operand) { 259 static bool classof(const Operand *Operand) {
257 return Operand->getKind() == kConstUndef; 260 return Operand->getKind() == kConstUndef;
258 } 261 }
259 262
260 private: 263 private:
261 ConstantUndef(Type Ty, uint32_t PoolEntryID) 264 ConstantUndef(Type Ty, uint32_t PoolEntryID)
262 : Constant(kConstUndef, Ty, PoolEntryID) {} 265 : Constant(kConstUndef, Ty, PoolEntryID) {}
263 ConstantUndef(const ConstantUndef &) = delete;
264 ConstantUndef &operator=(const ConstantUndef &) = delete;
265 ~ConstantUndef() override {} 266 ~ConstantUndef() override {}
266 }; 267 };
267 268
268 // RegWeight is a wrapper for a uint32_t weight value, with a 269 // RegWeight is a wrapper for a uint32_t weight value, with a
269 // special value that represents infinite weight, and an addWeight() 270 // special value that represents infinite weight, and an addWeight()
270 // method that ensures that W+infinity=infinity. 271 // method that ensures that W+infinity=infinity.
271 class RegWeight { 272 class RegWeight {
273 // RegWeight(const RegWeight &) = delete;
274 // RegWeight &operator=(const RegWeight &) = delete;
275
272 public: 276 public:
273 RegWeight() : Weight(0) {} 277 RegWeight() : Weight(0) {}
274 RegWeight(uint32_t Weight) : Weight(Weight) {} 278 RegWeight(uint32_t Weight) : Weight(Weight) {}
275 const static uint32_t Inf = ~0; // Force regalloc to give a register 279 const static uint32_t Inf = ~0; // Force regalloc to give a register
276 const static uint32_t Zero = 0; // Force regalloc NOT to give a register 280 const static uint32_t Zero = 0; // Force regalloc NOT to give a register
277 void addWeight(uint32_t Delta) { 281 void addWeight(uint32_t Delta) {
278 if (Delta == Inf) 282 if (Delta == Inf)
279 Weight = Inf; 283 Weight = Inf;
280 else if (Weight != Inf) 284 else if (Weight != Inf)
281 Weight += Delta; 285 Weight += Delta;
(...skipping 11 matching lines...) Expand all
293 bool operator<=(const RegWeight &A, const RegWeight &B); 297 bool operator<=(const RegWeight &A, const RegWeight &B);
294 bool operator==(const RegWeight &A, const RegWeight &B); 298 bool operator==(const RegWeight &A, const RegWeight &B);
295 299
296 // LiveRange is a set of instruction number intervals representing 300 // LiveRange is a set of instruction number intervals representing
297 // a variable's live range. Generally there is one interval per basic 301 // a variable's live range. Generally there is one interval per basic
298 // block where the variable is live, but adjacent intervals get 302 // block where the variable is live, but adjacent intervals get
299 // coalesced into a single interval. LiveRange also includes a 303 // coalesced into a single interval. LiveRange also includes a
300 // weight, in case e.g. we want a live range to have higher weight 304 // weight, in case e.g. we want a live range to have higher weight
301 // inside a loop. 305 // inside a loop.
302 class LiveRange { 306 class LiveRange {
307 // LiveRange(const LiveRange &) = delete;
308 // LiveRange &operator=(const LiveRange &) = delete;
309
303 public: 310 public:
304 LiveRange() : Weight(0), IsNonpoints(false) {} 311 LiveRange() : Weight(0), IsNonpoints(false) {}
305 312
306 void reset() { 313 void reset() {
307 Range.clear(); 314 Range.clear();
308 Weight.setWeight(0); 315 Weight.setWeight(0);
309 untrim(); 316 untrim();
310 IsNonpoints = false; 317 IsNonpoints = false;
311 } 318 }
312 void addSegment(InstNumberT Start, InstNumberT End); 319 void addSegment(InstNumberT Start, InstNumberT End);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // VarsReal (and Operand::Vars) are set up such that Vars[0] == 516 // VarsReal (and Operand::Vars) are set up such that Vars[0] ==
510 // this. 517 // this.
511 Variable *VarsReal[1]; 518 Variable *VarsReal[1];
512 }; 519 };
513 520
514 typedef std::vector<const Inst *> InstDefList; 521 typedef std::vector<const Inst *> InstDefList;
515 522
516 // VariableTracking tracks the metadata for a single variable. It is 523 // VariableTracking tracks the metadata for a single variable. It is
517 // only meant to be used internally by VariablesMetadata. 524 // only meant to be used internally by VariablesMetadata.
518 class VariableTracking { 525 class VariableTracking {
526 // VariableTracking(const VariableTracking &) = delete;
527 VariableTracking &operator=(const VariableTracking &) = delete;
528
519 public: 529 public:
520 enum MultiDefState { 530 enum MultiDefState {
521 // TODO(stichnot): Consider using just a simple counter. 531 // TODO(stichnot): Consider using just a simple counter.
522 MDS_Unknown, 532 MDS_Unknown,
523 MDS_SingleDef, 533 MDS_SingleDef,
524 MDS_MultiDefSingleBlock, 534 MDS_MultiDefSingleBlock,
525 MDS_MultiDefMultiBlock 535 MDS_MultiDefMultiBlock
526 }; 536 };
527 enum MultiBlockState { 537 enum MultiBlockState {
528 MBS_Unknown, 538 MBS_Unknown,
529 MBS_SingleBlock, 539 MBS_SingleBlock,
530 MBS_MultiBlock 540 MBS_MultiBlock
531 }; 541 };
532 VariableTracking() 542 VariableTracking()
533 : MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(NULL), 543 : MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(NULL),
534 SingleDefNode(NULL) {} 544 SingleDefNode(NULL) {}
535 MultiDefState getMultiDef() const { return MultiDef; } 545 MultiDefState getMultiDef() const { return MultiDef; }
536 MultiBlockState getMultiBlock() const { return MultiBlock; } 546 MultiBlockState getMultiBlock() const { return MultiBlock; }
537 const Inst *getFirstDefinition() const; 547 const Inst *getFirstDefinition() const;
538 const Inst *getSingleDefinition() const; 548 const Inst *getSingleDefinition() const;
539 const InstDefList &getDefinitions() const { return Definitions; } 549 const InstDefList &getDefinitions() const { return Definitions; }
540 const CfgNode *getNode() const { return SingleUseNode; } 550 const CfgNode *getNode() const { return SingleUseNode; }
541 void markUse(const Inst *Instr, const CfgNode *Node, bool IsFromDef, 551 void markUse(const Inst *Instr, const CfgNode *Node, bool IsFromDef,
542 bool IsImplicit); 552 bool IsImplicit);
543 void markDef(const Inst *Instr, const CfgNode *Node); 553 void markDef(const Inst *Instr, const CfgNode *Node);
544 554
545 private: 555 private:
546 VariableTracking &operator=(const VariableTracking &) = delete;
547 MultiDefState MultiDef; 556 MultiDefState MultiDef;
548 MultiBlockState MultiBlock; 557 MultiBlockState MultiBlock;
549 const CfgNode *SingleUseNode; 558 const CfgNode *SingleUseNode;
550 const CfgNode *SingleDefNode; 559 const CfgNode *SingleDefNode;
551 // All definitions of the variable are collected here, in increasing 560 // All definitions of the variable are collected here, in increasing
552 // order of instruction number. 561 // order of instruction number.
553 InstDefList Definitions; 562 InstDefList Definitions;
554 }; 563 };
555 564
556 // VariablesMetadata analyzes and summarizes the metadata for the 565 // VariablesMetadata analyzes and summarizes the metadata for the
557 // complete set of Variables. 566 // complete set of Variables.
558 class VariablesMetadata { 567 class VariablesMetadata {
568 VariablesMetadata(const VariablesMetadata &) = delete;
569 VariablesMetadata &operator=(const VariablesMetadata &) = delete;
570
559 public: 571 public:
560 VariablesMetadata(const Cfg *Func) : Func(Func) {} 572 VariablesMetadata(const Cfg *Func) : Func(Func) {}
561 // Initialize the state by traversing all instructions/variables in 573 // Initialize the state by traversing all instructions/variables in
562 // the CFG. 574 // the CFG.
563 void init(); 575 void init();
564 // Returns whether the given Variable is tracked in this object. It 576 // Returns whether the given Variable is tracked in this object. It
565 // should only return false if changes were made to the CFG after 577 // should only return false if changes were made to the CFG after
566 // running init(), in which case the state is stale and the results 578 // running init(), in which case the state is stale and the results
567 // shouldn't be trusted (but it may be OK e.g. for dumping). 579 // shouldn't be trusted (but it may be OK e.g. for dumping).
568 bool isTracked(const Variable *Var) const { 580 bool isTracked(const Variable *Var) const {
(...skipping 26 matching lines...) Expand all
595 // entry block. 607 // entry block.
596 bool isMultiBlock(const Variable *Var) const; 608 bool isMultiBlock(const Variable *Var) const;
597 // Returns the node that the given Variable is used in, assuming 609 // Returns the node that the given Variable is used in, assuming
598 // isMultiBlock() returns false. Otherwise, NULL is returned. 610 // isMultiBlock() returns false. Otherwise, NULL is returned.
599 const CfgNode *getLocalUseNode(const Variable *Var) const; 611 const CfgNode *getLocalUseNode(const Variable *Var) const;
600 612
601 private: 613 private:
602 const Cfg *Func; 614 const Cfg *Func;
603 std::vector<VariableTracking> Metadata; 615 std::vector<VariableTracking> Metadata;
604 const static InstDefList NoDefinitions; 616 const static InstDefList NoDefinitions;
605 VariablesMetadata(const VariablesMetadata &) = delete;
606 VariablesMetadata &operator=(const VariablesMetadata &) = delete;
607 }; 617 };
608 618
609 } // end of namespace Ice 619 } // end of namespace Ice
610 620
611 #endif // SUBZERO_SRC_ICEOPERAND_H 621 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« src/IceInstX8632.h ('K') | « src/IceLiveness.h ('k') | src/IceRNG.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698