]>
Commit | Line | Data |
---|---|---|
3e7a84ee TS |
1 | ## |
2 | ## Copyright(c) 2020-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. | |
3 | ## | |
4 | ## This program 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 2 of the License, or | |
7 | ## (at your option) any 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; if not, see <http://www.gnu.org/licenses/>. | |
16 | ## | |
17 | ||
18 | hexagon_ss = ss.source_set() | |
19 | ||
20 | hex_common_py = 'hex_common.py' | |
21 | attribs_def = meson.current_source_dir() / 'attribs_def.h.inc' | |
22 | gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h' | |
23 | ||
24 | # | |
25 | # Step 1 | |
26 | # We use a C program to create semantics_generated.pyinc | |
27 | # | |
28 | gen_semantics = executable( | |
29 | 'gen_semantics', | |
30 | 'gen_semantics.c', | |
31 | native: true, build_by_default: false) | |
32 | ||
33 | semantics_generated = custom_target( | |
34 | 'semantics_generated.pyinc', | |
35 | output: 'semantics_generated.pyinc', | |
a5158a96 | 36 | command: [gen_semantics, '@OUTPUT@'], |
3e7a84ee TS |
37 | ) |
38 | hexagon_ss.add(semantics_generated) | |
39 | ||
40 | # | |
41 | # Step 2 | |
42 | # We use Python scripts to generate the following files | |
43 | # shortcode_generated.h.inc | |
44 | # helper_protos_generated.h.inc | |
45 | # tcg_funcs_generated.c.inc | |
46 | # tcg_func_table_generated.c.inc | |
47 | # helper_funcs_generated.c.inc | |
48 | # printinsn_generated.h.inc | |
49 | # op_regs_generated.h.inc | |
50 | # op_attribs_generated.h.inc | |
51 | # opcodes_def_generated.h.inc | |
52 | # | |
53 | shortcode_generated = custom_target( | |
54 | 'shortcode_generated.h.inc', | |
55 | output: 'shortcode_generated.h.inc', | |
3e7a84ee TS |
56 | depends: [semantics_generated], |
57 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 58 | command: [python, files('gen_shortcode.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
59 | ) |
60 | hexagon_ss.add(shortcode_generated) | |
61 | ||
62 | helper_protos_generated = custom_target( | |
63 | 'helper_protos_generated.h.inc', | |
64 | output: 'helper_protos_generated.h.inc', | |
3e7a84ee TS |
65 | depends: [semantics_generated], |
66 | depend_files: [hex_common_py, attribs_def, gen_tcg_h], | |
2008b34a | 67 | command: [python, files('gen_helper_protos.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'], |
3e7a84ee TS |
68 | ) |
69 | hexagon_ss.add(helper_protos_generated) | |
70 | ||
71 | tcg_funcs_generated = custom_target( | |
72 | 'tcg_funcs_generated.c.inc', | |
73 | output: 'tcg_funcs_generated.c.inc', | |
3e7a84ee TS |
74 | depends: [semantics_generated], |
75 | depend_files: [hex_common_py, attribs_def, gen_tcg_h], | |
2008b34a | 76 | command: [python, files('gen_tcg_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'], |
3e7a84ee TS |
77 | ) |
78 | hexagon_ss.add(tcg_funcs_generated) | |
79 | ||
80 | tcg_func_table_generated = custom_target( | |
81 | 'tcg_func_table_generated.c.inc', | |
82 | output: 'tcg_func_table_generated.c.inc', | |
3e7a84ee TS |
83 | depends: [semantics_generated], |
84 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 85 | command: [python, files('gen_tcg_func_table.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
86 | ) |
87 | hexagon_ss.add(tcg_func_table_generated) | |
88 | ||
89 | helper_funcs_generated = custom_target( | |
90 | 'helper_funcs_generated.c.inc', | |
91 | output: 'helper_funcs_generated.c.inc', | |
3e7a84ee TS |
92 | depends: [semantics_generated], |
93 | depend_files: [hex_common_py, attribs_def, gen_tcg_h], | |
2008b34a | 94 | command: [python, files('gen_helper_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'], |
3e7a84ee TS |
95 | ) |
96 | hexagon_ss.add(helper_funcs_generated) | |
97 | ||
98 | printinsn_generated = custom_target( | |
99 | 'printinsn_generated.h.inc', | |
100 | output: 'printinsn_generated.h.inc', | |
3e7a84ee TS |
101 | depends: [semantics_generated], |
102 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 103 | command: [python, files('gen_printinsn.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
104 | ) |
105 | hexagon_ss.add(printinsn_generated) | |
106 | ||
107 | op_regs_generated = custom_target( | |
108 | 'op_regs_generated.h.inc', | |
109 | output: 'op_regs_generated.h.inc', | |
3e7a84ee TS |
110 | depends: [semantics_generated], |
111 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 112 | command: [python, files('gen_op_regs.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
113 | ) |
114 | hexagon_ss.add(op_regs_generated) | |
115 | ||
116 | op_attribs_generated = custom_target( | |
117 | 'op_attribs_generated.h.inc', | |
118 | output: 'op_attribs_generated.h.inc', | |
3e7a84ee TS |
119 | depends: [semantics_generated], |
120 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 121 | command: [python, files('gen_op_attribs.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
122 | ) |
123 | hexagon_ss.add(op_attribs_generated) | |
124 | ||
125 | opcodes_def_generated = custom_target( | |
126 | 'opcodes_def_generated.h.inc', | |
127 | output: 'opcodes_def_generated.h.inc', | |
3e7a84ee TS |
128 | depends: [semantics_generated], |
129 | depend_files: [hex_common_py, attribs_def], | |
2008b34a | 130 | command: [python, files('gen_opcodes_def.py'), semantics_generated, attribs_def, '@OUTPUT@'], |
3e7a84ee TS |
131 | ) |
132 | hexagon_ss.add(opcodes_def_generated) | |
133 | ||
134 | # | |
135 | # Step 3 | |
136 | # We use a C program to create iset.py which is imported into dectree.py | |
137 | # to create the decode tree | |
138 | # | |
139 | gen_dectree_import = executable( | |
140 | 'gen_dectree_import', | |
141 | 'gen_dectree_import.c', opcodes_def_generated, op_regs_generated, | |
142 | native: true, build_by_default: false) | |
143 | ||
144 | iset_py = custom_target( | |
145 | 'iset.py', | |
146 | output: 'iset.py', | |
a5158a96 | 147 | command: [gen_dectree_import, '@OUTPUT@'], |
3e7a84ee TS |
148 | ) |
149 | hexagon_ss.add(iset_py) | |
150 | ||
151 | # | |
152 | # Step 4 | |
153 | # We use the dectree.py script to generate the decode tree header file | |
154 | # | |
155 | dectree_generated = custom_target( | |
156 | 'dectree_generated.h.inc', | |
157 | output: 'dectree_generated.h.inc', | |
3e7a84ee | 158 | depends: [iset_py], |
2008b34a | 159 | command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'], |
3e7a84ee TS |
160 | ) |
161 | hexagon_ss.add(dectree_generated) | |
162 | ||
163 | hexagon_ss.add(files( | |
164 | 'cpu.c', | |
165 | 'translate.c', | |
166 | 'op_helper.c', | |
167 | 'gdbstub.c', | |
168 | 'genptr.c', | |
169 | 'reg_fields.c', | |
170 | 'decode.c', | |
171 | 'iclass.c', | |
172 | 'opcodes.c', | |
173 | 'printinsn.c', | |
174 | 'arch.c', | |
175 | 'fma_emu.c', | |
176 | 'conv_emu.c', | |
177 | )) | |
178 | ||
179 | target_arch += {'hexagon': hexagon_ss} |