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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::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 SizeT StackPtr = RegX8632::Reg_esp; | 71 static constexpr SizeT StackPtr = RegX8632::Reg_esp; |
72 static const SizeT FramePtr = RegX8632::Reg_ebp; | 72 static constexpr SizeT FramePtr = RegX8632::Reg_ebp; |
73 static const GPRRegister Encoded_Reg_Accumulator = RegX8632::Encoded_Reg_eax; | 73 static constexpr GPRRegister Encoded_Reg_Accumulator = |
74 static const GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx; | 74 RegX8632::Encoded_Reg_eax; |
| 75 static constexpr GPRRegister Encoded_Reg_Counter = RegX8632::Encoded_Reg_ecx; |
75 static constexpr FixupKind FK_PcRel = llvm::ELF::R_386_PC32; | 76 static constexpr FixupKind FK_PcRel = llvm::ELF::R_386_PC32; |
76 static constexpr FixupKind FK_Abs = llvm::ELF::R_386_32; | 77 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_Gotoff = llvm::ELF::R_386_GOTOFF; |
78 static constexpr FixupKind FK_GotPC = llvm::ELF::R_386_GOTPC; | 79 static constexpr FixupKind FK_GotPC = llvm::ELF::R_386_GOTPC; |
79 | 80 |
80 class Operand { | 81 class Operand { |
81 public: | 82 public: |
82 Operand(const Operand &other) | 83 Operand(const Operand &other) |
83 : fixup_(other.fixup_), length_(other.length_) { | 84 : fixup_(other.fixup_), length_(other.length_) { |
84 memmove(&encoding_[0], &other.encoding_[0], other.length_); | 85 memmove(&encoding_[0], &other.encoding_[0], other.length_); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 } | 652 } |
652 | 653 |
653 static int32_t getRaxOrDie() { | 654 static int32_t getRaxOrDie() { |
654 llvm::report_fatal_error("no rax in non-64-bit mode."); | 655 llvm::report_fatal_error("no rax in non-64-bit mode."); |
655 } | 656 } |
656 | 657 |
657 static int32_t getRdxOrDie() { | 658 static int32_t getRdxOrDie() { |
658 llvm::report_fatal_error("no rdx in non-64-bit mode."); | 659 llvm::report_fatal_error("no rdx in non-64-bit mode."); |
659 } | 660 } |
660 | 661 |
| 662 // x86-32 calling convention: |
| 663 // |
| 664 // * The first four arguments of vector type, regardless of their position |
| 665 // relative to the other arguments in the argument list, are placed in |
| 666 // registers xmm0 - xmm3. |
| 667 // |
| 668 // This intends to match the section "IA-32 Function Calling Convention" of |
| 669 // the document "OS X ABI Function Call Guide" by Apple. |
| 670 |
661 /// The maximum number of arguments to pass in XMM registers | 671 /// The maximum number of arguments to pass in XMM registers |
662 static const uint32_t X86_MAX_XMM_ARGS = 4; | 672 static constexpr uint32_t X86_MAX_XMM_ARGS = 4; |
663 /// The maximum number of arguments to pass in GPR registers | 673 /// The maximum number of arguments to pass in GPR registers |
664 static const uint32_t X86_MAX_GPR_ARGS = 0; | 674 static constexpr uint32_t X86_MAX_GPR_ARGS = 0; |
| 675 /// Whether scalar floating point arguments are passed in XMM registers |
| 676 static constexpr bool X86_PASS_SCALAR_FP_IN_XMM = false; |
| 677 /// Get the register for a given argument slot in the XMM registers. |
| 678 static int32_t getRegisterForXmmArgNum(uint32_t ArgNum) { |
| 679 // TODO(sehr): Change to use the CCArg technique used in ARM32. |
| 680 static_assert(RegisterSet::Reg_xmm0 + 1 == RegisterSet::Reg_xmm1, |
| 681 "Inconsistency between XMM register numbers and ordinals"); |
| 682 if (ArgNum >= X86_MAX_XMM_ARGS) { |
| 683 return Variable::NoRegister; |
| 684 } |
| 685 return static_cast<int32_t>(RegisterSet::Reg_xmm0 + ArgNum); |
| 686 } |
| 687 /// Get the register for a given argument slot in the GPRs. |
| 688 static int32_t getRegisterForGprArgNum(Type Ty, uint32_t ArgNum) { |
| 689 assert(Ty == IceType_i64 || Ty == IceType_i32); |
| 690 (void)Ty; |
| 691 (void)ArgNum; |
| 692 return Variable::NoRegister; |
| 693 } |
| 694 |
665 /// The number of bits in a byte | 695 /// The number of bits in a byte |
666 static const uint32_t X86_CHAR_BIT = 8; | 696 static constexpr uint32_t X86_CHAR_BIT = 8; |
667 /// Stack alignment. This is defined in IceTargetLoweringX8632.cpp because it | 697 /// Stack alignment. This is defined in IceTargetLoweringX8632.cpp because it |
668 /// is used as an argument to std::max(), and the default std::less<T> has an | 698 /// is used as an argument to std::max(), and the default std::less<T> has an |
669 /// operator(T const&, T const&) which requires this member to have an | 699 /// operator(T const&, T const&) which requires this member to have an |
670 /// address. | 700 /// address. |
671 static const uint32_t X86_STACK_ALIGNMENT_BYTES; | 701 static const uint32_t X86_STACK_ALIGNMENT_BYTES; |
672 /// Size of the return address on the stack | 702 /// Size of the return address on the stack |
673 static const uint32_t X86_RET_IP_SIZE_BYTES = 4; | 703 static constexpr uint32_t X86_RET_IP_SIZE_BYTES = 4; |
674 /// The number of different NOP instructions | 704 /// The number of different NOP instructions |
675 static const uint32_t X86_NUM_NOP_VARIANTS = 5; | 705 static constexpr uint32_t X86_NUM_NOP_VARIANTS = 5; |
676 | 706 |
677 /// \name Limits for unrolling memory intrinsics. | 707 /// \name Limits for unrolling memory intrinsics. |
678 /// @{ | 708 /// @{ |
679 static constexpr uint32_t MEMCPY_UNROLL_LIMIT = 8; | 709 static constexpr uint32_t MEMCPY_UNROLL_LIMIT = 8; |
680 static constexpr uint32_t MEMMOVE_UNROLL_LIMIT = 8; | 710 static constexpr uint32_t MEMMOVE_UNROLL_LIMIT = 8; |
681 static constexpr uint32_t MEMSET_UNROLL_LIMIT = 16; | 711 static constexpr uint32_t MEMSET_UNROLL_LIMIT = 16; |
682 /// @} | 712 /// @} |
683 | 713 |
684 /// Value is in bytes. Return Value adjusted to the next highest multiple of | 714 /// Value is in bytes. Return Value adjusted to the next highest multiple of |
685 /// the stack alignment. | 715 /// the stack alignment. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 988 |
959 static uint8_t InstSegmentPrefixes[]; | 989 static uint8_t InstSegmentPrefixes[]; |
960 }; | 990 }; |
961 | 991 |
962 using Traits = ::Ice::X8632::TargetX8632Traits; | 992 using Traits = ::Ice::X8632::TargetX8632Traits; |
963 } // end of namespace X8632 | 993 } // end of namespace X8632 |
964 | 994 |
965 } // end of namespace Ice | 995 } // end of namespace Ice |
966 | 996 |
967 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H | 997 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632TRAITS_H |
OLD | NEW |