1 |
709 |
jeremybenn |
;; Operand and operator predicates for the GCC CRIS port.
|
2 |
|
|
;; Copyright (C) 2005, 2007 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 |
|
|
;; .
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
;; Operator predicates.
|
22 |
|
|
|
23 |
|
|
(define_predicate "cris_orthogonal_operator"
|
24 |
|
|
(match_code "plus, minus, ior, and, umin"))
|
25 |
|
|
|
26 |
|
|
(define_predicate "cris_commutative_orth_op"
|
27 |
|
|
(match_code "plus, ior, and, umin"))
|
28 |
|
|
|
29 |
|
|
;; By the name, you might think we should include MULT. We don't because
|
30 |
|
|
;; it doesn't accept the same addressing modes as the others (only
|
31 |
|
|
;; registers) and there's also the problem of handling TARGET_MUL_BUG.
|
32 |
|
|
|
33 |
|
|
(define_predicate "cris_operand_extend_operator"
|
34 |
|
|
(match_code "plus, minus, umin"))
|
35 |
|
|
|
36 |
|
|
(define_predicate "cris_additive_operand_extend_operator"
|
37 |
|
|
(match_code "plus, minus"))
|
38 |
|
|
|
39 |
|
|
(define_predicate "cris_extend_operator"
|
40 |
|
|
(match_code "zero_extend, sign_extend"))
|
41 |
|
|
|
42 |
|
|
(define_predicate "cris_plus_or_bound_operator"
|
43 |
|
|
(match_code "plus, umin"))
|
44 |
|
|
|
45 |
|
|
;; Used as an operator to get a handle on a already-known-valid MEM rtx:es
|
46 |
|
|
;; (no need to validate the address), where some address expression parts
|
47 |
|
|
;; have their own match_operand.
|
48 |
|
|
|
49 |
|
|
(define_predicate "cris_mem_op"
|
50 |
|
|
(match_code "mem"))
|
51 |
|
|
|
52 |
|
|
(define_predicate "cris_load_multiple_op"
|
53 |
|
|
(and (match_code "parallel")
|
54 |
|
|
(match_test "cris_movem_load_rest_p (op, 0)")))
|
55 |
|
|
|
56 |
|
|
(define_predicate "cris_store_multiple_op"
|
57 |
|
|
(and (match_code "parallel")
|
58 |
|
|
(match_test "cris_store_multiple_op_p (op)")))
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
;; Operand helper predicates.
|
62 |
|
|
|
63 |
|
|
(define_predicate "cris_bdap_const_operand"
|
64 |
|
|
(and (match_code "label_ref, symbol_ref, const_int, const_double, const")
|
65 |
|
|
(ior (not (match_test "flag_pic"))
|
66 |
|
|
(match_test "cris_valid_pic_const (op, true)"))))
|
67 |
|
|
|
68 |
|
|
(define_predicate "cris_simple_address_operand"
|
69 |
|
|
(ior (match_operand:SI 0 "register_operand")
|
70 |
|
|
(and (match_code "post_inc")
|
71 |
|
|
(match_test "register_operand (XEXP (op, 0), Pmode)"))))
|
72 |
|
|
|
73 |
|
|
(define_predicate "cris_simple_operand"
|
74 |
|
|
(ior (match_operand 0 "register_operand")
|
75 |
|
|
(and (match_code "mem")
|
76 |
|
|
(match_test "cris_simple_address_operand (XEXP (op, 0),
|
77 |
|
|
Pmode)"))))
|
78 |
|
|
|
79 |
|
|
;; The caller needs to use :SI.
|
80 |
|
|
(define_predicate "cris_bdap_sign_extend_operand"
|
81 |
|
|
; Disabled until
|
82 |
|
|
; or is committed.
|
83 |
|
|
(match_test "0"))
|
84 |
|
|
; (and (match_code "sign_extend")
|
85 |
|
|
; (and (match_test "MEM_P (XEXP (op, 0))")
|
86 |
|
|
; (match_test "cris_simple_address_operand (XEXP (XEXP (op, 0), 0),
|
87 |
|
|
; Pmode)"))))
|
88 |
|
|
|
89 |
|
|
;; FIXME: Should not have to test for 1.
|
90 |
|
|
(define_predicate "cris_scale_int_operand"
|
91 |
|
|
(and (match_code "const_int")
|
92 |
|
|
(ior (ior (match_test "op == GEN_INT (4)")
|
93 |
|
|
(match_test "op == const2_rtx"))
|
94 |
|
|
(match_test "op == const1_rtx"))))
|
95 |
|
|
|
96 |
|
|
;; FIXME: Should be able to assume (reg int).
|
97 |
|
|
(define_predicate "cris_biap_mult_operand"
|
98 |
|
|
(and (match_code "mult")
|
99 |
|
|
(ior (and (match_test "register_operand (XEXP (op, 0), Pmode)")
|
100 |
|
|
(match_test "cris_scale_int_operand (XEXP (op, 1), Pmode)"))
|
101 |
|
|
(and (match_test "cris_scale_int_operand (XEXP (op, 0), Pmode)")
|
102 |
|
|
(match_test "register_operand (XEXP (op, 1), Pmode)")))))
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
;; Operand predicates.
|
106 |
|
|
|
107 |
|
|
;; This checks a part of an address, the one that is not a plain register
|
108 |
|
|
;; for an addressing mode using BDAP.
|
109 |
|
|
;; Allowed operands are either:
|
110 |
|
|
;; a) a register
|
111 |
|
|
;; b) a CONST operand (but not a symbol when generating PIC)
|
112 |
|
|
;; c) a [r] or [r+] in SImode, or sign-extend from HI or QI.
|
113 |
|
|
|
114 |
|
|
(define_predicate "cris_bdap_operand"
|
115 |
|
|
(ior (match_operand 0 "cris_bdap_const_operand")
|
116 |
|
|
(ior (match_operand:SI 0 "cris_simple_operand")
|
117 |
|
|
(match_operand:SI 0 "cris_bdap_sign_extend_operand"))))
|
118 |
|
|
|
119 |
|
|
;; This is similar to cris_bdap_operand:
|
120 |
|
|
;; It checks a part of an address, the one that is not a plain register
|
121 |
|
|
;; for an addressing mode using BDAP or BIAP.
|
122 |
|
|
;; Allowed operands are either:
|
123 |
|
|
;; a) a register
|
124 |
|
|
;; b) a CONST operand (but not a symbol when generating PIC)
|
125 |
|
|
;; c) a mult of (1, 2 or 4) and a register
|
126 |
|
|
;; d) a [r] or [r+] in SImode, or sign-extend from HI or QI. */
|
127 |
|
|
|
128 |
|
|
(define_predicate "cris_bdap_biap_operand"
|
129 |
|
|
(ior (match_operand 0 "cris_bdap_operand")
|
130 |
|
|
(match_operand 0 "cris_biap_mult_operand")))
|
131 |
|
|
|
132 |
|
|
;; Since with -fPIC, not all symbols are valid PIC symbols or indeed
|
133 |
|
|
;; general_operands, we have to have a predicate that matches it for the
|
134 |
|
|
;; "movsi" expander.
|
135 |
|
|
;; FIXME: Can s/special_// when PR 20413 is fixed.
|
136 |
|
|
|
137 |
|
|
(define_special_predicate "cris_general_operand_or_symbol"
|
138 |
|
|
(ior (match_operand 0 "general_operand")
|
139 |
|
|
(and (match_code "const, symbol_ref, label_ref")
|
140 |
|
|
; The following test is actually just an assertion.
|
141 |
|
|
(match_test "cris_pic_symbol_type_of (op) != cris_no_symbol"))))
|
142 |
|
|
|
143 |
|
|
;; A predicate for the anon movsi expansion, one that fits a PCREL
|
144 |
|
|
;; operand as well as general_operand.
|
145 |
|
|
|
146 |
|
|
(define_special_predicate "cris_general_operand_or_pic_source"
|
147 |
|
|
(ior (match_operand 0 "general_operand")
|
148 |
|
|
(and (match_test "flag_pic")
|
149 |
|
|
(match_test "cris_valid_pic_const (op, false)"))))
|
150 |
|
|
|
151 |
|
|
;; Since a PLT symbol is not a general_operand, we have to have a
|
152 |
|
|
;; predicate that matches it when we need it. We use this in the expanded
|
153 |
|
|
;; "call" and "call_value" anonymous patterns.
|
154 |
|
|
|
155 |
|
|
(define_predicate "cris_nonmemory_operand_or_callable_symbol"
|
156 |
|
|
(ior (match_operand 0 "nonmemory_operand")
|
157 |
|
|
(and (match_code "const")
|
158 |
|
|
(and
|
159 |
|
|
(match_test "GET_CODE (XEXP (op, 0)) == UNSPEC")
|
160 |
|
|
(ior
|
161 |
|
|
(match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PLT_PCREL")
|
162 |
|
|
(match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PCREL"))))))
|
163 |
|
|
|
164 |
|
|
;; This matches a (MEM (general_operand)) or
|
165 |
|
|
;; (MEM (cris_general_operand_or_symbol)). The second one isn't a valid
|
166 |
|
|
;; memory_operand, so we need this predicate to recognize call
|
167 |
|
|
;; destinations before we change them to a PLT operand (by wrapping in
|
168 |
|
|
;; UNSPEC CRIS_UNSPEC_PLT).
|
169 |
|
|
|
170 |
|
|
(define_predicate "cris_mem_call_operand"
|
171 |
|
|
(and (match_code "mem")
|
172 |
|
|
(ior (match_operand 0 "memory_operand")
|
173 |
|
|
(match_test "cris_general_operand_or_symbol (XEXP (op, 0),
|
174 |
|
|
Pmode)"))))
|