1 ;; Constraint definitions for CRIS.
2 ;; Copyright (C) 2011-2024 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 ;; Kept for compatibility. It used to exclude the CRIS v32
23 ;; register "ACR", which was like GENERAL_REGS except it
24 ;; couldn't be used for autoincrement, and intended mainly
25 ;; for use in user asm statements.
26 (define_register_constraint "b" "GENERAL_REGS"
29 (define_register_constraint "h" "MOF_REGS"
32 (define_register_constraint "x" "SPECIAL_REGS"
35 (define_register_constraint "c" "CC0_REGS"
38 ;; Integer constraints.
39 (define_constraint "I"
40 "MOVEQ, CMPQ, ANDQ, ORQ."
41 (and (match_code "const_int")
42 (match_test "IN_RANGE (ival, -32, 31)")))
44 (define_constraint "J"
46 (and (match_code "const_int")
47 (match_test "IN_RANGE (ival, 0, 63)")))
49 (define_constraint "Kc"
50 "ASRQ, BTSTQ, LSRQ, LSLQ."
51 (and (match_code "const_int")
52 (match_test "IN_RANGE (ival, 0, 31)")))
54 (define_constraint "Kp"
56 (and (match_code "const_int")
57 (match_test "exact_log2 (ival) >= 0")))
59 (define_constraint "L"
60 "A 16-bit signed number."
61 (and (match_code "const_int")
62 (match_test "IN_RANGE (ival, -32768, 32767)")))
64 (define_constraint "M"
65 "The constant 0 for CLEAR."
66 (and (match_code "const_int")
67 (match_test "ival == 0")))
69 (define_constraint "N"
70 "A negative ADDQ or SUBQ."
71 (and (match_code "const_int")
72 (match_test "IN_RANGE (ival, -63, -1)")))
74 (define_constraint "O"
75 "Quickened ints, QI and HI."
76 (and (match_code "const_int")
77 (ior (match_test "IN_RANGE (ival, (65535 - 31), 65535)")
78 (match_test "IN_RANGE (ival, (255 - 31), 255)"))))
80 (define_constraint "P"
81 "A 16-bit number signed *or* unsigned."
82 (and (match_code "const_int")
83 (match_test "IN_RANGE (ival, -32768, 65535)")))
85 ;; Floating-point constant constraints.
86 (define_constraint "G"
87 "The floating point zero constant"
88 (and (match_code "const_double")
89 (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT")
90 (match_test "op == CONST0_RTX (mode)")))
92 ;; Memory constraints.
94 ;; Just an indirect register (happens to also be "all" slottable
95 ;; memory addressing modes not covered by other constraints, i.e. '>').
96 (define_memory_constraint "Q"
98 (and (match_code "mem")
99 (match_test "cris_base_p (XEXP (op, 0), lra_in_progress
100 || reload_completed)")))
102 ;; Extra constraints.
103 (define_memory_constraint "T"
104 "Memory three-address operand."
105 ;; All are indirect-memory:
106 (and (match_code "mem")
107 ;; Double indirect: [[reg]] or [[reg+]]?
108 (ior (and (match_code "mem" "0")
109 (match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 0),
111 || reload_completed)"))
112 ;; Just an explicit indirect reference: [const]?
113 (match_test "CONSTANT_P (XEXP (op, 0))")
114 ;; Something that is indexed; [...+...]?
115 (and (match_code "plus" "0")
116 ;; A BDAP constant: [reg+(8|16|32)bit offset]?
117 (ior (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
119 || reload_completed)")
120 (match_test "CONSTANT_P (XEXP (XEXP (op, 0), 1))"))
121 ;; A BDAP register: [reg+[reg(+)].S]?
122 (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
124 || reload_completed)")
125 (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 1),
127 || reload_completed)"))
128 ;; Same, but with swapped arguments (no canonical
129 ;; ordering between e.g. REG and MEM as of LAST_UPDATED
130 ;; "Thu May 12 03:59:11 UTC 2005").
131 (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
133 || reload_completed)")
134 (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 0),
136 || reload_completed)"))
137 ;; A BIAP: [reg+reg.S] (MULT comes first).
138 (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
140 || reload_completed)")
141 (match_test "cris_biap_index_p (XEXP (XEXP (op, 0), 0),
143 || reload_completed)")))))))