xref: /qemu/target/hexagon/meson.build (revision 82f8b3dc)
13e7a84eeSTaylor Simpson##
23e7a84eeSTaylor Simpson##  Copyright(c) 2020-2021 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 Simpsonattribs_def = meson.current_source_dir() / 'attribs_def.h.inc'
223e7a84eeSTaylor Simpsongen_tcg_h = meson.current_source_dir() / 'gen_tcg.h'
233e7a84eeSTaylor Simpson
243e7a84eeSTaylor Simpson#
253e7a84eeSTaylor Simpson#  Step 1
263e7a84eeSTaylor Simpson#  We use a C program to create semantics_generated.pyinc
273e7a84eeSTaylor Simpson#
283e7a84eeSTaylor Simpsongen_semantics = executable(
293e7a84eeSTaylor Simpson    'gen_semantics',
303e7a84eeSTaylor Simpson    'gen_semantics.c',
313e7a84eeSTaylor Simpson    native: true, build_by_default: false)
323e7a84eeSTaylor Simpson
333e7a84eeSTaylor Simpsonsemantics_generated = custom_target(
343e7a84eeSTaylor Simpson    'semantics_generated.pyinc',
353e7a84eeSTaylor Simpson    output: 'semantics_generated.pyinc',
36a5158a96SPaolo Bonzini    command: [gen_semantics, '@OUTPUT@'],
373e7a84eeSTaylor Simpson)
383e7a84eeSTaylor Simpsonhexagon_ss.add(semantics_generated)
393e7a84eeSTaylor Simpson
403e7a84eeSTaylor Simpson#
413e7a84eeSTaylor Simpson# Step 2
423e7a84eeSTaylor Simpson# We use Python scripts to generate the following files
433e7a84eeSTaylor Simpson#     shortcode_generated.h.inc
443e7a84eeSTaylor Simpson#     helper_protos_generated.h.inc
453e7a84eeSTaylor Simpson#     tcg_funcs_generated.c.inc
463e7a84eeSTaylor Simpson#     tcg_func_table_generated.c.inc
473e7a84eeSTaylor Simpson#     helper_funcs_generated.c.inc
483e7a84eeSTaylor Simpson#     printinsn_generated.h.inc
493e7a84eeSTaylor Simpson#     op_regs_generated.h.inc
503e7a84eeSTaylor Simpson#     op_attribs_generated.h.inc
513e7a84eeSTaylor Simpson#     opcodes_def_generated.h.inc
523e7a84eeSTaylor Simpson#
533e7a84eeSTaylor Simpsonshortcode_generated = custom_target(
543e7a84eeSTaylor Simpson    'shortcode_generated.h.inc',
553e7a84eeSTaylor Simpson    output: 'shortcode_generated.h.inc',
563e7a84eeSTaylor Simpson    depends: [semantics_generated],
573e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
582008b34aSPaolo Bonzini    command: [python, files('gen_shortcode.py'), semantics_generated, attribs_def, '@OUTPUT@'],
593e7a84eeSTaylor Simpson)
603e7a84eeSTaylor Simpsonhexagon_ss.add(shortcode_generated)
613e7a84eeSTaylor Simpson
623e7a84eeSTaylor Simpsonhelper_protos_generated = custom_target(
633e7a84eeSTaylor Simpson    'helper_protos_generated.h.inc',
643e7a84eeSTaylor Simpson    output: 'helper_protos_generated.h.inc',
653e7a84eeSTaylor Simpson    depends: [semantics_generated],
663e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
672008b34aSPaolo Bonzini    command: [python, files('gen_helper_protos.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
683e7a84eeSTaylor Simpson)
693e7a84eeSTaylor Simpsonhexagon_ss.add(helper_protos_generated)
703e7a84eeSTaylor Simpson
713e7a84eeSTaylor Simpsontcg_funcs_generated = custom_target(
723e7a84eeSTaylor Simpson    'tcg_funcs_generated.c.inc',
733e7a84eeSTaylor Simpson    output: 'tcg_funcs_generated.c.inc',
743e7a84eeSTaylor Simpson    depends: [semantics_generated],
753e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
762008b34aSPaolo Bonzini    command: [python, files('gen_tcg_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
773e7a84eeSTaylor Simpson)
783e7a84eeSTaylor Simpsonhexagon_ss.add(tcg_funcs_generated)
793e7a84eeSTaylor Simpson
803e7a84eeSTaylor Simpsontcg_func_table_generated = custom_target(
813e7a84eeSTaylor Simpson    'tcg_func_table_generated.c.inc',
823e7a84eeSTaylor Simpson    output: 'tcg_func_table_generated.c.inc',
833e7a84eeSTaylor Simpson    depends: [semantics_generated],
843e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
852008b34aSPaolo Bonzini    command: [python, files('gen_tcg_func_table.py'), semantics_generated, attribs_def, '@OUTPUT@'],
863e7a84eeSTaylor Simpson)
873e7a84eeSTaylor Simpsonhexagon_ss.add(tcg_func_table_generated)
883e7a84eeSTaylor Simpson
893e7a84eeSTaylor Simpsonhelper_funcs_generated = custom_target(
903e7a84eeSTaylor Simpson    'helper_funcs_generated.c.inc',
913e7a84eeSTaylor Simpson    output: 'helper_funcs_generated.c.inc',
923e7a84eeSTaylor Simpson    depends: [semantics_generated],
933e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def, gen_tcg_h],
942008b34aSPaolo Bonzini    command: [python, files('gen_helper_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
953e7a84eeSTaylor Simpson)
963e7a84eeSTaylor Simpsonhexagon_ss.add(helper_funcs_generated)
973e7a84eeSTaylor Simpson
983e7a84eeSTaylor Simpsonprintinsn_generated = custom_target(
993e7a84eeSTaylor Simpson    'printinsn_generated.h.inc',
1003e7a84eeSTaylor Simpson    output: 'printinsn_generated.h.inc',
1013e7a84eeSTaylor Simpson    depends: [semantics_generated],
1023e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
1032008b34aSPaolo Bonzini    command: [python, files('gen_printinsn.py'), semantics_generated, attribs_def, '@OUTPUT@'],
1043e7a84eeSTaylor Simpson)
1053e7a84eeSTaylor Simpsonhexagon_ss.add(printinsn_generated)
1063e7a84eeSTaylor Simpson
1073e7a84eeSTaylor Simpsonop_regs_generated = custom_target(
1083e7a84eeSTaylor Simpson    'op_regs_generated.h.inc',
1093e7a84eeSTaylor Simpson    output: 'op_regs_generated.h.inc',
1103e7a84eeSTaylor Simpson    depends: [semantics_generated],
1113e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
1122008b34aSPaolo Bonzini    command: [python, files('gen_op_regs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
1133e7a84eeSTaylor Simpson)
1143e7a84eeSTaylor Simpsonhexagon_ss.add(op_regs_generated)
1153e7a84eeSTaylor Simpson
1163e7a84eeSTaylor Simpsonop_attribs_generated = custom_target(
1173e7a84eeSTaylor Simpson    'op_attribs_generated.h.inc',
1183e7a84eeSTaylor Simpson    output: 'op_attribs_generated.h.inc',
1193e7a84eeSTaylor Simpson    depends: [semantics_generated],
1203e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
1212008b34aSPaolo Bonzini    command: [python, files('gen_op_attribs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
1223e7a84eeSTaylor Simpson)
1233e7a84eeSTaylor Simpsonhexagon_ss.add(op_attribs_generated)
1243e7a84eeSTaylor Simpson
1253e7a84eeSTaylor Simpsonopcodes_def_generated = custom_target(
1263e7a84eeSTaylor Simpson    'opcodes_def_generated.h.inc',
1273e7a84eeSTaylor Simpson    output: 'opcodes_def_generated.h.inc',
1283e7a84eeSTaylor Simpson    depends: [semantics_generated],
1293e7a84eeSTaylor Simpson    depend_files: [hex_common_py, attribs_def],
1302008b34aSPaolo Bonzini    command: [python, files('gen_opcodes_def.py'), semantics_generated, attribs_def, '@OUTPUT@'],
1313e7a84eeSTaylor Simpson)
1323e7a84eeSTaylor Simpsonhexagon_ss.add(opcodes_def_generated)
1333e7a84eeSTaylor Simpson
1343e7a84eeSTaylor Simpson#
1353e7a84eeSTaylor Simpson# Step 3
1363e7a84eeSTaylor Simpson# We use a C program to create iset.py which is imported into dectree.py
1373e7a84eeSTaylor Simpson# to create the decode tree
1383e7a84eeSTaylor Simpson#
1393e7a84eeSTaylor Simpsongen_dectree_import = executable(
1403e7a84eeSTaylor Simpson    'gen_dectree_import',
1413e7a84eeSTaylor Simpson    'gen_dectree_import.c', opcodes_def_generated, op_regs_generated,
1423e7a84eeSTaylor Simpson    native: true, build_by_default: false)
1433e7a84eeSTaylor Simpson
1443e7a84eeSTaylor Simpsoniset_py = custom_target(
1453e7a84eeSTaylor Simpson    'iset.py',
1463e7a84eeSTaylor Simpson    output: 'iset.py',
147a5158a96SPaolo Bonzini    command: [gen_dectree_import, '@OUTPUT@'],
1483e7a84eeSTaylor Simpson)
1493e7a84eeSTaylor Simpsonhexagon_ss.add(iset_py)
1503e7a84eeSTaylor Simpson
1513e7a84eeSTaylor Simpson#
1523e7a84eeSTaylor Simpson# Step 4
1533e7a84eeSTaylor Simpson# We use the dectree.py script to generate the decode tree header file
1543e7a84eeSTaylor Simpson#
1553e7a84eeSTaylor Simpsondectree_generated = custom_target(
1563e7a84eeSTaylor Simpson    'dectree_generated.h.inc',
1573e7a84eeSTaylor Simpson    output: 'dectree_generated.h.inc',
1583e7a84eeSTaylor Simpson    depends: [iset_py],
1590a11c44eSPaolo Bonzini    env: {'PYTHONPATH': meson.current_build_dir()},
1600a11c44eSPaolo Bonzini    command: [python, files('dectree.py'), '@OUTPUT@'],
1613e7a84eeSTaylor Simpson)
1623e7a84eeSTaylor Simpsonhexagon_ss.add(dectree_generated)
1633e7a84eeSTaylor Simpson
1643e7a84eeSTaylor Simpsonhexagon_ss.add(files(
1653e7a84eeSTaylor Simpson    'cpu.c',
1663e7a84eeSTaylor Simpson    'translate.c',
1673e7a84eeSTaylor Simpson    'op_helper.c',
1683e7a84eeSTaylor Simpson    'gdbstub.c',
1693e7a84eeSTaylor Simpson    'genptr.c',
1703e7a84eeSTaylor Simpson    'reg_fields.c',
1713e7a84eeSTaylor Simpson    'decode.c',
1723e7a84eeSTaylor Simpson    'iclass.c',
1733e7a84eeSTaylor Simpson    'opcodes.c',
1743e7a84eeSTaylor Simpson    'printinsn.c',
1753e7a84eeSTaylor Simpson    'arch.c',
1763e7a84eeSTaylor Simpson    'fma_emu.c',
177*82f8b3dcSTaylor Simpson    'mmvec/system_ext_mmvec.c',
1783e7a84eeSTaylor Simpson))
1793e7a84eeSTaylor Simpson
1803e7a84eeSTaylor Simpsontarget_arch += {'hexagon': hexagon_ss}
181