Chromium Code Reviews| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 | 381 |
| 382 // Variable represents an operand that is register-allocated or | 382 // Variable represents an operand that is register-allocated or |
| 383 // stack-allocated. If it is register-allocated, it will ultimately | 383 // stack-allocated. If it is register-allocated, it will ultimately |
| 384 // have a non-negative RegNum field. | 384 // have a non-negative RegNum field. |
| 385 class Variable : public Operand { | 385 class Variable : public Operand { |
| 386 Variable(const Variable &) = delete; | 386 Variable(const Variable &) = delete; |
| 387 Variable &operator=(const Variable &) = delete; | 387 Variable &operator=(const Variable &) = delete; |
| 388 Variable(Variable &&V) = default; | 388 Variable(Variable &&V) = default; |
| 389 | 389 |
| 390 public: | 390 public: |
| 391 static Variable *create(Cfg *Func, Type Ty, SizeT Index, | 391 static Variable *create(Cfg *Func, Type Ty, SizeT Index) { |
| 392 const IceString &Name) { | 392 return new (Func->allocate<Variable>()) Variable(kVariable, Ty, Index); |
| 393 return new (Func->allocate<Variable>()) | |
| 394 Variable(kVariable, Ty, Index, Name); | |
| 395 } | 393 } |
| 396 | 394 |
| 397 SizeT getIndex() const { return Number; } | 395 SizeT getIndex() const { return Number; } |
| 398 IceString getName() const; | 396 IceString getName(const Cfg *Func) const; |
| 399 void setName(IceString &NewName) { | 397 void setName(Cfg *Func, const IceString &NewName) { |
| 400 // Make sure that the name can only be set once. | 398 // Make sure that the name can only be set once. |
| 401 assert(Name.empty()); | 399 assert(NameIndex == Cfg::IdentifierIndexInvalid); |
| 402 Name = NewName; | 400 if (!NewName.empty()) |
| 401 NameIndex = Func->addIdentifierName(NewName); | |
| 403 } | 402 } |
| 404 | 403 |
| 405 bool getIsArg() const { return IsArgument; } | 404 bool getIsArg() const { return IsArgument; } |
| 406 void setIsArg(bool Val = true) { IsArgument = Val; } | 405 void setIsArg(bool Val = true) { IsArgument = Val; } |
| 407 bool getIsImplicitArg() const { return IsImplicitArgument; } | 406 bool getIsImplicitArg() const { return IsImplicitArgument; } |
| 408 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } | 407 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } |
| 409 | 408 |
| 410 void setIgnoreLiveness() { IgnoreLiveness = true; } | 409 void setIgnoreLiveness() { IgnoreLiveness = true; } |
| 411 bool getIgnoreLiveness() const { return IgnoreLiveness; } | 410 bool getIgnoreLiveness() const { return IgnoreLiveness; } |
| 412 | 411 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 | 476 |
| 478 static bool classof(const Operand *Operand) { | 477 static bool classof(const Operand *Operand) { |
| 479 OperandKind Kind = Operand->getKind(); | 478 OperandKind Kind = Operand->getKind(); |
| 480 return Kind >= kVariable && Kind <= kVariable_Num; | 479 return Kind >= kVariable && Kind <= kVariable_Num; |
| 481 } | 480 } |
| 482 | 481 |
| 483 // The destructor is public because of the asType() method. | 482 // The destructor is public because of the asType() method. |
| 484 ~Variable() override {} | 483 ~Variable() override {} |
| 485 | 484 |
| 486 protected: | 485 protected: |
| 487 Variable(OperandKind K, Type Ty, SizeT Index, const IceString &Name) | 486 Variable(OperandKind K, Type Ty, SizeT Index) |
| 488 : Operand(K, Ty), Number(Index), Name(Name), IsArgument(false), | 487 : Operand(K, Ty), Number(Index), NameIndex(Cfg::IdentifierIndexInvalid), |
| 489 IsImplicitArgument(false), IgnoreLiveness(false), StackOffset(0), | 488 IsArgument(false), IsImplicitArgument(false), IgnoreLiveness(false), |
| 490 RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), LoVar(NULL), | 489 StackOffset(0), RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), |
| 491 HiVar(NULL) { | 490 LoVar(NULL), HiVar(NULL) { |
| 492 Vars = VarsReal; | 491 Vars = VarsReal; |
| 493 Vars[0] = this; | 492 Vars[0] = this; |
| 494 NumVars = 1; | 493 NumVars = 1; |
| 495 } | 494 } |
| 496 // Number is unique across all variables, and is used as a | 495 // Number is unique across all variables, and is used as a |
| 497 // (bit)vector index for liveness analysis. | 496 // (bit)vector index for liveness analysis. |
| 498 const SizeT Number; | 497 const SizeT Number; |
| 499 // Name is optional. | 498 Cfg::IdentifierIndexType NameIndex; |
| 500 IceString Name; | |
|
JF
2014/12/11 23:45:19
That would allow you to remove the ugly default mo
Jim Stichnoth
2014/12/11 23:51:25
Unfortunately, Variable::Live is still there and i
| |
| 501 bool IsArgument; | 499 bool IsArgument; |
| 502 bool IsImplicitArgument; | 500 bool IsImplicitArgument; |
| 503 // IgnoreLiveness means that the variable should be ignored when | 501 // IgnoreLiveness means that the variable should be ignored when |
| 504 // constructing and validating live ranges. This is usually | 502 // constructing and validating live ranges. This is usually |
| 505 // reserved for the stack pointer. | 503 // reserved for the stack pointer. |
| 506 bool IgnoreLiveness; | 504 bool IgnoreLiveness; |
| 507 // StackOffset is the canonical location on stack (only if | 505 // StackOffset is the canonical location on stack (only if |
| 508 // RegNum==NoRegister || IsArgument). | 506 // RegNum==NoRegister || IsArgument). |
| 509 int32_t StackOffset; | 507 int32_t StackOffset; |
| 510 // RegNum is the allocated register, or NoRegister if it isn't | 508 // RegNum is the allocated register, or NoRegister if it isn't |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 private: | 631 private: |
| 634 const Cfg *Func; | 632 const Cfg *Func; |
| 635 MetadataKind Kind; | 633 MetadataKind Kind; |
| 636 std::vector<VariableTracking> Metadata; | 634 std::vector<VariableTracking> Metadata; |
| 637 const static InstDefList NoDefinitions; | 635 const static InstDefList NoDefinitions; |
| 638 }; | 636 }; |
| 639 | 637 |
| 640 } // end of namespace Ice | 638 } // end of namespace Ice |
| 641 | 639 |
| 642 #endif // SUBZERO_SRC_ICEOPERAND_H | 640 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |