1 ;; Constraint definitions for MIPS.
2 ;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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)
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"
29 (define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS"
30 "A floating-point register (if available).")
32 (define_register_constraint "h" "NO_REGS"
33 "Formerly the @code{hi} register. This constraint is no longer supported.")
35 (define_register_constraint "l" "TARGET_BIG_ENDIAN ? MD1_REG : MD0_REG"
36 "The @code{lo} register. Use this register to store values that are
37 no bigger than a word.")
39 (define_register_constraint "x" "MD_REGS"
40 "The concatenated @code{hi} and @code{lo} registers. Use this register
41 to store doubleword values.")
43 (define_register_constraint "b" "ALL_REGS"
46 (define_register_constraint "u" "M16_REGS"
49 ;; MIPS16 code always calls through a MIPS16 register; see mips_emit_call_insn
51 (define_register_constraint "c" "TARGET_MIPS16 ? M16_REGS
52 : TARGET_USE_PIC_FN_ADDR_REG ? PIC_FN_ADDR_REG
54 "A register suitable for use in an indirect jump. This will always be
55 @code{$25} for @option{-mabicalls}.")
57 (define_register_constraint "e" "LEA_REGS"
60 (define_register_constraint "j" "PIC_FN_ADDR_REG"
63 ;; Don't use this constraint in gcc code! It runs the risk of
64 ;; introducing a spill failure; see tls_get_tp_<mode>.
65 (define_register_constraint "v" "V1_REG"
66 "Register @code{$3}. Do not use this constraint in new code;
67 it is retained only for compatibility with glibc.")
69 (define_register_constraint "y" "GR_REGS"
70 "Equivalent to @code{r}; retained for backwards compatibility.")
72 (define_register_constraint "z" "ST_REGS"
73 "A floating-point condition code register.")
75 (define_register_constraint "A" "DSP_ACC_REGS"
78 (define_register_constraint "a" "ACC_REGS"
81 (define_register_constraint "B" "COP0_REGS"
84 (define_register_constraint "C" "COP2_REGS"
87 (define_register_constraint "D" "COP3_REGS"
90 ;; Registers that can be used as the target of multiply-accumulate
91 ;; instructions. The core MIPS32 ISA provides a hi/lo madd,
92 ;; but the DSP version allows any accumulator target.
93 (define_register_constraint "ka" "ISA_HAS_DSP_MULT ? ACC_REGS : MD_REGS")
95 ;; The register class to use for an allocatable division result.
96 ;; MIPS16 uses M16_REGS because LO is fixed.
97 (define_register_constraint "kl"
98 "TARGET_MIPS16 ? M16_REGS : TARGET_BIG_ENDIAN ? MD1_REG : MD0_REG"
101 (define_constraint "kf"
103 (match_operand 0 "force_to_mem_operand"))
105 ;; This is a normal rather than a register constraint because we can
106 ;; never use the stack pointer as a reload register.
107 (define_constraint "ks"
109 (and (match_code "reg")
110 (match_test "REGNO (op) == STACK_POINTER_REGNUM")))
112 ;; Integer constraints
114 (define_constraint "I"
115 "A signed 16-bit constant (for arithmetic instructions)."
116 (and (match_code "const_int")
117 (match_test "SMALL_OPERAND (ival)")))
119 (define_constraint "J"
121 (and (match_code "const_int")
122 (match_test "ival == 0")))
124 (define_constraint "K"
125 "An unsigned 16-bit constant (for logic instructions)."
126 (and (match_code "const_int")
127 (match_test "SMALL_OPERAND_UNSIGNED (ival)")))
129 (define_constraint "L"
130 "A signed 32-bit constant in which the lower 16 bits are zero.
131 Such constants can be loaded using @code{lui}."
132 (and (match_code "const_int")
133 (match_test "LUI_OPERAND (ival)")))
135 (define_constraint "M"
136 "A constant that cannot be loaded using @code{lui}, @code{addiu}
138 (and (match_code "const_int")
139 (not (match_test "SMALL_OPERAND (ival)"))
140 (not (match_test "SMALL_OPERAND_UNSIGNED (ival)"))
141 (not (match_test "LUI_OPERAND (ival)"))))
143 (define_constraint "N"
144 "A constant in the range -65535 to -1 (inclusive)."
145 (and (match_code "const_int")
146 (match_test "ival >= -0xffff && ival < 0")))
148 (define_constraint "O"
149 "A signed 15-bit constant."
150 (and (match_code "const_int")
151 (match_test "ival >= -0x4000 && ival < 0x4000")))
153 (define_constraint "P"
154 "A constant in the range 1 to 65535 (inclusive)."
155 (and (match_code "const_int")
156 (match_test "ival > 0 && ival < 0x10000")))
158 ;; Floating-point constraints
160 (define_constraint "G"
161 "Floating-point zero."
162 (and (match_code "const_double")
163 (match_test "op == CONST0_RTX (mode)")))
165 ;; General constraints
167 (define_constraint "Q"
169 (match_operand 0 "const_arith_operand"))
171 (define_memory_constraint "R"
172 "An address that can be used in a non-macro load or store."
173 (and (match_code "mem")
174 (match_test "mips_address_insns (XEXP (op, 0), mode, false) == 1")))
176 (define_constraint "S"
178 A constant call address."
179 (and (match_operand 0 "call_insn_operand")
180 (match_test "CONSTANT_P (op)")))
182 (define_constraint "Udb7"
184 A decremented unsigned constant of 7 bits."
185 (match_operand 0 "db7_operand"))
187 (define_constraint "Udb8"
189 A decremented unsigned constant of 8 bits."
190 (match_operand 0 "db8_operand"))
192 (define_constraint "Uead"
194 A microMIPS encoded ADDIUR2 immediate operand."
195 (match_operand 0 "addiur2_operand"))
197 (define_constraint "Uean"
199 A microMIPS encoded ANDI operand."
200 (match_operand 0 "andi16_operand"))
202 (define_constraint "Uesp"
204 A microMIPS encoded ADDIUSP operand."
205 (match_operand 0 "addiusp_operand"))
207 (define_constraint "Uib3"
209 An unsigned, incremented constant of 3 bits."
210 (match_operand 0 "ib3_operand"))
212 (define_constraint "Usb4"
214 A signed constant of 4 bits."
215 (match_operand 0 "sb4_operand"))
217 (define_constraint "Usb5"
219 A signed constant of 5 bits."
220 (match_operand 0 "sb5_operand"))
222 (define_constraint "Usb8"
224 A signed constant of 8 bits."
225 (match_operand 0 "sb8_operand"))
227 (define_constraint "Usd8"
229 A signed constant of 8 bits, shifted left three places."
230 (match_operand 0 "sd8_operand"))
232 (define_constraint "Uub8"
234 An unsigned constant of 8 bits."
235 (match_operand 0 "ub8_operand"))
237 (define_constraint "Uuw5"
239 An unsigned constant of 5 bits, shifted left two places."
240 (match_operand 0 "uw5_operand"))
242 (define_constraint "Uuw6"
244 An unsigned constant of 6 bits, shifted left two places."
245 (match_operand 0 "uw6_operand"))
247 (define_constraint "Uuw8"
249 An unsigned constant of 8 bits, shifted left two places."
250 (match_operand 0 "uw8_operand"))
252 (define_memory_constraint "W"
254 A memory address based on a member of @code{BASE_REG_CLASS}. This is
255 true for all non-mips16 references (although it can sometimes be implicit
256 if @samp{!TARGET_EXPLICIT_RELOCS}). For MIPS16, it excludes stack and
257 constant-pool references."
258 (and (match_code "mem")
259 (match_operand 0 "memory_operand")
260 (ior (not (match_test "TARGET_MIPS16"))
261 (and (not (match_operand 0 "stack_operand"))
262 (not (match_test "CONSTANT_P (XEXP (op, 0))"))))))
264 (define_constraint "YG"
267 (and (match_code "const_vector")
268 (match_test "op == CONST0_RTX (mode)")))
270 (define_constraint "YA"
272 An unsigned 6-bit constant."
273 (and (match_code "const_int")
274 (match_test "UIMM6_OPERAND (ival)")))
276 (define_constraint "YB"
278 A signed 10-bit constant."
279 (and (match_code "const_int")
280 (match_test "IMM10_OPERAND (ival)")))
282 (define_constraint "Yb"
284 (match_operand 0 "qi_mask_operand"))
286 (define_constraint "Yd"
288 A constant @code{move_operand} that can be safely loaded into @code{$25}
290 (and (match_operand 0 "move_operand")
291 (match_test "CONSTANT_P (op)")
292 (not (match_test "mips_dangerous_for_la25_p (op)"))))
294 (define_constraint "Yf"
296 A constant @code{move_operand} that cannot be safely loaded into @code{$25}
298 (and (match_operand 0 "move_operand")
299 (match_test "CONSTANT_P (op)")
300 (match_test "mips_dangerous_for_la25_p (op)")))
302 (define_constraint "Yh"
304 (match_operand 0 "hi_mask_operand"))
306 (define_constraint "Yw"
308 (match_operand 0 "si_mask_operand"))
310 (define_constraint "Yx"
312 (match_operand 0 "low_bitmask_operand"))
314 (define_memory_constraint "ZC"
315 "When compiling microMIPS code, this constraint matches a memory operand
316 whose address is formed from a base register and a 12-bit offset. These
317 operands can be used for microMIPS instructions such as @code{ll} and
318 @code{sc}. When not compiling for microMIPS code, @code{ZC} is
319 equivalent to @code{R}."
320 (and (match_code "mem")
322 (match_test "TARGET_MICROMIPS")
323 (match_test "umips_12bit_offset_address_p (XEXP (op, 0), mode)")
324 (match_test "mips_address_insns (XEXP (op, 0), mode, false)"))))
326 (define_address_constraint "ZD"
327 "When compiling microMIPS code, this constraint matches an address operand
328 that is formed from a base register and a 12-bit offset. These operands
329 can be used for microMIPS instructions such as @code{prefetch}. When
330 not compiling for microMIPS code, @code{ZD} is equivalent to @code{p}."
331 (if_then_else (match_test "TARGET_MICROMIPS")
332 (match_test "umips_12bit_offset_address_p (op, mode)")
333 (match_test "mips_address_insns (op, mode, false)")))
335 (define_memory_constraint "ZR"
337 An address valid for loading/storing register exclusive"
338 (match_operand 0 "mem_noofs_operand"))
340 (define_memory_constraint "ZS"
342 A microMIPS memory operand for use with the LWSP/SWSP insns."
343 (and (match_code "mem")
344 (match_operand 0 "lwsp_swsp_operand")))
346 (define_memory_constraint "ZT"
348 A microMIPS memory operand for use with the LW16/SW16 insns."
349 (and (match_code "mem")
350 (match_operand 0 "lw16_sw16_operand")))
352 (define_memory_constraint "ZU"
354 A microMIPS memory operand for use with the LHU16/SH16 insns."
355 (and (match_code "mem")
356 (match_operand 0 "lhu16_sh16_operand")))
358 (define_memory_constraint "ZV"
360 A microMIPS memory operand for use with the SB16 insn."
361 (and (match_code "mem")
362 (match_operand 0 "sb16_operand")))
364 (define_memory_constraint "ZW"
366 A microMIPS memory operand for use with the LBU16 insn."
367 (and (match_code "mem")
368 (match_operand 0 "lbu16_operand")))