1169689Skan;; Constraint definitions for IA-32 and x86-64.
2169689Skan;; Copyright (C) 2006 Free Software Foundation, Inc.
3169689Skan;;
4169689Skan;; This file is part of GCC.
5169689Skan;;
6169689Skan;; GCC is free software; you can redistribute it and/or modify
7169689Skan;; it under the terms of the GNU General Public License as published by
8169689Skan;; the Free Software Foundation; either version 2, or (at your option)
9169689Skan;; any later version.
10169689Skan;;
11169689Skan;; GCC is distributed in the hope that it will be useful,
12169689Skan;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13169689Skan;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14169689Skan;; GNU General Public License for more details.
15169689Skan;;
16169689Skan;; You should have received a copy of the GNU General Public License
17169689Skan;; along with GCC; see the file COPYING.  If not, write to
18169689Skan;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19169689Skan;; Boston, MA 02110-1301, USA.
20169689Skan
21169689Skan;;; Unused letters:
22169689Skan;;;     B     H           TU W   
23169689Skan;;;           h jk          vw  z
24169689Skan
25169689Skan;; Integer register constraints.
26169689Skan;; It is not necessary to define 'r' here.
27169689Skan(define_register_constraint "R" "LEGACY_REGS"
28169689Skan "Legacy register---the eight integer registers available on all
29169689Skan  i386 processors (@code{a}, @code{b}, @code{c}, @code{d},
30169689Skan  @code{si}, @code{di}, @code{bp}, @code{sp}).")
31169689Skan
32169689Skan(define_register_constraint "q" "TARGET_64BIT ? GENERAL_REGS : Q_REGS"
33169689Skan "Any register accessible as @code{@var{r}l}.  In 32-bit mode, @code{a},
34169689Skan  @code{b}, @code{c}, and @code{d}; in 64-bit mode, any integer register.")
35169689Skan
36169689Skan(define_register_constraint "Q" "Q_REGS"
37169689Skan "Any register accessible as @code{@var{r}h}: @code{a}, @code{b},
38169689Skan  @code{c}, and @code{d}.")
39169689Skan
40169689Skan(define_register_constraint "l" "INDEX_REGS"
41169689Skan "@internal Any register that can be used as the index in a base+index
42169689Skan  memory access: that is, any general register except the stack pointer.")
43169689Skan
44169689Skan(define_register_constraint "a" "AREG"
45169689Skan "The @code{a} register.")
46169689Skan
47169689Skan(define_register_constraint "b" "BREG"
48169689Skan "The @code{b} register.")
49169689Skan
50169689Skan(define_register_constraint "c" "CREG"
51169689Skan "The @code{c} register.")
52169689Skan
53169689Skan(define_register_constraint "d" "DREG"
54169689Skan "The @code{d} register.")
55169689Skan
56169689Skan(define_register_constraint "S" "SIREG"
57169689Skan "The @code{si} register.")
58169689Skan
59169689Skan(define_register_constraint "D" "DIREG"
60169689Skan "The @code{di} register.")
61169689Skan
62169689Skan(define_register_constraint "A" "AD_REGS"
63169689Skan "The @code{a} and @code{d} registers, as a pair (for instructions
64169689Skan  that return half the result in one and half in the other).")
65169689Skan
66169689Skan;; Floating-point register constraints.
67169689Skan(define_register_constraint "f"
68169689Skan "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FLOAT_REGS : NO_REGS"
69169689Skan "Any 80387 floating-point (stack) register.")
70169689Skan
71169689Skan(define_register_constraint "t"
72169689Skan "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FP_TOP_REG : NO_REGS"
73169689Skan "Top of 80387 floating-point stack (@code{%st(0)}).")
74169689Skan
75169689Skan(define_register_constraint "u"
76169689Skan "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FP_SECOND_REG : NO_REGS"
77169689Skan "Second from top of 80387 floating-point stack (@code{%st(1)}).")
78169689Skan
79169689Skan;; Vector registers (also used for plain floating point nowadays).
80169689Skan(define_register_constraint "y" "TARGET_MMX ? MMX_REGS : NO_REGS"
81169689Skan "Any MMX register.")
82169689Skan
83169689Skan(define_register_constraint "x" "TARGET_SSE ? SSE_REGS : NO_REGS"
84169689Skan "Any SSE register.")
85169689Skan
86169689Skan(define_register_constraint "Y" "TARGET_SSE2? SSE_REGS : NO_REGS"
87169689Skan "@internal Any SSE2 register.")
88169689Skan
89169689Skan;; Integer constant constraints.
90169689Skan(define_constraint "I"
91169689Skan  "Integer constant in the range 0 @dots{} 31, for 32-bit shifts."
92169689Skan  (and (match_code "const_int")
93169689Skan       (match_test "ival >= 0 && ival <= 31")))
94169689Skan
95169689Skan(define_constraint "J"
96169689Skan  "Integer constant in the range 0 @dots{} 63, for 64-bit shifts."
97169689Skan  (and (match_code "const_int")
98169689Skan       (match_test "ival >= 0 && ival <= 63")))
99169689Skan
100169689Skan(define_constraint "K"
101169689Skan  "Signed 8-bit integer constant."
102169689Skan  (and (match_code "const_int")
103169689Skan       (match_test "ival >= -128 && ival <= 127")))
104169689Skan
105169689Skan(define_constraint "L"
106169689Skan  "@code{0xFF} or @code{0xFFFF}, for andsi as a zero-extending move."
107169689Skan  (and (match_code "const_int")
108169689Skan       (match_test "ival == 0xFF || ival == 0xFFFF")))
109169689Skan
110169689Skan(define_constraint "M"
111169689Skan  "0, 1, 2, or 3 (shifts for the @code{lea} instruction)."
112169689Skan  (and (match_code "const_int")
113169689Skan       (match_test "ival >= 0 && ival <= 3")))
114169689Skan
115169689Skan(define_constraint "N"
116169689Skan  "Unsigned 8-bit integer constant (for @code{in} and @code{out} 
117169689Skan   instructions)."
118169689Skan  (and (match_code "const_int")
119169689Skan       (match_test "ival >= 0 && ival <= 255")))
120169689Skan
121169689Skan(define_constraint "O"
122169689Skan  "@internal Integer constant in the range 0 @dots{} 127, for 128-bit shifts."
123169689Skan  (and (match_code "const_int")
124169689Skan       (match_test "ival >= 0 && ival <= 127")))
125169689Skan
126169689Skan;; Floating-point constant constraints.
127169689Skan;; We allow constants even if TARGET_80387 isn't set, because the
128169689Skan;; stack register converter may need to load 0.0 into the function
129169689Skan;; value register (top of stack).
130169689Skan(define_constraint "G"
131169689Skan  "Standard 80387 floating point constant."
132169689Skan  (and (match_code "const_double")
133169689Skan       (match_test "standard_80387_constant_p (op)")))
134169689Skan
135169689Skan;; This can theoretically be any mode's CONST0_RTX.
136169689Skan(define_constraint "C"
137169689Skan  "Standard SSE floating point constant."
138169689Skan  (match_test "standard_sse_constant_p (op)"))
139169689Skan
140169689Skan;; Constant-or-symbol-reference constraints.
141169689Skan
142169689Skan(define_constraint "e"
143169689Skan  "32-bit signed integer constant, or a symbolic reference known
144169689Skan   to fit that range (for immediate operands in sign-extending x86-64
145169689Skan   instructions)."
146169689Skan  (match_operand 0 "x86_64_immediate_operand"))
147169689Skan
148169689Skan(define_constraint "Z"
149169689Skan  "32-bit unsigned integer constant, or a symbolic reference known
150169689Skan   to fit that range (for immediate operands in zero-extending x86-64
151169689Skan   instructions)."
152169689Skan  (match_operand 0 "x86_64_zext_immediate_operand"))
153