summaryrefslogtreecommitdiff
path: root/gcc/config/cris/constraints.md
blob: 651fbedb0a01cd22aa0b6fa1278477300661d94d (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
;; Constraint definitions for CRIS.
;; Copyright (C) 2011-2014 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/>.

;; Register constraints.
(define_register_constraint "a" "ACR_REGS"
  "@internal")

(define_register_constraint "b" "GENNONACR_REGS"
  "@internal")

(define_register_constraint "h" "MOF_REGS"
  "@internal")

(define_register_constraint "x" "SPECIAL_REGS"
  "@internal")

(define_register_constraint "c" "CC0_REGS"
  "@internal")

;; Integer constraints.
(define_constraint "I"
  "MOVEQ, CMPQ, ANDQ, ORQ."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, -32, 31)")))

(define_constraint "J"
  "ADDQ, SUBQ."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, 0, 63)")))

(define_constraint "Kc"
  "ASRQ, BTSTQ, LSRQ, LSLQ."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, 0, 31)")))

(define_constraint "Kp"
  "A power of two."
  (and (match_code "const_int")
       (match_test "exact_log2 (ival) >= 0")))

(define_constraint "L"
  "A 16-bit signed number."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, -32768, 32767)")))

(define_constraint "M"
  "The constant 0 for CLEAR."
  (and (match_code "const_int")
       (match_test "ival == 0")))

(define_constraint "N"
  "A negative ADDQ or SUBQ."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, -63, -1)")))

(define_constraint "O"
  "Quickened ints, QI and HI."
  (and (match_code "const_int")
       (ior (match_test "IN_RANGE (ival, (65535 - 31), 65535)")
	    (match_test "IN_RANGE (ival, (255 - 31), 255)"))))

(define_constraint "P"
  "A 16-bit number signed *or* unsigned."
  (and (match_code "const_int")
       (match_test "IN_RANGE (ival, -32768, 65535)")))

;; Floating-point constant constraints.
(define_constraint "G"
  "The floating point zero constant"
  (and (match_code "const_double")
       (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT")
       (match_test "op == CONST0_RTX (mode)")))

;; Memory constraints.

;; Just an indirect register (happens to also be "all" slottable
;; memory addressing modes not covered by other constraints, i.e. '>').
(define_memory_constraint "Q"
  "@internal"
  (and (match_code "mem")
       (match_test "cris_base_p (XEXP (op, 0), reload_in_progress
					       || reload_completed)")))

;; Extra constraints.
(define_constraint "R"
  "An operand to BDAP or BIAP."
       ;; A BIAP; r.S?
  (ior (match_test "cris_biap_index_p (op, reload_in_progress
					   || reload_completed)")
       ;; A [reg] or (int) [reg], maybe with post-increment.
       (match_test "cris_bdap_index_p (op, reload_in_progress
					   || reload_completed)")
       (match_test "cris_constant_index_p (op)")))

(define_constraint "T"
  "Memory three-address operand."
  ;; All are indirect-memory:
  (and (match_code "mem")
	    ;; Double indirect: [[reg]] or [[reg+]]?
       (ior (and (match_code "mem" "0")
		 (match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 0),
						       reload_in_progress
						       || reload_completed)"))
	    ;; Just an explicit indirect reference: [const]?
	    (match_test "CONSTANT_P (XEXP (op, 0))")
	    ;; Something that is indexed; [...+...]?
	    (and (match_code "plus" "0")
		      ;; A BDAP constant: [reg+(8|16|32)bit offset]?
		 (ior (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
						     reload_in_progress
						     || reload_completed)")
			   (match_test "cris_constant_index_p (XEXP (XEXP (op, 0), 1))"))
		      ;; A BDAP register: [reg+[reg(+)].S]?
		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
						     reload_in_progress
						     || reload_completed)")
			   (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 1),
							   reload_in_progress
							   || reload_completed)"))
		      ;; Same, but with swapped arguments (no canonical
		      ;; ordering between e.g. REG and MEM as of LAST_UPDATED
		      ;; "Thu May 12 03:59:11 UTC 2005").
		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
						     reload_in_progress
						     || reload_completed)")
			   (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 0),
							   reload_in_progress
							   || reload_completed)"))
		      ;; A BIAP: [reg+reg.S] (MULT comes first).
		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
						     reload_in_progress
						     || reload_completed)")
			   (match_test "cris_biap_index_p (XEXP (XEXP (op, 0), 0),
							   reload_in_progress
							   || reload_completed)")))))))

(define_constraint "S"
  "PIC-constructs for symbols."
  (and (match_test "flag_pic")
       (match_code "const")
       (match_test "cris_valid_pic_const (op, false)")))

(define_constraint "U"
  "@internal"
  (and (match_test "flag_pic")
       (match_test "CONSTANT_P (op)")
       (match_operand 0 "cris_nonmemory_operand_or_callable_symbol")))