annotate gcc/config/cr16/predicates.md @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ;; Predicates of machine description for CR16.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 ;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 ;; Contributed by KPIT Cummins Infosystems Limited.
kono
parents:
diff changeset
4 ;;
kono
parents:
diff changeset
5 ;; This file is part of GCC.
kono
parents:
diff changeset
6 ;;
kono
parents:
diff changeset
7 ;; GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
8 ;; under the terms of the GNU General Public License as published
kono
parents:
diff changeset
9 ;; by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
10 ;; option) any later version.
kono
parents:
diff changeset
11 ;;
kono
parents:
diff changeset
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
15 ;; License for more details.
kono
parents:
diff changeset
16 ;;
kono
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 ;; along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 ;; <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 ;; Predicates
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 ;; Predicates for sbit/cbit instructions
kono
parents:
diff changeset
24 ;; bit operand used for the generation of bit insn generation
kono
parents:
diff changeset
25 (define_predicate "bit_operand"
kono
parents:
diff changeset
26 (match_code "mem")
kono
parents:
diff changeset
27 {
kono
parents:
diff changeset
28 return ((GET_CODE (op) == MEM && OK_FOR_Z (op)));
kono
parents:
diff changeset
29 })
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 ;; Unsigned 4-bits constant int or double value.
kono
parents:
diff changeset
32 (define_predicate "u4bits_operand"
kono
parents:
diff changeset
33 (match_code "const_int,const_double")
kono
parents:
diff changeset
34 {
kono
parents:
diff changeset
35 if (GET_CODE (op) == CONST_DOUBLE)
kono
parents:
diff changeset
36 return cr16_const_double_ok (op);
kono
parents:
diff changeset
37 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 4)) ? 1 : 0;
kono
parents:
diff changeset
38 })
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 ;; Operand is a constant integer where
kono
parents:
diff changeset
41 ;; only one bit is set to 1.
kono
parents:
diff changeset
42 (define_predicate "one_bit_operand"
kono
parents:
diff changeset
43 (match_code "const_int")
kono
parents:
diff changeset
44 {
kono
parents:
diff changeset
45 unsigned int val;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 val = INTVAL (op);
kono
parents:
diff changeset
48 if (mode == QImode)
kono
parents:
diff changeset
49 val &= 0xff;
kono
parents:
diff changeset
50 else if (mode == HImode)
kono
parents:
diff changeset
51 val &= 0xffff;
kono
parents:
diff changeset
52 else
kono
parents:
diff changeset
53 gcc_unreachable();
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 if (val != 0)
kono
parents:
diff changeset
56 return (val & (val - 1)) == 0; /* true if only one bit is set. */
kono
parents:
diff changeset
57 else
kono
parents:
diff changeset
58 return 0;
kono
parents:
diff changeset
59 })
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 ;; Operand is a constant integer where
kono
parents:
diff changeset
62 ;; only one bit is set to 0.
kono
parents:
diff changeset
63 (define_predicate "rev_one_bit_operand"
kono
parents:
diff changeset
64 (match_code "const_int")
kono
parents:
diff changeset
65 {
kono
parents:
diff changeset
66 unsigned int val;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 val = ~INTVAL (op); /* Invert and use. */
kono
parents:
diff changeset
69 if (mode == QImode)
kono
parents:
diff changeset
70 val &= 0xff;
kono
parents:
diff changeset
71 else if (mode == HImode)
kono
parents:
diff changeset
72 val &= 0xffff;
kono
parents:
diff changeset
73 else
kono
parents:
diff changeset
74 gcc_unreachable();
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 if (val != 0)
kono
parents:
diff changeset
77 return (val & (val - 1)) == 0; /* true if only one bit is set. */
kono
parents:
diff changeset
78 else
kono
parents:
diff changeset
79 return 0;
kono
parents:
diff changeset
80 })
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 ;; Predicates for shift instructions
kono
parents:
diff changeset
83 ;; Immediate operand predicate for count in shift operations.
kono
parents:
diff changeset
84 ;; Immediate shall be 3-bits in case operand to be operated on
kono
parents:
diff changeset
85 ;; is a qi mode operand.
kono
parents:
diff changeset
86 (define_predicate "shift_qi_imm_operand"
kono
parents:
diff changeset
87 (match_code "const_int")
kono
parents:
diff changeset
88 {
kono
parents:
diff changeset
89 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 3)) ? 1 : 0;
kono
parents:
diff changeset
90 })
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 ;; Immediate shall be 4-bits in case operand to be operated on
kono
parents:
diff changeset
93 ;; is a hi mode operand.
kono
parents:
diff changeset
94 (define_predicate "shift_hi_imm_operand"
kono
parents:
diff changeset
95 (match_code "const_int")
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 4)) ? 1 : 0;
kono
parents:
diff changeset
98 })
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 ;; Immediate shall be 3-bits in case operand to be operated on
kono
parents:
diff changeset
101 ;; is a si mode operand.
kono
parents:
diff changeset
102 (define_predicate "shift_si_imm_operand"
kono
parents:
diff changeset
103 (match_code "const_int")
kono
parents:
diff changeset
104 {
kono
parents:
diff changeset
105 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 5)) ? 1 : 0;
kono
parents:
diff changeset
106 })
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 ;; Predicates for jump/call instructions
kono
parents:
diff changeset
109 ;; Jump immediate cannot be more than 24-bits
kono
parents:
diff changeset
110 (define_predicate "jump_imm_operand"
kono
parents:
diff changeset
111 (match_code "const_int")
kono
parents:
diff changeset
112 {
kono
parents:
diff changeset
113 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 24)) ? 1 : 0;
kono
parents:
diff changeset
114 })
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 ;; Call immediate cannot be more than 24-bits
kono
parents:
diff changeset
117 (define_predicate "call_imm_operand"
kono
parents:
diff changeset
118 (match_operand 0 "immediate_operand")
kono
parents:
diff changeset
119 {
kono
parents:
diff changeset
120 if (GET_CODE (op) != CONST_INT) return 1;
kono
parents:
diff changeset
121 return (UNSIGNED_INT_FITS_N_BITS(INTVAL (op), 24)) ? 1 : 0;
kono
parents:
diff changeset
122 })
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 ;; Operand is register or 4-bit immediate operand
kono
parents:
diff changeset
125 (define_predicate "reg_or_u4bits_operand"
kono
parents:
diff changeset
126 (ior (match_operand 0 "u4bits_operand")
kono
parents:
diff changeset
127 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 ;; Operand is a register or symbol reference
kono
parents:
diff changeset
130 (define_predicate "reg_or_sym_operand"
kono
parents:
diff changeset
131 (ior (match_code "symbol_ref")
kono
parents:
diff changeset
132 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 ;; Operand is a non stack pointer register
kono
parents:
diff changeset
135 (define_predicate "nosp_reg_operand"
kono
parents:
diff changeset
136 (and (match_operand 0 "register_operand")
kono
parents:
diff changeset
137 (match_test "REGNO (op) != SP_REGNUM")))
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 (define_predicate "hard_reg_operand"
kono
parents:
diff changeset
140 (and (match_operand 0 "register_operand")
kono
parents:
diff changeset
141 (match_test "REGNO (op) <= 15")))
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 ;; Operand is a memory reference and
kono
parents:
diff changeset
144 ;; not a push operand.
kono
parents:
diff changeset
145 (define_predicate "store_operand"
kono
parents:
diff changeset
146 (and (match_operand 0 "memory_operand")
kono
parents:
diff changeset
147 (not (match_operand 0 "push_operand"))))
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 ;; Helper predicate
kono
parents:
diff changeset
150 (define_predicate "reg_or_int_operand"
kono
parents:
diff changeset
151 (ior (match_code "const_int")
kono
parents:
diff changeset
152 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 ;;
kono
parents:
diff changeset
155 ;;
kono
parents:
diff changeset
156 ;; Atithmetic/logical predicates
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 ;; QI Helper
kono
parents:
diff changeset
159 (define_predicate "arith_qi_operand"
kono
parents:
diff changeset
160 (match_code "const_int")
kono
parents:
diff changeset
161 {
kono
parents:
diff changeset
162 return (IN_RAN(INTVAL (op), 0, 15) && ((INTVAL (op) != 9)
kono
parents:
diff changeset
163 || (INTVAL (op) != 11))) ? 1 : 0 ;
kono
parents:
diff changeset
164 })
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 ;;QI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
167 (define_predicate "reg_qi_int_operand"
kono
parents:
diff changeset
168 (ior (match_operand 0 "arith_qi_operand")
kono
parents:
diff changeset
169 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 ;; HI Helper
kono
parents:
diff changeset
172 (define_predicate "arith_hi_operand"
kono
parents:
diff changeset
173 (match_code "const_int")
kono
parents:
diff changeset
174 {
kono
parents:
diff changeset
175 return (IN_RAN(INTVAL (op), -32768, 32768) ) ? 1 : 0 ;
kono
parents:
diff changeset
176 })
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 ;;HI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
179 (define_predicate "reg_hi_int_operand"
kono
parents:
diff changeset
180 (ior (match_operand 0 "arith_hi_operand")
kono
parents:
diff changeset
181 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 ;;SI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
184 (define_predicate "reg_si_int_operand"
kono
parents:
diff changeset
185 (ior (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
186 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 ;;
kono
parents:
diff changeset
189 ;; Shift predicates
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 ;; QI Helper
kono
parents:
diff changeset
192 (define_predicate "shift_qi_operand"
kono
parents:
diff changeset
193 (match_code "const_int")
kono
parents:
diff changeset
194 {
kono
parents:
diff changeset
195 return (IN_RAN(INTVAL (op), 0, 7) ) ? 1 : 0;
kono
parents:
diff changeset
196 })
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 ;;QI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
199 (define_predicate "shift_reg_qi_int_operand"
kono
parents:
diff changeset
200 (ior (match_operand 0 "shift_qi_operand")
kono
parents:
diff changeset
201 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 ;; HI Helper
kono
parents:
diff changeset
204 (define_predicate "shift_hi_operand"
kono
parents:
diff changeset
205 (match_code "const_int")
kono
parents:
diff changeset
206 {
kono
parents:
diff changeset
207 return (IN_RAN(INTVAL (op), 0, 15) ) ? 1 : 0 ;
kono
parents:
diff changeset
208 })
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 ;;HI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
211 (define_predicate "shift_reg_hi_int_operand"
kono
parents:
diff changeset
212 (ior (match_operand 0 "shift_hi_operand")
kono
parents:
diff changeset
213 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 ;; SI Helper
kono
parents:
diff changeset
216 (define_predicate "shift_si_operand"
kono
parents:
diff changeset
217 (match_code "const_int")
kono
parents:
diff changeset
218 {
kono
parents:
diff changeset
219 return (IN_RAN(INTVAL (op), 0, 31) ) ? 1 : 0;
kono
parents:
diff changeset
220 })
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 ;;SI Reg, subreg(reg) or const_int.
kono
parents:
diff changeset
223 (define_predicate "shift_reg_si_int_operand"
kono
parents:
diff changeset
224 (ior (match_operand 0 "shift_si_operand")
kono
parents:
diff changeset
225 (match_operand 0 "register_operand")))