Branch data Line data Source code
1 : : /* jit-target.h -- Data structure definitions for target-specific jit behavior.
2 : : Copyright (C) 2023 Free Software Foundation, Inc.
3 : :
4 : : This program is free software; you can redistribute it and/or modify it
5 : : under the terms of the GNU General Public License as published by the
6 : : Free Software Foundation; either version 3, or (at your option) any
7 : : later version.
8 : :
9 : : This program is distributed in the hope that it will be useful,
10 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : : GNU General Public License for more details.
13 : :
14 : : You should have received a copy of the GNU General Public License
15 : : along with this program; see the file COPYING3. If not see
16 : : <http://www.gnu.org/licenses/>. */
17 : :
18 : : #ifndef GCC_JIT_TARGET_H
19 : : #define GCC_JIT_TARGET_H
20 : :
21 : : #define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
22 : : #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
23 : : #define DEFHOOK_UNDOC DEFHOOK
24 : : #define HOOKSTRUCT(FRAGMENT) FRAGMENT
25 : :
26 : : #include "jit-target.def"
27 : : #include "libgccjit.h"
28 : :
29 : : #include <unordered_map>
30 : : #include <unordered_set>
31 : :
32 : 19068 : static size_t hash_cstr (const char *s)
33 : : {
34 : 19068 : const size_t seed = 0;
35 : 19068 : return std::_Hash_bytes (s, std::strlen (s), seed);
36 : : }
37 : :
38 : : struct CStringHash {
39 : 19068 : size_t operator () (const char* const &string) const {
40 : 19068 : auto res = hash_cstr (string);
41 : 19068 : return res;
42 : : }
43 : : };
44 : :
45 : : struct CStringEqual {
46 : : bool
47 : 7629 : operator () (const char *const &string1, const char *const &string2) const
48 : : {
49 : 7629 : return strcmp (string1, string2) == 0;
50 : : }
51 : : };
52 : :
53 : : struct target_info {
54 : : public:
55 : : bool has_target_value (const char *key, const char *value);
56 : :
57 : : std::unordered_map<const char *,
58 : : std::unordered_set<const char *, CStringHash, CStringEqual>,
59 : : CStringHash, CStringEqual>
60 : : m_info;
61 : : std::string m_arch;
62 : : std::unordered_set<enum gcc_jit_types> m_supported_target_dependent_types;
63 : : };
64 : :
65 : : /* Each target can provide their own. */
66 : : extern struct gcc_targetjitm targetjitm;
67 : :
68 : : extern void jit_target_init ();
69 : : extern void jit_target_set_arch (std::string const& arch);
70 : : extern void
71 : : jit_target_add_supported_target_dependent_type (enum gcc_jit_types type_);
72 : : extern void jit_add_target_info (const char *key, const char *value);
73 : : extern target_info * jit_get_target_info ();
74 : :
75 : : #endif /* GCC_JIT_TARGET_H */
|