constraints.md revision 169690
138494Sobrien;; Constraint definitions for IA-32 and x86-64.
2174294Sobrien;; Copyright (C) 2006 Free Software Foundation, Inc.
338494Sobrien;;
438494Sobrien;; This file is part of GCC.
538494Sobrien;;
638494Sobrien;; GCC is free software; you can redistribute it and/or modify
738494Sobrien;; it under the terms of the GNU General Public License as published by
838494Sobrien;; the Free Software Foundation; either version 2, or (at your option)
938494Sobrien;; any later version.
1038494Sobrien;;
1138494Sobrien;; GCC is distributed in the hope that it will be useful,
1238494Sobrien;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1338494Sobrien;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1438494Sobrien;; GNU General Public License for more details.
1538494Sobrien;;
1638494Sobrien;; You should have received a copy of the GNU General Public License
1738494Sobrien;; along with GCC; see the file COPYING.  If not, write to
1838494Sobrien;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
1938494Sobrien;; Boston, MA 02110-1301, USA.
2042629Sobrien
2138494Sobrien;;; Unused letters:
2238494Sobrien;;;     B     H           TU W   
2338494Sobrien;;;           h jk          vw  z
2438494Sobrien
2538494Sobrien;; Integer register constraints.
2638494Sobrien;; It is not necessary to define 'r' here.
2738494Sobrien(define_register_constraint "R" "LEGACY_REGS"
2838494Sobrien "Legacy register---the eight integer registers available on all
2938494Sobrien  i386 processors (@code{a}, @code{b}, @code{c}, @code{d},
3038494Sobrien  @code{si}, @code{di}, @code{bp}, @code{sp}).")
3138494Sobrien
3238494Sobrien(define_register_constraint "q" "TARGET_64BIT ? GENERAL_REGS : Q_REGS"
3338494Sobrien "Any register accessible as @code{@var{r}l}.  In 32-bit mode, @code{a},
3438494Sobrien  @code{b}, @code{c}, and @code{d}; in 64-bit mode, any integer register.")
3538494Sobrien
3638494Sobrien(define_register_constraint "Q" "Q_REGS"
3738494Sobrien "Any register accessible as @code{@var{r}h}: @code{a}, @code{b},
3838494Sobrien  @code{c}, and @code{d}.")
3938494Sobrien
40174294Sobrien(define_register_constraint "l" "INDEX_REGS"
4138494Sobrien "@internal Any register that can be used as the index in a base+index
4238494Sobrien  memory access: that is, any general register except the stack pointer.")
4338494Sobrien
4438494Sobrien(define_register_constraint "a" "AREG"
4538494Sobrien "The @code{a} register.")
4638494Sobrien
4738494Sobrien(define_register_constraint "b" "BREG"
4838494Sobrien "The @code{b} register.")
4938494Sobrien
5038494Sobrien(define_register_constraint "c" "CREG"
5138494Sobrien "The @code{c} register.")
5238494Sobrien
5338494Sobrien(define_register_constraint "d" "DREG"
5438494Sobrien "The @code{d} register.")
5538494Sobrien
5638494Sobrien(define_register_constraint "S" "SIREG"
5738494Sobrien "The @code{si} register.")
5838494Sobrien
5938494Sobrien(define_register_constraint "D" "DIREG"
6038494Sobrien "The @code{di} register.")
6138494Sobrien
6238494Sobrien(define_register_constraint "A" "AD_REGS"
6338494Sobrien "The @code{a} and @code{d} registers, as a pair (for instructions
6438494Sobrien  that return half the result in one and half in the other).")
65174294Sobrien
6638494Sobrien;; Floating-point register constraints.
6738494Sobrien(define_register_constraint "f"
6838494Sobrien "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FLOAT_REGS : NO_REGS"
69174294Sobrien "Any 80387 floating-point (stack) register.")
70174294Sobrien
7138494Sobrien(define_register_constraint "t"
7238494Sobrien "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FP_TOP_REG : NO_REGS"
73174294Sobrien "Top of 80387 floating-point stack (@code{%st(0)}).")
74174294Sobrien
75174294Sobrien(define_register_constraint "u"
76174294Sobrien "TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 ? FP_SECOND_REG : NO_REGS"
77174294Sobrien "Second from top of 80387 floating-point stack (@code{%st(1)}).")
78174294Sobrien
79174294Sobrien;; Vector registers (also used for plain floating point nowadays).
80174294Sobrien(define_register_constraint "y" "TARGET_MMX ? MMX_REGS : NO_REGS"
8138494Sobrien "Any MMX register.")
8238494Sobrien
8338494Sobrien(define_register_constraint "x" "TARGET_SSE ? SSE_REGS : NO_REGS"
8438494Sobrien "Any SSE register.")
8538494Sobrien
8638494Sobrien(define_register_constraint "Y" "TARGET_SSE2? SSE_REGS : NO_REGS"
8738494Sobrien "@internal Any SSE2 register.")
8838494Sobrien
8938494Sobrien;; Integer constant constraints.
9038494Sobrien(define_constraint "I"
9138494Sobrien  "Integer constant in the range 0 @dots{} 31, for 32-bit shifts."
9238494Sobrien  (and (match_code "const_int")
9338494Sobrien       (match_test "ival >= 0 && ival <= 31")))
9438494Sobrien
9538494Sobrien(define_constraint "J"
9638494Sobrien  "Integer constant in the range 0 @dots{} 63, for 64-bit shifts."
97174294Sobrien  (and (match_code "const_int")
98174294Sobrien       (match_test "ival >= 0 && ival <= 63")))
99174294Sobrien
100174294Sobrien(define_constraint "K"
10138494Sobrien  "Signed 8-bit integer constant."
10238494Sobrien  (and (match_code "const_int")
10338494Sobrien       (match_test "ival >= -128 && ival <= 127")))
10438494Sobrien
10538494Sobrien(define_constraint "L"
10638494Sobrien  "@code{0xFF} or @code{0xFFFF}, for andsi as a zero-extending move."
10738494Sobrien  (and (match_code "const_int")
10838494Sobrien       (match_test "ival == 0xFF || ival == 0xFFFF")))
10938494Sobrien
11038494Sobrien(define_constraint "M"
111  "0, 1, 2, or 3 (shifts for the @code{lea} instruction)."
112  (and (match_code "const_int")
113       (match_test "ival >= 0 && ival <= 3")))
114
115(define_constraint "N"
116  "Unsigned 8-bit integer constant (for @code{in} and @code{out} 
117   instructions)."
118  (and (match_code "const_int")
119       (match_test "ival >= 0 && ival <= 255")))
120
121(define_constraint "O"
122  "@internal Integer constant in the range 0 @dots{} 127, for 128-bit shifts."
123  (and (match_code "const_int")
124       (match_test "ival >= 0 && ival <= 127")))
125
126;; Floating-point constant constraints.
127;; We allow constants even if TARGET_80387 isn't set, because the
128;; stack register converter may need to load 0.0 into the function
129;; value register (top of stack).
130(define_constraint "G"
131  "Standard 80387 floating point constant."
132  (and (match_code "const_double")
133       (match_test "standard_80387_constant_p (op)")))
134
135;; This can theoretically be any mode's CONST0_RTX.
136(define_constraint "C"
137  "Standard SSE floating point constant."
138  (match_test "standard_sse_constant_p (op)"))
139
140;; Constant-or-symbol-reference constraints.
141
142(define_constraint "e"
143  "32-bit signed integer constant, or a symbolic reference known
144   to fit that range (for immediate operands in sign-extending x86-64
145   instructions)."
146  (match_operand 0 "x86_64_immediate_operand"))
147
148(define_constraint "Z"
149  "32-bit unsigned integer constant, or a symbolic reference known
150   to fit that range (for immediate operands in zero-extending x86-64
151   instructions)."
152  (match_operand 0 "x86_64_zext_immediate_operand"))
153