| 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 14 matching lines...) Expand all Loading... |
| 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 kConstUndef, |
| 35 kConstVector, |
| 36 kConstBitVector, |
| 35 kConst_Num, | 37 kConst_Num, |
| 36 kVariable, | 38 kVariable, |
| 37 // Target-specific operand classes use kTarget as the starting | 39 // Target-specific operand classes use kTarget as the starting |
| 38 // point for their Kind enum space. | 40 // point for their Kind enum space. |
| 39 kTarget | 41 kTarget |
| 40 }; | 42 }; |
| 41 OperandKind getKind() const { return Kind; } | 43 OperandKind getKind() const { return Kind; } |
| 42 Type getType() const { return Ty; } | 44 Type getType() const { return Ty; } |
| 43 | 45 |
| 44 // Every Operand keeps an array of the Variables referenced in | 46 // Every Operand keeps an array of the Variables referenced in |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // PoolEntryID is an integer that uniquely identifies the constant | 104 // PoolEntryID is an integer that uniquely identifies the constant |
| 103 // within its constant pool. It is used for building the constant | 105 // within its constant pool. It is used for building the constant |
| 104 // pool in the object code and for referencing its entries. | 106 // pool in the object code and for referencing its entries. |
| 105 const uint32_t PoolEntryID; | 107 const uint32_t PoolEntryID; |
| 106 | 108 |
| 107 private: | 109 private: |
| 108 Constant(const Constant &) LLVM_DELETED_FUNCTION; | 110 Constant(const Constant &) LLVM_DELETED_FUNCTION; |
| 109 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; | 111 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 // ConstantPrimitive<> wraps a primitive type. | 114 // ConstantValue<> wraps a concrete constant value. |
| 113 template <typename T, Operand::OperandKind K> | 115 template <typename T, Operand::OperandKind K> |
| 114 class ConstantPrimitive : public Constant { | 116 class ConstantValue : public Constant { |
| 115 public: | 117 public: |
| 116 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, | 118 static ConstantValue *create(GlobalContext *Ctx, Type Ty, T Value, |
| 117 uint32_t PoolEntryID) { | 119 uint32_t PoolEntryID) { |
| 118 return new (Ctx->allocate<ConstantPrimitive>()) | 120 return new (Ctx->allocate<ConstantValue>()) |
| 119 ConstantPrimitive(Ty, Value, PoolEntryID); | 121 ConstantValue(Ty, Value, PoolEntryID); |
| 120 } | 122 } |
| 121 T getValue() const { return Value; } | 123 T getValue() const { return Value; } |
| 124 |
| 122 using Constant::emit; | 125 using Constant::emit; |
| 123 virtual void emit(GlobalContext *Ctx) const { | 126 // The target needs to implement this for each ConstantValue |
| 124 Ostream &Str = Ctx->getStrEmit(); | 127 // specialization. |
| 125 Str << getValue(); | 128 virtual void emit(GlobalContext *Ctx) const; |
| 126 } | 129 |
| 127 using Constant::dump; | 130 using Constant::dump; |
| 128 virtual void dump(GlobalContext *Ctx) const { | 131 virtual void dump(GlobalContext *Ctx) const { |
| 129 Ostream &Str = Ctx->getStrDump(); | 132 Ostream &Str = Ctx->getStrDump(); |
| 130 Str << getValue(); | 133 Str << getValue(); |
| 131 } | 134 } |
| 132 | 135 |
| 133 static bool classof(const Operand *Operand) { | 136 static bool classof(const Operand *Operand) { |
| 134 return Operand->getKind() == K; | 137 return Operand->getKind() == K; |
| 135 } | 138 } |
| 136 | 139 |
| 137 private: | 140 private: |
| 138 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) | 141 ConstantValue(Type Ty, T Value, uint32_t PoolEntryID) |
| 139 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 142 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 140 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 143 ConstantValue(const ConstantValue &) LLVM_DELETED_FUNCTION; |
| 141 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 144 ConstantValue &operator=(const ConstantValue &) LLVM_DELETED_FUNCTION; |
| 142 virtual ~ConstantPrimitive() {} | 145 virtual ~ConstantValue() {} |
| 143 const T Value; | 146 const T Value; |
| 144 }; | 147 }; |
| 145 | 148 |
| 146 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; | 149 // Wrappers for primitive types |
| 147 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 150 typedef ConstantValue<uint64_t, Operand::kConstInteger> ConstantInteger; |
| 148 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 151 typedef ConstantValue<float, Operand::kConstFloat> ConstantFloat; |
| 152 typedef ConstantValue<double, Operand::kConstDouble> ConstantDouble; |
| 153 |
| 154 // ConstantVector wraps a 128 bit value. |
| 155 typedef ConstantValue<Vect128, Operand::kConstVector> ConstantVector; |
| 156 template <> void ConstantVector::dump(GlobalContext *Ctx) const; |
| 157 |
| 158 // ConstantBitVector wraps a vector of I1s. |
| 159 typedef ConstantValue<BitVect, Operand::kConstBitVector> ConstantBitVector; |
| 160 template <> void ConstantBitVector::dump(GlobalContext *Ctx) const; |
| 149 | 161 |
| 150 // RelocatableTuple bundles the parameters that are used to | 162 // RelocatableTuple bundles the parameters that are used to |
| 151 // construct an ConstantRelocatable. It is done this way so that | 163 // construct an ConstantRelocatable. It is done this way so that |
| 152 // ConstantRelocatable can fit into the global constant pool | 164 // ConstantRelocatable can fit into the global constant pool |
| 153 // template mechanism. | 165 // template mechanism. |
| 154 class RelocatableTuple { | 166 class RelocatableTuple { |
| 155 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; | 167 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; |
| 156 | 168 |
| 157 public: | 169 public: |
| 158 RelocatableTuple(const int64_t Offset, const IceString &Name, | 170 RelocatableTuple(const int64_t Offset, const IceString &Name, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 Variable *LoVar; | 476 Variable *LoVar; |
| 465 Variable *HiVar; | 477 Variable *HiVar; |
| 466 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 478 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 467 // this. | 479 // this. |
| 468 Variable *VarsReal[1]; | 480 Variable *VarsReal[1]; |
| 469 }; | 481 }; |
| 470 | 482 |
| 471 } // end of namespace Ice | 483 } // end of namespace Ice |
| 472 | 484 |
| 473 #endif // SUBZERO_SRC_ICEOPERAND_H | 485 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |