Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 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 kConstInteger, |
| 31 kConstFloat, | 31 kConstFloat, |
| 32 kConstDouble, | 32 kConstDouble, |
| 33 kConstRelocatable, | 33 kConstRelocatable, |
| 34 kConstUndef, | 34 kConstUndef, |
| 35 kConstVector, | |
| 36 kConstBitVector, | |
| 35 kConst_Num, | 37 kConst_Num, |
| 36 kVariable, | 38 kVariable, |
| 37 // Target-specific operand classes use kTarget as the starting | 39 // Target-specific operand classes use kTarget as the starting |
| 38 // point for their Kind enum space. | 40 // point for their Kind enum space. |
| 39 kTarget | 41 kTarget |
| 40 }; | 42 }; |
| 41 OperandKind getKind() const { return Kind; } | 43 OperandKind getKind() const { return Kind; } |
| 42 Type getType() const { return Ty; } | 44 Type getType() const { return Ty; } |
| 43 | 45 |
| 44 // Every Operand keeps an array of the Variables referenced in | 46 // Every Operand keeps an array of the Variables referenced in |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // PoolEntryID is an integer that uniquely identifies the constant | 104 // PoolEntryID is an integer that uniquely identifies the constant |
| 103 // within its constant pool. It is used for building the constant | 105 // within its constant pool. It is used for building the constant |
| 104 // pool in the object code and for referencing its entries. | 106 // pool in the object code and for referencing its entries. |
| 105 const uint32_t PoolEntryID; | 107 const uint32_t PoolEntryID; |
| 106 | 108 |
| 107 private: | 109 private: |
| 108 Constant(const Constant &) LLVM_DELETED_FUNCTION; | 110 Constant(const Constant &) LLVM_DELETED_FUNCTION; |
| 109 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; | 111 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 // ConstantPrimitive<> wraps a primitive type. | 114 // ConstantValue<> wraps a concrete constant value |
|
jvoung (off chromium)
2014/06/26 23:33:46
nit: keep the period at the end of the sentence.
| |
| 113 template <typename T, Operand::OperandKind K> | 115 template <typename T, Operand::OperandKind K> |
| 114 class ConstantPrimitive : public Constant { | 116 class ConstantValue : public Constant { |
| 115 public: | 117 public: |
| 116 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, | 118 static ConstantValue *create(GlobalContext *Ctx, Type Ty, T Value, |
| 117 uint32_t PoolEntryID) { | 119 uint32_t PoolEntryID) { |
| 118 return new (Ctx->allocate<ConstantPrimitive>()) | 120 return new (Ctx->allocate<ConstantValue>()) |
| 119 ConstantPrimitive(Ty, Value, PoolEntryID); | 121 ConstantValue(Ty, Value, PoolEntryID); |
| 120 } | 122 } |
| 121 T getValue() const { return Value; } | 123 T getValue() const { return Value; } |
| 124 | |
| 122 using Constant::emit; | 125 using Constant::emit; |
| 123 virtual void emit(GlobalContext *Ctx) const { | 126 virtual void emit(GlobalContext *Ctx) const { (void)Ctx; } |
|
Jim Stichnoth
2014/06/27 18:30:16
Assuming this is just a stub that the target lower
wala
2014/06/27 21:09:19
Just declaring it works. There is enough variation
Jim Stichnoth
2014/06/27 23:11:05
Thanks. I think it was the original way before I
| |
| 124 Ostream &Str = Ctx->getStrEmit(); | 127 |
| 125 Str << getValue(); | |
| 126 } | |
| 127 using Constant::dump; | 128 using Constant::dump; |
| 128 virtual void dump(GlobalContext *Ctx) const { | 129 virtual void dump(GlobalContext *Ctx) const { |
| 129 Ostream &Str = Ctx->getStrDump(); | 130 Ostream &Str = Ctx->getStrDump(); |
| 130 Str << getValue(); | 131 Str << getValue(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 static bool classof(const Operand *Operand) { | 134 static bool classof(const Operand *Operand) { |
| 134 return Operand->getKind() == K; | 135 return Operand->getKind() == K; |
| 135 } | 136 } |
| 136 | 137 |
| 137 private: | 138 private: |
| 138 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) | 139 ConstantValue(Type Ty, T Value, uint32_t PoolEntryID) |
| 139 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 140 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 140 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 141 ConstantValue(const ConstantValue &) LLVM_DELETED_FUNCTION; |
| 141 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; | 142 ConstantValue &operator=(const ConstantValue &) LLVM_DELETED_FUNCTION; |
| 142 virtual ~ConstantPrimitive() {} | 143 virtual ~ConstantValue() {} |
| 143 const T Value; | 144 const T Value; |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger> ConstantInteger; | 147 // Wrappers for primitive types |
| 147 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 148 typedef ConstantValue<uint64_t, Operand::kConstInteger> ConstantInteger; |
| 148 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 149 typedef ConstantValue<float, Operand::kConstFloat> ConstantFloat; |
| 150 typedef ConstantValue<double, Operand::kConstDouble> ConstantDouble; | |
| 151 | |
| 152 // ConstantVector wraps a 128 bit value. | |
| 153 typedef ConstantValue<Vect128, Operand::kConstVector> ConstantVector; | |
| 154 template <> void ConstantVector::dump(GlobalContext *Ctx) const; | |
| 155 | |
| 156 // ConstantBitVector wraps a vector of I1s. | |
| 157 typedef ConstantValue<BitVect, Operand::kConstBitVector> ConstantBitVector; | |
| 158 template <> void ConstantBitVector::dump(GlobalContext *Ctx) const; | |
| 149 | 159 |
| 150 // RelocatableTuple bundles the parameters that are used to | 160 // RelocatableTuple bundles the parameters that are used to |
| 151 // construct an ConstantRelocatable. It is done this way so that | 161 // construct an ConstantRelocatable. It is done this way so that |
| 152 // ConstantRelocatable can fit into the global constant pool | 162 // ConstantRelocatable can fit into the global constant pool |
| 153 // template mechanism. | 163 // template mechanism. |
| 154 class RelocatableTuple { | 164 class RelocatableTuple { |
| 155 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; | 165 RelocatableTuple &operator=(const RelocatableTuple &) LLVM_DELETED_FUNCTION; |
| 156 | 166 |
| 157 public: | 167 public: |
| 158 RelocatableTuple(const int64_t Offset, const IceString &Name, | 168 RelocatableTuple(const int64_t Offset, const IceString &Name, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 Variable *LoVar; | 474 Variable *LoVar; |
| 465 Variable *HiVar; | 475 Variable *HiVar; |
| 466 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 476 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 467 // this. | 477 // this. |
| 468 Variable *VarsReal[1]; | 478 Variable *VarsReal[1]; |
| 469 }; | 479 }; |
| 470 | 480 |
| 471 } // end of namespace Ice | 481 } // end of namespace Ice |
| 472 | 482 |
| 473 #endif // SUBZERO_SRC_ICEOPERAND_H | 483 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |