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 /// \file | 10 /// \file |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 bool getIgnoreLiveness() const { return IgnoreLiveness; } | 527 bool getIgnoreLiveness() const { return IgnoreLiveness; } |
528 | 528 |
529 int32_t getStackOffset() const { return StackOffset; } | 529 int32_t getStackOffset() const { return StackOffset; } |
530 void setStackOffset(int32_t Offset) { StackOffset = Offset; } | 530 void setStackOffset(int32_t Offset) { StackOffset = Offset; } |
531 /// Returns the variable's stack offset in symbolic form, to improve | 531 /// Returns the variable's stack offset in symbolic form, to improve |
532 /// readability in DecorateAsm mode. | 532 /// readability in DecorateAsm mode. |
533 IceString getSymbolicStackOffset(const Cfg *Func) const { | 533 IceString getSymbolicStackOffset(const Cfg *Func) const { |
534 return "lv$" + getName(Func); | 534 return "lv$" + getName(Func); |
535 } | 535 } |
536 | 536 |
537 static constexpr int32_t NoRegister = -1; | 537 bool hasReg() const { return getRegNum() != RegNumT::NoRegister; } |
538 bool hasReg() const { return getRegNum() != NoRegister; } | 538 RegNumT getRegNum() const { return RegNum; } |
539 int32_t getRegNum() const { return RegNum; } | 539 void setRegNum(RegNumT NewRegNum) { |
540 void setRegNum(int32_t NewRegNum) { | |
541 // Regnum shouldn't be set more than once. | 540 // Regnum shouldn't be set more than once. |
542 assert(!hasReg() || RegNum == NewRegNum); | 541 assert(!hasReg() || RegNum == NewRegNum); |
543 RegNum = NewRegNum; | 542 RegNum = NewRegNum; |
544 } | 543 } |
545 bool hasRegTmp() const { return getRegNumTmp() != NoRegister; } | 544 bool hasRegTmp() const { return getRegNumTmp() != RegNumT::NoRegister; } |
546 int32_t getRegNumTmp() const { return RegNumTmp; } | 545 RegNumT getRegNumTmp() const { return RegNumTmp; } |
547 void setRegNumTmp(int32_t NewRegNum) { RegNumTmp = NewRegNum; } | 546 void setRegNumTmp(RegNumT NewRegNum) { RegNumTmp = NewRegNum; } |
548 | 547 |
549 RegWeight getWeight(const Cfg *Func) const; | 548 RegWeight getWeight(const Cfg *Func) const; |
550 | 549 |
551 void setMustHaveReg() { RegRequirement = RR_MustHaveRegister; } | 550 void setMustHaveReg() { RegRequirement = RR_MustHaveRegister; } |
552 bool mustHaveReg() const { return RegRequirement == RR_MustHaveRegister; } | 551 bool mustHaveReg() const { return RegRequirement == RR_MustHaveRegister; } |
553 void setMustNotHaveReg() { RegRequirement = RR_MustNotHaveRegister; } | 552 void setMustNotHaveReg() { RegRequirement = RR_MustNotHaveRegister; } |
554 bool mustNotHaveReg() const { | 553 bool mustNotHaveReg() const { |
555 return RegRequirement == RR_MustNotHaveRegister; | 554 return RegRequirement == RR_MustNotHaveRegister; |
556 } | 555 } |
557 void setRematerializable(int32_t NewRegNum, int32_t NewOffset) { | 556 void setRematerializable(RegNumT NewRegNum, int32_t NewOffset) { |
558 IsRematerializable = true; | 557 IsRematerializable = true; |
559 setRegNum(NewRegNum); | 558 setRegNum(NewRegNum); |
560 setStackOffset(NewOffset); | 559 setStackOffset(NewOffset); |
561 setMustHaveReg(); | 560 setMustHaveReg(); |
562 } | 561 } |
563 bool isRematerializable() const { return IsRematerializable; } | 562 bool isRematerializable() const { return IsRematerializable; } |
564 | 563 |
565 void setRegClass(uint8_t RC) { RegisterClass = static_cast<RegClass>(RC); } | 564 void setRegClass(uint8_t RC) { RegisterClass = static_cast<RegClass>(RC); } |
566 RegClass getRegClass() const { return RegisterClass; } | 565 RegClass getRegClass() const { return RegisterClass; } |
567 | 566 |
(...skipping 18 matching lines...) Expand all Loading... |
586 constexpr bool UseTrimmed = true; | 585 constexpr bool UseTrimmed = true; |
587 return Live.overlapsInst(Other->Live.getStart(), UseTrimmed); | 586 return Live.overlapsInst(Other->Live.getStart(), UseTrimmed); |
588 } | 587 } |
589 | 588 |
590 /// Creates a temporary copy of the variable with a different type. Used | 589 /// Creates a temporary copy of the variable with a different type. Used |
591 /// primarily for syntactic correctness of textual assembly emission. Note | 590 /// primarily for syntactic correctness of textual assembly emission. Note |
592 /// that only basic information is copied, in particular not IsArgument, | 591 /// that only basic information is copied, in particular not IsArgument, |
593 /// IsImplicitArgument, IgnoreLiveness, RegNumTmp, Live, LoVar, HiVar, | 592 /// IsImplicitArgument, IgnoreLiveness, RegNumTmp, Live, LoVar, HiVar, |
594 /// VarsReal. If NewRegNum!=NoRegister, then that register assignment is made | 593 /// VarsReal. If NewRegNum!=NoRegister, then that register assignment is made |
595 /// instead of copying the existing assignment. | 594 /// instead of copying the existing assignment. |
596 const Variable *asType(Type Ty, int32_t NewRegNum) const; | 595 const Variable *asType(Type Ty, RegNumT NewRegNum) const; |
597 | 596 |
598 void emit(const Cfg *Func) const override; | 597 void emit(const Cfg *Func) const override; |
599 using Operand::dump; | 598 using Operand::dump; |
600 void dump(const Cfg *Func, Ostream &Str) const override; | 599 void dump(const Cfg *Func, Ostream &Str) const override; |
601 | 600 |
602 /// Return reg num of base register, if different from stack/frame register. | 601 /// Return reg num of base register, if different from stack/frame register. |
603 virtual int32_t getBaseRegNum() const { return NoRegister; } | 602 virtual RegNumT getBaseRegNum() const { return RegNumT::NoRegister; } |
604 | 603 |
605 static bool classof(const Operand *Operand) { | 604 static bool classof(const Operand *Operand) { |
606 OperandKind Kind = Operand->getKind(); | 605 OperandKind Kind = Operand->getKind(); |
607 return Kind >= kVariable && Kind <= kVariable_Max; | 606 return Kind >= kVariable && Kind <= kVariable_Max; |
608 } | 607 } |
609 | 608 |
610 protected: | 609 protected: |
611 Variable(OperandKind K, Type Ty, SizeT Index) | 610 Variable(OperandKind K, Type Ty, SizeT Index) |
612 : Operand(K, Ty), Number(Index), | 611 : Operand(K, Ty), Number(Index), |
613 RegisterClass(static_cast<RegClass>(Ty)) { | 612 RegisterClass(static_cast<RegClass>(Ty)) { |
(...skipping 11 matching lines...) Expand all Loading... |
625 /// and validating live ranges. This is usually reserved for the stack | 624 /// and validating live ranges. This is usually reserved for the stack |
626 /// pointer and other physical registers specifically referenced by name. | 625 /// pointer and other physical registers specifically referenced by name. |
627 bool IgnoreLiveness = false; | 626 bool IgnoreLiveness = false; |
628 // If IsRematerializable, RegNum keeps track of which register (stack or frame | 627 // If IsRematerializable, RegNum keeps track of which register (stack or frame |
629 // pointer), and StackOffset is the known offset from that register. | 628 // pointer), and StackOffset is the known offset from that register. |
630 bool IsRematerializable = false; | 629 bool IsRematerializable = false; |
631 RegRequirement RegRequirement = RR_MayHaveRegister; | 630 RegRequirement RegRequirement = RR_MayHaveRegister; |
632 RegClass RegisterClass; | 631 RegClass RegisterClass; |
633 /// RegNum is the allocated register, or NoRegister if it isn't | 632 /// RegNum is the allocated register, or NoRegister if it isn't |
634 /// register-allocated. | 633 /// register-allocated. |
635 int32_t RegNum = NoRegister; | 634 RegNumT RegNum = RegNumT::NoRegister; |
636 /// RegNumTmp is the tentative assignment during register allocation. | 635 /// RegNumTmp is the tentative assignment during register allocation. |
637 int32_t RegNumTmp = NoRegister; | 636 RegNumT RegNumTmp = RegNumT::NoRegister; |
638 /// StackOffset is the canonical location on stack (only if | 637 /// StackOffset is the canonical location on stack (only if |
639 /// RegNum==NoRegister || IsArgument). | 638 /// RegNum==NoRegister || IsArgument). |
640 int32_t StackOffset = 0; | 639 int32_t StackOffset = 0; |
641 LiveRange Live; | 640 LiveRange Live; |
642 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. | 641 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. |
643 Variable *VarsReal[1]; | 642 Variable *VarsReal[1]; |
644 }; | 643 }; |
645 | 644 |
646 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In | 645 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In |
647 // this situation the variable must be split into a low and a high word. | 646 // this situation the variable must be split into a low and a high word. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 private: | 811 private: |
813 const Cfg *Func; | 812 const Cfg *Func; |
814 MetadataKind Kind; | 813 MetadataKind Kind; |
815 CfgVector<VariableTracking> Metadata; | 814 CfgVector<VariableTracking> Metadata; |
816 const static InstDefList NoDefinitions; | 815 const static InstDefList NoDefinitions; |
817 }; | 816 }; |
818 | 817 |
819 } // end of namespace Ice | 818 } // end of namespace Ice |
820 | 819 |
821 #endif // SUBZERO_SRC_ICEOPERAND_H | 820 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |