xref: /qemu/target/hexagon/meson.build (revision 7cebff0d)
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    input: gen_semantics,
37    command: ['@INPUT@', '@OUTPUT@'],
38)
39hexagon_ss.add(semantics_generated)
40
41#
42# Step 2
43# We use Python scripts to generate the following files
44#     shortcode_generated.h.inc
45#     helper_protos_generated.h.inc
46#     tcg_funcs_generated.c.inc
47#     tcg_func_table_generated.c.inc
48#     helper_funcs_generated.c.inc
49#     printinsn_generated.h.inc
50#     op_regs_generated.h.inc
51#     op_attribs_generated.h.inc
52#     opcodes_def_generated.h.inc
53#
54shortcode_generated = custom_target(
55    'shortcode_generated.h.inc',
56    output: 'shortcode_generated.h.inc',
57    input: 'gen_shortcode.py',
58    depends: [semantics_generated],
59    depend_files: [hex_common_py, attribs_def],
60    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
61)
62hexagon_ss.add(shortcode_generated)
63
64helper_protos_generated = custom_target(
65    'helper_protos_generated.h.inc',
66    output: 'helper_protos_generated.h.inc',
67    input: 'gen_helper_protos.py',
68    depends: [semantics_generated],
69    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
70    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
71)
72hexagon_ss.add(helper_protos_generated)
73
74tcg_funcs_generated = custom_target(
75    'tcg_funcs_generated.c.inc',
76    output: 'tcg_funcs_generated.c.inc',
77    input: 'gen_tcg_funcs.py',
78    depends: [semantics_generated],
79    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
80    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
81)
82hexagon_ss.add(tcg_funcs_generated)
83
84tcg_func_table_generated = custom_target(
85    'tcg_func_table_generated.c.inc',
86    output: 'tcg_func_table_generated.c.inc',
87    input: 'gen_tcg_func_table.py',
88    depends: [semantics_generated],
89    depend_files: [hex_common_py, attribs_def],
90    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
91)
92hexagon_ss.add(tcg_func_table_generated)
93
94helper_funcs_generated = custom_target(
95    'helper_funcs_generated.c.inc',
96    output: 'helper_funcs_generated.c.inc',
97    input: 'gen_helper_funcs.py',
98    depends: [semantics_generated],
99    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
100    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
101)
102hexagon_ss.add(helper_funcs_generated)
103
104printinsn_generated = custom_target(
105    'printinsn_generated.h.inc',
106    output: 'printinsn_generated.h.inc',
107    input: 'gen_printinsn.py',
108    depends: [semantics_generated],
109    depend_files: [hex_common_py, attribs_def],
110    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
111)
112hexagon_ss.add(printinsn_generated)
113
114op_regs_generated = custom_target(
115    'op_regs_generated.h.inc',
116    output: 'op_regs_generated.h.inc',
117    input: 'gen_op_regs.py',
118    depends: [semantics_generated],
119    depend_files: [hex_common_py, attribs_def],
120    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
121)
122hexagon_ss.add(op_regs_generated)
123
124op_attribs_generated = custom_target(
125    'op_attribs_generated.h.inc',
126    output: 'op_attribs_generated.h.inc',
127    input: 'gen_op_attribs.py',
128    depends: [semantics_generated],
129    depend_files: [hex_common_py, attribs_def],
130    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
131)
132hexagon_ss.add(op_attribs_generated)
133
134opcodes_def_generated = custom_target(
135    'opcodes_def_generated.h.inc',
136    output: 'opcodes_def_generated.h.inc',
137    input: 'gen_opcodes_def.py',
138    depends: [semantics_generated],
139    depend_files: [hex_common_py, attribs_def],
140    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
141)
142hexagon_ss.add(opcodes_def_generated)
143
144#
145# Step 3
146# We use a C program to create iset.py which is imported into dectree.py
147# to create the decode tree
148#
149gen_dectree_import = executable(
150    'gen_dectree_import',
151    'gen_dectree_import.c', opcodes_def_generated, op_regs_generated,
152    native: true, build_by_default: false)
153
154iset_py = custom_target(
155    'iset.py',
156    output: 'iset.py',
157    input: gen_dectree_import,
158    command: ['@INPUT@', '@OUTPUT@'],
159)
160hexagon_ss.add(iset_py)
161
162#
163# Step 4
164# We use the dectree.py script to generate the decode tree header file
165#
166dectree_generated = custom_target(
167    'dectree_generated.h.inc',
168    output: 'dectree_generated.h.inc',
169    input: 'dectree.py',
170    depends: [iset_py],
171    command: ['PYTHONPATH=' + meson.current_build_dir(), '@INPUT@', '@OUTPUT@'],
172)
173hexagon_ss.add(dectree_generated)
174
175hexagon_ss.add(files(
176    'cpu.c',
177    'translate.c',
178    'op_helper.c',
179    'gdbstub.c',
180    'genptr.c',
181    'reg_fields.c',
182    'decode.c',
183    'iclass.c',
184    'opcodes.c',
185    'printinsn.c',
186    'arch.c',
187    'fma_emu.c',
188    'conv_emu.c',
189))
190
191target_arch += {'hexagon': hexagon_ss}
192