| 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 /// \file | 10 /// \file |
| 11 /// This file declares the Operand class and its target-independent | 11 /// This file declares the Operand class and its target-independent subclasses. |
| 12 /// subclasses. The main classes are Variable, which represents an | 12 /// The main classes are Variable, which represents an LLVM variable that is |
| 13 /// LLVM variable that is either register- or stack-allocated, and the | 13 /// either register- or stack-allocated, and the Constant hierarchy, which |
| 14 /// Constant hierarchy, which represents integer, floating-point, | 14 /// represents integer, floating-point, and/or symbolic constants. |
| 15 /// and/or symbolic constants. | |
| 16 /// | 15 /// |
| 17 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 18 | 17 |
| 19 #ifndef SUBZERO_SRC_ICEOPERAND_H | 18 #ifndef SUBZERO_SRC_ICEOPERAND_H |
| 20 #define SUBZERO_SRC_ICEOPERAND_H | 19 #define SUBZERO_SRC_ICEOPERAND_H |
| 21 | 20 |
| 22 #include "IceCfg.h" | 21 #include "IceCfg.h" |
| 23 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 24 #include "IceGlobalContext.h" | 23 #include "IceGlobalContext.h" |
| 24 #include "IceTargetKinds.def" |
| 25 #include "IceTypes.h" | 25 #include "IceTypes.h" |
| 26 | 26 |
| 27 namespace Ice { | 27 namespace Ice { |
| 28 | 28 |
| 29 class Operand { | 29 class Operand { |
| 30 Operand() = delete; | 30 Operand() = delete; |
| 31 Operand(const Operand &) = delete; | 31 Operand(const Operand &) = delete; |
| 32 Operand &operator=(const Operand &) = delete; | 32 Operand &operator=(const Operand &) = delete; |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 static const size_t MaxTargetKinds = 10; | 35 static const size_t MaxTargetKinds = 10; |
| 36 enum OperandKind { | 36 enum OperandKind { |
| 37 kConst_Base, | 37 kConst_Base, |
| 38 kConstInteger32, | 38 kConstInteger32, |
| 39 kConstInteger64, | 39 kConstInteger64, |
| 40 kConstFloat, | 40 kConstFloat, |
| 41 kConstDouble, | 41 kConstDouble, |
| 42 kConstRelocatable, | 42 kConstRelocatable, |
| 43 kConstUndef, | 43 kConstUndef, |
| 44 kConst_Target, // leave space for target-specific constant kinds | 44 #define X(n) kConst_Target##n, |
| 45 kConst_Num = kConst_Target + MaxTargetKinds, | 45 TARGETKINDS_TABLE |
| 46 #undef X |
| 47 kConst_Max = kConst_Target0 + TARGETKINDS_TABLE_MAX, |
| 46 kVariable, | 48 kVariable, |
| 47 kVariable_Target, // leave space for target-specific variable kinds | 49 #define X(n) kVariable_Target##n, |
| 48 kVariable_Num = kVariable_Target + MaxTargetKinds, | 50 TARGETKINDS_TABLE |
| 51 #undef X |
| 52 kVariable_Max = kVariable_Target0 + TARGETKINDS_TABLE_MAX, |
| 49 // Target-specific operand classes use kTarget as the starting | 53 // Target-specific operand classes use kTarget as the starting |
| 50 // point for their Kind enum space. Note that the value-spaces are shared | 54 // point for their Kind enum space. Note that the value-spaces are shared |
| 51 // across targets. To avoid confusion over the definition of shared | 55 // across targets. To avoid confusion over the definition of shared |
| 52 // values, an object specific to one target should never be passed | 56 // values, an object specific to one target should never be passed |
| 53 // to a different target. | 57 // to a different target. |
| 54 kTarget | 58 #define X(n) kTarget##n, |
| 59 TARGETKINDS_TABLE |
| 60 #undef X |
| 55 }; | 61 }; |
| 56 OperandKind getKind() const { return Kind; } | 62 OperandKind getKind() const { return Kind; } |
| 57 Type getType() const { return Ty; } | 63 Type getType() const { return Ty; } |
| 58 | 64 |
| 59 /// Every Operand keeps an array of the Variables referenced in | 65 /// Every Operand keeps an array of the Variables referenced in the operand. |
| 60 /// the operand. This is so that the liveness operations can get | 66 /// This is so that the liveness operations can get quick access to the |
| 61 /// quick access to the variables of interest, without having to dig | 67 /// variables of interest, without having to dig so far into the operand. |
| 62 /// so far into the operand. | |
| 63 SizeT getNumVars() const { return NumVars; } | 68 SizeT getNumVars() const { return NumVars; } |
| 64 Variable *getVar(SizeT I) const { | 69 Variable *getVar(SizeT I) const { |
| 65 assert(I < getNumVars()); | 70 assert(I < getNumVars()); |
| 66 return Vars[I]; | 71 return Vars[I]; |
| 67 } | 72 } |
| 68 virtual void emit(const Cfg *Func) const = 0; | 73 virtual void emit(const Cfg *Func) const = 0; |
| 69 | 74 |
| 70 /// \name Dumping functions. | 75 /// \name Dumping functions. |
| 71 /// @{ | 76 /// @{ |
| 72 | 77 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 116 |
| 112 public: | 117 public: |
| 113 void emitPoolLabel(Ostream &Str) const { | 118 void emitPoolLabel(Ostream &Str) const { |
| 114 Str << ".L$" << getType() << "$" << PoolEntryID; | 119 Str << ".L$" << getType() << "$" << PoolEntryID; |
| 115 } | 120 } |
| 116 void emit(const Cfg *Func) const override { emit(Func->getTarget()); } | 121 void emit(const Cfg *Func) const override { emit(Func->getTarget()); } |
| 117 virtual void emit(TargetLowering *Target) const = 0; | 122 virtual void emit(TargetLowering *Target) const = 0; |
| 118 | 123 |
| 119 static bool classof(const Operand *Operand) { | 124 static bool classof(const Operand *Operand) { |
| 120 OperandKind Kind = Operand->getKind(); | 125 OperandKind Kind = Operand->getKind(); |
| 121 return Kind >= kConst_Base && Kind <= kConst_Num; | 126 return Kind >= kConst_Base && Kind <= kConst_Max; |
| 122 } | 127 } |
| 123 | 128 |
| 124 /// Judge if this given immediate should be randomized or pooled | 129 /// Judge if this given immediate should be randomized or pooled |
| 125 /// By default should return false, only constant integers should | 130 /// By default should return false, only constant integers should |
| 126 /// truly go through this method. | 131 /// truly go through this method. |
| 127 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) { | 132 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) { |
| 128 (void)Ctx; | 133 (void)Ctx; |
| 129 return false; | 134 return false; |
| 130 } | 135 } |
| 131 | 136 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 506 |
| 502 void emit(const Cfg *Func) const override; | 507 void emit(const Cfg *Func) const override; |
| 503 using Operand::dump; | 508 using Operand::dump; |
| 504 void dump(const Cfg *Func, Ostream &Str) const override; | 509 void dump(const Cfg *Func, Ostream &Str) const override; |
| 505 | 510 |
| 506 /// Return reg num of base register, if different from stack/frame register. | 511 /// Return reg num of base register, if different from stack/frame register. |
| 507 virtual int32_t getBaseRegNum() const { return NoRegister; } | 512 virtual int32_t getBaseRegNum() const { return NoRegister; } |
| 508 | 513 |
| 509 static bool classof(const Operand *Operand) { | 514 static bool classof(const Operand *Operand) { |
| 510 OperandKind Kind = Operand->getKind(); | 515 OperandKind Kind = Operand->getKind(); |
| 511 return Kind >= kVariable && Kind <= kVariable_Num; | 516 return Kind >= kVariable && Kind <= kVariable_Max; |
| 512 } | 517 } |
| 513 | 518 |
| 514 protected: | 519 protected: |
| 515 Variable(OperandKind K, Type Ty, SizeT Index) | 520 Variable(OperandKind K, Type Ty, SizeT Index) |
| 516 : Operand(K, Ty), Number(Index) { | 521 : Operand(K, Ty), Number(Index) { |
| 517 Vars = VarsReal; | 522 Vars = VarsReal; |
| 518 Vars[0] = this; | 523 Vars[0] = this; |
| 519 NumVars = 1; | 524 NumVars = 1; |
| 520 } | 525 } |
| 521 /// Number is unique across all variables, and is used as a | 526 /// Number is unique across all variables, and is used as a |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 private: | 661 private: |
| 657 const Cfg *Func; | 662 const Cfg *Func; |
| 658 MetadataKind Kind; | 663 MetadataKind Kind; |
| 659 std::vector<VariableTracking> Metadata; | 664 std::vector<VariableTracking> Metadata; |
| 660 const static InstDefList NoDefinitions; | 665 const static InstDefList NoDefinitions; |
| 661 }; | 666 }; |
| 662 | 667 |
| 663 } // end of namespace Ice | 668 } // end of namespace Ice |
| 664 | 669 |
| 665 #endif // SUBZERO_SRC_ICEOPERAND_H | 670 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |