OLD | NEW |
---|---|
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 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 | 130 |
131 // ConstantPrimitive<> wraps a primitive type. | 131 // ConstantPrimitive<> wraps a primitive type. |
132 template <typename T, Operand::OperandKind K> | 132 template <typename T, Operand::OperandKind K> |
133 class ConstantPrimitive : public Constant { | 133 class ConstantPrimitive : public Constant { |
134 ConstantPrimitive(const ConstantPrimitive &) = delete; | 134 ConstantPrimitive(const ConstantPrimitive &) = delete; |
135 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete; | 135 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete; |
136 | 136 |
137 public: | 137 public: |
138 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, | 138 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, |
139 uint32_t PoolEntryID) { | 139 uint32_t PoolEntryID) { |
140 assert(!Ctx->getFlags().DisableIRGeneration && | |
141 "Attempt to build primitive constant when IR generation disabled"); | |
140 return new (Ctx->allocate<ConstantPrimitive>()) | 142 return new (Ctx->allocate<ConstantPrimitive>()) |
141 ConstantPrimitive(Ty, Value, PoolEntryID); | 143 ConstantPrimitive(Ty, Value, PoolEntryID); |
142 } | 144 } |
143 T getValue() const { return Value; } | 145 T getValue() const { return Value; } |
144 using Constant::emit; | 146 using Constant::emit; |
145 // The target needs to implement this for each ConstantPrimitive | 147 // The target needs to implement this for each ConstantPrimitive |
146 // specialization. | 148 // specialization. |
147 void emit(GlobalContext *Ctx) const override; | 149 void emit(GlobalContext *Ctx) const override; |
148 using Constant::dump; | 150 using Constant::dump; |
149 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); } | 151 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 // ConstantRelocatable represents a symbolic constant combined with | 201 // ConstantRelocatable represents a symbolic constant combined with |
200 // a fixed offset. | 202 // a fixed offset. |
201 class ConstantRelocatable : public Constant { | 203 class ConstantRelocatable : public Constant { |
202 ConstantRelocatable(const ConstantRelocatable &) = delete; | 204 ConstantRelocatable(const ConstantRelocatable &) = delete; |
203 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete; | 205 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete; |
204 | 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) { |
211 assert(!Ctx->getFlags().DisableIRGeneration && | |
212 "Attempt to build relocatable constant when IR generation disabled"); | |
209 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( | 213 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( |
210 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); | 214 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); |
211 } | 215 } |
212 | 216 |
213 RelocOffsetT getOffset() const { return Offset; } | 217 RelocOffsetT getOffset() const { return Offset; } |
214 IceString getName() const { return Name; } | 218 IceString getName() const { return Name; } |
215 void setSuppressMangling(bool Value) { SuppressMangling = Value; } | 219 void setSuppressMangling(bool Value) { SuppressMangling = Value; } |
216 bool getSuppressMangling() const { return SuppressMangling; } | 220 bool getSuppressMangling() const { return SuppressMangling; } |
217 using Constant::emit; | 221 using Constant::emit; |
218 using Constant::dump; | 222 using Constant::dump; |
(...skipping 20 matching lines...) Expand all Loading... | |
239 // ConstantUndef represents an unspecified bit pattern. Although it is | 243 // ConstantUndef represents an unspecified bit pattern. Although it is |
240 // legal to lower ConstantUndef to any value, backends should try to | 244 // legal to lower ConstantUndef to any value, backends should try to |
241 // make code generation deterministic by lowering ConstantUndefs to 0. | 245 // make code generation deterministic by lowering ConstantUndefs to 0. |
242 class ConstantUndef : public Constant { | 246 class ConstantUndef : public Constant { |
243 ConstantUndef(const ConstantUndef &) = delete; | 247 ConstantUndef(const ConstantUndef &) = delete; |
244 ConstantUndef &operator=(const ConstantUndef &) = delete; | 248 ConstantUndef &operator=(const ConstantUndef &) = delete; |
245 | 249 |
246 public: | 250 public: |
247 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, | 251 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, |
248 uint32_t PoolEntryID) { | 252 uint32_t PoolEntryID) { |
253 assert(!Ctx->getFlags().DisableIRGeneration && | |
254 "Attempt to build undefined constant when IR generation disabled"); | |
249 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); | 255 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); |
250 } | 256 } |
251 | 257 |
252 using Constant::emit; | 258 using Constant::emit; |
253 using Constant::dump; | 259 using Constant::dump; |
254 // The target needs to implement this. | 260 // The target needs to implement this. |
255 void emit(GlobalContext *Ctx) const override; | 261 void emit(GlobalContext *Ctx) const override; |
256 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; } | 262 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; } |
257 | 263 |
258 static bool classof(const Operand *Operand) { | 264 static bool classof(const Operand *Operand) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 // stack-allocated. If it is register-allocated, it will ultimately | 378 // stack-allocated. If it is register-allocated, it will ultimately |
373 // have a non-negative RegNum field. | 379 // have a non-negative RegNum field. |
374 class Variable : public Operand { | 380 class Variable : public Operand { |
375 Variable(const Variable &) = delete; | 381 Variable(const Variable &) = delete; |
376 Variable &operator=(const Variable &) = delete; | 382 Variable &operator=(const Variable &) = delete; |
377 Variable(Variable &&V) = default; | 383 Variable(Variable &&V) = default; |
378 | 384 |
379 public: | 385 public: |
380 static Variable *create(Cfg *Func, Type Ty, SizeT Index, | 386 static Variable *create(Cfg *Func, Type Ty, SizeT Index, |
381 const IceString &Name) { | 387 const IceString &Name) { |
382 return new (Func->allocate<Variable>()) | 388 return new (Func->allocate<Variable>()) |
jvoung (off chromium)
2014/11/04 22:30:15
Why not have Cfg's makeVariable() also assert?
Jim Stichnoth
2014/11/04 23:43:15
I think the assert in the Cfg ctor dominates this.
Karl
2014/11/05 21:13:33
Since makeVariable is a member function, and the C
| |
383 Variable(kVariable, Ty, Index, Name); | 389 Variable(kVariable, Ty, Index, Name); |
384 } | 390 } |
385 | 391 |
386 SizeT getIndex() const { return Number; } | 392 SizeT getIndex() const { return Number; } |
387 IceString getName() const; | 393 IceString getName() const; |
388 void setName(IceString &NewName) { | 394 void setName(IceString &NewName) { |
389 // Make sure that the name can only be set once. | 395 // Make sure that the name can only be set once. |
390 assert(Name.empty()); | 396 assert(Name.empty()); |
391 Name = NewName; | 397 Name = NewName; |
392 } | 398 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 private: | 633 private: |
628 const Cfg *Func; | 634 const Cfg *Func; |
629 MetadataKind Kind; | 635 MetadataKind Kind; |
630 std::vector<VariableTracking> Metadata; | 636 std::vector<VariableTracking> Metadata; |
631 const static InstDefList NoDefinitions; | 637 const static InstDefList NoDefinitions; |
632 }; | 638 }; |
633 | 639 |
634 } // end of namespace Ice | 640 } // end of namespace Ice |
635 | 641 |
636 #endif // SUBZERO_SRC_ICEOPERAND_H | 642 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |