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 13 matching lines...) Expand all Loading... |
24 namespace Ice { | 24 namespace Ice { |
25 | 25 |
26 class Operand { | 26 class Operand { |
27 public: | 27 public: |
28 enum OperandKind { | 28 enum OperandKind { |
29 kConst_Base, | 29 kConst_Base, |
30 kConstInteger, | 30 kConstInteger, |
31 kConstFloat, | 31 kConstFloat, |
32 kConstDouble, | 32 kConstDouble, |
33 kConstRelocatable, | 33 kConstRelocatable, |
| 34 kConstUndef, |
34 kConst_Num, | 35 kConst_Num, |
35 kVariable, | 36 kVariable, |
36 // Target-specific operand classes use kTarget as the starting | 37 // Target-specific operand classes use kTarget as the starting |
37 // point for their Kind enum space. | 38 // point for their Kind enum space. |
38 kTarget | 39 kTarget |
39 }; | 40 }; |
40 OperandKind getKind() const { return Kind; } | 41 OperandKind getKind() const { return Kind; } |
41 Type getType() const { return Ty; } | 42 Type getType() const { return Ty; } |
42 | 43 |
43 // Every Operand keeps an array of the Variables referenced in | 44 // Every Operand keeps an array of the Variables referenced in |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 Name(Name), SuppressMangling(SuppressMangling) {} | 200 Name(Name), SuppressMangling(SuppressMangling) {} |
200 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; | 201 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; |
201 ConstantRelocatable & | 202 ConstantRelocatable & |
202 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; | 203 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; |
203 virtual ~ConstantRelocatable() {} | 204 virtual ~ConstantRelocatable() {} |
204 const int64_t Offset; // fixed offset to add | 205 const int64_t Offset; // fixed offset to add |
205 const IceString Name; // optional for debug/dump | 206 const IceString Name; // optional for debug/dump |
206 bool SuppressMangling; | 207 bool SuppressMangling; |
207 }; | 208 }; |
208 | 209 |
| 210 // ConstantUndef represents an unspecified bit pattern. Although it is |
| 211 // legal to lower ConstantUndef to any value, backends should try to |
| 212 // make code generation deterministic by lowering ConstantUndefs to 0. |
| 213 class ConstantUndef : public Constant { |
| 214 public: |
| 215 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, |
| 216 uint32_t PoolEntryID) { |
| 217 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); |
| 218 } |
| 219 |
| 220 using Constant::emit; |
| 221 virtual void emit(GlobalContext *Ctx) const { |
| 222 Ostream &Str = Ctx->getStrEmit(); |
| 223 Str << "undef"; |
| 224 } |
| 225 |
| 226 using Constant::dump; |
| 227 virtual void dump(GlobalContext *Ctx) const { |
| 228 Ostream &Str = Ctx->getStrEmit(); |
| 229 Str << "undef"; |
| 230 } |
| 231 |
| 232 static bool classof(const Operand *Operand) { |
| 233 return Operand->getKind() == kConstUndef; |
| 234 } |
| 235 |
| 236 private: |
| 237 ConstantUndef(Type Ty, uint32_t PoolEntryID) |
| 238 : Constant(kConstUndef, Ty, PoolEntryID) {} |
| 239 ConstantUndef(const ConstantUndef &) LLVM_DELETED_FUNCTION; |
| 240 ConstantUndef &operator=(const ConstantUndef &) LLVM_DELETED_FUNCTION; |
| 241 virtual ~ConstantUndef() {} |
| 242 }; |
| 243 |
209 // RegWeight is a wrapper for a uint32_t weight value, with a | 244 // RegWeight is a wrapper for a uint32_t weight value, with a |
210 // special value that represents infinite weight, and an addWeight() | 245 // special value that represents infinite weight, and an addWeight() |
211 // method that ensures that W+infinity=infinity. | 246 // method that ensures that W+infinity=infinity. |
212 class RegWeight { | 247 class RegWeight { |
213 public: | 248 public: |
214 RegWeight() : Weight(0) {} | 249 RegWeight() : Weight(0) {} |
215 RegWeight(uint32_t Weight) : Weight(Weight) {} | 250 RegWeight(uint32_t Weight) : Weight(Weight) {} |
216 const static uint32_t Inf = ~0; // Force regalloc to give a register | 251 const static uint32_t Inf = ~0; // Force regalloc to give a register |
217 const static uint32_t Zero = 0; // Force regalloc NOT to give a register | 252 const static uint32_t Zero = 0; // Force regalloc NOT to give a register |
218 void addWeight(uint32_t Delta) { | 253 void addWeight(uint32_t Delta) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 Variable *LoVar; | 464 Variable *LoVar; |
430 Variable *HiVar; | 465 Variable *HiVar; |
431 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 466 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
432 // this. | 467 // this. |
433 Variable *VarsReal[1]; | 468 Variable *VarsReal[1]; |
434 }; | 469 }; |
435 | 470 |
436 } // end of namespace Ice | 471 } // end of namespace Ice |
437 | 472 |
438 #endif // SUBZERO_SRC_ICEOPERAND_H | 473 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |