summaryrefslogtreecommitdiff
path: root/gcc/config/csky/constraints.md
blob: d22e5a6237c23453764a74d11431495c7ba4bad0 (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
;; Constraints for C-SKY.
;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
;; Contributed by C-SKY Microsystems and Mentor Graphics.
;;
;; 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/>.  */

;; Register constraints.

(define_register_constraint "a" "MINI_REGS" "r0 - r7")
(define_register_constraint "b" "LOW_REGS"  "r0 - r15")
(define_register_constraint "c" "C_REGS" "C register")
(define_register_constraint "y" "HILO_REGS" "HI and LO registers")
(define_register_constraint "l" "LO_REGS" "LO register")
(define_register_constraint "h" "HI_REGS" "HI register")
(define_register_constraint "v" "V_REGS" "vector registers")
(define_register_constraint "z" "SP_REGS" "SP register")


;; Memory and misc constraints.

(define_memory_constraint "Q"
  "Memory operands with base register, index register and short displacement for FPUV2"
  (match_test "csky_valid_fpuv2_mem_operand (op)"))

(define_constraint "R"
  "Memory operands whose address is a label_ref"
  (and (match_code "mem")
       (match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF")))

(define_constraint "S"
  "Symbol reference with optional offset"
  (match_test "csky_symbolic_address_p (op)"))


;; Constant integer constraints.

(define_constraint "I"
  "Constant in range [0, 65535]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_I (ival)")))

(define_constraint "J"
  "Constant in range [1, 32]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_J (ival)")))

(define_constraint "K"
  "Constant in range [0, 31]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_K (ival)")))

(define_constraint "L"
  "Constant in range [1, 8]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_L (ival)")))

(define_constraint "M"
  "Constant in range [1, 4096]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_M (ival)")))

(define_constraint "N"
  "Constant in range [1, 256]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_N (ival)")))

(define_constraint "O"
  "Constant in range [0, 4095]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_O (ival)")))

(define_constraint "P"
  "Constant in range [4, 508] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_P (ival)")))

(define_constraint "T"
  "Constant in range [-256, -1]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_T (ival)")))

(define_constraint "Ua"
  "Constant 0"
  (and (match_code "const_int")
       (match_test "ival == 0")))

(define_constraint "Ub"
  "Unsigned int that is an exact power of 2"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Ub (ival)")))

(define_constraint "Uc"
  "Unsigned int X such that X+1 is an exact power of 2"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uc (ival)")))

(define_constraint "Ud"
  "64-bit int whose high/low words separately satisfy I, Ub, or Uc"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Ud (ival)")))

(define_constraint "Ug"
  "Constant in range [-508, -4] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Ug (ival)")))

(define_constraint "Uh"
  "Constant in range [-31, 0]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uh (ival)")))

(define_constraint "Uj"
  "Constant in range [4, 1024] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uj (ival)")))

(define_constraint "Uk"
  "Constant in range [1, 65536]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uk (ival)")))

(define_constraint "Ul"
  "Constant in range [-1024, -4] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Ul (ival)")))

(define_constraint "Um"
  "Constant in range [-4096, -1]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Um (ival)")))

(define_constraint "Un"
  "Constant whose low 16 bits are all zeros"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_MOVIH (ival)")))

(define_constraint "Uo"
  "Constant that can be synthesized with an extra instruction"
  (and (match_code "const_int")
       (match_test "csky_inlinable_constant (ival)")))

(define_constraint "Up"
  "Constant in range [0, 255]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_N (ival + 1)")))

(define_constraint "Uq"
  "Constant in range [0, 1020] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uj (ival + 4)")))

(define_constraint "Ur"
  "Constant in range [-1020, -4] that is divisible by 4"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_Uj (-ival + 4)")))

(define_constraint "Us"
  "Constant in range [-8, -1]"
  (and (match_code "const_int")
       (match_test "CSKY_CONST_OK_FOR_US (ival)")))