]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/jit/jit-builtins.h
Update copyright years.
[thirdparty/gcc.git] / gcc / jit / jit-builtins.h
CommitLineData
35485da9 1/* jit-builtins.h -- Handling of builtin functions during JIT-compilation.
99dee823 2 Copyright (C) 2014-2021 Free Software Foundation, Inc.
35485da9
DM
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef JIT_BUILTINS_H
21#define JIT_BUILTINS_H
22
23#include "jit-common.h"
24
25namespace gcc {
26
27namespace jit {
28
35485da9
DM
29/* Create an enum of the builtin types. */
30
31enum jit_builtin_type
32{
33#define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
34#define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
35#define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
36#define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
37#define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
38#define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
39#define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
56a9f6bc
TS
40#define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
41 ARG6) NAME,
42#define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
43 ARG6, ARG7) NAME,
44#define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
45 ARG6, ARG7, ARG8) NAME,
d9a6bd32
JJ
46#define DEF_FUNCTION_TYPE_9(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
47 ARG6, ARG7, ARG8, ARG9) NAME,
48#define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
49 ARG6, ARG7, ARG8, ARG9, ARG10) NAME,
50#define DEF_FUNCTION_TYPE_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
51 ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME,
35485da9
DM
52#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
53#define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
54#define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
55#define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
56#define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
e989e68d 57#define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
56a9f6bc 58 NAME,
20a44562
MK
59#define DEF_FUNCTION_TYPE_VAR_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
60 ARG6) NAME,
56a9f6bc
TS
61#define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
62 ARG6, ARG7) NAME,
35485da9
DM
63#define DEF_POINTER_TYPE(NAME, TYPE) NAME,
64#include "builtin-types.def"
65#undef DEF_PRIMITIVE_TYPE
66#undef DEF_FUNCTION_TYPE_0
67#undef DEF_FUNCTION_TYPE_1
68#undef DEF_FUNCTION_TYPE_2
69#undef DEF_FUNCTION_TYPE_3
70#undef DEF_FUNCTION_TYPE_4
71#undef DEF_FUNCTION_TYPE_5
72#undef DEF_FUNCTION_TYPE_6
73#undef DEF_FUNCTION_TYPE_7
74#undef DEF_FUNCTION_TYPE_8
d9a6bd32
JJ
75#undef DEF_FUNCTION_TYPE_9
76#undef DEF_FUNCTION_TYPE_10
77#undef DEF_FUNCTION_TYPE_11
35485da9
DM
78#undef DEF_FUNCTION_TYPE_VAR_0
79#undef DEF_FUNCTION_TYPE_VAR_1
80#undef DEF_FUNCTION_TYPE_VAR_2
81#undef DEF_FUNCTION_TYPE_VAR_3
82#undef DEF_FUNCTION_TYPE_VAR_4
83#undef DEF_FUNCTION_TYPE_VAR_5
fa83660d 84#undef DEF_FUNCTION_TYPE_VAR_6
56a9f6bc 85#undef DEF_FUNCTION_TYPE_VAR_7
35485da9
DM
86#undef DEF_POINTER_TYPE
87 BT_LAST
88}; /* enum jit_builtin_type */
89
eeafb319
DM
90/* Create an enum of the attributes that can be present on builtins. */
91
92enum built_in_attribute
93{
94#define DEF_ATTR_NULL_TREE(ENUM) ENUM,
95#define DEF_ATTR_INT(ENUM, VALUE) ENUM,
96#define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
97#define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
98#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
99#include "builtin-attrs.def"
100#undef DEF_ATTR_NULL_TREE
101#undef DEF_ATTR_INT
102#undef DEF_ATTR_STRING
103#undef DEF_ATTR_IDENT
104#undef DEF_ATTR_TREE_LIST
105 ATTR_LAST
106};
107
35485da9
DM
108/***********************************************************************/
109
110class builtins_manager
111{
112public:
eeafb319 113 builtins_manager (recording::context *ctxt);
35485da9 114
eeafb319 115 recording::function *
35485da9
DM
116 get_builtin_function (const char *name);
117
eeafb319
DM
118 static enum built_in_class
119 get_class (enum built_in_function builtin_id);
120
121 static bool
122 implicit_p (enum built_in_function builtin_id);
123
124 tree
125 get_attrs_tree (enum built_in_function builtin_id);
126
127 tree
128 get_attrs_tree (enum built_in_attribute attr);
129
130 void
131 finish_playback (void);
132
35485da9 133private:
eeafb319
DM
134 recording::function *
135 get_builtin_function_by_id (enum built_in_function builtin_id);
136
137 recording::function *
138 make_builtin_function (enum built_in_function builtin_id);
35485da9 139
eeafb319
DM
140 recording::type *
141 get_type (enum jit_builtin_type type_id);
35485da9 142
eeafb319
DM
143 recording::type *
144 make_type (enum jit_builtin_type type_id);
35485da9 145
eeafb319 146 recording::type*
35485da9
DM
147 make_primitive_type (enum jit_builtin_type type_id);
148
eeafb319 149 recording::function_type*
35485da9
DM
150 make_fn_type (enum jit_builtin_type type_id,
151 enum jit_builtin_type return_type_id,
152 bool is_variadic,
153 int num_args, ...);
154
eeafb319 155 recording::type*
35485da9
DM
156 make_ptr_type (enum jit_builtin_type type_id,
157 enum jit_builtin_type other_type_id);
158
eeafb319
DM
159 tree
160 make_attrs_tree (enum built_in_attribute attr);
161
35485da9 162private:
eeafb319
DM
163 /* Recording fields. */
164 recording::context *m_ctxt;
165 recording::type *m_types[BT_LAST];
166 recording::function *m_builtin_functions[END_BUILTINS];
167
168 /* Playback fields. */
169 /* m_attributes is not GTY-marked, but is only ever used from within
170 the region of playback::context::replay () in which a GC can't
171 happen. */
172 tree m_attributes[ATTR_LAST];
35485da9
DM
173};
174
35485da9
DM
175} // namespace jit
176} // namespace gcc
177
178#endif /* JIT_BUILTINS_H */