annotate gcc/config/riscv/predicates.md @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ;; Predicate description for RISC-V target.
kono
parents:
diff changeset
2 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 ;; Contributed by Andrew Waterman (andrew@sifive.com).
kono
parents:
diff changeset
4 ;; Based on MIPS target for GNU compiler.
kono
parents:
diff changeset
5 ;;
kono
parents:
diff changeset
6 ;; This file is part of GCC.
kono
parents:
diff changeset
7 ;;
kono
parents:
diff changeset
8 ;; GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
10 ;; the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
11 ;; any later version.
kono
parents:
diff changeset
12 ;;
kono
parents:
diff changeset
13 ;; GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
16 ;; GNU General Public License for more details.
kono
parents:
diff changeset
17 ;;
kono
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 ;; along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 ;; <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 (define_predicate "const_arith_operand"
kono
parents:
diff changeset
23 (and (match_code "const_int")
kono
parents:
diff changeset
24 (match_test "SMALL_OPERAND (INTVAL (op))")))
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 (define_predicate "arith_operand"
kono
parents:
diff changeset
27 (ior (match_operand 0 "const_arith_operand")
kono
parents:
diff changeset
28 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 (define_predicate "const_csr_operand"
kono
parents:
diff changeset
31 (and (match_code "const_int")
kono
parents:
diff changeset
32 (match_test "IN_RANGE (INTVAL (op), 0, 31)")))
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 (define_predicate "csr_operand"
kono
parents:
diff changeset
35 (ior (match_operand 0 "const_csr_operand")
kono
parents:
diff changeset
36 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 (define_predicate "sle_operand"
kono
parents:
diff changeset
39 (and (match_code "const_int")
kono
parents:
diff changeset
40 (match_test "SMALL_OPERAND (INTVAL (op) + 1)")))
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 (define_predicate "sleu_operand"
kono
parents:
diff changeset
43 (and (match_operand 0 "sle_operand")
kono
parents:
diff changeset
44 (match_test "INTVAL (op) + 1 != 0")))
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 (define_predicate "const_0_operand"
kono
parents:
diff changeset
47 (and (match_code "const_int,const_wide_int,const_double,const_vector")
kono
parents:
diff changeset
48 (match_test "op == CONST0_RTX (GET_MODE (op))")))
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 (define_predicate "reg_or_0_operand"
kono
parents:
diff changeset
51 (ior (match_operand 0 "const_0_operand")
kono
parents:
diff changeset
52 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 ;; Only use branch-on-bit sequences when the mask is not an ANDI immediate.
kono
parents:
diff changeset
55 (define_predicate "branch_on_bit_operand"
kono
parents:
diff changeset
56 (and (match_code "const_int")
kono
parents:
diff changeset
57 (match_test "INTVAL (op) >= IMM_BITS - 1")))
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 ;; A legitimate CONST_INT operand that takes more than one instruction
kono
parents:
diff changeset
60 ;; to load.
kono
parents:
diff changeset
61 (define_predicate "splittable_const_int_operand"
kono
parents:
diff changeset
62 (match_code "const_int")
kono
parents:
diff changeset
63 {
kono
parents:
diff changeset
64 /* Don't handle multi-word moves this way; we don't want to introduce
kono
parents:
diff changeset
65 the individual word-mode moves until after reload. */
kono
parents:
diff changeset
66 if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
kono
parents:
diff changeset
67 return false;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Otherwise check whether the constant can be loaded in a single
kono
parents:
diff changeset
70 instruction. */
kono
parents:
diff changeset
71 return !LUI_OPERAND (INTVAL (op)) && !SMALL_OPERAND (INTVAL (op));
kono
parents:
diff changeset
72 })
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 (define_predicate "move_operand"
kono
parents:
diff changeset
75 (match_operand 0 "general_operand")
kono
parents:
diff changeset
76 {
kono
parents:
diff changeset
77 enum riscv_symbol_type symbol_type;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* The thinking here is as follows:
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 (1) The move expanders should split complex load sequences into
kono
parents:
diff changeset
82 individual instructions. Those individual instructions can
kono
parents:
diff changeset
83 then be optimized by all rtl passes.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 (2) The target of pre-reload load sequences should not be used
kono
parents:
diff changeset
86 to store temporary results. If the target register is only
kono
parents:
diff changeset
87 assigned one value, reload can rematerialize that value
kono
parents:
diff changeset
88 on demand, rather than spill it to the stack.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 (3) If we allowed pre-reload passes like combine and cse to recreate
kono
parents:
diff changeset
91 complex load sequences, we would want to be able to split the
kono
parents:
diff changeset
92 sequences before reload as well, so that the pre-reload scheduler
kono
parents:
diff changeset
93 can see the individual instructions. This falls foul of (2);
kono
parents:
diff changeset
94 the splitter would be forced to reuse the target register for
kono
parents:
diff changeset
95 intermediate results.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 (4) We want to define complex load splitters for combine. These
kono
parents:
diff changeset
98 splitters can request a temporary scratch register, which avoids
kono
parents:
diff changeset
99 the problem in (2). They allow things like:
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 (set (reg T1) (high SYM))
kono
parents:
diff changeset
102 (set (reg T2) (low (reg T1) SYM))
kono
parents:
diff changeset
103 (set (reg X) (plus (reg T2) (const_int OFFSET)))
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 to be combined into:
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 (set (reg T3) (high SYM+OFFSET))
kono
parents:
diff changeset
108 (set (reg X) (lo_sum (reg T3) SYM+OFFSET))
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 if T2 is only used this once. */
kono
parents:
diff changeset
111 switch (GET_CODE (op))
kono
parents:
diff changeset
112 {
kono
parents:
diff changeset
113 case CONST_INT:
kono
parents:
diff changeset
114 return !splittable_const_int_operand (op, mode);
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 case CONST:
kono
parents:
diff changeset
117 case SYMBOL_REF:
kono
parents:
diff changeset
118 case LABEL_REF:
kono
parents:
diff changeset
119 return riscv_symbolic_constant_p (op, &symbol_type)
kono
parents:
diff changeset
120 && !riscv_split_symbol_type (symbol_type);
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 case HIGH:
kono
parents:
diff changeset
123 op = XEXP (op, 0);
kono
parents:
diff changeset
124 return riscv_symbolic_constant_p (op, &symbol_type)
kono
parents:
diff changeset
125 && riscv_split_symbol_type (symbol_type)
kono
parents:
diff changeset
126 && symbol_type != SYMBOL_PCREL;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 default:
kono
parents:
diff changeset
129 return true;
kono
parents:
diff changeset
130 }
kono
parents:
diff changeset
131 })
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 (define_predicate "symbolic_operand"
kono
parents:
diff changeset
134 (match_code "const,symbol_ref,label_ref")
kono
parents:
diff changeset
135 {
kono
parents:
diff changeset
136 enum riscv_symbol_type type;
kono
parents:
diff changeset
137 return riscv_symbolic_constant_p (op, &type);
kono
parents:
diff changeset
138 })
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 (define_predicate "absolute_symbolic_operand"
kono
parents:
diff changeset
141 (match_code "const,symbol_ref,label_ref")
kono
parents:
diff changeset
142 {
kono
parents:
diff changeset
143 enum riscv_symbol_type type;
kono
parents:
diff changeset
144 return (riscv_symbolic_constant_p (op, &type)
kono
parents:
diff changeset
145 && (type == SYMBOL_ABSOLUTE || type == SYMBOL_PCREL));
kono
parents:
diff changeset
146 })
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 (define_predicate "plt_symbolic_operand"
kono
parents:
diff changeset
149 (match_code "const,symbol_ref,label_ref")
kono
parents:
diff changeset
150 {
kono
parents:
diff changeset
151 enum riscv_symbol_type type;
kono
parents:
diff changeset
152 return (riscv_symbolic_constant_p (op, &type)
kono
parents:
diff changeset
153 && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op) && TARGET_PLT);
kono
parents:
diff changeset
154 })
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 (define_predicate "call_insn_operand"
kono
parents:
diff changeset
157 (ior (match_operand 0 "absolute_symbolic_operand")
kono
parents:
diff changeset
158 (match_operand 0 "plt_symbolic_operand")
kono
parents:
diff changeset
159 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 (define_predicate "modular_operator"
kono
parents:
diff changeset
162 (match_code "plus,minus,mult,ashift"))
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 (define_predicate "equality_operator"
kono
parents:
diff changeset
165 (match_code "eq,ne"))
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 (define_predicate "order_operator"
kono
parents:
diff changeset
168 (match_code "eq,ne,lt,ltu,le,leu,ge,geu,gt,gtu"))
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 (define_predicate "signed_order_operator"
kono
parents:
diff changeset
171 (match_code "eq,ne,lt,le,ge,gt"))
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 (define_predicate "fp_native_comparison"
kono
parents:
diff changeset
174 (match_code "eq,lt,le,gt,ge"))
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 (define_predicate "fp_scc_comparison"
kono
parents:
diff changeset
177 (match_code "unordered,ordered,unlt,unge,unle,ungt,ltgt,ne,eq,lt,le,gt,ge"))
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 (define_predicate "fp_branch_comparison"
kono
parents:
diff changeset
180 (match_code "unordered,ordered,unlt,unge,unle,ungt,uneq,ltgt,ne,eq,lt,le,gt,ge"))