| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // constants are allocated from a global arena and are pooled. | 99 // constants are allocated from a global arena and are pooled. |
| 100 class Constant : public Operand { | 100 class Constant : public Operand { |
| 101 Constant() = delete; | 101 Constant() = delete; |
| 102 Constant(const Constant &) = delete; | 102 Constant(const Constant &) = delete; |
| 103 Constant &operator=(const Constant &) = delete; | 103 Constant &operator=(const Constant &) = delete; |
| 104 | 104 |
| 105 public: | 105 public: |
| 106 void emitPoolLabel(Ostream &Str) const { | 106 void emitPoolLabel(Ostream &Str) const { |
| 107 Str << ".L$" << getType() << "$" << PoolEntryID; | 107 Str << ".L$" << getType() << "$" << PoolEntryID; |
| 108 } | 108 } |
| 109 void emit(const Cfg *Func) const override { emit(Func->getContext()); } | 109 void emit(const Cfg *Func) const override { emit(Func->getTarget()); } |
| 110 virtual void emit(GlobalContext *Ctx) const = 0; | 110 virtual void emit(TargetLowering *Target) const = 0; |
| 111 virtual void emitWithoutDollar(GlobalContext *Ctx) const = 0; | |
| 112 | 111 |
| 113 static bool classof(const Operand *Operand) { | 112 static bool classof(const Operand *Operand) { |
| 114 OperandKind Kind = Operand->getKind(); | 113 OperandKind Kind = Operand->getKind(); |
| 115 return Kind >= kConst_Base && Kind <= kConst_Num; | 114 return Kind >= kConst_Base && Kind <= kConst_Num; |
| 116 } | 115 } |
| 117 | 116 |
| 118 protected: | 117 protected: |
| 119 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) | 118 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) |
| 120 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { | 119 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { |
| 121 Vars = nullptr; | 120 Vars = nullptr; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 140 | 139 |
| 141 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, PrimType Value, | 140 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, PrimType Value, |
| 142 uint32_t PoolEntryID) { | 141 uint32_t PoolEntryID) { |
| 143 assert(!Ctx->isIRGenerationDisabled() && | 142 assert(!Ctx->isIRGenerationDisabled() && |
| 144 "Attempt to build primitive constant when IR generation disabled"); | 143 "Attempt to build primitive constant when IR generation disabled"); |
| 145 return new (Ctx->allocate<ConstantPrimitive>()) | 144 return new (Ctx->allocate<ConstantPrimitive>()) |
| 146 ConstantPrimitive(Ty, Value, PoolEntryID); | 145 ConstantPrimitive(Ty, Value, PoolEntryID); |
| 147 } | 146 } |
| 148 PrimType getValue() const { return Value; } | 147 PrimType getValue() const { return Value; } |
| 149 using Constant::emit; | 148 using Constant::emit; |
| 150 // The target needs to implement this for each ConstantPrimitive | 149 void emit(TargetLowering *Target) const final; |
| 151 // specialization. | |
| 152 void emit(GlobalContext *Ctx) const override; | |
| 153 void emitWithoutDollar(GlobalContext *Ctx) const override; | |
| 154 using Constant::dump; | 150 using Constant::dump; |
| 155 void dump(const Cfg *, Ostream &Str) const override { | 151 void dump(const Cfg *, Ostream &Str) const override { |
| 156 if (ALLOW_DUMP) | 152 if (ALLOW_DUMP) |
| 157 Str << getValue(); | 153 Str << getValue(); |
| 158 } | 154 } |
| 159 | 155 |
| 160 static bool classof(const Operand *Operand) { | 156 static bool classof(const Operand *Operand) { |
| 161 return Operand->getKind() == K; | 157 return Operand->getKind() == K; |
| 162 } | 158 } |
| 163 | 159 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 "Attempt to build relocatable constant when IR generation disabled"); | 223 "Attempt to build relocatable constant when IR generation disabled"); |
| 228 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( | 224 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( |
| 229 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); | 225 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); |
| 230 } | 226 } |
| 231 | 227 |
| 232 RelocOffsetT getOffset() const { return Offset; } | 228 RelocOffsetT getOffset() const { return Offset; } |
| 233 const IceString &getName() const { return Name; } | 229 const IceString &getName() const { return Name; } |
| 234 void setSuppressMangling(bool Value) { SuppressMangling = Value; } | 230 void setSuppressMangling(bool Value) { SuppressMangling = Value; } |
| 235 bool getSuppressMangling() const { return SuppressMangling; } | 231 bool getSuppressMangling() const { return SuppressMangling; } |
| 236 using Constant::emit; | 232 using Constant::emit; |
| 233 void emit(TargetLowering *Target) const final; |
| 234 void emitWithoutPrefix(TargetLowering *Target) const; |
| 237 using Constant::dump; | 235 using Constant::dump; |
| 238 void emit(GlobalContext *Ctx) const override; | |
| 239 void emitWithoutDollar(GlobalContext *Ctx) const override; | |
| 240 void dump(const Cfg *Func, Ostream &Str) const override; | 236 void dump(const Cfg *Func, Ostream &Str) const override; |
| 241 | 237 |
| 242 static bool classof(const Operand *Operand) { | 238 static bool classof(const Operand *Operand) { |
| 243 OperandKind Kind = Operand->getKind(); | 239 OperandKind Kind = Operand->getKind(); |
| 244 return Kind == kConstRelocatable; | 240 return Kind == kConstRelocatable; |
| 245 } | 241 } |
| 246 | 242 |
| 247 private: | 243 private: |
| 248 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, | 244 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, |
| 249 bool SuppressMangling, uint32_t PoolEntryID) | 245 bool SuppressMangling, uint32_t PoolEntryID) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 265 | 261 |
| 266 public: | 262 public: |
| 267 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, | 263 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, |
| 268 uint32_t PoolEntryID) { | 264 uint32_t PoolEntryID) { |
| 269 assert(!Ctx->isIRGenerationDisabled() && | 265 assert(!Ctx->isIRGenerationDisabled() && |
| 270 "Attempt to build undefined constant when IR generation disabled"); | 266 "Attempt to build undefined constant when IR generation disabled"); |
| 271 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); | 267 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); |
| 272 } | 268 } |
| 273 | 269 |
| 274 using Constant::emit; | 270 using Constant::emit; |
| 271 void emit(TargetLowering *Target) const final; |
| 275 using Constant::dump; | 272 using Constant::dump; |
| 276 // The target needs to implement this. | |
| 277 void emit(GlobalContext *Ctx) const override; | |
| 278 void emitWithoutDollar(GlobalContext *Ctx) const override; | |
| 279 void dump(const Cfg *, Ostream &Str) const override { | 273 void dump(const Cfg *, Ostream &Str) const override { |
| 280 if (ALLOW_DUMP) | 274 if (ALLOW_DUMP) |
| 281 Str << "undef"; | 275 Str << "undef"; |
| 282 } | 276 } |
| 283 | 277 |
| 284 static bool classof(const Operand *Operand) { | 278 static bool classof(const Operand *Operand) { |
| 285 return Operand->getKind() == kConstUndef; | 279 return Operand->getKind() == kConstUndef; |
| 286 } | 280 } |
| 287 | 281 |
| 288 private: | 282 private: |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 private: | 628 private: |
| 635 const Cfg *Func; | 629 const Cfg *Func; |
| 636 MetadataKind Kind; | 630 MetadataKind Kind; |
| 637 std::vector<VariableTracking> Metadata; | 631 std::vector<VariableTracking> Metadata; |
| 638 const static InstDefList NoDefinitions; | 632 const static InstDefList NoDefinitions; |
| 639 }; | 633 }; |
| 640 | 634 |
| 641 } // end of namespace Ice | 635 } // end of namespace Ice |
| 642 | 636 |
| 643 #endif // SUBZERO_SRC_ICEOPERAND_H | 637 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |