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 env: {'PYTHONPATH': meson.current_build_dir()}, 160 command: [python, files('dectree.py'), '@OUTPUT@'], 161) 162hexagon_ss.add(dectree_generated) 163 164hexagon_ss.add(files( 165 'cpu.c', 166 'translate.c', 167 'op_helper.c', 168 'gdbstub.c', 169 'genptr.c', 170 'reg_fields.c', 171 'decode.c', 172 'iclass.c', 173 'opcodes.c', 174 'printinsn.c', 175 'arch.c', 176 'fma_emu.c', 177)) 178 179target_arch += {'hexagon': hexagon_ss} 180