| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 Operand(const Operand &) LLVM_DELETED_FUNCTION; | 75 Operand(const Operand &) LLVM_DELETED_FUNCTION; |
| 76 Operand &operator=(const Operand &) LLVM_DELETED_FUNCTION; | 76 Operand &operator=(const Operand &) LLVM_DELETED_FUNCTION; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // Constant is the abstract base class for constants. All | 79 // Constant is the abstract base class for constants. All |
| 80 // constants are allocated from a global arena and are pooled. | 80 // constants are allocated from a global arena and are pooled. |
| 81 class Constant : public Operand { | 81 class Constant : public Operand { |
| 82 public: | 82 public: |
| 83 uint32_t getPoolEntryID() const { return PoolEntryID; } |
| 83 virtual void emit(const Cfg *Func) const = 0; | 84 virtual void emit(const Cfg *Func) const = 0; |
| 84 virtual void dump(const Cfg *Func) const = 0; | 85 virtual void dump(const Cfg *Func) const = 0; |
| 85 | 86 |
| 86 static bool classof(const Operand *Operand) { | 87 static bool classof(const Operand *Operand) { |
| 87 OperandKind Kind = Operand->getKind(); | 88 OperandKind Kind = Operand->getKind(); |
| 88 return Kind >= kConst_Base && Kind <= kConst_Num; | 89 return Kind >= kConst_Base && Kind <= kConst_Num; |
| 89 } | 90 } |
| 90 | 91 |
| 91 protected: | 92 protected: |
| 92 Constant(OperandKind Kind, Type Ty) : Operand(Kind, Ty) { | 93 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) |
| 94 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { |
| 93 Vars = NULL; | 95 Vars = NULL; |
| 94 NumVars = 0; | 96 NumVars = 0; |
| 95 } | 97 } |
| 96 virtual ~Constant() {} | 98 virtual ~Constant() {} |
| 99 // PoolEntryID is an integer that uniquely identifies the constant |
| 100 // within its constant pool. It is used for building the constant |
| 101 // pool in the object code and for referencing its entries. |
| 102 const uint32_t PoolEntryID; |
| 97 | 103 |
| 98 private: | 104 private: |
| 99 Constant(const Constant &) LLVM_DELETED_FUNCTION; | 105 Constant(const Constant &) LLVM_DELETED_FUNCTION; |
| 100 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; | 106 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 // ConstantPrimitive<> wraps a primitive type. | 109 // ConstantPrimitive<> wraps a primitive type. |
| 104 template <typename T, Operand::OperandKind K> | 110 template <typename T, Operand::OperandKind K> |
| 105 class ConstantPrimitive : public Constant { | 111 class ConstantPrimitive : public Constant { |
| 106 public: | 112 public: |
| 107 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value) { | 113 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, |
| 114 uint32_t PoolEntryID) { |
| 108 return new (Ctx->allocate<ConstantPrimitive>()) | 115 return new (Ctx->allocate<ConstantPrimitive>()) |
| 109 ConstantPrimitive(Ty, Value); | 116 ConstantPrimitive(Ty, Value, PoolEntryID); |
| 110 } | 117 } |
| 111 T getValue() const { return Value; } | 118 T getValue() const { return Value; } |
| 112 virtual void emit(const Cfg *Func) const { | 119 virtual void emit(const Cfg *Func) const { |
| 113 Ostream &Str = Func->getContext()->getStrEmit(); | 120 Ostream &Str = Func->getContext()->getStrEmit(); |
| 114 Str << getValue(); | 121 Str << getValue(); |
| 115 } | 122 } |
| 116 virtual void dump(const Cfg *Func) const { | 123 virtual void dump(const Cfg *Func) const { |
| 117 Ostream &Str = Func->getContext()->getStrDump(); | 124 Ostream &Str = Func->getContext()->getStrDump(); |
| 118 Str << getValue(); | 125 Str << getValue(); |
| 119 } | 126 } |
| 120 | 127 |
| 121 static bool classof(const Operand *Operand) { | 128 static bool classof(const Operand *Operand) { |
| 122 return Operand->getKind() == K; | 129 return Operand->getKind() == K; |
| 123 } | 130 } |
| 124 | 131 |
| 125 private: | 132 private: |
| 126 ConstantPrimitive(Type Ty, T Value) : Constant(K, Ty), Value(Value) {} | 133 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) |
| 134 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 127 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 135 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 128 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 136 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 129 virtual ~ConstantPrimitive() {} | 137 virtual ~ConstantPrimitive() {} |
| 130 const T Value; | 138 const T Value; |
| 131 }; | 139 }; |
| 132 | 140 |
| 133 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; | 141 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; |
| 134 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 142 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 135 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 143 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 136 | 144 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 154 bool SuppressMangling; | 162 bool SuppressMangling; |
| 155 }; | 163 }; |
| 156 | 164 |
| 157 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B); | 165 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B); |
| 158 | 166 |
| 159 // ConstantRelocatable represents a symbolic constant combined with | 167 // ConstantRelocatable represents a symbolic constant combined with |
| 160 // a fixed offset. | 168 // a fixed offset. |
| 161 class ConstantRelocatable : public Constant { | 169 class ConstantRelocatable : public Constant { |
| 162 public: | 170 public: |
| 163 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, | 171 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, |
| 164 const RelocatableTuple &Tuple) { | 172 const RelocatableTuple &Tuple, |
| 173 uint32_t PoolEntryID) { |
| 165 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( | 174 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( |
| 166 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling); | 175 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); |
| 167 } | 176 } |
| 168 int64_t getOffset() const { return Offset; } | 177 int64_t getOffset() const { return Offset; } |
| 169 IceString getName() const { return Name; } | 178 IceString getName() const { return Name; } |
| 170 void setSuppressMangling(bool Value) { SuppressMangling = Value; } | 179 void setSuppressMangling(bool Value) { SuppressMangling = Value; } |
| 171 bool getSuppressMangling() const { return SuppressMangling; } | 180 bool getSuppressMangling() const { return SuppressMangling; } |
| 172 virtual void emit(const Cfg *Func) const; | 181 virtual void emit(const Cfg *Func) const; |
| 173 virtual void dump(const Cfg *Func) const; | 182 virtual void dump(const Cfg *Func) const; |
| 174 | 183 |
| 175 static bool classof(const Operand *Operand) { | 184 static bool classof(const Operand *Operand) { |
| 176 OperandKind Kind = Operand->getKind(); | 185 OperandKind Kind = Operand->getKind(); |
| 177 return Kind == kConstRelocatable; | 186 return Kind == kConstRelocatable; |
| 178 } | 187 } |
| 179 | 188 |
| 180 private: | 189 private: |
| 181 ConstantRelocatable(Type Ty, int64_t Offset, const IceString &Name, | 190 ConstantRelocatable(Type Ty, int64_t Offset, const IceString &Name, |
| 182 bool SuppressMangling) | 191 bool SuppressMangling, uint32_t PoolEntryID) |
| 183 : Constant(kConstRelocatable, Ty), Offset(Offset), Name(Name), | 192 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), |
| 184 SuppressMangling(SuppressMangling) {} | 193 Name(Name), SuppressMangling(SuppressMangling) {} |
| 185 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; | 194 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; |
| 186 ConstantRelocatable & | 195 ConstantRelocatable & |
| 187 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; | 196 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; |
| 188 virtual ~ConstantRelocatable() {} | 197 virtual ~ConstantRelocatable() {} |
| 189 const int64_t Offset; // fixed offset to add | 198 const int64_t Offset; // fixed offset to add |
| 190 const IceString Name; // optional for debug/dump | 199 const IceString Name; // optional for debug/dump |
| 191 bool SuppressMangling; | 200 bool SuppressMangling; |
| 192 }; | 201 }; |
| 193 | 202 |
| 194 // RegWeight is a wrapper for a uint32_t weight value, with a | 203 // RegWeight is a wrapper for a uint32_t weight value, with a |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 Variable *LoVar; | 355 Variable *LoVar; |
| 347 Variable *HiVar; | 356 Variable *HiVar; |
| 348 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 357 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 349 // this. | 358 // this. |
| 350 Variable *VarsReal[1]; | 359 Variable *VarsReal[1]; |
| 351 }; | 360 }; |
| 352 | 361 |
| 353 } // end of namespace Ice | 362 } // end of namespace Ice |
| 354 | 363 |
| 355 #endif // SUBZERO_SRC_ICEOPERAND_H | 364 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |