| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 }; | 61 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 }; |
| 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 SizeT StackPtr = RegX8664::Reg_rsp; |
| 71 static const SizeT FramePtr = RegX8664::Reg_rbp; |
| 70 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax; | 72 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax; |
| 71 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx; | 73 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx; |
| 72 static const FixupKind PcRelFixup = llvm::ELF::R_X86_64_PC32; | 74 static const FixupKind PcRelFixup = llvm::ELF::R_X86_64_PC32; |
| 73 static const FixupKind RelFixup = llvm::ELF::R_X86_64_32S; | 75 static const FixupKind RelFixup = llvm::ELF::R_X86_64_32; |
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 SetModRM(2, RegX8664::Encoded_Reg_esp); | 250 SetModRM(2, RegX8664::Encoded_Reg_esp); |
| 249 SetSIB(Scale, Index, Base); | 251 SetSIB(Scale, Index, Base); |
| 250 SetDisp32(Disp); | 252 SetDisp32(Disp); |
| 251 if (Fixup) | 253 if (Fixup) |
| 252 SetFixup(Fixup); | 254 SetFixup(Fixup); |
| 253 } | 255 } |
| 254 } | 256 } |
| 255 | 257 |
| 256 /// Generate a RIP-relative address expression on x86-64. | 258 /// Generate a RIP-relative address expression on x86-64. |
| 257 Address(RelocOffsetT Offset, AssemblerFixup *Fixup) { | 259 Address(RelocOffsetT Offset, AssemblerFixup *Fixup) { |
| 258 SetModRM(0, RegX8664::Encoded_Reg_ebp); | 260 SetModRM(0x0, RegX8664::Encoded_Reg_esp); |
| 261 |
| 262 static constexpr ScaleFactor Scale = TIMES_1; |
| 263 SetSIB(Scale, RegX8664::Encoded_Reg_esp, RegX8664::Encoded_Reg_ebp); |
| 259 // Use the Offset in the displacement for now. If we decide to process | 264 // 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. | 265 // fixups later, we'll need to patch up the emitted displacement. |
| 261 SetDisp32(Offset); | 266 SetDisp32(Offset); |
| 262 if (Fixup) | 267 if (Fixup) |
| 263 SetFixup(Fixup); | 268 SetFixup(Fixup); |
| 264 } | 269 } |
| 265 | 270 |
| 266 static Address ofConstPool(Assembler *Asm, const Constant *Imm) { | 271 static Address ofConstPool(Assembler *Asm, const Constant *Imm) { |
| 267 // TODO(jpp): ??? | 272 // TODO(jpp): ??? |
| 268 AssemblerFixup *Fixup = Asm->createFixup(RelFixup, Imm); | 273 AssemblerFixup *Fixup = Asm->createFixup(RelFixup, Imm); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (!First) | 559 if (!First) |
| 555 Str << " "; | 560 Str << " "; |
| 556 First = false; | 561 First = false; |
| 557 Str << getRegName(Register); | 562 Str << getRegName(Register); |
| 558 } | 563 } |
| 559 Str << "}\n"; | 564 Str << "}\n"; |
| 560 } | 565 } |
| 561 } | 566 } |
| 562 } | 567 } |
| 563 | 568 |
| 569 static int32_t getRaxOrDie() { return RegisterSet::Reg_rax; } |
| 570 |
| 571 static int32_t getRdxOrDie() { return RegisterSet::Reg_rdx; } |
| 572 |
| 564 /// The maximum number of arguments to pass in XMM registers | 573 /// The maximum number of arguments to pass in XMM registers |
| 565 static const uint32_t X86_MAX_XMM_ARGS = 8; | 574 static const uint32_t X86_MAX_XMM_ARGS = 8; |
| 566 /// The maximum number of arguments to pass in GPR registers | 575 /// The maximum number of arguments to pass in GPR registers |
| 567 static const uint32_t X86_MAX_GPR_ARGS = 6; | 576 static const uint32_t X86_MAX_GPR_ARGS = 6; |
| 568 /// The number of bits in a byte | 577 /// The number of bits in a byte |
| 569 static const uint32_t X86_CHAR_BIT = 8; | 578 static const uint32_t X86_CHAR_BIT = 8; |
| 570 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it | 579 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it |
| 571 /// is used as an argument to std::max(), and the default std::less<T> has an | 580 /// is used as an argument to std::max(), and the default std::less<T> has an |
| 572 /// operator(T const&, T const&) which requires this member to have an | 581 /// operator(T const&, T const&) which requires this member to have an |
| 573 /// address. | 582 /// address. |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 851 |
| 843 } // end of namespace X86Internal | 852 } // end of namespace X86Internal |
| 844 | 853 |
| 845 namespace X8664 { | 854 namespace X8664 { |
| 846 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; | 855 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; |
| 847 } // end of namespace X8664 | 856 } // end of namespace X8664 |
| 848 | 857 |
| 849 } // end of namespace Ice | 858 } // end of namespace Ice |
| 850 | 859 |
| 851 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H | 860 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H |
| OLD | NEW |