| 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 "IceDefs.h" | 21 #include "IceDefs.h" |
| 22 #include "IceTypes.h" | 22 #include "IceTypes.h" |
| 23 | 23 |
| 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 kConstInteger32, |
| 31 kConstInteger64, |
| 31 kConstFloat, | 32 kConstFloat, |
| 32 kConstDouble, | 33 kConstDouble, |
| 33 kConstRelocatable, | 34 kConstRelocatable, |
| 34 kConstUndef, | 35 kConstUndef, |
| 35 kConst_Num, | 36 kConst_Num, |
| 36 kVariable, | 37 kVariable, |
| 37 // Target-specific operand classes use kTarget as the starting | 38 // Target-specific operand classes use kTarget as the starting |
| 38 // point for their Kind enum space. | 39 // point for their Kind enum space. |
| 39 kTarget | 40 kTarget |
| 40 }; | 41 }; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) | 138 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) |
| 138 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 139 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 139 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 140 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 140 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 141 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 141 virtual ~ConstantPrimitive() {} | 142 virtual ~ConstantPrimitive() {} |
| 142 const T Value; | 143 const T Value; |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; | 146 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; |
| 147 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; |
| 146 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 148 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 147 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 149 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 148 | 150 |
| 149 template <> inline void ConstantInteger::dump(GlobalContext *Ctx) const { | 151 template <> inline void ConstantInteger32::dump(GlobalContext *Ctx) const { |
| 150 Ostream &Str = Ctx->getStrDump(); | 152 Ostream &Str = Ctx->getStrDump(); |
| 151 if (getType() == IceType_i1) | 153 if (getType() == IceType_i1) |
| 152 Str << (getValue() ? "true" : "false"); | 154 Str << (getValue() ? "true" : "false"); |
| 153 else | 155 else |
| 154 Str << static_cast<int64_t>(getValue()); | 156 Str << static_cast<int32_t>(getValue()); |
| 157 } |
| 158 |
| 159 template <> inline void ConstantInteger64::dump(GlobalContext *Ctx) const { |
| 160 assert(getType() == IceType_i64); |
| 161 Ostream &Str = Ctx->getStrDump(); |
| 162 Str << static_cast<int64_t>(getValue()); |
| 155 } | 163 } |
| 156 | 164 |
| 157 // RelocatableTuple bundles the parameters that are used to | 165 // RelocatableTuple bundles the parameters that are used to |
| 158 // construct an ConstantRelocatable. It is done this way so that | 166 // construct an ConstantRelocatable. It is done this way so that |
| 159 // ConstantRelocatable can fit into the global constant pool | 167 // ConstantRelocatable can fit into the global constant pool |
| 160 // template mechanism. | 168 // template mechanism. |
| 161 class RelocatableTuple { | 169 class RelocatableTuple { |
| 162 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; | 170 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; |
| 163 | 171 |
| 164 public: | 172 public: |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Variable *LoVar; | 492 Variable *LoVar; |
| 485 Variable *HiVar; | 493 Variable *HiVar; |
| 486 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 494 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 487 // this. | 495 // this. |
| 488 Variable *VarsReal[1]; | 496 Variable *VarsReal[1]; |
| 489 }; | 497 }; |
| 490 | 498 |
| 491 } // end of namespace Ice | 499 } // end of namespace Ice |
| 492 | 500 |
| 493 #endif // SUBZERO_SRC_ICEOPERAND_H | 501 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |