2014-11-20 Robert Dewar <dewar@adacore.com>
[official-gcc.git] / gcc / jit / jit-builtins.h
blob7c46bfdbe468c68b7178fa435b4c9d60beb56268
1 /* jit-builtins.h -- Handling of builtin functions during JIT-compilation.
2 Copyright (C) 2014 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
9 version.
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.
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"
25 namespace gcc {
27 namespace jit {
29 namespace recording {
31 /* Create an enum of the builtin types. */
33 enum jit_builtin_type
35 #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
36 #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
37 #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
38 #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
39 #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
40 #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
41 #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
42 #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) NAME,
43 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) NAME,
44 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8) NAME,
45 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
46 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
47 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
48 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
49 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
50 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \
51 NAME,
52 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
53 #include "builtin-types.def"
54 #undef DEF_PRIMITIVE_TYPE
55 #undef DEF_FUNCTION_TYPE_0
56 #undef DEF_FUNCTION_TYPE_1
57 #undef DEF_FUNCTION_TYPE_2
58 #undef DEF_FUNCTION_TYPE_3
59 #undef DEF_FUNCTION_TYPE_4
60 #undef DEF_FUNCTION_TYPE_5
61 #undef DEF_FUNCTION_TYPE_6
62 #undef DEF_FUNCTION_TYPE_7
63 #undef DEF_FUNCTION_TYPE_8
64 #undef DEF_FUNCTION_TYPE_VAR_0
65 #undef DEF_FUNCTION_TYPE_VAR_1
66 #undef DEF_FUNCTION_TYPE_VAR_2
67 #undef DEF_FUNCTION_TYPE_VAR_3
68 #undef DEF_FUNCTION_TYPE_VAR_4
69 #undef DEF_FUNCTION_TYPE_VAR_5
70 #undef DEF_POINTER_TYPE
71 BT_LAST
72 }; /* enum jit_builtin_type */
74 /***********************************************************************/
76 class builtins_manager
78 public:
79 builtins_manager (context *ctxt);
81 function *
82 get_builtin_function (const char *name);
84 private:
85 function *make_builtin_function (enum built_in_function builtin_id);
87 type *get_type (enum jit_builtin_type type_id);
89 type *make_type (enum jit_builtin_type type_id);
91 type*
92 make_primitive_type (enum jit_builtin_type type_id);
94 function_type*
95 make_fn_type (enum jit_builtin_type type_id,
96 enum jit_builtin_type return_type_id,
97 bool is_variadic,
98 int num_args, ...);
100 type*
101 make_ptr_type (enum jit_builtin_type type_id,
102 enum jit_builtin_type other_type_id);
104 private:
105 context *m_ctxt;
106 type *m_types[BT_LAST];
107 function *m_builtin_functions[END_BUILTINS];
110 } // namespace recording
111 } // namespace jit
112 } // namespace gcc
114 #endif /* JIT_BUILTINS_H */