| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 146 |
| 146 private: | 147 private: |
| 147 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) | 148 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) |
| 148 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 149 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 149 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 150 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 150 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 151 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; |
| 151 virtual ~ConstantPrimitive() {} | 152 virtual ~ConstantPrimitive() {} |
| 152 const T Value; | 153 const T Value; |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; | 156 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; |
| 157 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; |
| 156 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 158 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 157 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 159 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 158 | 160 |
| 159 template <> inline void ConstantInteger::dump(const Cfg *, Ostream &Str) const { | 161 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
{ |
| 160 if (getType() == IceType_i1) | 162 if (getType() == IceType_i1) |
| 161 Str << (getValue() ? "true" : "false"); | 163 Str << (getValue() ? "true" : "false"); |
| 162 else | 164 else |
| 163 Str << static_cast<int64_t>(getValue()); | 165 Str << static_cast<int32_t>(getValue()); |
| 166 } |
| 167 |
| 168 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const
{ |
| 169 assert(getType() == IceType_i64); |
| 170 Str << static_cast<int64_t>(getValue()); |
| 164 } | 171 } |
| 165 | 172 |
| 166 // RelocatableTuple bundles the parameters that are used to | 173 // RelocatableTuple bundles the parameters that are used to |
| 167 // construct an ConstantRelocatable. It is done this way so that | 174 // construct an ConstantRelocatable. It is done this way so that |
| 168 // ConstantRelocatable can fit into the global constant pool | 175 // ConstantRelocatable can fit into the global constant pool |
| 169 // template mechanism. | 176 // template mechanism. |
| 170 class RelocatableTuple { | 177 class RelocatableTuple { |
| 171 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; | 178 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; |
| 172 | 179 |
| 173 public: | 180 public: |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 Variable *LoVar; | 497 Variable *LoVar; |
| 491 Variable *HiVar; | 498 Variable *HiVar; |
| 492 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 499 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 493 // this. | 500 // this. |
| 494 Variable *VarsReal[1]; | 501 Variable *VarsReal[1]; |
| 495 }; | 502 }; |
| 496 | 503 |
| 497 } // end of namespace Ice | 504 } // end of namespace Ice |
| 498 | 505 |
| 499 #endif // SUBZERO_SRC_ICEOPERAND_H | 506 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |