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, ARG6) \
50 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
51 #include "builtin-types.def"
52 #undef DEF_PRIMITIVE_TYPE
53 #undef DEF_FUNCTION_TYPE_0
54 #undef DEF_FUNCTION_TYPE_1
55 #undef DEF_FUNCTION_TYPE_2
56 #undef DEF_FUNCTION_TYPE_3
57 #undef DEF_FUNCTION_TYPE_4
58 #undef DEF_FUNCTION_TYPE_5
59 #undef DEF_FUNCTION_TYPE_6
60 #undef DEF_FUNCTION_TYPE_7
61 #undef DEF_FUNCTION_TYPE_8
62 #undef DEF_FUNCTION_TYPE_VAR_0
63 #undef DEF_FUNCTION_TYPE_VAR_1
64 #undef DEF_FUNCTION_TYPE_VAR_2
65 #undef DEF_FUNCTION_TYPE_VAR_3
66 #undef DEF_FUNCTION_TYPE_VAR_4
67 #undef DEF_FUNCTION_TYPE_VAR_5
68 #undef DEF_POINTER_TYPE
70 }; /* enum jit_builtin_type */
72 /* Create an enum of the attributes that can be present on builtins. */
74 enum built_in_attribute
76 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
77 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
78 #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
79 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
80 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
81 #include "builtin-attrs.def"
82 #undef DEF_ATTR_NULL_TREE
84 #undef DEF_ATTR_STRING
86 #undef DEF_ATTR_TREE_LIST
90 /***********************************************************************/
92 class builtins_manager
95 builtins_manager (recording::context
*ctxt
);
98 get_builtin_function (const char *name
);
100 static enum built_in_class
101 get_class (enum built_in_function builtin_id
);
104 implicit_p (enum built_in_function builtin_id
);
107 get_attrs_tree (enum built_in_function builtin_id
);
110 get_attrs_tree (enum built_in_attribute attr
);
113 finish_playback (void);
116 recording::function
*
117 get_builtin_function_by_id (enum built_in_function builtin_id
);
119 recording::function
*
120 make_builtin_function (enum built_in_function builtin_id
);
123 get_type (enum jit_builtin_type type_id
);
126 make_type (enum jit_builtin_type type_id
);
129 make_primitive_type (enum jit_builtin_type type_id
);
131 recording::function_type
*
132 make_fn_type (enum jit_builtin_type type_id
,
133 enum jit_builtin_type return_type_id
,
138 make_ptr_type (enum jit_builtin_type type_id
,
139 enum jit_builtin_type other_type_id
);
142 make_attrs_tree (enum built_in_attribute attr
);
145 /* Recording fields. */
146 recording::context
*m_ctxt
;
147 recording::type
*m_types
[BT_LAST
];
148 recording::function
*m_builtin_functions
[END_BUILTINS
];
150 /* Playback fields. */
151 /* m_attributes is not GTY-marked, but is only ever used from within
152 the region of playback::context::replay () in which a GC can't
154 tree m_attributes
[ATTR_LAST
];
160 #endif /* JIT_BUILTINS_H */