summaryrefslogtreecommitdiff
path: root/gcc/config/tilepro/predicates.md
blob: 6c4ffbe4a206642714ee3724db0bac07e5ccc20f (plain)
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
;; Predicate definitions for Tilera TILEPro chip.
;; Copyright (C) 2011, 2012
;; Free Software Foundation, Inc.
;; Contributed by Walter Lee (walt@tilera.com)
;;
;; 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 3, 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 COPYING3.  If not see
;; <http://www.gnu.org/licenses/>.

;; Return true if OP is the zero constant for MODE.
(define_predicate "const_zero_operand"
  (and (match_code "const_int,const_double,const_vector")
       (match_test "op == CONST0_RTX (mode)")))

;; Returns true if OP is either the constant zero or a register.
(define_predicate "reg_or_0_operand"
  (and (ior (match_operand 0 "register_operand")
	    (match_operand 0 "const_zero_operand"))
       (match_test "GET_MODE_SIZE (mode) <= UNITS_PER_WORD")))

; Return 1 if OP is a network register identifier.
(define_predicate "netreg_operand"
  (and (match_code "const_int")
       (match_test "IN_RANGE (INTVAL (op), 0, 6)")))

; Return 1 if OP is an unsigned 5-bit constant.
(define_predicate "u5bit_cint_operand"
  (and (match_code "const_int")
       (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)")))

;; Return 1 if OP is an unsigned 16-bit constant.
(define_predicate "u16bit_cint_operand"
  (and (match_code "const_int")
       (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 16)")))

;; Return 1 if OP is a signed 8-bit constant.
(define_predicate "s8bit_cint_operand"
  (and (match_code "const_int")
       (match_test "satisfies_constraint_I (op)")))

;; Return 1 if OP is a signed 16-bit constant.
(define_predicate "s16bit_cint_operand"
  (and (match_code "const_int")
       (match_test "satisfies_constraint_J (op)")))

;; Return 1 if OP is a nonzero integer constant whose low 16 bits are zero.
(define_predicate "auli_cint_operand"
  (and (match_code "const_int")
       (match_test "satisfies_constraint_K (op)")))

;; Return 1 if OP is an unsigned 15-bit constant.
(define_predicate "u15bit_cint_operand"
  (and (match_code "const_int")
       (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 15)")))

;; Return 1 if OP is a constant or any register.
(define_predicate "reg_or_cint_operand"
  (ior (match_operand 0 "register_operand")
       (match_operand 0 "const_int_operand")))

;; Return 1 if OP is a 4-element vector constant with identical signed
;; 8-bit elements or any register.
(define_predicate "reg_or_v4s8bit_operand"
  (ior (match_operand 0 "register_operand")
       (and (match_code "const_vector")
	    (match_test "CONST_VECTOR_NUNITS (op) == 4
                         && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0))
                         && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1)
                         && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 2)
                         && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 3)"))))

;; Return 1 if OP is a 2-element vector constant with identical signed
;; 8-bit elements or any register.
(define_predicate "reg_or_v2s8bit_operand"
  (ior (match_operand 0 "register_operand")
       (and (match_code "const_vector")
	    (match_test "CONST_VECTOR_NUNITS (op) == 2
                         && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0))
                         && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1)"))))

;; Return 1 if the operand is a valid second operand to an add insn.
(define_predicate "add_operand"
  (if_then_else (match_code "const_int")
    (match_test "satisfies_constraint_J (op) || satisfies_constraint_K (op)")
    (match_operand 0 "register_operand")))

;; Return 1 if the operand is a register or signed 8-bit immediate operand.
(define_predicate "reg_or_s8bit_operand"
  (if_then_else (match_code "const_int")
    (match_test "satisfies_constraint_I (op)")
    (match_operand 0 "register_operand")))

;; Return 1 for an operand suitable for ANDing with a register.
(define_predicate "and_operand"
  (if_then_else (match_code "const_int")
    (match_test "satisfies_constraint_I (op) || satisfies_constraint_M (op)")
    (match_operand 0 "register_operand")))

;; Return 1 if the operand is a register or unsigned 5-bit immediate operand.
(define_predicate "reg_or_u5bit_operand"
  (if_then_else (match_code "const_int")
    (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)")
    (match_operand 0 "register_operand")))

; Return 1 if the operand is 2, 4 or 8.
(define_predicate "cint_248_operand"
  (and (match_code "const_int")
       (match_test
        "INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8")))


;; Return true if OP is a TLS symbolic operand.
(define_predicate "tls_symbolic_operand"
  (and (match_code "symbol_ref")
       (match_test "SYMBOL_REF_TLS_MODEL (op) !=  TLS_MODEL_NONE")))

;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
(define_predicate "tls_gd_symbolic_operand"
  (and (match_code "symbol_ref")
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))

;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
(define_predicate "tls_ld_symbolic_operand"
  (and (match_code "symbol_ref")
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))

;; Return true if OP is a symbolic operand that can be used for the
;; TLS Initial Exec model.
(define_predicate "tls_ie_symbolic_operand"
  (and (match_code "symbol_ref")
       (ior (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")
            (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))))

;; Return true if OP is a symbolic operand for the TLS Local Exec model.
(define_predicate "tls_le_symbolic_operand"
  (and (match_code "symbol_ref")
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))

;; Returns true if OP is any general operand except for an
;; auto-incrementing address operand.
(define_predicate "nonautoinc_operand"
  (and (match_operand 0 "general_operand")
       (not (ior (match_code "pre_dec") (match_code "pre_inc")
		 (match_code "post_dec") (match_code "post_inc")
		 (match_code "post_modify") (match_code "pre_modify")))))

;; Returns true if OP is a non-auto-incrementing memory operand.
(define_predicate "nonautoincmem_operand"
  (match_operand 0 "memory_operand")
{
  return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
})

;; Returns true if OP is a non-auto-incrementing memory, general
;; operand.
(define_predicate "nonautoincmem_general_operand"
  (match_operand 0 "general_operand")
{
  if (memory_operand (op, mode))
    return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
  else
    return true;
})
 
;; Returns true if OP is a non-auto-incrementing memory, non-immediate
;; operand.
(define_predicate "nonautoincmem_nonimmediate_operand"
  (match_operand 0 "nonimmediate_operand")
{
  if (memory_operand (op, mode))
    return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
  else
    return true;
})
 
;; Return true if OP is a valid operand for the source of a move insn.
(define_predicate "move_operand"
  (match_operand 0 "general_operand")
{
  /* If both modes are non-void they must be the same.  */
  if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op))
    return false;

  if (GET_MODE_SIZE (mode) > 4)
    return false;

  switch (GET_CODE (op))
    {
    case CONST_INT:
      return (satisfies_constraint_J (op)
              || satisfies_constraint_K (op)
              || satisfies_constraint_N (op)
              || satisfies_constraint_P (op));

    case HIGH:
      return true;

    case MEM:
      return memory_address_p (mode, XEXP (op, 0));

    default:
      return register_operand (op, mode);
    }
})

;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
;; possibly with an offset.
(define_predicate "symbolic_operand"
  (ior (match_code "symbol_ref,label_ref")
       (and (match_code "const")
	    (match_test "GET_CODE (XEXP (op,0)) == PLUS
			 && (GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF
			     || GET_CODE (XEXP (XEXP (op,0), 0)) == LABEL_REF)
			 && CONST_INT_P (XEXP (XEXP (op,0), 1))"))))

;; Returns 1 if OP is a symbolic operand, or a const unspec wrapper
;; representing a got reference, a tls reference, or pc-relative
;; reference.
(define_predicate "const_symbolic_operand"
  (ior (match_operand 0 "symbolic_operand")
       (and (match_code "const")
	    (match_test "GET_CODE (XEXP (op,0)) == UNSPEC")
	    (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT16_SYM")
		 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT32_SYM")
		 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_PCREL_SYM")
		 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_GD")
		 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_IE")
		 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_LE")))))

;; Return true if OP is an address suitable for a call insn.
;; Call insn on TILE can take a PC-relative constant address
;; or any regular memory address.
(define_predicate "call_address_operand"
  (ior (match_operand 0 "symbolic_operand")
       (match_test "memory_address_p (Pmode, op)")))

;; Return true if OP is an operand suitable for a call insn.
(define_predicate "call_operand"
  (and (match_code "mem")
       (match_test "call_address_operand (XEXP (op, 0), mode)")))

;; Return 1 if OP is a signed comparison operation.
;; We can use these directly in compares against zero.
(define_predicate "signed_comparison_operator"
  (match_code "eq,ne,le,lt,ge,gt"))

;; Return 1 if OP is a equal or not-equal operation.
(define_predicate "eqne_operator"
  (match_code "eq,ne"))