OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632Traits.h - x86-32 traits -*- C++ -*-=// | 1 //===- subzero/src/IceTargetLoweringX8632Traits.h - x86-32 traits -*- 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 using XmmRegister = ::Ice::RegX8632::XmmRegister; | 65 using XmmRegister = ::Ice::RegX8632::XmmRegister; |
66 using X87STRegister = ::Ice::RegX8632::X87STRegister; | 66 using X87STRegister = ::Ice::RegX8632::X87STRegister; |
67 | 67 |
68 using Cond = ::Ice::CondX86; | 68 using Cond = ::Ice::CondX86; |
69 | 69 |
70 using RegisterSet = ::Ice::RegX8632; | 70 using RegisterSet = ::Ice::RegX8632; |
71 static const SizeT StackPtr = RegX8632::Reg_esp; | 71 static const SizeT StackPtr = RegX8632::Reg_esp; |
72 static const SizeT FramePtr = RegX8632::Reg_ebp; | 72 static const SizeT FramePtr = RegX8632::Reg_ebp; |
73 static const GPRRegister Encoded_Reg_Accumulator = RegX8632::Encoded_Reg_eax; | 73 static const GPRRegister Encoded_Reg_Accumulator = RegX8632::Encoded_Reg_eax; |
74 static const GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx; | 74 static const GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx; |
75 static const FixupKind PcRelFixup = llvm::ELF::R_386_PC32; | 75 static constexpr FixupKind FK_PcRel = llvm::ELF::R_386_PC32; |
76 static const FixupKind RelFixup = llvm::ELF::R_386_32; | 76 static constexpr FixupKind FK_Abs = llvm::ELF::R_386_32; |
| 77 static constexpr FixupKind FK_Gotoff = llvm::ELF::R_386_GOTOFF; |
| 78 static constexpr FixupKind FK_GotPC = llvm::ELF::R_386_GOTPC; |
77 | 79 |
78 class Operand { | 80 class Operand { |
79 public: | 81 public: |
80 Operand(const Operand &other) | 82 Operand(const Operand &other) |
81 : fixup_(other.fixup_), length_(other.length_) { | 83 : fixup_(other.fixup_), length_(other.length_) { |
82 memmove(&encoding_[0], &other.encoding_[0], other.length_); | 84 memmove(&encoding_[0], &other.encoding_[0], other.length_); |
83 } | 85 } |
84 | 86 |
85 Operand &operator=(const Operand &other) { | 87 Operand &operator=(const Operand &other) { |
86 length_ = other.length_; | 88 length_ = other.length_; |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 enum SegmentRegisters { | 732 enum SegmentRegisters { |
731 DefaultSegment = -1, | 733 DefaultSegment = -1, |
732 #define X(val, name, prefix) val, | 734 #define X(val, name, prefix) val, |
733 SEG_REGX8632_TABLE | 735 SEG_REGX8632_TABLE |
734 #undef X | 736 #undef X |
735 SegReg_NUM | 737 SegReg_NUM |
736 }; | 738 }; |
737 static X86OperandMem *create(Cfg *Func, Type Ty, Variable *Base, | 739 static X86OperandMem *create(Cfg *Func, Type Ty, Variable *Base, |
738 Constant *Offset, Variable *Index = nullptr, | 740 Constant *Offset, Variable *Index = nullptr, |
739 uint16_t Shift = 0, | 741 uint16_t Shift = 0, |
740 SegmentRegisters SegmentReg = DefaultSegment) { | 742 SegmentRegisters SegmentReg = DefaultSegment, |
741 return new (Func->allocate<X86OperandMem>()) | 743 bool IsPIC = false) { |
742 X86OperandMem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); | 744 return new (Func->allocate<X86OperandMem>()) X86OperandMem( |
| 745 Func, Ty, Base, Offset, Index, Shift, SegmentReg, IsPIC); |
743 } | 746 } |
744 Variable *getBase() const { return Base; } | 747 Variable *getBase() const { return Base; } |
745 Constant *getOffset() const { return Offset; } | 748 Constant *getOffset() const { return Offset; } |
746 Variable *getIndex() const { return Index; } | 749 Variable *getIndex() const { return Index; } |
747 uint16_t getShift() const { return Shift; } | 750 uint16_t getShift() const { return Shift; } |
748 SegmentRegisters getSegmentRegister() const { return SegmentReg; } | 751 SegmentRegisters getSegmentRegister() const { return SegmentReg; } |
749 void emitSegmentOverride(Assembler *Asm) const; | 752 void emitSegmentOverride(Assembler *Asm) const; |
| 753 void setIsPIC() { IsPIC = true; } |
| 754 bool getIsPIC() const { return IsPIC; } |
750 Address toAsmAddress(Assembler *Asm, | 755 Address toAsmAddress(Assembler *Asm, |
751 const Ice::TargetLowering *Target) const; | 756 const Ice::TargetLowering *Target) const; |
752 | 757 |
753 void emit(const Cfg *Func) const override; | 758 void emit(const Cfg *Func) const override; |
754 using X86Operand::dump; | 759 using X86Operand::dump; |
755 void dump(const Cfg *Func, Ostream &Str) const override; | 760 void dump(const Cfg *Func, Ostream &Str) const override; |
756 | 761 |
757 static bool classof(const Operand *Operand) { | 762 static bool classof(const Operand *Operand) { |
758 return Operand->getKind() == static_cast<OperandKind>(kMem); | 763 return Operand->getKind() == static_cast<OperandKind>(kMem); |
759 } | 764 } |
760 | 765 |
761 void setRandomized(bool R) { Randomized = R; } | 766 void setRandomized(bool R) { Randomized = R; } |
762 | 767 |
763 bool getRandomized() const { return Randomized; } | 768 bool getRandomized() const { return Randomized; } |
764 | 769 |
765 private: | 770 private: |
766 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, | 771 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, |
767 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); | 772 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg, |
| 773 bool IsPIC); |
768 | 774 |
769 Variable *Base; | 775 Variable *Base; |
770 Constant *Offset; | 776 Constant *Offset; |
771 Variable *Index; | 777 Variable *Index; |
772 uint16_t Shift; | 778 uint16_t Shift; |
773 SegmentRegisters SegmentReg : 16; | 779 SegmentRegisters SegmentReg : 16; |
| 780 bool IsPIC; |
774 /// A flag to show if this memory operand is a randomized one. Randomized | 781 /// A flag to show if this memory operand is a randomized one. Randomized |
775 /// memory operands are generated in | 782 /// memory operands are generated in |
776 /// TargetX86Base::randomizeOrPoolImmediate() | 783 /// TargetX86Base::randomizeOrPoolImmediate() |
777 bool Randomized; | 784 bool Randomized = false; |
778 }; | 785 }; |
779 | 786 |
780 /// VariableSplit is a way to treat an f64 memory location as a pair of i32 | 787 /// VariableSplit is a way to treat an f64 memory location as a pair of i32 |
781 /// locations (Low and High). This is needed for some cases of the Bitcast | 788 /// locations (Low and High). This is needed for some cases of the Bitcast |
782 /// instruction. Since it's not possible for integer registers to access the | 789 /// instruction. Since it's not possible for integer registers to access the |
783 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to | 790 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to |
784 /// the stack and then accesses through the VariableSplit. | 791 /// the stack and then accesses through the VariableSplit. |
785 // TODO(jpp): remove references to VariableSplit from IceInstX86Base as 64bit | 792 // TODO(jpp): remove references to VariableSplit from IceInstX86Base as 64bit |
786 // targets can natively handle these. | 793 // targets can natively handle these. |
787 class VariableSplit : public X86Operand { | 794 class VariableSplit : public X86Operand { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 884 |
878 } // end of namespace X86Internal | 885 } // end of namespace X86Internal |
879 | 886 |
880 namespace X8632 { | 887 namespace X8632 { |
881 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8632>; | 888 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8632>; |
882 } // end of namespace X8632 | 889 } // end of namespace X8632 |
883 | 890 |
884 } // end of namespace Ice | 891 } // end of namespace Ice |
885 | 892 |
886 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H | 893 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H |
OLD | NEW |