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

Side by Side Diff: src/IceTargetLoweringX8664Traits.h

Issue 1592033002: Merge lowerCall and lowerRet between x86 and x64 (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review comments Created 4 years, 11 months 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 }; 62 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 };
63 63
64 using GPRRegister = ::Ice::RegX8664::GPRRegister; 64 using GPRRegister = ::Ice::RegX8664::GPRRegister;
65 using ByteRegister = ::Ice::RegX8664::ByteRegister; 65 using ByteRegister = ::Ice::RegX8664::ByteRegister;
66 using XmmRegister = ::Ice::RegX8664::XmmRegister; 66 using XmmRegister = ::Ice::RegX8664::XmmRegister;
67 67
68 using Cond = ::Ice::CondX8664; 68 using Cond = ::Ice::CondX8664;
69 69
70 using RegisterSet = ::Ice::RegX8664; 70 using RegisterSet = ::Ice::RegX8664;
71 static const SizeT StackPtr = RegX8664::Reg_rsp; 71 static constexpr SizeT StackPtr = RegX8664::Reg_rsp;
72 static const SizeT FramePtr = RegX8664::Reg_rbp; 72 static constexpr SizeT FramePtr = RegX8664::Reg_rbp;
73 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax; 73 static constexpr GPRRegister Encoded_Reg_Accumulator =
74 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx; 74 RegX8664::Encoded_Reg_eax;
75 static constexpr GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx;
75 static constexpr FixupKind FK_PcRel = llvm::ELF::R_X86_64_PC32; 76 static constexpr FixupKind FK_PcRel = llvm::ELF::R_X86_64_PC32;
76 static constexpr FixupKind FK_Abs = llvm::ELF::R_X86_64_32; 77 static constexpr FixupKind FK_Abs = llvm::ELF::R_X86_64_32;
77 static constexpr FixupKind FK_Gotoff = llvm::ELF::R_X86_64_GOTOFF64; 78 static constexpr FixupKind FK_Gotoff = llvm::ELF::R_X86_64_GOTOFF64;
78 static constexpr FixupKind FK_GotPC = llvm::ELF::R_X86_64_GOTPC32; 79 static constexpr FixupKind FK_GotPC = llvm::ELF::R_X86_64_GOTPC32;
79 80
80 class Operand { 81 class Operand {
81 public: 82 public:
82 enum RexBits { 83 enum RexBits {
83 RexNone = 0x00, 84 RexNone = 0x00,
84 RexBase = 0x40, 85 RexBase = 0x40,
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 709 }
709 Str << "}\n"; 710 Str << "}\n";
710 } 711 }
711 } 712 }
712 } 713 }
713 714
714 static int32_t getRaxOrDie() { return RegisterSet::Reg_rax; } 715 static int32_t getRaxOrDie() { return RegisterSet::Reg_rax; }
715 716
716 static int32_t getRdxOrDie() { return RegisterSet::Reg_rdx; } 717 static int32_t getRdxOrDie() { return RegisterSet::Reg_rdx; }
717 718
719 // x86-64 calling convention:
720 //
721 // * The first eight arguments of vector/fp type, regardless of their
722 // position relative to the other arguments in the argument list, are placed
723 // in registers %xmm0 - %xmm7.
724 //
725 // * The first six arguments of integer types, regardless of their position
726 // relative to the other arguments in the argument list, are placed in
727 // registers %rdi, %rsi, %rdx, %rcx, %r8, and %r9.
728 //
729 // This intends to match the section "Function Calling Sequence" of the
730 // document "System V Application Binary Interface."
731
718 /// The maximum number of arguments to pass in XMM registers 732 /// The maximum number of arguments to pass in XMM registers
719 static const uint32_t X86_MAX_XMM_ARGS = 8; 733 static constexpr uint32_t X86_MAX_XMM_ARGS = 8;
720 /// The maximum number of arguments to pass in GPR registers 734 /// The maximum number of arguments to pass in GPR registers
721 static const uint32_t X86_MAX_GPR_ARGS = 6; 735 static constexpr uint32_t X86_MAX_GPR_ARGS = 6;
736 /// Whether scalar floating point arguments are passed in XMM registers
737 static constexpr bool X86_PASS_SCALAR_FP_IN_XMM = true;
738 /// Get the register for a given argument slot in the XMM registers.
739 static int32_t getRegisterForXmmArgNum(uint32_t ArgNum) {
740 // TODO(sehr): Change to use the CCArg technique used in ARM32.
741 static_assert(RegisterSet::Reg_xmm0 + 1 == RegisterSet::Reg_xmm1,
742 "Inconsistency between XMM register numbers and ordinals");
743 if (ArgNum >= X86_MAX_XMM_ARGS) {
744 return Variable::NoRegister;
745 }
746 return static_cast<int32_t>(RegisterSet::Reg_xmm0 + ArgNum);
747 }
748 /// Get the register for a given argument slot in the GPRs.
749 static int32_t getRegisterForGprArgNum(Type Ty, uint32_t ArgNum) {
750 if (ArgNum >= X86_MAX_GPR_ARGS) {
751 return Variable::NoRegister;
752 }
753 static const RegisterSet::AllRegisters GprForArgNum[] = {
754 RegisterSet::Reg_rdi, RegisterSet::Reg_rsi, RegisterSet::Reg_rdx,
755 RegisterSet::Reg_rcx, RegisterSet::Reg_r8, RegisterSet::Reg_r9,
756 };
757 static_assert(llvm::array_lengthof(GprForArgNum) == X86_MAX_GPR_ARGS,
758 "Mismatch between MAX_GPR_ARGS and GprForArgNum.");
759 assert(Ty == IceType_i64 || Ty == IceType_i32);
760 return static_cast<int32_t>(getGprForType(Ty, GprForArgNum[ArgNum]));
761 }
762
722 /// The number of bits in a byte 763 /// The number of bits in a byte
723 static const uint32_t X86_CHAR_BIT = 8; 764 static constexpr uint32_t X86_CHAR_BIT = 8;
724 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it 765 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it
725 /// is used as an argument to std::max(), and the default std::less<T> has an 766 /// is used as an argument to std::max(), and the default std::less<T> has an
726 /// operator(T const&, T const&) which requires this member to have an 767 /// operator(T const&, T const&) which requires this member to have an
727 /// address. 768 /// address.
728 static const uint32_t X86_STACK_ALIGNMENT_BYTES; 769 static const uint32_t X86_STACK_ALIGNMENT_BYTES;
729 /// Size of the return address on the stack 770 /// Size of the return address on the stack
730 static const uint32_t X86_RET_IP_SIZE_BYTES = 8; 771 static constexpr uint32_t X86_RET_IP_SIZE_BYTES = 8;
731 /// The number of different NOP instructions 772 /// The number of different NOP instructions
732 static const uint32_t X86_NUM_NOP_VARIANTS = 5; 773 static constexpr uint32_t X86_NUM_NOP_VARIANTS = 5;
733 774
734 /// \name Limits for unrolling memory intrinsics. 775 /// \name Limits for unrolling memory intrinsics.
735 /// @{ 776 /// @{
736 static constexpr uint32_t MEMCPY_UNROLL_LIMIT = 8; 777 static constexpr uint32_t MEMCPY_UNROLL_LIMIT = 8;
737 static constexpr uint32_t MEMMOVE_UNROLL_LIMIT = 8; 778 static constexpr uint32_t MEMMOVE_UNROLL_LIMIT = 8;
738 static constexpr uint32_t MEMSET_UNROLL_LIMIT = 16; 779 static constexpr uint32_t MEMSET_UNROLL_LIMIT = 16;
739 /// @} 780 /// @}
740 781
741 /// Value is in bytes. Return Value adjusted to the next highest multiple of 782 /// Value is in bytes. Return Value adjusted to the next highest multiple of
742 /// the stack alignment. 783 /// the stack alignment.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 const char *FldString; // s, l, or <blank> 1046 const char *FldString; // s, l, or <blank>
1006 } TypeAttributes[]; 1047 } TypeAttributes[];
1007 }; 1048 };
1008 1049
1009 using Traits = ::Ice::X8664::TargetX8664Traits; 1050 using Traits = ::Ice::X8664::TargetX8664Traits;
1010 } // end of namespace X8664 1051 } // end of namespace X8664
1011 1052
1012 } // end of namespace Ice 1053 } // end of namespace Ice
1013 1054
1014 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H 1055 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698