1 ;; Constraint definitions for LoongArch.
2 ;; Copyright (C) 2021-2023 Free Software Foundation, Inc.
3 ;; Contributed by Loongson Ltd.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; Register constraints
24 ;; "b" "A constant call not local address."
25 ;; "c" "A constant call local address."
31 ;; "i" "Matches a general integer constant." (Global non-architectural)
33 ;; "k" "A memory operand whose address is formed by a base register and
34 ;; (optionally scaled) index register."
35 ;; "l" "A signed 16-bit constant."
36 ;; "m" "A memory operand whose address is formed by a base register and offset
37 ;; that is suitable for use in instructions with the same addressing mode
38 ;; as @code{st.w} and @code{ld.w}."
39 ;; "n" "Matches a non-symbolic integer constant." (Global non-architectural)
40 ;; "o" "Matches an offsettable memory reference." (Global non-architectural)
41 ;; "p" "Matches a general address." (Global non-architectural)
43 ;; "r" GENERAL_REGS (Global non-architectural)
44 ;; "s" "Matches a symbolic integer constant." (Global non-architectural)
46 ;; "u" "A signed 52bit constant and low 32-bit is zero (for logic instructions)"
47 ;; "v" "A signed 64-bit constant and low 44-bit is zero (for logic instructions)."
48 ;; "w" "Matches any valid memory."
56 ;; "E" "Matches a floating-point constant." (Global non-architectural)
57 ;; "F" "Matches a floating-point constant." (Global non-architectural)
58 ;; "G" "Floating-point zero."
60 ;; "I" "A signed 12-bit constant (for arithmetic instructions)."
61 ;; "J" "Integer zero."
62 ;; "K" "An unsigned 12-bit constant (for logic instructions)."
73 ;; "V" "Matches a non-offsettable memory reference." (Global non-architectural)
75 ;; "X" "Matches anything." (Global non-architectural)
78 ;; "A constant @code{move_operand} that can be safely loaded using
83 ;; "A memory operand whose address is formed by a base register and offset
84 ;; that is suitable for use in instructions with the same addressing mode
85 ;; as @code{ll.w} and @code{sc.w}."
87 ;; "An address that is held in a general-purpose register.
88 ;; The offset is zero"
90 ;; "An address operand whose address is formed by a base register
91 ;; and offset that is suitable for use in instructions with the same
92 ;; addressing mode as @code{preld}."
93 ;; "<" "Matches a pre-dec or post-dec operand." (Global non-architectural)
94 ;; ">" "Matches a pre-inc or post-inc operand." (Global non-architectural)
96 (define_constraint "b"
98 A constant call no local address."
99 (match_operand 0 "is_const_call_no_local_symbol"))
101 (define_constraint "c"
103 A constant call local address."
104 (match_operand 0 "is_const_call_local_symbol"))
106 (define_register_constraint "e" "JIRL_REGS"
109 (define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS"
110 "A floating-point register (if available).")
112 (define_register_constraint "j" "SIBCALL_REGS"
115 (define_memory_constraint "k"
116 "A memory operand whose address is formed by a base register and (optionally scaled)
118 (and (match_code "mem")
119 (match_test "loongarch_base_index_address_p (XEXP (op, 0), mode)")))
121 (define_constraint "l"
122 "A signed 16-bit constant."
123 (and (match_code "const_int")
124 (match_test "IMM16_OPERAND (ival)")))
126 (define_memory_constraint "m"
127 "A memory operand whose address is formed by a base register and offset
128 that is suitable for use in instructions with the same addressing mode
129 as @code{st.w} and @code{ld.w}."
130 (and (match_code "mem")
131 (match_test "loongarch_12bit_offset_address_p (XEXP (op, 0), mode)")))
133 (define_register_constraint "q" "CSR_REGS"
134 "A general-purpose register except for $r0 and $r1 for lcsr.")
136 (define_constraint "u"
137 "A signed 52bit constant and low 32-bit is zero (for logic instructions)."
138 (and (match_code "const_int")
139 (match_test "LU32I_OPERAND (ival)")))
141 (define_constraint "v"
142 "A signed 64-bit constant and low 44-bit is zero (for logic instructions)."
143 (and (match_code "const_int")
144 (match_test "LU52I_OPERAND (ival)")))
146 (define_register_constraint "z" "FCC_REGS"
147 "A floating-point condition code register.")
149 ;; Floating-point constraints
151 (define_constraint "G"
152 "Floating-point zero."
153 (and (match_code "const_double")
154 (match_test "op == CONST0_RTX (mode)")))
156 ;; Integer constraints
158 (define_constraint "I"
159 "A signed 12-bit constant (for arithmetic instructions)."
160 (and (match_code "const_int")
161 (match_test "IMM12_OPERAND (ival)")))
163 (define_constraint "J"
165 (and (match_code "const_int")
166 (match_test "ival == 0")))
168 (define_constraint "K"
169 "An unsigned 12-bit constant (for logic instructions)."
170 (and (match_code "const_int")
171 (match_test "IMM12_OPERAND_UNSIGNED (ival)")))
173 (define_constraint "Yd"
175 A constant @code{move_operand} that can be safely loaded using
177 (and (match_operand 0 "move_operand")
178 (match_test "CONSTANT_P (op)")))
180 (define_constraint "Yx"
182 (match_operand 0 "low_bitmask_operand"))
184 (define_memory_constraint "ZC"
185 "A memory operand whose address is formed by a base register and offset
186 that is suitable for use in instructions with the same addressing mode
187 as @code{ll.w} and @code{sc.w}."
188 (and (match_code "mem")
189 (match_test "loongarch_14bit_shifted_offset_address_p (XEXP (op, 0), mode)")))
191 (define_memory_constraint "ZB"
193 An address that is held in a general-purpose register.
195 (and (match_code "mem")
196 (match_test "REG_P (XEXP (op, 0))")))
198 (define_address_constraint "ZD"
199 "An address operand whose address is formed by a base register
200 and offset that is suitable for use in instructions with the same
201 addressing mode as @code{preld}."
202 (match_test "loongarch_12bit_offset_address_p (op, mode)"))