1 /* jit-builtins.h -- Handling of builtin functions during JIT-compilation.
2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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/>. */
20 #ifndef JIT_BUILTINS_H
21 #define JIT_BUILTINS_H
23 #include "jit-common.h"
29 /* Create an enum of the builtin types. */
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,
40 #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) NAME,
41 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) NAME,
42 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8) NAME,
43 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
44 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
45 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
46 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
47 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
48 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
50 #define DEF_FUNCTION_TYPE_VAR_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
51 ARG6, ARG7, ARG8) NAME,
52 #define DEF_FUNCTION_TYPE_VAR_12(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
53 ARG6, ARG7, ARG8, ARG9, ARG10, ARG11, ARG12) \
55 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
56 #include "builtin-types.def"
57 #undef DEF_PRIMITIVE_TYPE
58 #undef DEF_FUNCTION_TYPE_0
59 #undef DEF_FUNCTION_TYPE_1
60 #undef DEF_FUNCTION_TYPE_2
61 #undef DEF_FUNCTION_TYPE_3
62 #undef DEF_FUNCTION_TYPE_4
63 #undef DEF_FUNCTION_TYPE_5
64 #undef DEF_FUNCTION_TYPE_6
65 #undef DEF_FUNCTION_TYPE_7
66 #undef DEF_FUNCTION_TYPE_8
67 #undef DEF_FUNCTION_TYPE_VAR_0
68 #undef DEF_FUNCTION_TYPE_VAR_1
69 #undef DEF_FUNCTION_TYPE_VAR_2
70 #undef DEF_FUNCTION_TYPE_VAR_3
71 #undef DEF_FUNCTION_TYPE_VAR_4
72 #undef DEF_FUNCTION_TYPE_VAR_5
73 #undef DEF_FUNCTION_TYPE_VAR_8
74 #undef DEF_FUNCTION_TYPE_VAR_12
75 #undef DEF_POINTER_TYPE
77 }; /* enum jit_builtin_type */
79 /* Create an enum of the attributes that can be present on builtins. */
81 enum built_in_attribute
83 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
84 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
85 #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
86 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
87 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
88 #include "builtin-attrs.def"
89 #undef DEF_ATTR_NULL_TREE
91 #undef DEF_ATTR_STRING
93 #undef DEF_ATTR_TREE_LIST
97 /***********************************************************************/
99 class builtins_manager
102 builtins_manager (recording::context
*ctxt
);
104 recording::function
*
105 get_builtin_function (const char *name
);
107 static enum built_in_class
108 get_class (enum built_in_function builtin_id
);
111 implicit_p (enum built_in_function builtin_id
);
114 get_attrs_tree (enum built_in_function builtin_id
);
117 get_attrs_tree (enum built_in_attribute attr
);
120 finish_playback (void);
123 recording::function
*
124 get_builtin_function_by_id (enum built_in_function builtin_id
);
126 recording::function
*
127 make_builtin_function (enum built_in_function builtin_id
);
130 get_type (enum jit_builtin_type type_id
);
133 make_type (enum jit_builtin_type type_id
);
136 make_primitive_type (enum jit_builtin_type type_id
);
138 recording::function_type
*
139 make_fn_type (enum jit_builtin_type type_id
,
140 enum jit_builtin_type return_type_id
,
145 make_ptr_type (enum jit_builtin_type type_id
,
146 enum jit_builtin_type other_type_id
);
149 make_attrs_tree (enum built_in_attribute attr
);
152 /* Recording fields. */
153 recording::context
*m_ctxt
;
154 recording::type
*m_types
[BT_LAST
];
155 recording::function
*m_builtin_functions
[END_BUILTINS
];
157 /* Playback fields. */
158 /* m_attributes is not GTY-marked, but is only ever used from within
159 the region of playback::context::replay () in which a GC can't
161 tree m_attributes
[ATTR_LAST
];
167 #endif /* JIT_BUILTINS_H */