xref: /openbmc/qemu/target/hexagon/meson.build (revision 278f064e)
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
18hexagon_ss = ss.source_set()
19
20hex_common_py = 'hex_common.py'
21attribs_def = meson.current_source_dir() / 'attribs_def.h.inc'
22gen_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#
28gen_semantics = executable(
29    'gen_semantics',
30    'gen_semantics.c',
31    native: true, build_by_default: false)
32
33semantics_generated = custom_target(
34    'semantics_generated.pyinc',
35    output: 'semantics_generated.pyinc',
36    command: [gen_semantics, '@OUTPUT@'],
37)
38hexagon_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#
53shortcode_generated = custom_target(
54    'shortcode_generated.h.inc',
55    output: 'shortcode_generated.h.inc',
56    depends: [semantics_generated],
57    depend_files: [hex_common_py, attribs_def],
58    command: [python, files('gen_shortcode.py'), semantics_generated, attribs_def, '@OUTPUT@'],
59)
60hexagon_ss.add(shortcode_generated)
61
62helper_protos_generated = custom_target(
63    'helper_protos_generated.h.inc',
64    output: 'helper_protos_generated.h.inc',
65    depends: [semantics_generated],
66    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
67    command: [python, files('gen_helper_protos.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
68)
69hexagon_ss.add(helper_protos_generated)
70
71tcg_funcs_generated = custom_target(
72    'tcg_funcs_generated.c.inc',
73    output: 'tcg_funcs_generated.c.inc',
74    depends: [semantics_generated],
75    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
76    command: [python, files('gen_tcg_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
77)
78hexagon_ss.add(tcg_funcs_generated)
79
80tcg_func_table_generated = custom_target(
81    'tcg_func_table_generated.c.inc',
82    output: 'tcg_func_table_generated.c.inc',
83    depends: [semantics_generated],
84    depend_files: [hex_common_py, attribs_def],
85    command: [python, files('gen_tcg_func_table.py'), semantics_generated, attribs_def, '@OUTPUT@'],
86)
87hexagon_ss.add(tcg_func_table_generated)
88
89helper_funcs_generated = custom_target(
90    'helper_funcs_generated.c.inc',
91    output: 'helper_funcs_generated.c.inc',
92    depends: [semantics_generated],
93    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
94    command: [python, files('gen_helper_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
95)
96hexagon_ss.add(helper_funcs_generated)
97
98printinsn_generated = custom_target(
99    'printinsn_generated.h.inc',
100    output: 'printinsn_generated.h.inc',
101    depends: [semantics_generated],
102    depend_files: [hex_common_py, attribs_def],
103    command: [python, files('gen_printinsn.py'), semantics_generated, attribs_def, '@OUTPUT@'],
104)
105hexagon_ss.add(printinsn_generated)
106
107op_regs_generated = custom_target(
108    'op_regs_generated.h.inc',
109    output: 'op_regs_generated.h.inc',
110    depends: [semantics_generated],
111    depend_files: [hex_common_py, attribs_def],
112    command: [python, files('gen_op_regs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
113)
114hexagon_ss.add(op_regs_generated)
115
116op_attribs_generated = custom_target(
117    'op_attribs_generated.h.inc',
118    output: 'op_attribs_generated.h.inc',
119    depends: [semantics_generated],
120    depend_files: [hex_common_py, attribs_def],
121    command: [python, files('gen_op_attribs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
122)
123hexagon_ss.add(op_attribs_generated)
124
125opcodes_def_generated = custom_target(
126    'opcodes_def_generated.h.inc',
127    output: 'opcodes_def_generated.h.inc',
128    depends: [semantics_generated],
129    depend_files: [hex_common_py, attribs_def],
130    command: [python, files('gen_opcodes_def.py'), semantics_generated, attribs_def, '@OUTPUT@'],
131)
132hexagon_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#
139gen_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
144iset_py = custom_target(
145    'iset.py',
146    output: 'iset.py',
147    command: [gen_dectree_import, '@OUTPUT@'],
148)
149hexagon_ss.add(iset_py)
150
151#
152# Step 4
153# We use the dectree.py script to generate the decode tree header file
154#
155dectree_generated = custom_target(
156    'dectree_generated.h.inc',
157    output: 'dectree_generated.h.inc',
158    depends: [iset_py],
159    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],
160)
161hexagon_ss.add(dectree_generated)
162
163hexagon_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))
177
178target_arch += {'hexagon': hexagon_ss}
179