| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 SizeT getNumVars() const { return NumVars; } | 62 SizeT getNumVars() const { return NumVars; } |
| 63 Variable *getVar(SizeT I) const { | 63 Variable *getVar(SizeT I) const { |
| 64 assert(I < getNumVars()); | 64 assert(I < getNumVars()); |
| 65 return Vars[I]; | 65 return Vars[I]; |
| 66 } | 66 } |
| 67 virtual void emit(const Cfg *Func) const = 0; | 67 virtual void emit(const Cfg *Func) const = 0; |
| 68 // The dump(Func,Str) implementation must be sure to handle the | 68 // The dump(Func,Str) implementation must be sure to handle the |
| 69 // situation where Func==nullptr. | 69 // situation where Func==nullptr. |
| 70 virtual void dump(const Cfg *Func, Ostream &Str) const = 0; | 70 virtual void dump(const Cfg *Func, Ostream &Str) const = 0; |
| 71 void dump(const Cfg *Func) const { | 71 void dump(const Cfg *Func) const { |
| 72 if (!ALLOW_DUMP) | 72 if (!buildAllowsDump()) |
| 73 return; | 73 return; |
| 74 assert(Func); | 74 assert(Func); |
| 75 dump(Func, Func->getContext()->getStrDump()); | 75 dump(Func, Func->getContext()->getStrDump()); |
| 76 } | 76 } |
| 77 void dump(Ostream &Str) const { | 77 void dump(Ostream &Str) const { |
| 78 if (ALLOW_DUMP) | 78 if (buildAllowsDump()) |
| 79 dump(nullptr, Str); | 79 dump(nullptr, Str); |
| 80 } | 80 } |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) {} | 83 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) {} |
| 84 | 84 |
| 85 const Type Ty; | 85 const Type Ty; |
| 86 const OperandKind Kind; | 86 const OperandKind Kind; |
| 87 // Vars and NumVars are initialized by the derived class. | 87 // Vars and NumVars are initialized by the derived class. |
| 88 SizeT NumVars = 0; | 88 SizeT NumVars = 0; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 assert(!Ctx->isIRGenerationDisabled() && | 156 assert(!Ctx->isIRGenerationDisabled() && |
| 157 "Attempt to build primitive constant when IR generation disabled"); | 157 "Attempt to build primitive constant when IR generation disabled"); |
| 158 return new (Ctx->allocate<ConstantPrimitive>()) | 158 return new (Ctx->allocate<ConstantPrimitive>()) |
| 159 ConstantPrimitive(Ty, Value, PoolEntryID); | 159 ConstantPrimitive(Ty, Value, PoolEntryID); |
| 160 } | 160 } |
| 161 PrimType getValue() const { return Value; } | 161 PrimType getValue() const { return Value; } |
| 162 using Constant::emit; | 162 using Constant::emit; |
| 163 void emit(TargetLowering *Target) const final; | 163 void emit(TargetLowering *Target) const final; |
| 164 using Constant::dump; | 164 using Constant::dump; |
| 165 void dump(const Cfg *, Ostream &Str) const override { | 165 void dump(const Cfg *, Ostream &Str) const override { |
| 166 if (ALLOW_DUMP) | 166 if (buildAllowsDump()) |
| 167 Str << getValue(); | 167 Str << getValue(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 static bool classof(const Operand *Operand) { | 170 static bool classof(const Operand *Operand) { |
| 171 return Operand->getKind() == K; | 171 return Operand->getKind() == K; |
| 172 } | 172 } |
| 173 | 173 |
| 174 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override { | 174 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override { |
| 175 (void)Ctx; | 175 (void)Ctx; |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 private: | 179 private: |
| 180 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) | 180 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) |
| 181 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 181 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 182 const PrimType Value; | 182 const PrimType Value; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; | 185 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; |
| 186 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; | 186 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; |
| 187 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 187 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 188 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 188 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 189 | 189 |
| 190 template <> | 190 template <> |
| 191 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { | 191 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { |
| 192 if (!ALLOW_DUMP) | 192 if (!buildAllowsDump()) |
| 193 return; | 193 return; |
| 194 if (getType() == IceType_i1) | 194 if (getType() == IceType_i1) |
| 195 Str << (getValue() ? "true" : "false"); | 195 Str << (getValue() ? "true" : "false"); |
| 196 else | 196 else |
| 197 Str << static_cast<int32_t>(getValue()); | 197 Str << static_cast<int32_t>(getValue()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Specialization of the template member function for ConstantInteger32 | 200 // Specialization of the template member function for ConstantInteger32 |
| 201 template <> | 201 template <> |
| 202 bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx); | 202 bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx); |
| 203 | 203 |
| 204 template <> | 204 template <> |
| 205 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { | 205 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { |
| 206 if (!ALLOW_DUMP) | 206 if (!buildAllowsDump()) |
| 207 return; | 207 return; |
| 208 assert(getType() == IceType_i64); | 208 assert(getType() == IceType_i64); |
| 209 Str << static_cast<int64_t>(getValue()); | 209 Str << static_cast<int64_t>(getValue()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // RelocatableTuple bundles the parameters that are used to | 212 // RelocatableTuple bundles the parameters that are used to |
| 213 // construct an ConstantRelocatable. It is done this way so that | 213 // construct an ConstantRelocatable. It is done this way so that |
| 214 // ConstantRelocatable can fit into the global constant pool | 214 // ConstantRelocatable can fit into the global constant pool |
| 215 // template mechanism. | 215 // template mechanism. |
| 216 class RelocatableTuple { | 216 class RelocatableTuple { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 uint32_t PoolEntryID) { | 285 uint32_t PoolEntryID) { |
| 286 assert(!Ctx->isIRGenerationDisabled() && | 286 assert(!Ctx->isIRGenerationDisabled() && |
| 287 "Attempt to build undefined constant when IR generation disabled"); | 287 "Attempt to build undefined constant when IR generation disabled"); |
| 288 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); | 288 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); |
| 289 } | 289 } |
| 290 | 290 |
| 291 using Constant::emit; | 291 using Constant::emit; |
| 292 void emit(TargetLowering *Target) const final; | 292 void emit(TargetLowering *Target) const final; |
| 293 using Constant::dump; | 293 using Constant::dump; |
| 294 void dump(const Cfg *, Ostream &Str) const override { | 294 void dump(const Cfg *, Ostream &Str) const override { |
| 295 if (ALLOW_DUMP) | 295 if (buildAllowsDump()) |
| 296 Str << "undef"; | 296 Str << "undef"; |
| 297 } | 297 } |
| 298 | 298 |
| 299 static bool classof(const Operand *Operand) { | 299 static bool classof(const Operand *Operand) { |
| 300 return Operand->getKind() == kConstUndef; | 300 return Operand->getKind() == kConstUndef; |
| 301 } | 301 } |
| 302 | 302 |
| 303 private: | 303 private: |
| 304 ConstantUndef(Type Ty, uint32_t PoolEntryID) | 304 ConstantUndef(Type Ty, uint32_t PoolEntryID) |
| 305 : Constant(kConstUndef, Ty, PoolEntryID) {} | 305 : Constant(kConstUndef, Ty, PoolEntryID) {} |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 private: | 643 private: |
| 644 const Cfg *Func; | 644 const Cfg *Func; |
| 645 MetadataKind Kind; | 645 MetadataKind Kind; |
| 646 std::vector<VariableTracking> Metadata; | 646 std::vector<VariableTracking> Metadata; |
| 647 const static InstDefList NoDefinitions; | 647 const static InstDefList NoDefinitions; |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 } // end of namespace Ice | 650 } // end of namespace Ice |
| 651 | 651 |
| 652 #endif // SUBZERO_SRC_ICEOPERAND_H | 652 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |