| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 SizeT getNumVars() const { return NumVars; } | 58 SizeT getNumVars() const { return NumVars; } |
| 59 Variable *getVar(SizeT I) const { | 59 Variable *getVar(SizeT I) const { |
| 60 assert(I < getNumVars()); | 60 assert(I < getNumVars()); |
| 61 return Vars[I]; | 61 return Vars[I]; |
| 62 } | 62 } |
| 63 virtual void emit(const Cfg *Func) const = 0; | 63 virtual void emit(const Cfg *Func) const = 0; |
| 64 // The dump(Func,Str) implementation must be sure to handle the | 64 // The dump(Func,Str) implementation must be sure to handle the |
| 65 // situation where Func==NULL. | 65 // situation where Func==NULL. |
| 66 virtual void dump(const Cfg *Func, Ostream &Str) const = 0; | 66 virtual void dump(const Cfg *Func, Ostream &Str) const = 0; |
| 67 void dump(const Cfg *Func) const { | 67 void dump(const Cfg *Func) const { |
| 68 if (!ALLOW_DUMP) |
| 69 return; |
| 68 assert(Func); | 70 assert(Func); |
| 69 dump(Func, Func->getContext()->getStrDump()); | 71 dump(Func, Func->getContext()->getStrDump()); |
| 70 } | 72 } |
| 71 void dump(Ostream &Str) const { dump(NULL, Str); } | 73 void dump(Ostream &Str) const { |
| 74 if (ALLOW_DUMP) |
| 75 dump(NULL, Str); |
| 76 } |
| 72 | 77 |
| 73 // Query whether this object was allocated in isolation, or added to | 78 // Query whether this object was allocated in isolation, or added to |
| 74 // some higher-level pool. This determines whether a containing | 79 // some higher-level pool. This determines whether a containing |
| 75 // object's destructor should delete this object. Generally, | 80 // object's destructor should delete this object. Generally, |
| 76 // constants are pooled globally, variables are pooled per-CFG, and | 81 // constants are pooled globally, variables are pooled per-CFG, and |
| 77 // target-specific operands are not pooled. | 82 // target-specific operands are not pooled. |
| 78 virtual bool isPooled() const { return false; } | 83 virtual bool isPooled() const { return false; } |
| 79 | 84 |
| 80 virtual ~Operand() {} | 85 virtual ~Operand() {} |
| 81 | 86 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 "Attempt to build primitive constant when IR generation disabled"); | 146 "Attempt to build primitive constant when IR generation disabled"); |
| 142 return new (Ctx->allocate<ConstantPrimitive>()) | 147 return new (Ctx->allocate<ConstantPrimitive>()) |
| 143 ConstantPrimitive(Ty, Value, PoolEntryID); | 148 ConstantPrimitive(Ty, Value, PoolEntryID); |
| 144 } | 149 } |
| 145 T getValue() const { return Value; } | 150 T getValue() const { return Value; } |
| 146 using Constant::emit; | 151 using Constant::emit; |
| 147 // The target needs to implement this for each ConstantPrimitive | 152 // The target needs to implement this for each ConstantPrimitive |
| 148 // specialization. | 153 // specialization. |
| 149 void emit(GlobalContext *Ctx) const override; | 154 void emit(GlobalContext *Ctx) const override; |
| 150 using Constant::dump; | 155 using Constant::dump; |
| 151 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); } | 156 void dump(const Cfg *, Ostream &Str) const override { |
| 157 if (ALLOW_DUMP) |
| 158 Str << getValue(); |
| 159 } |
| 152 | 160 |
| 153 static bool classof(const Operand *Operand) { | 161 static bool classof(const Operand *Operand) { |
| 154 return Operand->getKind() == K; | 162 return Operand->getKind() == K; |
| 155 } | 163 } |
| 156 | 164 |
| 157 private: | 165 private: |
| 158 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) | 166 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) |
| 159 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 167 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 160 ~ConstantPrimitive() override {} | 168 ~ConstantPrimitive() override {} |
| 161 const T Value; | 169 const T Value; |
| 162 }; | 170 }; |
| 163 | 171 |
| 164 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; | 172 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; |
| 165 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; | 173 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; |
| 166 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 174 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 167 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 175 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 168 | 176 |
| 169 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
{ | 177 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
{ |
| 178 if (!ALLOW_DUMP) |
| 179 return; |
| 170 if (getType() == IceType_i1) | 180 if (getType() == IceType_i1) |
| 171 Str << (getValue() ? "true" : "false"); | 181 Str << (getValue() ? "true" : "false"); |
| 172 else | 182 else |
| 173 Str << static_cast<int32_t>(getValue()); | 183 Str << static_cast<int32_t>(getValue()); |
| 174 } | 184 } |
| 175 | 185 |
| 176 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const
{ | 186 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const
{ |
| 187 if (!ALLOW_DUMP) |
| 188 return; |
| 177 assert(getType() == IceType_i64); | 189 assert(getType() == IceType_i64); |
| 178 Str << static_cast<int64_t>(getValue()); | 190 Str << static_cast<int64_t>(getValue()); |
| 179 } | 191 } |
| 180 | 192 |
| 181 // RelocatableTuple bundles the parameters that are used to | 193 // RelocatableTuple bundles the parameters that are used to |
| 182 // construct an ConstantRelocatable. It is done this way so that | 194 // construct an ConstantRelocatable. It is done this way so that |
| 183 // ConstantRelocatable can fit into the global constant pool | 195 // ConstantRelocatable can fit into the global constant pool |
| 184 // template mechanism. | 196 // template mechanism. |
| 185 class RelocatableTuple { | 197 class RelocatableTuple { |
| 186 // RelocatableTuple(const RelocatableTuple &) = delete; | 198 // RelocatableTuple(const RelocatableTuple &) = delete; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 uint32_t PoolEntryID) { | 264 uint32_t PoolEntryID) { |
| 253 assert(!Ctx->isIRGenerationDisabled() && | 265 assert(!Ctx->isIRGenerationDisabled() && |
| 254 "Attempt to build undefined constant when IR generation disabled"); | 266 "Attempt to build undefined constant when IR generation disabled"); |
| 255 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); | 267 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); |
| 256 } | 268 } |
| 257 | 269 |
| 258 using Constant::emit; | 270 using Constant::emit; |
| 259 using Constant::dump; | 271 using Constant::dump; |
| 260 // The target needs to implement this. | 272 // The target needs to implement this. |
| 261 void emit(GlobalContext *Ctx) const override; | 273 void emit(GlobalContext *Ctx) const override; |
| 262 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; } | 274 void dump(const Cfg *, Ostream &Str) const override { |
| 275 if (ALLOW_DUMP) |
| 276 Str << "undef"; |
| 277 } |
| 263 | 278 |
| 264 static bool classof(const Operand *Operand) { | 279 static bool classof(const Operand *Operand) { |
| 265 return Operand->getKind() == kConstUndef; | 280 return Operand->getKind() == kConstUndef; |
| 266 } | 281 } |
| 267 | 282 |
| 268 private: | 283 private: |
| 269 ConstantUndef(Type Ty, uint32_t PoolEntryID) | 284 ConstantUndef(Type Ty, uint32_t PoolEntryID) |
| 270 : Constant(kConstUndef, Ty, PoolEntryID) {} | 285 : Constant(kConstUndef, Ty, PoolEntryID) {} |
| 271 ~ConstantUndef() override {} | 286 ~ConstantUndef() override {} |
| 272 }; | 287 }; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 private: | 648 private: |
| 634 const Cfg *Func; | 649 const Cfg *Func; |
| 635 MetadataKind Kind; | 650 MetadataKind Kind; |
| 636 std::vector<VariableTracking> Metadata; | 651 std::vector<VariableTracking> Metadata; |
| 637 const static InstDefList NoDefinitions; | 652 const static InstDefList NoDefinitions; |
| 638 }; | 653 }; |
| 639 | 654 |
| 640 } // end of namespace Ice | 655 } // end of namespace Ice |
| 641 | 656 |
| 642 #endif // SUBZERO_SRC_ICEOPERAND_H | 657 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |