1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
;; Machine Descriptions for R8C/M16C/M32C
;; Copyright (C) 2005
;; Free Software Foundation, Inc.
;; Contributed by Red Hat.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2, or (at your
;; option) any later version.
;;
;; GCC is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING. If not, write to the Free
;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301, USA.
;; Predicates
; TRUE if the operand is a pseudo-register.
(define_predicate "m32c_pseudo"
(ior (and (match_code "reg")
(match_test "REGNO(op) >= FIRST_PSEUDO_REGISTER"))
(and (match_code "subreg")
(and (match_test "GET_CODE (XEXP (op, 0)) == REG")
(match_test "REGNO(XEXP (op,0)) >= FIRST_PSEUDO_REGISTER")))))
; Returning true causes many predicates to NOT match. We allow
; subregs for type changing, but not for size changing.
(define_predicate "m32c_wide_subreg"
(and (match_code "subreg")
(not (match_operand 0 "m32c_pseudo")))
{
unsigned int sizeo = GET_MODE_SIZE (GET_MODE (op));
unsigned int sizei = GET_MODE_SIZE (GET_MODE (XEXP (op, 0)));
sizeo = (sizeo + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
sizei = (sizei + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
return sizeo != sizei;
})
; TRUE for r0 through r3, or a pseudo that reload could put in r0
; through r3 (likewise for the next couple too)
(define_predicate "r0123_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) <= R3_REGNO"))))
; TRUE for r0
(define_predicate "m32c_r0_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) == R0_REGNO"))))
; TRUE for r1
(define_predicate "m32c_r1_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) == R1_REGNO"))))
; TRUE for r2
(define_predicate "m32c_r2_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) == R2_REGNO"))))
; TRUE for any general operand except r2.
(define_predicate "m32c_notr2_operand"
(and (match_operand 0 "general_operand")
(ior (not (match_code "reg"))
(match_test "REGNO(op) != R2_REGNO"))))
; TRUE for the stack pointer.
(define_predicate "m32c_sp_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) == SP_REGNO"))))
; TRUE for control registers.
(define_predicate "cr_operand"
(match_code "reg")
"return (REGNO (op) >= SB_REGNO
&& REGNO (op) <= FLG_REGNO);")
; TRUE for $a0 or $a1.
(define_predicate "a_operand"
(match_code "reg")
"return (REGNO (op) == A0_REGNO
|| REGNO (op) == A1_REGNO);")
; TRUE for r0 through r3, or a0 or a1.
(define_predicate "ra_operand"
(and (and (match_operand 0 "register_operand" "")
(not (match_operand 1 "cr_operand" "")))
(not (match_operand 2 "m32c_wide_subreg" ""))))
; Likewise, plus TRUE for memory references.
(define_predicate "mra_operand"
(and (and (match_operand 0 "nonimmediate_operand" "")
(not (match_operand 1 "cr_operand" "")))
(not (match_operand 2 "m32c_wide_subreg" ""))))
; Likewise, plus TRUE for subregs.
(define_predicate "mras_operand"
(and (match_operand 0 "nonimmediate_operand" "")
(not (match_operand 1 "cr_operand" ""))))
; TRUE for memory, r0..r3, a0..a1, or immediates.
(define_predicate "mrai_operand"
(and (and (match_operand 0 "general_operand" "")
(not (match_operand 1 "cr_operand" "")))
(not (match_operand 2 "m32c_wide_subreg" ""))))
; Likewise, plus true for subregs.
(define_predicate "mrasi_operand"
(and (match_operand 0 "general_operand" "")
(not (match_operand 1 "cr_operand" ""))))
; TRUE for r0..r3 or memory.
(define_predicate "mr_operand"
(and (match_operand 0 "mra_operand" "")
(not (match_operand 1 "a_operand" ""))))
; TRUE for r1h. This complicated since r1h isn't a register GCC
; normally knows about.
(define_predicate "r1h_operand"
(match_code "zero_extract")
{
rtx reg = XEXP (op, 0);
rtx size = XEXP (op, 1);
rtx pos = XEXP (op, 2);
return (GET_CODE (reg) == REG
&& REGNO (reg) == R1_REGNO
&& GET_CODE (size) == CONST_INT
&& INTVAL (size) == 8
&& GET_CODE (pos) == CONST_INT
&& INTVAL (pos) == 8);
})
; TRUE if we can shift by this amount. Constant shift counts have a
; limited range.
(define_predicate "shiftcount_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_operand 2 "const_int_operand" "")
(match_test "-8 <= INTVAL (op) && INTVAL (op) && INTVAL (op) <= 8"))))
; TRUE for r0..r3, a0..a1, or sp.
(define_predicate "mra_or_sp_operand"
(and (ior (match_operand 0 "mra_operand")
(match_operand 1 "m32c_sp_operand"))
(not (match_operand 2 "m32c_wide_subreg" ""))))
; TRUE for r2 or r3.
(define_predicate "m32c_r2r3_operand"
(ior (and (match_code "reg")
(ior (match_test "REGNO(op) == R2_REGNO")
(match_test "REGNO(op) == R3_REGNO")))
(and (match_code "subreg")
(match_test "GET_CODE (XEXP (op, 0)) == REG && (REGNO (XEXP (op, 0)) == R2_REGNO || REGNO (XEXP (op, 0)) == R3_REGNO)"))))
; Likewise, plus TRUE for a0..a1.
(define_predicate "m32c_r2r3a_operand"
(ior (match_operand 0 "m32c_r2r3_operand" "")
(match_operand 0 "a_operand" "")))
; These two are only for movqi - no subreg limit
(define_predicate "mra_qi_operand"
(and (and (match_operand 0 "nonimmediate_operand" "")
(not (match_operand 1 "cr_operand" "")))
(not (match_operand 1 "m32c_r2r3a_operand" ""))))
(define_predicate "mrai_qi_operand"
(and (and (match_operand 0 "general_operand" "")
(not (match_operand 1 "cr_operand" "")))
(not (match_operand 1 "m32c_r2r3a_operand" ""))))
; TRUE for comparisons we support.
(define_predicate "m32c_cmp_operator"
(match_code "eq,ne,gt,gtu,lt,ltu,ge,geu,le,leu"))
; TRUE for mem0
(define_predicate "m32c_mem0_operand"
(ior (match_operand 0 "m32c_pseudo" "")
(and (match_code "reg")
(match_test "REGNO(op) == MEM0_REGNO"))))
; TRUE for things the call patterns can return.
(define_predicate "m32c_return_operand"
(ior (match_operand 0 "m32c_r0_operand")
(ior (match_operand 0 "m32c_mem0_operand")
(match_code "parallel"))))
|