Mercurial > hg > CbC > CbC_gcc
comparison gcc/optabs-query.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* IR-agnostic target query functions relating to optabs | |
2 Copyright (C) 2001-2017 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 #ifndef GCC_OPTABS_QUERY_H | |
21 #define GCC_OPTABS_QUERY_H | |
22 | |
23 #include "insn-opinit.h" | |
24 #include "target.h" | |
25 | |
26 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing | |
27 if the target does not have such an insn. */ | |
28 | |
29 inline enum insn_code | |
30 optab_handler (optab op, machine_mode mode) | |
31 { | |
32 unsigned scode = (op << 16) | mode; | |
33 gcc_assert (op > LAST_CONV_OPTAB); | |
34 return raw_optab_handler (scode); | |
35 } | |
36 | |
37 /* Return the insn used to perform conversion OP from mode FROM_MODE | |
38 to mode TO_MODE; return CODE_FOR_nothing if the target does not have | |
39 such an insn. */ | |
40 | |
41 inline enum insn_code | |
42 convert_optab_handler (convert_optab op, machine_mode to_mode, | |
43 machine_mode from_mode) | |
44 { | |
45 unsigned scode = (op << 16) | (from_mode << 8) | to_mode; | |
46 gcc_assert (op > unknown_optab && op <= LAST_CONV_OPTAB); | |
47 return raw_optab_handler (scode); | |
48 } | |
49 | |
50 enum insn_code convert_optab_handler (convert_optab, machine_mode, | |
51 machine_mode, optimization_type); | |
52 | |
53 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing | |
54 if the target does not have such an insn. */ | |
55 | |
56 inline enum insn_code | |
57 direct_optab_handler (direct_optab op, machine_mode mode) | |
58 { | |
59 return optab_handler (op, mode); | |
60 } | |
61 | |
62 enum insn_code direct_optab_handler (convert_optab, machine_mode, | |
63 optimization_type); | |
64 | |
65 /* Return true if UNOPTAB is for a trapping-on-overflow operation. */ | |
66 | |
67 inline bool | |
68 trapv_unoptab_p (optab unoptab) | |
69 { | |
70 return (unoptab == negv_optab | |
71 || unoptab == absv_optab); | |
72 } | |
73 | |
74 /* Return true if BINOPTAB is for a trapping-on-overflow operation. */ | |
75 | |
76 inline bool | |
77 trapv_binoptab_p (optab binoptab) | |
78 { | |
79 return (binoptab == addv_optab | |
80 || binoptab == subv_optab | |
81 || binoptab == smulv_optab); | |
82 } | |
83 | |
84 /* Return insn code for a comparison operator with VMODE | |
85 resultin MASK_MODE, unsigned if UNS is true. */ | |
86 | |
87 static inline enum insn_code | |
88 get_vec_cmp_icode (machine_mode vmode, machine_mode mask_mode, bool uns) | |
89 { | |
90 optab tab = uns ? vec_cmpu_optab : vec_cmp_optab; | |
91 return convert_optab_handler (tab, vmode, mask_mode); | |
92 } | |
93 | |
94 /* Return insn code for a comparison operator with VMODE | |
95 resultin MASK_MODE (only for EQ/NE). */ | |
96 | |
97 static inline enum insn_code | |
98 get_vec_cmp_eq_icode (machine_mode vmode, machine_mode mask_mode) | |
99 { | |
100 return convert_optab_handler (vec_cmpeq_optab, vmode, mask_mode); | |
101 } | |
102 | |
103 /* Return insn code for a conditional operator with a comparison in | |
104 mode CMODE, unsigned if UNS is true, resulting in a value of mode VMODE. */ | |
105 | |
106 inline enum insn_code | |
107 get_vcond_icode (machine_mode vmode, machine_mode cmode, bool uns) | |
108 { | |
109 enum insn_code icode = CODE_FOR_nothing; | |
110 if (uns) | |
111 icode = convert_optab_handler (vcondu_optab, vmode, cmode); | |
112 else | |
113 icode = convert_optab_handler (vcond_optab, vmode, cmode); | |
114 return icode; | |
115 } | |
116 | |
117 /* Return insn code for a conditional operator with a mask mode | |
118 MMODE resulting in a value of mode VMODE. */ | |
119 | |
120 static inline enum insn_code | |
121 get_vcond_mask_icode (machine_mode vmode, machine_mode mmode) | |
122 { | |
123 return convert_optab_handler (vcond_mask_optab, vmode, mmode); | |
124 } | |
125 | |
126 /* Return insn code for a conditional operator with a comparison in | |
127 mode CMODE (only EQ/NE), resulting in a value of mode VMODE. */ | |
128 | |
129 static inline enum insn_code | |
130 get_vcond_eq_icode (machine_mode vmode, machine_mode cmode) | |
131 { | |
132 return convert_optab_handler (vcondeq_optab, vmode, cmode); | |
133 } | |
134 | |
135 /* Enumerates the possible extraction_insn operations. */ | |
136 enum extraction_pattern { EP_insv, EP_extv, EP_extzv }; | |
137 | |
138 /* Describes an instruction that inserts or extracts a bitfield. */ | |
139 struct extraction_insn | |
140 { | |
141 /* The code of the instruction. */ | |
142 enum insn_code icode; | |
143 | |
144 /* The mode that the structure operand should have. This is byte_mode | |
145 when using the legacy insv, extv and extzv patterns to access memory. | |
146 If no mode is given, the structure is a BLKmode memory. */ | |
147 opt_scalar_int_mode struct_mode; | |
148 | |
149 /* The mode of the field to be inserted or extracted, and by extension | |
150 the mode of the insertion or extraction itself. */ | |
151 scalar_int_mode field_mode; | |
152 | |
153 /* The mode of the field's bit position. This is only important | |
154 when the position is variable rather than constant. */ | |
155 scalar_int_mode pos_mode; | |
156 }; | |
157 | |
158 bool get_best_reg_extraction_insn (extraction_insn *, | |
159 enum extraction_pattern, | |
160 unsigned HOST_WIDE_INT, machine_mode); | |
161 bool get_best_mem_extraction_insn (extraction_insn *, | |
162 enum extraction_pattern, | |
163 HOST_WIDE_INT, HOST_WIDE_INT, machine_mode); | |
164 | |
165 enum insn_code can_extend_p (machine_mode, machine_mode, int); | |
166 enum insn_code can_float_p (machine_mode, machine_mode, int); | |
167 enum insn_code can_fix_p (machine_mode, machine_mode, int, bool *); | |
168 bool can_conditionally_move_p (machine_mode mode); | |
169 bool can_vec_perm_p (machine_mode, bool, vec_perm_indices *); | |
170 enum insn_code widening_optab_handler (optab, machine_mode, machine_mode); | |
171 /* Find a widening optab even if it doesn't widen as much as we want. */ | |
172 #define find_widening_optab_handler(A,B,C,D) \ | |
173 find_widening_optab_handler_and_mode (A, B, C, D, NULL) | |
174 enum insn_code find_widening_optab_handler_and_mode (optab, machine_mode, | |
175 machine_mode, int, | |
176 machine_mode *); | |
177 int can_mult_highpart_p (machine_mode, bool); | |
178 bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool); | |
179 bool can_compare_and_swap_p (machine_mode, bool); | |
180 bool can_atomic_exchange_p (machine_mode, bool); | |
181 bool can_atomic_load_p (machine_mode); | |
182 bool lshift_cheap_p (bool); | |
183 | |
184 #endif |