| 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 |
| 11 // subclasses. The main classes are Variable, which represents an | 11 // subclasses. The main classes are Variable, which represents an |
| 12 // LLVM variable that is either register- or stack-allocated, and the | 12 // LLVM variable that is either register- or stack-allocated, and the |
| 13 // Constant hierarchy, which represents integer, floating-point, | 13 // Constant hierarchy, which represents integer, floating-point, |
| 14 // and/or symbolic constants. | 14 // and/or symbolic constants. |
| 15 // | 15 // |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #ifndef SUBZERO_SRC_ICEOPERAND_H | 18 #ifndef SUBZERO_SRC_ICEOPERAND_H |
| 19 #define SUBZERO_SRC_ICEOPERAND_H | 19 #define SUBZERO_SRC_ICEOPERAND_H |
| 20 | 20 |
| 21 #include "IceDefs.h" | 21 #include "IceDefs.h" |
| 22 #include "IceTypes.h" | 22 #include "IceTypes.h" |
| 23 | 23 |
| 24 namespace Ice { | 24 namespace Ice { |
| 25 | 25 |
| 26 class Operand { | 26 class Operand { |
| 27 public: | 27 public: |
| 28 static const size_t MaxTargetKinds = 10; |
| 28 enum OperandKind { | 29 enum OperandKind { |
| 29 kConst_Base, | 30 kConst_Base, |
| 30 kConstInteger32, | 31 kConstInteger32, |
| 31 kConstInteger64, | 32 kConstInteger64, |
| 32 kConstFloat, | 33 kConstFloat, |
| 33 kConstDouble, | 34 kConstDouble, |
| 34 kConstRelocatable, | 35 kConstRelocatable, |
| 35 kConstUndef, | 36 kConstUndef, |
| 36 kConst_Num, | 37 kConst_Target, // leave space for target-specific constant kinds |
| 38 kConst_Num = kConst_Target + MaxTargetKinds, |
| 37 kVariable, | 39 kVariable, |
| 40 kVariable_Target, // leave space for target-specific variable kinds |
| 41 kVariable_Num = kVariable_Target + MaxTargetKinds, |
| 38 // Target-specific operand classes use kTarget as the starting | 42 // Target-specific operand classes use kTarget as the starting |
| 39 // point for their Kind enum space. | 43 // point for their Kind enum space. |
| 40 kTarget | 44 kTarget |
| 41 }; | 45 }; |
| 42 OperandKind getKind() const { return Kind; } | 46 OperandKind getKind() const { return Kind; } |
| 43 Type getType() const { return Ty; } | 47 Type getType() const { return Ty; } |
| 44 | 48 |
| 45 // Every Operand keeps an array of the Variables referenced in | 49 // Every Operand keeps an array of the Variables referenced in |
| 46 // the operand. This is so that the liveness operations can get | 50 // the operand. This is so that the liveness operations can get |
| 47 // quick access to the variables of interest, without having to dig | 51 // quick access to the variables of interest, without having to dig |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 RangeType Range; | 336 RangeType Range; |
| 333 RegWeight Weight; | 337 RegWeight Weight; |
| 334 }; | 338 }; |
| 335 | 339 |
| 336 Ostream &operator<<(Ostream &Str, const LiveRange &L); | 340 Ostream &operator<<(Ostream &Str, const LiveRange &L); |
| 337 | 341 |
| 338 // Variable represents an operand that is register-allocated or | 342 // Variable represents an operand that is register-allocated or |
| 339 // stack-allocated. If it is register-allocated, it will ultimately | 343 // stack-allocated. If it is register-allocated, it will ultimately |
| 340 // have a non-negative RegNum field. | 344 // have a non-negative RegNum field. |
| 341 class Variable : public Operand { | 345 class Variable : public Operand { |
| 346 Variable(const Variable &) LLVM_DELETED_FUNCTION; |
| 347 Variable &operator=(const Variable &) LLVM_DELETED_FUNCTION; |
| 348 |
| 342 public: | 349 public: |
| 343 static Variable *create(Cfg *Func, Type Ty, const CfgNode *Node, SizeT Index, | 350 static Variable *create(Cfg *Func, Type Ty, const CfgNode *Node, SizeT Index, |
| 344 const IceString &Name) { | 351 const IceString &Name) { |
| 345 return new (Func->allocate<Variable>()) Variable(Ty, Node, Index, Name); | 352 return new (Func->allocate<Variable>()) |
| 353 Variable(kVariable, Ty, Node, Index, Name); |
| 346 } | 354 } |
| 347 | 355 |
| 348 SizeT getIndex() const { return Number; } | 356 SizeT getIndex() const { return Number; } |
| 349 IceString getName() const; | 357 IceString getName() const; |
| 350 void setName(IceString &NewName) { | 358 void setName(IceString &NewName) { |
| 351 // Make sure that the name can only be set once. | 359 // Make sure that the name can only be set once. |
| 352 assert(Name.empty()); | 360 assert(Name.empty()); |
| 353 Name = NewName; | 361 Name = NewName; |
| 354 } | 362 } |
| 355 | 363 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // emission. Note that only basic information is copied, in | 432 // emission. Note that only basic information is copied, in |
| 425 // particular not DefInst, IsArgument, Weight, RegisterPreference, | 433 // particular not DefInst, IsArgument, Weight, RegisterPreference, |
| 426 // AllowRegisterOverlap, LoVar, HiVar, VarsReal. | 434 // AllowRegisterOverlap, LoVar, HiVar, VarsReal. |
| 427 Variable asType(Type Ty); | 435 Variable asType(Type Ty); |
| 428 | 436 |
| 429 virtual void emit(const Cfg *Func) const; | 437 virtual void emit(const Cfg *Func) const; |
| 430 using Operand::dump; | 438 using Operand::dump; |
| 431 virtual void dump(const Cfg *Func, Ostream &Str) const; | 439 virtual void dump(const Cfg *Func, Ostream &Str) const; |
| 432 | 440 |
| 433 static bool classof(const Operand *Operand) { | 441 static bool classof(const Operand *Operand) { |
| 434 return Operand->getKind() == kVariable; | 442 OperandKind Kind = Operand->getKind(); |
| 443 return Kind >= kVariable && Kind <= kVariable_Num; |
| 435 } | 444 } |
| 436 | 445 |
| 437 // The destructor is public because of the asType() method. | 446 // The destructor is public because of the asType() method. |
| 438 virtual ~Variable() {} | 447 virtual ~Variable() {} |
| 439 | 448 |
| 440 private: | 449 protected: |
| 441 Variable(Type Ty, const CfgNode *Node, SizeT Index, const IceString &Name) | 450 Variable(OperandKind K, Type Ty, const CfgNode *Node, SizeT Index, |
| 442 : Operand(kVariable, Ty), Number(Index), Name(Name), DefInst(NULL), | 451 const IceString &Name) |
| 443 DefNode(Node), IsMultidef(false), IsArgument(false), StackOffset(0), | 452 : Operand(K, Ty), Number(Index), Name(Name), DefInst(NULL), DefNode(Node), |
| 453 IsMultidef(false), IsArgument(false), StackOffset(0), |
| 444 RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), | 454 RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), |
| 445 RegisterPreference(NULL), AllowRegisterOverlap(false), LoVar(NULL), | 455 RegisterPreference(NULL), AllowRegisterOverlap(false), LoVar(NULL), |
| 446 HiVar(NULL) { | 456 HiVar(NULL) { |
| 447 Vars = VarsReal; | 457 Vars = VarsReal; |
| 448 Vars[0] = this; | 458 Vars[0] = this; |
| 449 NumVars = 1; | 459 NumVars = 1; |
| 450 } | 460 } |
| 451 Variable(const Variable &) LLVM_DELETED_FUNCTION; | |
| 452 Variable &operator=(const Variable &) LLVM_DELETED_FUNCTION; | |
| 453 // Number is unique across all variables, and is used as a | 461 // Number is unique across all variables, and is used as a |
| 454 // (bit)vector index for liveness analysis. | 462 // (bit)vector index for liveness analysis. |
| 455 const SizeT Number; | 463 const SizeT Number; |
| 456 // Name is optional. | 464 // Name is optional. |
| 457 IceString Name; | 465 IceString Name; |
| 458 // DefInst is the instruction that produces this variable as its | 466 // DefInst is the instruction that produces this variable as its |
| 459 // dest. | 467 // dest. |
| 460 Inst *DefInst; | 468 Inst *DefInst; |
| 461 // DefNode is the node where this variable was produced, and is | 469 // DefNode is the node where this variable was produced, and is |
| 462 // reset to NULL if it is used outside that node. This is used for | 470 // reset to NULL if it is used outside that node. This is used for |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 Variable *LoVar; | 505 Variable *LoVar; |
| 498 Variable *HiVar; | 506 Variable *HiVar; |
| 499 // VarsReal (and Operand::Vars) are set up such that Vars[0] == | 507 // VarsReal (and Operand::Vars) are set up such that Vars[0] == |
| 500 // this. | 508 // this. |
| 501 Variable *VarsReal[1]; | 509 Variable *VarsReal[1]; |
| 502 }; | 510 }; |
| 503 | 511 |
| 504 } // end of namespace Ice | 512 } // end of namespace Ice |
| 505 | 513 |
| 506 #endif // SUBZERO_SRC_ICEOPERAND_H | 514 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |