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, \
42 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
44 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
45 ARG6, ARG7, ARG8) NAME,
46 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
47 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
48 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
49 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
50 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
51 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
53 #define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
55 #define DEF_FUNCTION_TYPE_VAR_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
56 ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME,
57 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
58 #include "builtin-types.def"
59 #undef DEF_PRIMITIVE_TYPE
60 #undef DEF_FUNCTION_TYPE_0
61 #undef DEF_FUNCTION_TYPE_1
62 #undef DEF_FUNCTION_TYPE_2
63 #undef DEF_FUNCTION_TYPE_3
64 #undef DEF_FUNCTION_TYPE_4
65 #undef DEF_FUNCTION_TYPE_5
66 #undef DEF_FUNCTION_TYPE_6
67 #undef DEF_FUNCTION_TYPE_7
68 #undef DEF_FUNCTION_TYPE_8
69 #undef DEF_FUNCTION_TYPE_VAR_0
70 #undef DEF_FUNCTION_TYPE_VAR_1
71 #undef DEF_FUNCTION_TYPE_VAR_2
72 #undef DEF_FUNCTION_TYPE_VAR_3
73 #undef DEF_FUNCTION_TYPE_VAR_4
74 #undef DEF_FUNCTION_TYPE_VAR_5
75 #undef DEF_FUNCTION_TYPE_VAR_7
76 #undef DEF_FUNCTION_TYPE_VAR_11
77 #undef DEF_POINTER_TYPE
79 }; /* enum jit_builtin_type */
81 /* Create an enum of the attributes that can be present on builtins. */
83 enum built_in_attribute
85 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
86 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
87 #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
88 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
89 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
90 #include "builtin-attrs.def"
91 #undef DEF_ATTR_NULL_TREE
93 #undef DEF_ATTR_STRING
95 #undef DEF_ATTR_TREE_LIST
99 /***********************************************************************/
101 class builtins_manager
104 builtins_manager (recording::context
*ctxt
);
106 recording::function
*
107 get_builtin_function (const char *name
);
109 static enum built_in_class
110 get_class (enum built_in_function builtin_id
);
113 implicit_p (enum built_in_function builtin_id
);
116 get_attrs_tree (enum built_in_function builtin_id
);
119 get_attrs_tree (enum built_in_attribute attr
);
122 finish_playback (void);
125 recording::function
*
126 get_builtin_function_by_id (enum built_in_function builtin_id
);
128 recording::function
*
129 make_builtin_function (enum built_in_function builtin_id
);
132 get_type (enum jit_builtin_type type_id
);
135 make_type (enum jit_builtin_type type_id
);
138 make_primitive_type (enum jit_builtin_type type_id
);
140 recording::function_type
*
141 make_fn_type (enum jit_builtin_type type_id
,
142 enum jit_builtin_type return_type_id
,
147 make_ptr_type (enum jit_builtin_type type_id
,
148 enum jit_builtin_type other_type_id
);
151 make_attrs_tree (enum built_in_attribute attr
);
154 /* Recording fields. */
155 recording::context
*m_ctxt
;
156 recording::type
*m_types
[BT_LAST
];
157 recording::function
*m_builtin_functions
[END_BUILTINS
];
159 /* Playback fields. */
160 /* m_attributes is not GTY-marked, but is only ever used from within
161 the region of playback::context::replay () in which a GC can't
163 tree m_attributes
[ATTR_LAST
];
169 #endif /* JIT_BUILTINS_H */