1;; Constraint definitions for GCN.
2;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
3;;
4;; This file is part of GCC.
5;;
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)
9;; any later version.
10;;
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.
15;;
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/>.
19
20(define_constraint "I"
21  "Inline integer constant"
22  (and (match_code "const_int")
23       (match_test "ival >= -16 && ival <= 64")))
24
25(define_constraint "J"
26  "Signed integer 16-bit inline constant"
27  (and (match_code "const_int")
28       (match_test "((unsigned HOST_WIDE_INT) ival + 0x8000) < 0x10000")))
29
30(define_constraint "Kf"
31  "Immeditate constant -1"
32  (and (match_code "const_int")
33       (match_test "ival == -1")))
34
35(define_constraint "L"
36  "Unsigned integer 15-bit constant"
37  (and (match_code "const_int")
38       (match_test "((unsigned HOST_WIDE_INT) ival) < 0x8000")))
39
40(define_constraint "A"
41  "Inline immediate parameter"
42  (and (match_code "const_int,const_double,const_vector")
43       (match_test "gcn_inline_constant_p (op)")))
44
45(define_constraint "B"
46  "Immediate 32-bit parameter"
47  (and (match_code "const_int,const_double,const_vector")
48	(match_test "gcn_constant_p (op)")))
49
50(define_constraint "C"
51  "Immediate 32-bit parameter zero-extended to 64-bits"
52  (and (match_code "const_int,const_double,const_vector")
53	(match_test "gcn_constant64_p (op)")))
54
55(define_constraint "DA"
56  "Splittable inline immediate 64-bit parameter"
57  (and (match_code "const_int,const_double,const_vector")
58       (match_test "gcn_inline_constant64_p (op)")))
59
60(define_constraint "DB"
61  "Splittable immediate 64-bit parameter"
62  (match_code "const_int,const_double,const_vector"))
63
64(define_constraint "U"
65  "unspecified value"
66  (match_code "unspec"))
67
68(define_constraint "Y"
69  "Symbol or label for relative calls"
70  (match_code "symbol_ref,label_ref"))
71
72(define_register_constraint "v" "VGPR_REGS"
73  "VGPR registers")
74
75(define_register_constraint "Sg" "SGPR_REGS"
76  "SGPR registers")
77
78(define_register_constraint "SD" "SGPR_DST_REGS"
79  "registers useable as a destination of scalar operation")
80
81(define_register_constraint "SS" "SGPR_SRC_REGS"
82  "registers useable as a source of scalar operation")
83
84(define_register_constraint "Sm" "SGPR_MEM_SRC_REGS"
85  "registers useable as a source of scalar memory operation")
86
87(define_register_constraint "Sv" "SGPR_VOP_SRC_REGS"
88  "registers useable as a source of VOP3A instruction")
89
90(define_register_constraint "ca" "ALL_CONDITIONAL_REGS"
91  "SCC VCCZ or EXECZ")
92
93(define_register_constraint "cs" "SCC_CONDITIONAL_REG"
94  "SCC")
95
96(define_register_constraint "cV" "VCC_CONDITIONAL_REG"
97  "VCC")
98
99(define_register_constraint "e" "EXEC_MASK_REG"
100  "EXEC")
101
102(define_special_memory_constraint "RB"
103  "Buffer memory address to scratch memory."
104  (and (match_code "mem")
105       (match_test "AS_SCRATCH_P (MEM_ADDR_SPACE (op))")))
106
107(define_special_memory_constraint "RF"
108  "Buffer memory address to flat memory."
109  (and (match_code "mem")
110       (match_test "AS_FLAT_P (MEM_ADDR_SPACE (op))
111		    && gcn_flat_address_p (XEXP (op, 0), mode)")))
112
113(define_special_memory_constraint "RS"
114  "Buffer memory address to scalar flat memory."
115  (and (match_code "mem")
116       (match_test "AS_SCALAR_FLAT_P (MEM_ADDR_SPACE (op))
117		    && gcn_scalar_flat_mem_p (op)")))
118
119(define_special_memory_constraint "RL"
120  "Buffer memory address to LDS memory."
121  (and (match_code "mem")
122       (match_test "AS_LDS_P (MEM_ADDR_SPACE (op))")))
123
124(define_special_memory_constraint "RG"
125  "Buffer memory address to GDS memory."
126  (and (match_code "mem")
127       (match_test "AS_GDS_P (MEM_ADDR_SPACE (op))")))
128
129(define_special_memory_constraint "RD"
130  "Buffer memory address to GDS or LDS memory."
131  (and (match_code "mem")
132       (ior (match_test "AS_GDS_P (MEM_ADDR_SPACE (op))")
133	    (match_test "AS_LDS_P (MEM_ADDR_SPACE (op))"))))
134
135(define_special_memory_constraint "RM"
136  "Memory address to global (main) memory."
137  (and (match_code "mem")
138       (match_test "AS_GLOBAL_P (MEM_ADDR_SPACE (op))
139		    && gcn_global_address_p (XEXP (op, 0))")))
140