aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/gcn/predicates.md
blob: 6bace028393dce301694eeef5f47ce934c6519b4 (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
;; Predicate definitions for GCN.
;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
;;
;; 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 VALUE can be stored in a sign extended immediate field.

(define_predicate "gcn_conditional_register_operand"
  (match_operand 0 "register_operand")
{
  if (GET_CODE (op) == SUBREG)
    op = SUBREG_REG (op);

  if (!REG_P (op) || GET_MODE (op) != BImode)
    return 0;

  return REGNO (op) == VCCZ_REG
	 || REGNO (op) == VCC_REG   /* Implied VCCZ.  */
	 || REGNO (op) == SCC_REG
	 || REGNO (op) == EXECZ_REG
	 || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})

(define_predicate "gcn_ssrc_register_operand"
  (match_operand 0 "register_operand")
{
  if (GET_CODE (op) == SUBREG)
    op = SUBREG_REG (op);

  if (!REG_P (op))
    return false;

  return SSRC_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})

(define_predicate "gcn_sdst_register_operand"
  (match_operand 0 "register_operand")
{
  if (GET_CODE (op) == SUBREG)
    op = SUBREG_REG (op);

  if (!REG_P (op))
    return false;

  return SDST_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})

(define_predicate "gcn_vgpr_register_operand"
  (match_operand 0 "register_operand")
{
  if (GET_CODE (op) == SUBREG)
    op = SUBREG_REG (op);

  if (!REG_P (op))
    return false;

  return VGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})

(define_predicate "gcn_inline_immediate_operand"
  (match_code "const_int,const_double,const_vector")
{
  return gcn_inline_constant_p (op);
})

(define_predicate "gcn_vop3_operand"
  (ior (match_operand 0 "gcn_inline_immediate_operand")
       (match_operand 0 "register_operand")))

(define_predicate "gcn_vec0_operand"
  (match_code "const_vector")
{
  return CONST_VECTOR_ELT (op, 0) == const0_rtx && gcn_inline_constant_p (op);
})

(define_predicate "gcn_vec1_operand"
  (match_code "const_vector")
{
  return CONST_VECTOR_ELT (op, 0) == const1_rtx && gcn_inline_constant_p (op);
})

(define_predicate "gcn_vec1d_operand"
  (match_code "const_vector")
{
  if (!gcn_inline_constant_p (op))
    return false;

  rtx elem = CONST_VECTOR_ELT (op, 0);
  if (!CONST_DOUBLE_P (elem))
    return false;
  return real_identical (CONST_DOUBLE_REAL_VALUE (elem), &dconst1);
})

(define_predicate "gcn_const1d_operand"
  (match_code "const_double")
{
  return gcn_inline_constant_p (op)
      && real_identical (CONST_DOUBLE_REAL_VALUE (op), &dconst1);
})

(define_predicate "gcn_32bit_immediate_operand"
  (match_code "const_int,const_double,const_vector,symbol_ref,label_ref")
{
  return gcn_constant_p (op);
})

; LRA works smoother when exec values are immediate constants
; prior register allocation.
(define_predicate "gcn_exec_operand"
  (ior (match_operand 0 "register_operand")
       (match_code "const_int")))

(define_predicate "gcn_exec_reg_operand"
  (match_operand 0 "register_operand"))

(define_predicate "gcn_load_operand"
  (ior (match_operand 0 "nonimmediate_operand")
       (match_operand 0 "gcn_32bit_immediate_operand")))

(define_predicate "gcn_alu_operand"
  (ior (match_operand 0 "register_operand")
       (match_operand 0 "gcn_32bit_immediate_operand")))

(define_predicate "gcn_ds_memory_operand"
  (and (match_code "mem")
       (and (match_test "AS_ANY_DS_P (MEM_ADDR_SPACE (op))")
	    (match_operand 0 "memory_operand"))))

(define_predicate "gcn_valu_dst_operand"
  (ior (match_operand 0 "register_operand")
       (match_operand 0 "gcn_ds_memory_operand")))

(define_predicate "gcn_valu_src0_operand"
  (ior (match_operand 0 "register_operand")
       (ior (match_operand 0 "gcn_32bit_immediate_operand")
	    (match_operand 0 "gcn_ds_memory_operand"))))

(define_predicate "gcn_valu_src1_operand"
  (match_operand 0 "register_operand"))

(define_predicate "gcn_valu_src1com_operand"
  (ior (match_operand 0 "register_operand")
       (match_operand 0 "gcn_32bit_immediate_operand")))

(define_predicate "gcn_conditional_operator"
  (match_code "eq,ne"))

(define_predicate "gcn_compare_64bit_operator"
  (match_code "eq,ne"))

(define_predicate "gcn_compare_operator"
  (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu"))

(define_predicate "gcn_fp_compare_operator"
  (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu,ordered,unordered,uneq,unge,ungt,unle,unlt,ltgt"))

(define_predicate "unary_operator"
  (match_code "not,popcount"))

(define_predicate "binary_operator"
  (match_code "and,ior,xor,ashift,lshiftrt,ashiftrt,smin,smax,umin,umax"))

(define_predicate "gcn_unspec_operand"
  (and (match_code "unspec")
       (match_test "XINT (op, 1) == UNSPEC_VECTOR")))

(define_predicate "general_or_unspec_operand"
  (ior (match_operand 0 "general_operand")
       (and (match_code "unspec")
            (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))

(define_predicate "gcn_register_or_unspec_operand"
  (ior (match_operand 0 "register_operand")
       (and (match_code "unspec")
            (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))

(define_predicate "gcn_alu_or_unspec_operand"
  (ior (match_operand 0 "gcn_alu_operand")
       (and (match_code "unspec")
            (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))

(define_predicate "gcn_register_ds_or_unspec_operand"
  (ior (match_operand 0 "register_operand")
       (ior (match_operand 0 "gcn_ds_memory_operand")
	    (and (match_code "unspec")
              (match_test "XINT (op, 1) == UNSPEC_VECTOR")))))