Branch data Line data Source code
1 : : /* jit-target.cc -- Target interface for the jit front end.
2 : : Copyright (C) 2023 Free Software Foundation, Inc.
3 : :
4 : : GCC is free software; you can redistribute it and/or modify
5 : : it under the terms of the GNU General Public License as published by
6 : : the Free Software Foundation; either version 3, or (at your option)
7 : : any later version.
8 : :
9 : : GCC 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 GCC; see the file COPYING3. If not see
16 : : <http://www.gnu.org/licenses/>. */
17 : :
18 : : #define INCLUDE_STRING
19 : : #define INCLUDE_ALGORITHM
20 : : #include "config.h"
21 : : #include "system.h"
22 : : #include "coretypes.h"
23 : :
24 : : #include "tree.h"
25 : : #include "memmodel.h"
26 : : #include "fold-const.h"
27 : : #include "diagnostic.h"
28 : : #include "stor-layout.h"
29 : : #include "tm.h"
30 : : #include "tm_p.h"
31 : : #include "target.h"
32 : : #include "calls.h"
33 : :
34 : : #include "jit-playback.h"
35 : : #include "jit-target.h"
36 : :
37 : : /* Initialize all variables of the Target structure. */
38 : :
39 : : void
40 : 1271 : jit_target_init ()
41 : : {
42 : : /* Initialize target info tables, the keys required by the language are added
43 : : last, so that the CPU handler can override. */
44 : 1271 : targetjitm.jit_register_cpu_target_info ();
45 : 1271 : }
46 : :
47 : : /* Add a target info key:value to JIT_TARGET_INFO for use by
48 : : target_info::has_target_value (). */
49 : :
50 : : void
51 : 6355 : jit_add_target_info (const char *key, const char *value)
52 : : {
53 : 6355 : gcc_assert (gcc::jit::active_playback_ctxt != NULL);
54 : 6355 : target_info* jit_target_info
55 : 6355 : = gcc::jit::active_playback_ctxt->get_target_info ();
56 : 6355 : if (jit_target_info->m_info.find (key) == jit_target_info->m_info.end ())
57 : 2542 : jit_target_info->m_info.insert ({key, {value}});
58 : : else
59 : 3813 : jit_target_info->m_info[key].insert (value);
60 : 6355 : }
61 : :
62 : : void
63 : 1271 : jit_target_set_arch (std::string const& arch)
64 : : {
65 : 1271 : gcc_assert (gcc::jit::active_playback_ctxt != NULL);
66 : 1271 : target_info* jit_target_info
67 : 1271 : = gcc::jit::active_playback_ctxt->get_target_info ();
68 : 1271 : jit_target_info->m_arch = arch;
69 : 1271 : }
70 : :
71 : : void
72 : 2542 : jit_target_add_supported_target_dependent_type (enum gcc_jit_types type_)
73 : : {
74 : 2542 : gcc_assert (gcc::jit::active_playback_ctxt != NULL);
75 : 2542 : target_info* jit_target_info
76 : 2542 : = gcc::jit::active_playback_ctxt->get_target_info ();
77 : 2542 : jit_target_info->m_supported_target_dependent_types.insert (type_);
78 : 2542 : }
79 : :
80 : : target_info *
81 : 0 : jit_get_target_info ()
82 : : {
83 : 0 : gcc_assert (gcc::jit::active_playback_ctxt != NULL);
84 : 0 : target_info* info = gcc::jit::active_playback_ctxt->move_target_info ();
85 : 0 : return info;
86 : : }
87 : :
88 : : bool
89 : 1 : target_info::has_target_value (const char *key, const char *value)
90 : : {
91 : 1 : if (m_info.find (key) == m_info.end ())
92 : : return false;
93 : :
94 : 1 : auto& set = m_info[key];
95 : 1 : return set.find (value) != set.end ();
96 : : }
|