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

Side by Side Diff: src/IceTargetLoweringX8664Traits.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/IceTargetLoweringX8664Traits.h - x86-64 traits -*- C++ -*-=// 1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 using GPRRegister = ::Ice::RegX8664::GPRRegister; 63 using GPRRegister = ::Ice::RegX8664::GPRRegister;
64 using ByteRegister = ::Ice::RegX8664::ByteRegister; 64 using ByteRegister = ::Ice::RegX8664::ByteRegister;
65 using XmmRegister = ::Ice::RegX8664::XmmRegister; 65 using XmmRegister = ::Ice::RegX8664::XmmRegister;
66 66
67 using Cond = ::Ice::CondX8664; 67 using Cond = ::Ice::CondX8664;
68 68
69 using RegisterSet = ::Ice::RegX8664; 69 using RegisterSet = ::Ice::RegX8664;
70 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax; 70 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax;
71 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx; 71 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx;
72 static const FixupKind PcRelFixup = llvm::ELF::R_X86_64_PC32; 72 static constexpr FixupKind FixupKindPcRel = llvm::ELF::R_X86_64_PC32;
73 static const FixupKind RelFixup = llvm::ELF::R_X86_64_32S; 73 static constexpr FixupKind FixupKindAbs = llvm::ELF::R_X86_64_32S;
74 static constexpr FixupKind FixupKindGotoff = llvm::ELF::R_X86_64_GOTOFF64;
75 static constexpr FixupKind FixupKindGotPC = llvm::ELF::R_X86_64_GOTPC32;
74 76
75 class Operand { 77 class Operand {
76 public: 78 public:
77 enum RexBits { 79 enum RexBits {
78 RexNone = 0x00, 80 RexNone = 0x00,
79 RexBase = 0x40, 81 RexBase = 0x40,
80 RexW = RexBase | (1 << 3), 82 RexW = RexBase | (1 << 3),
81 RexR = RexBase | (1 << 2), 83 RexR = RexBase | (1 << 2),
82 RexX = RexBase | (1 << 1), 84 RexX = RexBase | (1 << 1),
83 RexB = RexBase | (1 << 0), 85 RexB = RexBase | (1 << 0),
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 SetModRM(0, RegX8664::Encoded_Reg_ebp); 260 SetModRM(0, RegX8664::Encoded_Reg_ebp);
259 // Use the Offset in the displacement for now. If we decide to process 261 // Use the Offset in the displacement for now. If we decide to process
260 // fixups later, we'll need to patch up the emitted displacement. 262 // fixups later, we'll need to patch up the emitted displacement.
261 SetDisp32(Offset); 263 SetDisp32(Offset);
262 if (Fixup) 264 if (Fixup)
263 SetFixup(Fixup); 265 SetFixup(Fixup);
264 } 266 }
265 267
266 static Address ofConstPool(Assembler *Asm, const Constant *Imm) { 268 static Address ofConstPool(Assembler *Asm, const Constant *Imm) {
267 // TODO(jpp): ??? 269 // TODO(jpp): ???
268 AssemblerFixup *Fixup = Asm->createFixup(RelFixup, Imm); 270 AssemblerFixup *Fixup = Asm->createFixup(FixupKindAbs, Imm);
269 const RelocOffsetT Offset = 4; 271 const RelocOffsetT Offset = 4;
270 return Address(Offset, Fixup); 272 return Address(Offset, Fixup);
271 } 273 }
272 }; 274 };
273 275
274 //---------------------------------------------------------------------------- 276 //----------------------------------------------------------------------------
275 // __ ______ __ __ ______ ______ __ __ __ ______ 277 // __ ______ __ __ ______ ______ __ __ __ ______
276 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ 278 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\
277 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ 279 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \
278 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ 280 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 class X86OperandMem : public X86Operand { 700 class X86OperandMem : public X86Operand {
699 X86OperandMem() = delete; 701 X86OperandMem() = delete;
700 X86OperandMem(const X86OperandMem &) = delete; 702 X86OperandMem(const X86OperandMem &) = delete;
701 X86OperandMem &operator=(const X86OperandMem &) = delete; 703 X86OperandMem &operator=(const X86OperandMem &) = delete;
702 704
703 public: 705 public:
704 enum SegmentRegisters { DefaultSegment = -1, SegReg_NUM }; 706 enum SegmentRegisters { DefaultSegment = -1, SegReg_NUM };
705 static X86OperandMem * 707 static X86OperandMem *
706 create(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, 708 create(Cfg *Func, Type Ty, Variable *Base, Constant *Offset,
707 Variable *Index = nullptr, uint16_t Shift = 0, 709 Variable *Index = nullptr, uint16_t Shift = 0,
708 SegmentRegisters SegmentRegister = DefaultSegment) { 710 SegmentRegisters SegmentRegister = DefaultSegment,
711 bool IsPIC = false) {
709 assert(SegmentRegister == DefaultSegment); 712 assert(SegmentRegister == DefaultSegment);
710 (void)SegmentRegister; 713 (void)SegmentRegister;
711 return new (Func->allocate<X86OperandMem>()) 714 return new (Func->allocate<X86OperandMem>())
712 X86OperandMem(Func, Ty, Base, Offset, Index, Shift); 715 X86OperandMem(Func, Ty, Base, Offset, Index, Shift, IsPIC);
713 } 716 }
714 Variable *getBase() const { return Base; } 717 Variable *getBase() const { return Base; }
715 Constant *getOffset() const { return Offset; } 718 Constant *getOffset() const { return Offset; }
716 Variable *getIndex() const { return Index; } 719 Variable *getIndex() const { return Index; }
717 uint16_t getShift() const { return Shift; } 720 uint16_t getShift() const { return Shift; }
718 SegmentRegisters getSegmentRegister() const { return DefaultSegment; } 721 SegmentRegisters getSegmentRegister() const { return DefaultSegment; }
719 void emitSegmentOverride(Assembler *) const {} 722 void emitSegmentOverride(Assembler *) const {}
723 void setIsPIC() { IsPIC = true; }
724 bool getIsPIC() const { return IsPIC; }
720 Address toAsmAddress(Assembler *Asm, 725 Address toAsmAddress(Assembler *Asm,
721 const Ice::TargetLowering *Target) const; 726 const Ice::TargetLowering *Target) const;
722 727
723 void emit(const Cfg *Func) const override; 728 void emit(const Cfg *Func) const override;
724 using X86Operand::dump; 729 using X86Operand::dump;
725 void dump(const Cfg *Func, Ostream &Str) const override; 730 void dump(const Cfg *Func, Ostream &Str) const override;
726 731
727 static bool classof(const Operand *Operand) { 732 static bool classof(const Operand *Operand) {
728 return Operand->getKind() == static_cast<OperandKind>(kMem); 733 return Operand->getKind() == static_cast<OperandKind>(kMem);
729 } 734 }
730 735
731 void setRandomized(bool R) { Randomized = R; } 736 void setRandomized(bool R) { Randomized = R; }
732 737
733 bool getRandomized() const { return Randomized; } 738 bool getRandomized() const { return Randomized; }
734 739
735 private: 740 private:
736 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, 741 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset,
737 Variable *Index, uint16_t Shift); 742 Variable *Index, uint16_t Shift, bool IsPIC);
738 743
739 Variable *Base; 744 Variable *Base;
740 Constant *Offset; 745 Constant *Offset;
741 Variable *Index; 746 Variable *Index;
742 uint16_t Shift; 747 uint16_t Shift;
748 bool IsPIC;
743 /// A flag to show if this memory operand is a randomized one. Randomized 749 /// A flag to show if this memory operand is a randomized one. Randomized
744 /// memory operands are generated in 750 /// memory operands are generated in
745 /// TargetX86Base::randomizeOrPoolImmediate() 751 /// TargetX86Base::randomizeOrPoolImmediate()
746 bool Randomized = false; 752 bool Randomized = false;
747 }; 753 };
748 754
749 /// VariableSplit is a way to treat an f64 memory location as a pair of i32 755 /// VariableSplit is a way to treat an f64 memory location as a pair of i32
750 /// locations (Low and High). This is needed for some cases of the Bitcast 756 /// locations (Low and High). This is needed for some cases of the Bitcast
751 /// instruction. Since it's not possible for integer registers to access the 757 /// instruction. Since it's not possible for integer registers to access the
752 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to 758 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 848
843 } // end of namespace X86Internal 849 } // end of namespace X86Internal
844 850
845 namespace X8664 { 851 namespace X8664 {
846 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; 852 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>;
847 } // end of namespace X8664 853 } // end of namespace X8664
848 854
849 } // end of namespace Ice 855 } // end of namespace Ice
850 856
851 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H 857 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698