gimple.h: Remove all includes.
[gcc.git] / gcc / internal-fn.c
1 /* Internal functions.
2 Copyright (C) 2011-2013 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 it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 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 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "internal-fn.h"
24 #include "tree.h"
25 #include "stor-layout.h"
26 #include "expr.h"
27 #include "optabs.h"
28 #include "basic-block.h"
29 #include "tree-ssa-alias.h"
30 #include "internal-fn.h"
31 #include "gimple-expr.h"
32 #include "is-a.h"
33 #include "gimple.h"
34
35 /* The names of each internal function, indexed by function number. */
36 const char *const internal_fn_name_array[] = {
37 #define DEF_INTERNAL_FN(CODE, FLAGS) #CODE,
38 #include "internal-fn.def"
39 #undef DEF_INTERNAL_FN
40 "<invalid-fn>"
41 };
42
43 /* The ECF_* flags of each internal function, indexed by function number. */
44 const int internal_fn_flags_array[] = {
45 #define DEF_INTERNAL_FN(CODE, FLAGS) FLAGS,
46 #include "internal-fn.def"
47 #undef DEF_INTERNAL_FN
48 0
49 };
50
51 /* ARRAY_TYPE is an array of vector modes. Return the associated insn
52 for load-lanes-style optab OPTAB. The insn must exist. */
53
54 static enum insn_code
55 get_multi_vector_move (tree array_type, convert_optab optab)
56 {
57 enum insn_code icode;
58 enum machine_mode imode;
59 enum machine_mode vmode;
60
61 gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
62 imode = TYPE_MODE (array_type);
63 vmode = TYPE_MODE (TREE_TYPE (array_type));
64
65 icode = convert_optab_handler (optab, imode, vmode);
66 gcc_assert (icode != CODE_FOR_nothing);
67 return icode;
68 }
69
70 /* Expand LOAD_LANES call STMT. */
71
72 static void
73 expand_LOAD_LANES (gimple stmt)
74 {
75 struct expand_operand ops[2];
76 tree type, lhs, rhs;
77 rtx target, mem;
78
79 lhs = gimple_call_lhs (stmt);
80 rhs = gimple_call_arg (stmt, 0);
81 type = TREE_TYPE (lhs);
82
83 target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
84 mem = expand_normal (rhs);
85
86 gcc_assert (MEM_P (mem));
87 PUT_MODE (mem, TYPE_MODE (type));
88
89 create_output_operand (&ops[0], target, TYPE_MODE (type));
90 create_fixed_operand (&ops[1], mem);
91 expand_insn (get_multi_vector_move (type, vec_load_lanes_optab), 2, ops);
92 }
93
94 /* Expand STORE_LANES call STMT. */
95
96 static void
97 expand_STORE_LANES (gimple stmt)
98 {
99 struct expand_operand ops[2];
100 tree type, lhs, rhs;
101 rtx target, reg;
102
103 lhs = gimple_call_lhs (stmt);
104 rhs = gimple_call_arg (stmt, 0);
105 type = TREE_TYPE (rhs);
106
107 target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
108 reg = expand_normal (rhs);
109
110 gcc_assert (MEM_P (target));
111 PUT_MODE (target, TYPE_MODE (type));
112
113 create_fixed_operand (&ops[0], target);
114 create_input_operand (&ops[1], reg, TYPE_MODE (type));
115 expand_insn (get_multi_vector_move (type, vec_store_lanes_optab), 2, ops);
116 }
117
118 static void
119 expand_ANNOTATE (gimple stmt ATTRIBUTE_UNUSED)
120 {
121 gcc_unreachable ();
122 }
123
124 /* This should get expanded in adjust_simduid_builtins. */
125
126 static void
127 expand_GOMP_SIMD_LANE (gimple stmt ATTRIBUTE_UNUSED)
128 {
129 gcc_unreachable ();
130 }
131
132 /* This should get expanded in adjust_simduid_builtins. */
133
134 static void
135 expand_GOMP_SIMD_VF (gimple stmt ATTRIBUTE_UNUSED)
136 {
137 gcc_unreachable ();
138 }
139
140 /* This should get expanded in adjust_simduid_builtins. */
141
142 static void
143 expand_GOMP_SIMD_LAST_LANE (gimple stmt ATTRIBUTE_UNUSED)
144 {
145 gcc_unreachable ();
146 }
147
148 /* This should get expanded in the sanopt pass. */
149
150 static void
151 expand_UBSAN_NULL (gimple stmt ATTRIBUTE_UNUSED)
152 {
153 gcc_unreachable ();
154 }
155
156 /* Routines to expand each internal function, indexed by function number.
157 Each routine has the prototype:
158
159 expand_<NAME> (gimple stmt)
160
161 where STMT is the statement that performs the call. */
162 static void (*const internal_fn_expanders[]) (gimple) = {
163 #define DEF_INTERNAL_FN(CODE, FLAGS) expand_##CODE,
164 #include "internal-fn.def"
165 #undef DEF_INTERNAL_FN
166 0
167 };
168
169 /* Expand STMT, which is a call to internal function FN. */
170
171 void
172 expand_internal_call (gimple stmt)
173 {
174 internal_fn_expanders[(int) gimple_call_internal_fn (stmt)] (stmt);
175 }