1 ;; Constraint definitions for Xtensa.
2 ;; Copyright (C) 2006 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 2, 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 COPYING. If not, write to
18 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
21 ;; Register constraints.
23 (define_register_constraint "a" "GR_REGS"
24 "General-purpose AR registers @code{a0}-@code{a15},
25 except @code{a1} (@code{sp}).")
27 (define_register_constraint "b" "TARGET_BOOLEANS ? BR_REGS : NO_REGS"
28 "Boolean registers @code{b0}-@code{b15}; only available if the Xtensa
29 Boolean Option is configured.")
31 (define_register_constraint "d" "TARGET_DENSITY ? AR_REGS: NO_REGS"
33 All AR registers, including sp, but only if the Xtensa Code Density
34 Option is configured.")
36 (define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS"
37 "Floating-point registers @code{f0}-@code{f15}; only available if the
38 Xtensa Floating-Pointer Coprocessor is configured.")
40 (define_register_constraint "q" "SP_REG"
42 The stack pointer (register @code{a1}).")
44 (define_register_constraint "A" "TARGET_MAC16 ? ACC_REG : NO_REGS"
45 "The low 32 bits of the accumulator from the Xtensa MAC16 Option.")
47 (define_register_constraint "B" "TARGET_SEXT ? GR_REGS : NO_REGS"
49 General-purpose AR registers, but only if the Xtensa Sign Extend
50 Option is configured.")
52 (define_register_constraint "C" "TARGET_MUL16 ? GR_REGS: NO_REGS"
54 General-purpose AR registers, but only if the Xtensa 16-Bit Integer
55 Multiply Option is configured.")
57 (define_register_constraint "D" "TARGET_DENSITY ? GR_REGS: NO_REGS"
59 General-purpose AR registers, but only if the Xtensa Code Density
60 Option is configured.")
62 (define_register_constraint "W" "TARGET_CONST16 ? GR_REGS: NO_REGS"
64 General-purpose AR registers, but only if the Xtensa Const16
65 Option is configured.")
67 ;; Integer constant constraints.
69 (define_constraint "I"
70 "A signed 12-bit integer constant for use with MOVI instructions."
71 (and (match_code "const_int")
72 (match_test "xtensa_simm12b (ival)")))
74 (define_constraint "J"
75 "A signed 8-bit integer constant for use with ADDI instructions."
76 (and (match_code "const_int")
77 (match_test "xtensa_simm8 (ival)")))
79 (define_constraint "K"
80 "A constant integer that can be an immediate operand of an Xtensa
81 conditional branch instruction that performs a signed comparison or
82 a comparison against zero."
83 (and (match_code "const_int")
84 (match_test "xtensa_b4const_or_zero (ival)")))
86 (define_constraint "L"
87 "A constant integer that can be an immediate operand of an Xtensa
88 conditional branch instruction that performs an unsigned comparison."
89 (and (match_code "const_int")
90 (match_test "xtensa_b4constu (ival)")))
92 (define_constraint "M"
93 "An integer constant in the range @minus{}32-95 for use with MOVI.N
95 (and (match_code "const_int")
96 (match_test "ival >= -32 && ival <= 95")))
98 (define_constraint "N"
99 "An unsigned 8-bit integer constant shifted left by 8 bits for use
100 with ADDMI instructions."
101 (and (match_code "const_int")
102 (match_test "xtensa_simm8x256 (ival)")))
104 (define_constraint "O"
105 "An integer constant that can be used in ADDI.N instructions."
106 (and (match_code "const_int")
107 (match_test "ival == -1 || (ival >= 1 && ival <= 15)")))
109 (define_constraint "P"
110 "An integer constant that can be used as a mask value in an EXTUI
112 (and (match_code "const_int")
113 (match_test "xtensa_mask_immediate (ival)")))
115 ;; Memory constraints. Do not use define_memory_constraint here. Doing so
116 ;; causes reload to force some constants into the constant pool, but since
117 ;; the Xtensa constant pool can only be accessed with L32R instructions, it
118 ;; is always better to just copy a constant into a register. Instead, use
119 ;; regular constraints but add a check to allow pseudos during reload.
121 (define_constraint "R"
122 "Memory that can be accessed with a 4-bit unsigned offset from a register."
123 (ior (and (match_code "mem")
124 (match_test "smalloffset_mem_p (op)"))
125 (and (match_code "reg")
126 (match_test "reload_in_progress
127 && REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
129 (define_constraint "T"
130 "Memory in a literal pool (addressable with an L32R instruction)."
131 (and (match_code "mem")
132 (match_test "!TARGET_CONST16 && constantpool_mem_p (op)")))
134 (define_constraint "U"
135 "Memory that is not in a literal pool."
136 (ior (and (match_code "mem")
137 (match_test "! constantpool_mem_p (op)"))
138 (and (match_code "reg")
139 (match_test "reload_in_progress
140 && REGNO (op) >= FIRST_PSEUDO_REGISTER"))))