| 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 |
| 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 "IceDefs.h" | 22 #include "IceDefs.h" |
| 23 #include "IceGlobalContext.h" |
| 22 #include "IceTypes.h" | 24 #include "IceTypes.h" |
| 23 | 25 |
| 24 namespace Ice { | 26 namespace Ice { |
| 25 | 27 |
| 26 class Operand { | 28 class Operand { |
| 27 public: | 29 public: |
| 28 static const size_t MaxTargetKinds = 10; | 30 static const size_t MaxTargetKinds = 10; |
| 29 enum OperandKind { | 31 enum OperandKind { |
| 30 kConst_Base, | 32 kConst_Base, |
| 31 kConstInteger32, | 33 kConstInteger32, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 178 } |
| 177 | 179 |
| 178 // RelocatableTuple bundles the parameters that are used to | 180 // RelocatableTuple bundles the parameters that are used to |
| 179 // construct an ConstantRelocatable. It is done this way so that | 181 // construct an ConstantRelocatable. It is done this way so that |
| 180 // ConstantRelocatable can fit into the global constant pool | 182 // ConstantRelocatable can fit into the global constant pool |
| 181 // template mechanism. | 183 // template mechanism. |
| 182 class RelocatableTuple { | 184 class RelocatableTuple { |
| 183 RelocatableTuple &operator=(const RelocatableTuple &) = delete; | 185 RelocatableTuple &operator=(const RelocatableTuple &) = delete; |
| 184 | 186 |
| 185 public: | 187 public: |
| 186 RelocatableTuple(const int64_t Offset, const IceString &Name, | 188 RelocatableTuple(const RelocOffsetT Offset, const IceString &Name, |
| 187 bool SuppressMangling) | 189 bool SuppressMangling) |
| 188 : Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {} | 190 : Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {} |
| 189 RelocatableTuple(const RelocatableTuple &Other) | 191 RelocatableTuple(const RelocatableTuple &Other) |
| 190 : Offset(Other.Offset), Name(Other.Name), | 192 : Offset(Other.Offset), Name(Other.Name), |
| 191 SuppressMangling(Other.SuppressMangling) {} | 193 SuppressMangling(Other.SuppressMangling) {} |
| 192 | 194 |
| 193 const int64_t Offset; | 195 const RelocOffsetT Offset; |
| 194 const IceString Name; | 196 const IceString Name; |
| 195 bool SuppressMangling; | 197 bool SuppressMangling; |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B); | 200 bool operator<(const RelocatableTuple &A, const RelocatableTuple &B); |
| 199 | 201 |
| 200 // ConstantRelocatable represents a symbolic constant combined with | 202 // ConstantRelocatable represents a symbolic constant combined with |
| 201 // a fixed offset. | 203 // a fixed offset. |
| 202 class ConstantRelocatable : public Constant { | 204 class ConstantRelocatable : public Constant { |
| 203 public: | 205 public: |
| 204 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, | 206 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, |
| 205 const RelocatableTuple &Tuple, | 207 const RelocatableTuple &Tuple, |
| 206 uint32_t PoolEntryID) { | 208 uint32_t PoolEntryID) { |
| 207 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( | 209 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( |
| 208 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); | 210 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); |
| 209 } | 211 } |
| 210 int64_t getOffset() const { return Offset; } | 212 |
| 213 RelocOffsetT getOffset() const { return Offset; } |
| 211 IceString getName() const { return Name; } | 214 IceString getName() const { return Name; } |
| 212 void setSuppressMangling(bool Value) { SuppressMangling = Value; } | 215 void setSuppressMangling(bool Value) { SuppressMangling = Value; } |
| 213 bool getSuppressMangling() const { return SuppressMangling; } | 216 bool getSuppressMangling() const { return SuppressMangling; } |
| 214 using Constant::emit; | 217 using Constant::emit; |
| 215 using Constant::dump; | 218 using Constant::dump; |
| 216 void emit(GlobalContext *Ctx) const override; | 219 void emit(GlobalContext *Ctx) const override; |
| 217 void dump(const Cfg *Func, Ostream &Str) const override; | 220 void dump(const Cfg *Func, Ostream &Str) const override; |
| 218 | 221 |
| 219 static bool classof(const Operand *Operand) { | 222 static bool classof(const Operand *Operand) { |
| 220 OperandKind Kind = Operand->getKind(); | 223 OperandKind Kind = Operand->getKind(); |
| 221 return Kind == kConstRelocatable; | 224 return Kind == kConstRelocatable; |
| 222 } | 225 } |
| 223 | 226 |
| 224 private: | 227 private: |
| 225 ConstantRelocatable(Type Ty, int64_t Offset, const IceString &Name, | 228 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, |
| 226 bool SuppressMangling, uint32_t PoolEntryID) | 229 bool SuppressMangling, uint32_t PoolEntryID) |
| 227 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), | 230 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), |
| 228 Name(Name), SuppressMangling(SuppressMangling) {} | 231 Name(Name), SuppressMangling(SuppressMangling) {} |
| 229 ConstantRelocatable(const ConstantRelocatable &) = delete; | 232 ConstantRelocatable(const ConstantRelocatable &) = delete; |
| 230 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete; | 233 ConstantRelocatable &operator=(const ConstantRelocatable &) = delete; |
| 231 ~ConstantRelocatable() override {} | 234 ~ConstantRelocatable() override {} |
| 232 const int64_t Offset; // fixed offset to add | 235 const RelocOffsetT Offset; // fixed offset to add |
| 233 const IceString Name; // optional for debug/dump | 236 const IceString Name; // optional for debug/dump |
| 234 bool SuppressMangling; | 237 bool SuppressMangling; |
| 235 }; | 238 }; |
| 236 | 239 |
| 237 // ConstantUndef represents an unspecified bit pattern. Although it is | 240 // ConstantUndef represents an unspecified bit pattern. Although it is |
| 238 // legal to lower ConstantUndef to any value, backends should try to | 241 // legal to lower ConstantUndef to any value, backends should try to |
| 239 // make code generation deterministic by lowering ConstantUndefs to 0. | 242 // make code generation deterministic by lowering ConstantUndefs to 0. |
| 240 class ConstantUndef : public Constant { | 243 class ConstantUndef : public Constant { |
| 241 public: | 244 public: |
| 242 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, | 245 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 const Cfg *Func; | 582 const Cfg *Func; |
| 580 std::vector<VariableTracking> Metadata; | 583 std::vector<VariableTracking> Metadata; |
| 581 const static InstDefList NoDefinitions; | 584 const static InstDefList NoDefinitions; |
| 582 VariablesMetadata(const VariablesMetadata &) = delete; | 585 VariablesMetadata(const VariablesMetadata &) = delete; |
| 583 VariablesMetadata &operator=(const VariablesMetadata &) = delete; | 586 VariablesMetadata &operator=(const VariablesMetadata &) = delete; |
| 584 }; | 587 }; |
| 585 | 588 |
| 586 } // end of namespace Ice | 589 } // end of namespace Ice |
| 587 | 590 |
| 588 #endif // SUBZERO_SRC_ICEOPERAND_H | 591 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |