xref: /qemu/target/hexagon/meson.build (revision a4696661)
13e7a84eeSTaylor Simpson##
2b45c1b51STaylor Simpson##  Copyright(c) 2020-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
33e7a84eeSTaylor Simpson##
43e7a84eeSTaylor Simpson##  This program is free software; you can redistribute it and/or modify
53e7a84eeSTaylor Simpson##  it under the terms of the GNU General Public License as published by
63e7a84eeSTaylor Simpson##  the Free Software Foundation; either version 2 of the License, or
73e7a84eeSTaylor Simpson##  (at your option) any later version.
83e7a84eeSTaylor Simpson##
93e7a84eeSTaylor Simpson##  This program is distributed in the hope that it will be useful,
103e7a84eeSTaylor Simpson##  but WITHOUT ANY WARRANTY; without even the implied warranty of
113e7a84eeSTaylor Simpson##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
123e7a84eeSTaylor Simpson##  GNU General Public License for more details.
133e7a84eeSTaylor Simpson##
143e7a84eeSTaylor Simpson##  You should have received a copy of the GNU General Public License
153e7a84eeSTaylor Simpson##  along with this program; if not, see <http://www.gnu.org/licenses/>.
163e7a84eeSTaylor Simpson##
173e7a84eeSTaylor Simpson
183e7a84eeSTaylor Simpsonhexagon_ss = ss.source_set()
193e7a84eeSTaylor Simpson
203e7a84eeSTaylor Simpsonhex_common_py = 'hex_common.py'
213e7a84eeSTaylor Simpsongen_tcg_h = meson.current_source_dir() / 'gen_tcg.h'
22d51bcabeSTaylor Simpsongen_tcg_hvx_h = meson.current_source_dir() / 'gen_tcg_hvx.h'
237c19dcc5SAlessandro Di Federicoidef_parser_dir = meson.current_source_dir() / 'idef-parser'
243e7a84eeSTaylor Simpson
253e7a84eeSTaylor Simpson#
263e7a84eeSTaylor Simpson#  Step 1
273e7a84eeSTaylor Simpson#  We use a C program to create semantics_generated.pyinc
283e7a84eeSTaylor Simpson#
293e7a84eeSTaylor Simpsongen_semantics = executable(
303e7a84eeSTaylor Simpson    'gen_semantics',
313e7a84eeSTaylor Simpson    'gen_semantics.c',
323e7a84eeSTaylor Simpson    native: true, build_by_default: false)
333e7a84eeSTaylor Simpson
343e7a84eeSTaylor Simpsonsemantics_generated = custom_target(
353e7a84eeSTaylor Simpson    'semantics_generated.pyinc',
363e7a84eeSTaylor Simpson    output: 'semantics_generated.pyinc',
37a5158a96SPaolo Bonzini    command: [gen_semantics, '@OUTPUT@'],
383e7a84eeSTaylor Simpson)
393e7a84eeSTaylor Simpsonhexagon_ss.add(semantics_generated)
403e7a84eeSTaylor Simpson
413e7a84eeSTaylor Simpson#
423e7a84eeSTaylor Simpson# Step 2
433e7a84eeSTaylor Simpson# We use Python scripts to generate the following files
443e7a84eeSTaylor Simpson#     tcg_func_table_generated.c.inc
453e7a84eeSTaylor Simpson#     printinsn_generated.h.inc
463e7a84eeSTaylor Simpson#     op_attribs_generated.h.inc
473e7a84eeSTaylor Simpson#     opcodes_def_generated.h.inc
483e7a84eeSTaylor Simpson#
493e7a84eeSTaylor Simpsontcg_func_table_generated = custom_target(
503e7a84eeSTaylor Simpson    'tcg_func_table_generated.c.inc',
513e7a84eeSTaylor Simpson    output: 'tcg_func_table_generated.c.inc',
523e7a84eeSTaylor Simpson    depends: [semantics_generated],
53a4696661STaylor Simpson    depend_files: [hex_common_py],
54a4696661STaylor Simpson    command: [python, files('gen_tcg_func_table.py'), semantics_generated, '@OUTPUT@'],
553e7a84eeSTaylor Simpson)
563e7a84eeSTaylor Simpsonhexagon_ss.add(tcg_func_table_generated)
573e7a84eeSTaylor Simpson
583e7a84eeSTaylor Simpsonprintinsn_generated = custom_target(
593e7a84eeSTaylor Simpson    'printinsn_generated.h.inc',
603e7a84eeSTaylor Simpson    output: 'printinsn_generated.h.inc',
613e7a84eeSTaylor Simpson    depends: [semantics_generated],
62a4696661STaylor Simpson    depend_files: [hex_common_py],
63a4696661STaylor Simpson    command: [python, files('gen_printinsn.py'), semantics_generated, '@OUTPUT@'],
643e7a84eeSTaylor Simpson)
653e7a84eeSTaylor Simpsonhexagon_ss.add(printinsn_generated)
663e7a84eeSTaylor Simpson
673e7a84eeSTaylor Simpsonop_attribs_generated = custom_target(
683e7a84eeSTaylor Simpson    'op_attribs_generated.h.inc',
693e7a84eeSTaylor Simpson    output: 'op_attribs_generated.h.inc',
703e7a84eeSTaylor Simpson    depends: [semantics_generated],
71a4696661STaylor Simpson    depend_files: [hex_common_py],
72a4696661STaylor Simpson    command: [python, files('gen_op_attribs.py'), semantics_generated, '@OUTPUT@'],
733e7a84eeSTaylor Simpson)
743e7a84eeSTaylor Simpsonhexagon_ss.add(op_attribs_generated)
753e7a84eeSTaylor Simpson
763e7a84eeSTaylor Simpsonopcodes_def_generated = custom_target(
773e7a84eeSTaylor Simpson    'opcodes_def_generated.h.inc',
783e7a84eeSTaylor Simpson    output: 'opcodes_def_generated.h.inc',
793e7a84eeSTaylor Simpson    depends: [semantics_generated],
80a4696661STaylor Simpson    depend_files: [hex_common_py],
81a4696661STaylor Simpson    command: [python, files('gen_opcodes_def.py'), semantics_generated, '@OUTPUT@'],
823e7a84eeSTaylor Simpson)
833e7a84eeSTaylor Simpsonhexagon_ss.add(opcodes_def_generated)
843e7a84eeSTaylor Simpson
853e7a84eeSTaylor Simpson#
863e7a84eeSTaylor Simpson# Step 3
873e7a84eeSTaylor Simpson# We use a C program to create iset.py which is imported into dectree.py
883e7a84eeSTaylor Simpson# to create the decode tree
893e7a84eeSTaylor Simpson#
903e7a84eeSTaylor Simpsongen_dectree_import = executable(
913e7a84eeSTaylor Simpson    'gen_dectree_import',
92b45c1b51STaylor Simpson    'gen_dectree_import.c', opcodes_def_generated,
933e7a84eeSTaylor Simpson    native: true, build_by_default: false)
943e7a84eeSTaylor Simpson
953e7a84eeSTaylor Simpsoniset_py = custom_target(
963e7a84eeSTaylor Simpson    'iset.py',
973e7a84eeSTaylor Simpson    output: 'iset.py',
98a5158a96SPaolo Bonzini    command: [gen_dectree_import, '@OUTPUT@'],
993e7a84eeSTaylor Simpson)
1003e7a84eeSTaylor Simpsonhexagon_ss.add(iset_py)
1013e7a84eeSTaylor Simpson
1023e7a84eeSTaylor Simpson#
1033e7a84eeSTaylor Simpson# Step 4
1041547a2d3STaylor Simpson# Generate the input to the QEMU decodetree.py script
1051547a2d3STaylor Simpson#
1061547a2d3STaylor Simpsonnormal_decode_generated = custom_target(
1071547a2d3STaylor Simpson    'normal_decode_generated',
1081547a2d3STaylor Simpson    output: 'normal_decode_generated',
1091547a2d3STaylor Simpson    depends: [iset_py, semantics_generated],
1101547a2d3STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
1111547a2d3STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'NORMAL', '@OUTPUT@'],
1121547a2d3STaylor Simpson)
1131547a2d3STaylor Simpsonhexagon_ss.add(normal_decode_generated)
1141547a2d3STaylor Simpson
1151547a2d3STaylor Simpsonhvx_decode_generated = custom_target(
1161547a2d3STaylor Simpson    'hvx_decode_generated',
1171547a2d3STaylor Simpson    output: 'hvx_decode_generated',
1181547a2d3STaylor Simpson    depends: [iset_py, semantics_generated],
1191547a2d3STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
1201547a2d3STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'EXT_mmvec', '@OUTPUT@'],
1211547a2d3STaylor Simpson)
1221547a2d3STaylor Simpsonhexagon_ss.add(hvx_decode_generated)
1231547a2d3STaylor Simpson
124f6c01009STaylor Simpsonsubinsn_a_decode_generated = custom_target(
125f6c01009STaylor Simpson    'subinsn_a_decode_generated',
126f6c01009STaylor Simpson    output: 'subinsn_a_decode_generated',
127f6c01009STaylor Simpson    depends: [iset_py, semantics_generated],
128f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
129f6c01009STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'SUBINSN_A', '@OUTPUT@'],
130f6c01009STaylor Simpson)
131f6c01009STaylor Simpsonhexagon_ss.add(subinsn_a_decode_generated)
132f6c01009STaylor Simpson
133f6c01009STaylor Simpsonsubinsn_l1_decode_generated = custom_target(
134f6c01009STaylor Simpson    'subinsn_l1_decode_generated',
135f6c01009STaylor Simpson    output: 'subinsn_l1_decode_generated',
136f6c01009STaylor Simpson    depends: [iset_py, semantics_generated],
137f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
138f6c01009STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'SUBINSN_L1', '@OUTPUT@'],
139f6c01009STaylor Simpson)
140f6c01009STaylor Simpsonhexagon_ss.add(subinsn_l1_decode_generated)
141f6c01009STaylor Simpson
142f6c01009STaylor Simpsonsubinsn_l2_decode_generated = custom_target(
143f6c01009STaylor Simpson    'subinsn_l2_decode_generated',
144f6c01009STaylor Simpson    output: 'subinsn_l2_decode_generated',
145f6c01009STaylor Simpson    depends: [iset_py, semantics_generated],
146f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
147f6c01009STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'SUBINSN_L2', '@OUTPUT@'],
148f6c01009STaylor Simpson)
149f6c01009STaylor Simpsonhexagon_ss.add(subinsn_l2_decode_generated)
150f6c01009STaylor Simpson
151f6c01009STaylor Simpsonsubinsn_s1_decode_generated = custom_target(
152f6c01009STaylor Simpson    'subinsn_s1_decode_generated',
153f6c01009STaylor Simpson    output: 'subinsn_s1_decode_generated',
154f6c01009STaylor Simpson    depends: [iset_py, semantics_generated],
155f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
156f6c01009STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'SUBINSN_S1', '@OUTPUT@'],
157f6c01009STaylor Simpson)
158f6c01009STaylor Simpsonhexagon_ss.add(subinsn_s1_decode_generated)
159f6c01009STaylor Simpson
160f6c01009STaylor Simpsonsubinsn_s2_decode_generated = custom_target(
161f6c01009STaylor Simpson    'subinsn_s2_decode_generated',
162f6c01009STaylor Simpson    output: 'subinsn_s2_decode_generated',
163f6c01009STaylor Simpson    depends: [iset_py, semantics_generated],
164f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
165f6c01009STaylor Simpson    command: [python, files('gen_decodetree.py'), semantics_generated, 'SUBINSN_S2', '@OUTPUT@'],
166f6c01009STaylor Simpson)
167f6c01009STaylor Simpsonhexagon_ss.add(subinsn_s2_decode_generated)
168f6c01009STaylor Simpson
1691547a2d3STaylor Simpson#
1701547a2d3STaylor Simpson# Run the QEMU decodetree.py script to produce the instruction decoder
1711547a2d3STaylor Simpson#
1721547a2d3STaylor Simpsondecodetree_py = meson.current_source_dir() / '../../scripts/decodetree.py'
1731547a2d3STaylor Simpsondecode_normal_generated = custom_target(
1741547a2d3STaylor Simpson    'decode_normal_generated.c.inc',
1751547a2d3STaylor Simpson    output: 'decode_normal_generated.c.inc',
1761547a2d3STaylor Simpson    input: normal_decode_generated,
1771547a2d3STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
1781547a2d3STaylor Simpson    command: [python, files(decodetree_py), normal_decode_generated, '--static-decode=decode_normal', '-o', '@OUTPUT@'],
1791547a2d3STaylor Simpson)
1801547a2d3STaylor Simpsonhexagon_ss.add(decode_normal_generated)
1811547a2d3STaylor Simpson
1821547a2d3STaylor Simpsondecode_hvx_generated = custom_target(
1831547a2d3STaylor Simpson    'decode_hvx_generated.c.inc',
1841547a2d3STaylor Simpson    output: 'decode_hvx_generated.c.inc',
1851547a2d3STaylor Simpson    input: hvx_decode_generated,
1861547a2d3STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
1871547a2d3STaylor Simpson    command: [python, files(decodetree_py), hvx_decode_generated, '--static-decode=decode_hvx', '-o', '@OUTPUT@'],
1881547a2d3STaylor Simpson)
1891547a2d3STaylor Simpsonhexagon_ss.add(decode_hvx_generated)
1901547a2d3STaylor Simpson
191f6c01009STaylor Simpsondecode_subinsn_a_generated = custom_target(
192f6c01009STaylor Simpson    'decode_subinsn_a_generated.c.inc',
193f6c01009STaylor Simpson    output: 'decode_subinsn_a_generated.c.inc',
194f6c01009STaylor Simpson    input: subinsn_a_decode_generated,
195f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
196f6c01009STaylor Simpson    command: [python, files(decodetree_py), subinsn_a_decode_generated, ['--static-decode=decode_subinsn_a', '--insnwidth=16'], '-o', '@OUTPUT@'],
197f6c01009STaylor Simpson)
198f6c01009STaylor Simpsonhexagon_ss.add(decode_subinsn_a_generated)
199f6c01009STaylor Simpson
200f6c01009STaylor Simpsondecode_subinsn_l1_generated = custom_target(
201f6c01009STaylor Simpson    'decode_subinsn_l1_generated.c.inc',
202f6c01009STaylor Simpson    output: 'decode_subinsn_l1_generated.c.inc',
203f6c01009STaylor Simpson    input: subinsn_l1_decode_generated,
204f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
205f6c01009STaylor Simpson    command: [python, files(decodetree_py), subinsn_l1_decode_generated, ['--static-decode=decode_subinsn_l1', '--insnwidth=16'], '-o', '@OUTPUT@'],
206f6c01009STaylor Simpson)
207f6c01009STaylor Simpsonhexagon_ss.add(decode_subinsn_l1_generated)
208f6c01009STaylor Simpson
209f6c01009STaylor Simpsondecode_subinsn_l2_generated = custom_target(
210f6c01009STaylor Simpson    'decode_subinsn_l2_generated.c.inc',
211f6c01009STaylor Simpson    output: 'decode_subinsn_l2_generated.c.inc',
212f6c01009STaylor Simpson    input: subinsn_l2_decode_generated,
213f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
214f6c01009STaylor Simpson    command: [python, files(decodetree_py), subinsn_l2_decode_generated, ['--static-decode=decode_subinsn_l2', '--insnwidth=16'], '-o', '@OUTPUT@'],
215f6c01009STaylor Simpson)
216f6c01009STaylor Simpsonhexagon_ss.add(decode_subinsn_l2_generated)
217f6c01009STaylor Simpson
218f6c01009STaylor Simpsondecode_subinsn_s1_generated = custom_target(
219f6c01009STaylor Simpson    'decode_subinsn_s1_generated.c.inc',
220f6c01009STaylor Simpson    output: 'decode_subinsn_s1_generated.c.inc',
221f6c01009STaylor Simpson    input: subinsn_s1_decode_generated,
222f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
223f6c01009STaylor Simpson    command: [python, files(decodetree_py), subinsn_s1_decode_generated, ['--static-decode=decode_subinsn_s1', '--insnwidth=16'], '-o', '@OUTPUT@'],
224f6c01009STaylor Simpson)
225f6c01009STaylor Simpsonhexagon_ss.add(decode_subinsn_s1_generated)
226f6c01009STaylor Simpson
227f6c01009STaylor Simpsondecode_subinsn_s2_generated = custom_target(
228f6c01009STaylor Simpson    'decode_subinsn_s2_generated.c.inc',
229f6c01009STaylor Simpson    output: 'decode_subinsn_s2_generated.c.inc',
230f6c01009STaylor Simpson    input: subinsn_s2_decode_generated,
231f6c01009STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
232f6c01009STaylor Simpson    command: [python, files(decodetree_py), subinsn_s2_decode_generated, ['--static-decode=decode_subinsn_s2', '--insnwidth=16'], '-o', '@OUTPUT@'],
233f6c01009STaylor Simpson)
234f6c01009STaylor Simpsonhexagon_ss.add(decode_subinsn_s2_generated)
235f6c01009STaylor Simpson
2361547a2d3STaylor Simpson#
2371547a2d3STaylor Simpson# Generate the trans_* functions that the decoder will use
2381547a2d3STaylor Simpson#
2391547a2d3STaylor Simpsondecodetree_trans_funcs_generated = custom_target(
2401547a2d3STaylor Simpson    'decodetree_trans_funcs_generated.c.inc',
2411547a2d3STaylor Simpson    output: 'decodetree_trans_funcs_generated.c.inc',
2421547a2d3STaylor Simpson    depends: [iset_py, semantics_generated],
2431547a2d3STaylor Simpson    env: {'PYTHONPATH': meson.current_build_dir()},
2441547a2d3STaylor Simpson    command: [python, files('gen_trans_funcs.py'), semantics_generated, '@OUTPUT@'],
2451547a2d3STaylor Simpson)
2461547a2d3STaylor Simpsonhexagon_ss.add(decodetree_trans_funcs_generated)
2471547a2d3STaylor Simpson
2483e7a84eeSTaylor Simpsonhexagon_ss.add(files(
2493e7a84eeSTaylor Simpson    'cpu.c',
2503e7a84eeSTaylor Simpson    'translate.c',
2513e7a84eeSTaylor Simpson    'op_helper.c',
2523e7a84eeSTaylor Simpson    'gdbstub.c',
2533e7a84eeSTaylor Simpson    'genptr.c',
2543e7a84eeSTaylor Simpson    'reg_fields.c',
2553e7a84eeSTaylor Simpson    'decode.c',
2563e7a84eeSTaylor Simpson    'iclass.c',
2573e7a84eeSTaylor Simpson    'opcodes.c',
2583e7a84eeSTaylor Simpson    'printinsn.c',
2593e7a84eeSTaylor Simpson    'arch.c',
2603e7a84eeSTaylor Simpson    'fma_emu.c',
26160d1180bSTaylor Simpson    'mmvec/decode_ext_mmvec.c',
26282f8b3dcSTaylor Simpson    'mmvec/system_ext_mmvec.c',
2633e7a84eeSTaylor Simpson))
2643e7a84eeSTaylor Simpson
265e71fdc4fSAlessandro Di Federico#
266e71fdc4fSAlessandro Di Federico# Step 4.5
267e71fdc4fSAlessandro Di Federico# We use flex/bison based idef-parser to generate TCG code for a lot
268e71fdc4fSAlessandro Di Federico# of instructions. idef-parser outputs
269e71fdc4fSAlessandro Di Federico#     idef-generated-emitter.c
270e71fdc4fSAlessandro Di Federico#     idef-generated-emitter.h.inc
271e71fdc4fSAlessandro Di Federico#     idef-generated-enabled-instructions
272e71fdc4fSAlessandro Di Federico#
2737c19dcc5SAlessandro Di Federicoidef_parser_enabled = get_option('hexagon_idef_parser')
2747c19dcc5SAlessandro Di Federicoif idef_parser_enabled and 'hexagon-linux-user' in target_dirs
2757c19dcc5SAlessandro Di Federico    idef_parser_input_generated = custom_target(
2767c19dcc5SAlessandro Di Federico        'idef_parser_input.h.inc',
2777c19dcc5SAlessandro Di Federico        output: 'idef_parser_input.h.inc',
2787c19dcc5SAlessandro Di Federico        depends: [semantics_generated],
2797c19dcc5SAlessandro Di Federico        depend_files: [hex_common_py],
280a4696661STaylor Simpson        command: [python, files('gen_idef_parser_funcs.py'), semantics_generated, '@OUTPUT@'],
2817c19dcc5SAlessandro Di Federico    )
2827c19dcc5SAlessandro Di Federico
2837c19dcc5SAlessandro Di Federico    preprocessed_idef_parser_input_generated = custom_target(
2847c19dcc5SAlessandro Di Federico        'idef_parser_input.preprocessed.h.inc',
2857c19dcc5SAlessandro Di Federico        output: 'idef_parser_input.preprocessed.h.inc',
2867c19dcc5SAlessandro Di Federico        input: idef_parser_input_generated,
2877c19dcc5SAlessandro Di Federico        depend_files: [idef_parser_dir / 'macros.inc'],
2887c19dcc5SAlessandro Di Federico        command: [idef_parser_dir / 'prepare', '@INPUT@', '-I' + idef_parser_dir, '-o', '@OUTPUT@'],
2897c19dcc5SAlessandro Di Federico    )
290fd8171feSPaolo Montesel
291fd8171feSPaolo Montesel    flex = generator(
292fd8171feSPaolo Montesel        find_program('flex'),
293fd8171feSPaolo Montesel        output: ['@BASENAME@.yy.c', '@BASENAME@.yy.h'],
294fd8171feSPaolo Montesel        arguments: ['-o', '@OUTPUT0@', '--header-file=@OUTPUT1@', '@INPUT@']
295fd8171feSPaolo Montesel    )
296c0a41ee6SAnton Johansson
297c0a41ee6SAnton Johansson    bison = generator(
298243ec1c2SMatheus Tavares Bernardino        find_program('bison', version: '>=3.0'),
299c0a41ee6SAnton Johansson        output: ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
300c0a41ee6SAnton Johansson        arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
301c0a41ee6SAnton Johansson    )
302c0a41ee6SAnton Johansson
303c0a41ee6SAnton Johansson    glib_dep = dependency('glib-2.0', native: true)
304c0a41ee6SAnton Johansson
305c0a41ee6SAnton Johansson    idef_parser = executable(
306c0a41ee6SAnton Johansson        'idef-parser',
307c0a41ee6SAnton Johansson        [flex.process(idef_parser_dir / 'idef-parser.lex'),
308c0a41ee6SAnton Johansson         bison.process(idef_parser_dir / 'idef-parser.y'),
309c0a41ee6SAnton Johansson         idef_parser_dir / 'parser-helpers.c'],
310c0a41ee6SAnton Johansson        include_directories: ['idef-parser', '../../include/'],
311c0a41ee6SAnton Johansson        dependencies: [glib_dep],
312c0a41ee6SAnton Johansson        native: true
313c0a41ee6SAnton Johansson    )
314c0a41ee6SAnton Johansson
315c0a41ee6SAnton Johansson    idef_generated_tcg = custom_target(
316c0a41ee6SAnton Johansson        'idef-generated-tcg',
317c0a41ee6SAnton Johansson        output: ['idef-generated-emitter.c',
318c0a41ee6SAnton Johansson                 'idef-generated-emitter.h.inc',
319c0a41ee6SAnton Johansson                 'idef-generated-enabled-instructions'],
320c0a41ee6SAnton Johansson        input: preprocessed_idef_parser_input_generated,
321c0a41ee6SAnton Johansson        depend_files: [hex_common_py],
322c0a41ee6SAnton Johansson        command: [idef_parser, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']
323c0a41ee6SAnton Johansson    )
324e71fdc4fSAlessandro Di Federico
325e71fdc4fSAlessandro Di Federico    indent = find_program('indent', required: false)
326e71fdc4fSAlessandro Di Federico    if indent.found()
327e71fdc4fSAlessandro Di Federico        idef_generated_tcg_c = custom_target(
328e71fdc4fSAlessandro Di Federico            'indent',
329e71fdc4fSAlessandro Di Federico            input: idef_generated_tcg[0],
330e71fdc4fSAlessandro Di Federico            output: 'idef-generated-emitter.indented.c',
331e71fdc4fSAlessandro Di Federico            command: [indent, '-linux', '@INPUT@', '-o', '@OUTPUT@']
332e71fdc4fSAlessandro Di Federico        )
333e71fdc4fSAlessandro Di Federico    else
334e71fdc4fSAlessandro Di Federico        idef_generated_tcg_c = custom_target(
335e71fdc4fSAlessandro Di Federico            'copy',
336e71fdc4fSAlessandro Di Federico            input: idef_generated_tcg[0],
337e71fdc4fSAlessandro Di Federico            output: 'idef-generated-emitter.indented.c',
338e71fdc4fSAlessandro Di Federico            command: ['cp', '@INPUT@', '@OUTPUT@']
339e71fdc4fSAlessandro Di Federico        )
3407c19dcc5SAlessandro Di Federico    endif
3417c19dcc5SAlessandro Di Federico
342e71fdc4fSAlessandro Di Federico    idef_generated_list = idef_generated_tcg[2].full_path()
343e71fdc4fSAlessandro Di Federico
344e71fdc4fSAlessandro Di Federico    hexagon_ss.add(idef_generated_tcg_c)
345e71fdc4fSAlessandro Di Federico
346e71fdc4fSAlessandro Di Federico    # Setup input and dependencies for the next step, this depends on whether or
347e71fdc4fSAlessandro Di Federico    # not idef-parser is enabled
348e71fdc4fSAlessandro Di Federico    helper_dep = [semantics_generated, idef_generated_tcg_c, idef_generated_tcg]
349a4696661STaylor Simpson    helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, idef_generated_list]
350e71fdc4fSAlessandro Di Federicoelse
351e71fdc4fSAlessandro Di Federico    # Setup input and dependencies for the next step, this depends on whether or
352e71fdc4fSAlessandro Di Federico    # not idef-parser is enabled
353e71fdc4fSAlessandro Di Federico    helper_dep = [semantics_generated]
354a4696661STaylor Simpson    helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h]
355e71fdc4fSAlessandro Di Federicoendif
356e71fdc4fSAlessandro Di Federico
357e71fdc4fSAlessandro Di Federico#
358e71fdc4fSAlessandro Di Federico# Step 5
359e71fdc4fSAlessandro Di Federico# We use Python scripts to generate the following files
360e71fdc4fSAlessandro Di Federico#     helper_protos_generated.h.inc
361e71fdc4fSAlessandro Di Federico#     helper_funcs_generated.c.inc
362e71fdc4fSAlessandro Di Federico#     tcg_funcs_generated.c.inc
363e71fdc4fSAlessandro Di Federico#
364e71fdc4fSAlessandro Di Federicohelper_protos_generated = custom_target(
365e71fdc4fSAlessandro Di Federico    'helper_protos_generated.h.inc',
366e71fdc4fSAlessandro Di Federico    output: 'helper_protos_generated.h.inc',
367e71fdc4fSAlessandro Di Federico    depends: helper_dep,
368a4696661STaylor Simpson    depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h],
369e71fdc4fSAlessandro Di Federico    command: [python, files('gen_helper_protos.py'), helper_in, '@OUTPUT@'],
370e71fdc4fSAlessandro Di Federico)
371e71fdc4fSAlessandro Di Federicohexagon_ss.add(helper_protos_generated)
372e71fdc4fSAlessandro Di Federico
373e71fdc4fSAlessandro Di Federicohelper_funcs_generated = custom_target(
374e71fdc4fSAlessandro Di Federico    'helper_funcs_generated.c.inc',
375e71fdc4fSAlessandro Di Federico    output: 'helper_funcs_generated.c.inc',
376e71fdc4fSAlessandro Di Federico    depends: helper_dep,
377a4696661STaylor Simpson    depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h],
378e71fdc4fSAlessandro Di Federico    command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'],
379e71fdc4fSAlessandro Di Federico)
380e71fdc4fSAlessandro Di Federicohexagon_ss.add(helper_funcs_generated)
381e71fdc4fSAlessandro Di Federico
382e71fdc4fSAlessandro Di Federicotcg_funcs_generated = custom_target(
383e71fdc4fSAlessandro Di Federico    'tcg_funcs_generated.c.inc',
384e71fdc4fSAlessandro Di Federico    output: 'tcg_funcs_generated.c.inc',
385e71fdc4fSAlessandro Di Federico    depends: helper_dep,
386a4696661STaylor Simpson    depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h],
387e71fdc4fSAlessandro Di Federico    command: [python, files('gen_tcg_funcs.py'), helper_in, '@OUTPUT@'],
388e71fdc4fSAlessandro Di Federico)
389e71fdc4fSAlessandro Di Federicohexagon_ss.add(tcg_funcs_generated)
390e71fdc4fSAlessandro Di Federico
39110849c26STaylor Simpsonanalyze_funcs_generated = custom_target(
39210849c26STaylor Simpson    'analyze_funcs_generated.c.inc',
39310849c26STaylor Simpson    output: 'analyze_funcs_generated.c.inc',
39410849c26STaylor Simpson    depends: helper_dep,
395a4696661STaylor Simpson    depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h],
39610849c26STaylor Simpson    command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'],
39710849c26STaylor Simpson)
39810849c26STaylor Simpsonhexagon_ss.add(analyze_funcs_generated)
39910849c26STaylor Simpson
4003e7a84eeSTaylor Simpsontarget_arch += {'hexagon': hexagon_ss}
401