Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / config / mips / constraints.md
blob53e0189ec947f4e9b4e95460c9c66765cecaa6fe
1 ;; Constraint definitions for MIPS.
2 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
9 ;; any later version.
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3.  If not see
18 ;; <http://www.gnu.org/licenses/>.
20 ;; Register constraints
22 (define_register_constraint "d" "BASE_REG_CLASS"
23   "An address register.  This is equivalent to @code{r} unless
24    generating MIPS16 code.")
26 (define_register_constraint "t" "T_REG"
27   "@internal")
29 (define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS"
30   "A floating-point register (if available).")
32 (define_register_constraint "h" "TARGET_BIG_ENDIAN ? MD0_REG : MD1_REG"
33   "The @code{hi} register.")
35 (define_register_constraint "l" "TARGET_BIG_ENDIAN ? MD1_REG : MD0_REG"
36   "The @code{lo} register.")
38 (define_register_constraint "x" "MD_REGS"
39   "The @code{hi} and @code{lo} registers.")
41 (define_register_constraint "b" "ALL_REGS"
42   "@internal")
44 (define_register_constraint "c" "TARGET_USE_PIC_FN_ADDR_REG ? PIC_FN_ADDR_REG
45                                  : TARGET_MIPS16 ? M16_NA_REGS
46                                  : GR_REGS"
47   "A register suitable for use in an indirect jump.  This will always be
48    @code{$25} for @option{-mabicalls}.")
50 (define_register_constraint "e" "LEA_REGS"
51   "@internal")
53 (define_register_constraint "j" "PIC_FN_ADDR_REG"
54   "@internal")
56 (define_register_constraint "v" "V1_REG"
57   "@internal")
59 (define_register_constraint "y" "GR_REGS"
60   "Equivalent to @code{r}; retained for backwards compatibility.")
62 (define_register_constraint "z" "ST_REGS"
63   "A floating-point condition code register.")
65 (define_register_constraint "A" "DSP_ACC_REGS"
66   "@internal")
68 (define_register_constraint "a" "ACC_REGS"
69   "@internal")
71 (define_register_constraint "B" "COP0_REGS"
72   "@internal")
74 (define_register_constraint "C" "COP2_REGS"
75   "@internal")
77 (define_register_constraint "D" "COP3_REGS"
78   "@internal")
80 ;; Registers that can be used as the target of multiply-accumulate
81 ;; instructions.  The core MIPS32 ISA provides a hi/lo madd,
82 ;; but the DSPr2 version allows any accumulator target.
83 (define_register_constraint "ka" "ISA_HAS_DSPR2 ? ACC_REGS : MD_REGS")
85 (define_constraint "kf"
86   "@internal"
87   (match_operand 0 "force_to_mem_operand"))
89 ;; This is a normal rather than a register constraint because we can
90 ;; never use the stack pointer as a reload register.
91 (define_constraint "ks"
92   "@internal"
93   (and (match_code "reg")
94        (match_test "REGNO (op) == STACK_POINTER_REGNUM")))
96 ;; Integer constraints
98 (define_constraint "I"
99   "A signed 16-bit constant (for arithmetic instructions)."
100   (and (match_code "const_int")
101        (match_test "SMALL_OPERAND (ival)")))
103 (define_constraint "J"
104   "Integer zero."
105   (and (match_code "const_int")
106        (match_test "ival == 0")))
108 (define_constraint "K"
109   "An unsigned 16-bit constant (for logic instructions)."
110   (and (match_code "const_int")
111        (match_test "SMALL_OPERAND_UNSIGNED (ival)")))
113 (define_constraint "L"
114   "A signed 32-bit constant in which the lower 16 bits are zero.
115    Such constants can be loaded using @code{lui}."
116   (and (match_code "const_int")
117        (match_test "LUI_OPERAND (ival)")))
119 (define_constraint "M"
120   "A constant that cannot be loaded using @code{lui}, @code{addiu}
121    or @code{ori}."
122   (and (match_code "const_int")
123        (match_test "!SMALL_OPERAND (ival)")
124        (match_test "!SMALL_OPERAND_UNSIGNED (ival)")
125        (match_test "!LUI_OPERAND (ival)")))
127 (define_constraint "N"
128   "A constant in the range -65535 to -1 (inclusive)."
129   (and (match_code "const_int")
130        (match_test "ival >= -0xffff && ival < 0")))
132 (define_constraint "O"
133   "A signed 15-bit constant."
134   (and (match_code "const_int")
135        (match_test "ival >= -0x4000 && ival < 0x4000")))
137 (define_constraint "P"
138   "A constant in the range 1 to 65535 (inclusive)."
139   (and (match_code "const_int")
140        (match_test "ival > 0 && ival < 0x10000")))
142 ;; Floating-point constraints
144 (define_constraint "G"
145   "Floating-point zero."
146   (and (match_code "const_double")
147        (match_test "op == CONST0_RTX (mode)")))
149 ;; General constraints
151 (define_constraint "Q"
152   "@internal"
153   (match_operand 0 "const_arith_operand"))
155 (define_memory_constraint "R"
156   "An address that can be used in a non-macro load or store."
157   (and (match_code "mem")
158        (match_test "mips_address_insns (XEXP (op, 0), mode, false) == 1")))
160 (define_constraint "S"
161   "@internal
162    A constant call address."
163   (and (match_operand 0 "call_insn_operand")
164        (match_test "CONSTANT_P (op)")))
166 (define_constraint "T"
167   "@internal
168    A constant @code{move_operand} that cannot be safely loaded into @code{$25}
169    using @code{la}."
170   (and (match_operand 0 "move_operand")
171        (match_test "CONSTANT_P (op)")
172        (match_test "mips_dangerous_for_la25_p (op)")))
174 (define_constraint "U"
175   "@internal
176    A constant @code{move_operand} that can be safely loaded into @code{$25}
177    using @code{la}."
178   (and (match_operand 0 "move_operand")
179        (match_test "CONSTANT_P (op)")
180        (match_test "!mips_dangerous_for_la25_p (op)")))
182 (define_memory_constraint "W"
183   "@internal
184    A memory address based on a member of @code{BASE_REG_CLASS}.  This is
185    true for all non-mips16 references (although it can sometimes be implicit
186    if @samp{!TARGET_EXPLICIT_RELOCS}).  For MIPS16, it excludes stack and
187    constant-pool references."
188   (and (match_code "mem")
189        (match_operand 0 "memory_operand")
190        (ior (match_test "!TARGET_MIPS16")
191             (and (not (match_operand 0 "stack_operand"))
192                  (not (match_test "CONSTANT_P (XEXP (op, 0))"))))))
194 (define_constraint "YG"
195   "@internal
196    A vector zero."
197   (and (match_code "const_vector")
198        (match_test "op == CONST0_RTX (mode)")))
200 (define_constraint "YA"
201   "@internal
202    An unsigned 6-bit constant."
203   (and (match_code "const_int")
204        (match_test "UIMM6_OPERAND (ival)")))
206 (define_constraint "YB"
207   "@internal
208    A signed 10-bit constant."
209   (and (match_code "const_int")
210        (match_test "IMM10_OPERAND (ival)")))