Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: src/IceTargetLoweringX8632Traits.h

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fill in part of the lit test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 using GPRRegister = ::Ice::RegX8632::GPRRegister; 63 using GPRRegister = ::Ice::RegX8632::GPRRegister;
64 using ByteRegister = ::Ice::RegX8632::ByteRegister; 64 using ByteRegister = ::Ice::RegX8632::ByteRegister;
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 GPRRegister Encoded_Reg_Accumulator = RegX8632::Encoded_Reg_eax; 71 static const GPRRegister Encoded_Reg_Accumulator = RegX8632::Encoded_Reg_eax;
72 static const GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx; 72 static const GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx;
73 static const FixupKind PcRelFixup = llvm::ELF::R_386_PC32; 73 static constexpr FixupKind FixupKindPcRel = llvm::ELF::R_386_PC32;
74 static const FixupKind RelFixup = llvm::ELF::R_386_32; 74 static constexpr FixupKind FixupKindAbs = llvm::ELF::R_386_32;
75 static constexpr FixupKind FixupKindGotoff = llvm::ELF::R_386_GOTOFF;
76 static constexpr FixupKind FixupKindGotPC = llvm::ELF::R_386_GOTPC;
75 77
76 class Operand { 78 class Operand {
77 public: 79 public:
78 Operand(const Operand &other) 80 Operand(const Operand &other)
79 : fixup_(other.fixup_), length_(other.length_) { 81 : fixup_(other.fixup_), length_(other.length_) {
80 memmove(&encoding_[0], &other.encoding_[0], other.length_); 82 memmove(&encoding_[0], &other.encoding_[0], other.length_);
81 } 83 }
82 84
83 Operand &operator=(const Operand &other) { 85 Operand &operator=(const Operand &other) {
84 length_ = other.length_; 86 length_ = other.length_;
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 enum SegmentRegisters { 722 enum SegmentRegisters {
721 DefaultSegment = -1, 723 DefaultSegment = -1,
722 #define X(val, name, prefix) val, 724 #define X(val, name, prefix) val,
723 SEG_REGX8632_TABLE 725 SEG_REGX8632_TABLE
724 #undef X 726 #undef X
725 SegReg_NUM 727 SegReg_NUM
726 }; 728 };
727 static X86OperandMem *create(Cfg *Func, Type Ty, Variable *Base, 729 static X86OperandMem *create(Cfg *Func, Type Ty, Variable *Base,
728 Constant *Offset, Variable *Index = nullptr, 730 Constant *Offset, Variable *Index = nullptr,
729 uint16_t Shift = 0, 731 uint16_t Shift = 0,
730 SegmentRegisters SegmentReg = DefaultSegment) { 732 SegmentRegisters SegmentReg = DefaultSegment,
731 return new (Func->allocate<X86OperandMem>()) 733 bool IsPIC = false) {
732 X86OperandMem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); 734 return new (Func->allocate<X86OperandMem>()) X86OperandMem(
735 Func, Ty, Base, Offset, Index, Shift, SegmentReg, IsPIC);
733 } 736 }
734 Variable *getBase() const { return Base; } 737 Variable *getBase() const { return Base; }
735 Constant *getOffset() const { return Offset; } 738 Constant *getOffset() const { return Offset; }
736 Variable *getIndex() const { return Index; } 739 Variable *getIndex() const { return Index; }
737 uint16_t getShift() const { return Shift; } 740 uint16_t getShift() const { return Shift; }
738 SegmentRegisters getSegmentRegister() const { return SegmentReg; } 741 SegmentRegisters getSegmentRegister() const { return SegmentReg; }
739 void emitSegmentOverride(Assembler *Asm) const; 742 void emitSegmentOverride(Assembler *Asm) const;
743 void setIsPIC() { IsPIC = true; }
744 bool getIsPIC() const { return IsPIC; }
740 Address toAsmAddress(Assembler *Asm, 745 Address toAsmAddress(Assembler *Asm,
741 const Ice::TargetLowering *Target) const; 746 const Ice::TargetLowering *Target) const;
742 747
743 void emit(const Cfg *Func) const override; 748 void emit(const Cfg *Func) const override;
744 using X86Operand::dump; 749 using X86Operand::dump;
745 void dump(const Cfg *Func, Ostream &Str) const override; 750 void dump(const Cfg *Func, Ostream &Str) const override;
746 751
747 static bool classof(const Operand *Operand) { 752 static bool classof(const Operand *Operand) {
748 return Operand->getKind() == static_cast<OperandKind>(kMem); 753 return Operand->getKind() == static_cast<OperandKind>(kMem);
749 } 754 }
750 755
751 void setRandomized(bool R) { Randomized = R; } 756 void setRandomized(bool R) { Randomized = R; }
752 757
753 bool getRandomized() const { return Randomized; } 758 bool getRandomized() const { return Randomized; }
754 759
755 private: 760 private:
756 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, 761 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset,
757 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); 762 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg,
763 bool IsPIC);
758 764
759 Variable *Base; 765 Variable *Base;
760 Constant *Offset; 766 Constant *Offset;
761 Variable *Index; 767 Variable *Index;
762 uint16_t Shift; 768 uint16_t Shift;
763 SegmentRegisters SegmentReg : 16; 769 SegmentRegisters SegmentReg : 16;
770 bool IsPIC;
764 /// A flag to show if this memory operand is a randomized one. Randomized 771 /// A flag to show if this memory operand is a randomized one. Randomized
765 /// memory operands are generated in 772 /// memory operands are generated in
766 /// TargetX86Base::randomizeOrPoolImmediate() 773 /// TargetX86Base::randomizeOrPoolImmediate()
767 bool Randomized; 774 bool Randomized = false;
768 }; 775 };
769 776
770 /// VariableSplit is a way to treat an f64 memory location as a pair of i32 777 /// VariableSplit is a way to treat an f64 memory location as a pair of i32
771 /// locations (Low and High). This is needed for some cases of the Bitcast 778 /// locations (Low and High). This is needed for some cases of the Bitcast
772 /// instruction. Since it's not possible for integer registers to access the 779 /// instruction. Since it's not possible for integer registers to access the
773 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to 780 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to
774 /// the stack and then accesses through the VariableSplit. 781 /// the stack and then accesses through the VariableSplit.
775 // TODO(jpp): remove references to VariableSplit from IceInstX86Base as 64bit 782 // TODO(jpp): remove references to VariableSplit from IceInstX86Base as 64bit
776 // targets can natively handle these. 783 // targets can natively handle these.
777 class VariableSplit : public X86Operand { 784 class VariableSplit : public X86Operand {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 874
868 } // end of namespace X86Internal 875 } // end of namespace X86Internal
869 876
870 namespace X8632 { 877 namespace X8632 {
871 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8632>; 878 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8632>;
872 } // end of namespace X8632 879 } // end of namespace X8632
873 880
874 } // end of namespace Ice 881 } // end of namespace Ice
875 882
876 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H 883 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698