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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 Str << ".L$" << getType() << "$" << PoolEntryID; | 110 Str << ".L$" << getType() << "$" << PoolEntryID; |
111 } | 111 } |
112 void emit(const Cfg *Func) const override { emit(Func->getTarget()); } | 112 void emit(const Cfg *Func) const override { emit(Func->getTarget()); } |
113 virtual void emit(TargetLowering *Target) const = 0; | 113 virtual void emit(TargetLowering *Target) const = 0; |
114 | 114 |
115 static bool classof(const Operand *Operand) { | 115 static bool classof(const Operand *Operand) { |
116 OperandKind Kind = Operand->getKind(); | 116 OperandKind Kind = Operand->getKind(); |
117 return Kind >= kConst_Base && Kind <= kConst_Num; | 117 return Kind >= kConst_Base && Kind <= kConst_Num; |
118 } | 118 } |
119 | 119 |
120 // Judge if this given immediate should be randomized or pooled | |
121 // By default should return false, only constant integers should | |
122 // truly go through this method. | |
123 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) { | |
124 (void)Ctx; | |
125 return false; | |
126 } | |
127 | |
128 // Whether we should pool this constant. Usually Float/Doubled Relocatables | |
Jim Stichnoth
2015/06/19 16:51:03
Doubled ==> Double
qining
2015/06/19 20:22:25
Done.
| |
129 // and pooled Integers should be flaged true. | |
Jim Stichnoth
2015/06/19 16:51:03
flagged
qining
2015/06/19 20:22:25
Done.
| |
130 bool shouldBePooled; | |
131 | |
120 protected: | 132 protected: |
121 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) | 133 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) |
122 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { | 134 : Operand(Kind, Ty), shouldBePooled(false), PoolEntryID(PoolEntryID) { |
123 Vars = nullptr; | 135 Vars = nullptr; |
124 NumVars = 0; | 136 NumVars = 0; |
125 } | 137 } |
126 ~Constant() override {} | 138 ~Constant() override {} |
127 // PoolEntryID is an integer that uniquely identifies the constant | 139 // PoolEntryID is an integer that uniquely identifies the constant |
128 // within its constant pool. It is used for building the constant | 140 // within its constant pool. It is used for building the constant |
129 // pool in the object code and for referencing its entries. | 141 // pool in the object code and for referencing its entries. |
130 const uint32_t PoolEntryID; | 142 const uint32_t PoolEntryID; |
131 }; | 143 }; |
132 | 144 |
(...skipping 20 matching lines...) Expand all Loading... | |
153 using Constant::dump; | 165 using Constant::dump; |
154 void dump(const Cfg *, Ostream &Str) const override { | 166 void dump(const Cfg *, Ostream &Str) const override { |
155 if (ALLOW_DUMP) | 167 if (ALLOW_DUMP) |
156 Str << getValue(); | 168 Str << getValue(); |
157 } | 169 } |
158 | 170 |
159 static bool classof(const Operand *Operand) { | 171 static bool classof(const Operand *Operand) { |
160 return Operand->getKind() == K; | 172 return Operand->getKind() == K; |
161 } | 173 } |
162 | 174 |
175 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override { | |
176 (void)Ctx; | |
177 return false; | |
178 } | |
179 | |
163 private: | 180 private: |
164 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) | 181 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) |
165 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 182 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
166 ~ConstantPrimitive() override {} | 183 ~ConstantPrimitive() override {} |
167 const PrimType Value; | 184 const PrimType Value; |
168 }; | 185 }; |
169 | 186 |
170 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; | 187 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; |
171 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; | 188 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; |
172 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 189 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
173 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 190 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
174 | 191 |
175 template <> | 192 template <> |
176 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { | 193 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { |
177 if (!ALLOW_DUMP) | 194 if (!ALLOW_DUMP) |
178 return; | 195 return; |
179 if (getType() == IceType_i1) | 196 if (getType() == IceType_i1) |
180 Str << (getValue() ? "true" : "false"); | 197 Str << (getValue() ? "true" : "false"); |
181 else | 198 else |
182 Str << static_cast<int32_t>(getValue()); | 199 Str << static_cast<int32_t>(getValue()); |
183 } | 200 } |
184 | 201 |
202 // Specialization of the template member function for ConstantInteger32 | |
203 template <> | |
204 bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx); | |
205 | |
185 template <> | 206 template <> |
186 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { | 207 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { |
187 if (!ALLOW_DUMP) | 208 if (!ALLOW_DUMP) |
188 return; | 209 return; |
189 assert(getType() == IceType_i64); | 210 assert(getType() == IceType_i64); |
190 Str << static_cast<int64_t>(getValue()); | 211 Str << static_cast<int64_t>(getValue()); |
191 } | 212 } |
192 | 213 |
193 // RelocatableTuple bundles the parameters that are used to | 214 // RelocatableTuple bundles the parameters that are used to |
194 // construct an ConstantRelocatable. It is done this way so that | 215 // construct an ConstantRelocatable. It is done this way so that |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 private: | 652 private: |
632 const Cfg *Func; | 653 const Cfg *Func; |
633 MetadataKind Kind; | 654 MetadataKind Kind; |
634 std::vector<VariableTracking> Metadata; | 655 std::vector<VariableTracking> Metadata; |
635 const static InstDefList NoDefinitions; | 656 const static InstDefList NoDefinitions; |
636 }; | 657 }; |
637 | 658 |
638 } // end of namespace Ice | 659 } // end of namespace Ice |
639 | 660 |
640 #endif // SUBZERO_SRC_ICEOPERAND_H | 661 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |