meson.build (6041B)
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 18 hexagon_ss = ss.source_set() 19 20 hex_common_py = 'hex_common.py' 21 attribs_def = meson.current_source_dir() / 'attribs_def.h.inc' 22 gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h' 23 gen_tcg_hvx_h = meson.current_source_dir() / 'gen_tcg_hvx.h' 24 25 # 26 # Step 1 27 # We use a C program to create semantics_generated.pyinc 28 # 29 gen_semantics = executable( 30 'gen_semantics', 31 'gen_semantics.c', 32 native: true, build_by_default: false) 33 34 semantics_generated = custom_target( 35 'semantics_generated.pyinc', 36 output: 'semantics_generated.pyinc', 37 command: [gen_semantics, '@OUTPUT@'], 38 ) 39 hexagon_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 # 54 shortcode_generated = custom_target( 55 'shortcode_generated.h.inc', 56 output: 'shortcode_generated.h.inc', 57 depends: [semantics_generated], 58 depend_files: [hex_common_py, attribs_def], 59 command: [python, files('gen_shortcode.py'), semantics_generated, attribs_def, '@OUTPUT@'], 60 ) 61 hexagon_ss.add(shortcode_generated) 62 63 helper_protos_generated = custom_target( 64 'helper_protos_generated.h.inc', 65 output: 'helper_protos_generated.h.inc', 66 depends: [semantics_generated], 67 depend_files: [hex_common_py, attribs_def, gen_tcg_h, gen_tcg_hvx_h], 68 command: [python, files('gen_helper_protos.py'), semantics_generated, attribs_def, gen_tcg_h, gen_tcg_hvx_h, '@OUTPUT@'], 69 ) 70 hexagon_ss.add(helper_protos_generated) 71 72 tcg_funcs_generated = custom_target( 73 'tcg_funcs_generated.c.inc', 74 output: 'tcg_funcs_generated.c.inc', 75 depends: [semantics_generated], 76 depend_files: [hex_common_py, attribs_def, gen_tcg_h, gen_tcg_hvx_h], 77 command: [python, files('gen_tcg_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, gen_tcg_hvx_h, '@OUTPUT@'], 78 ) 79 hexagon_ss.add(tcg_funcs_generated) 80 81 tcg_func_table_generated = custom_target( 82 'tcg_func_table_generated.c.inc', 83 output: 'tcg_func_table_generated.c.inc', 84 depends: [semantics_generated], 85 depend_files: [hex_common_py, attribs_def], 86 command: [python, files('gen_tcg_func_table.py'), semantics_generated, attribs_def, '@OUTPUT@'], 87 ) 88 hexagon_ss.add(tcg_func_table_generated) 89 90 helper_funcs_generated = custom_target( 91 'helper_funcs_generated.c.inc', 92 output: 'helper_funcs_generated.c.inc', 93 depends: [semantics_generated], 94 depend_files: [hex_common_py, attribs_def, gen_tcg_h, gen_tcg_hvx_h], 95 command: [python, files('gen_helper_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, gen_tcg_hvx_h, '@OUTPUT@'], 96 ) 97 hexagon_ss.add(helper_funcs_generated) 98 99 printinsn_generated = custom_target( 100 'printinsn_generated.h.inc', 101 output: 'printinsn_generated.h.inc', 102 depends: [semantics_generated], 103 depend_files: [hex_common_py, attribs_def], 104 command: [python, files('gen_printinsn.py'), semantics_generated, attribs_def, '@OUTPUT@'], 105 ) 106 hexagon_ss.add(printinsn_generated) 107 108 op_regs_generated = custom_target( 109 'op_regs_generated.h.inc', 110 output: 'op_regs_generated.h.inc', 111 depends: [semantics_generated], 112 depend_files: [hex_common_py, attribs_def], 113 command: [python, files('gen_op_regs.py'), semantics_generated, attribs_def, '@OUTPUT@'], 114 ) 115 hexagon_ss.add(op_regs_generated) 116 117 op_attribs_generated = custom_target( 118 'op_attribs_generated.h.inc', 119 output: 'op_attribs_generated.h.inc', 120 depends: [semantics_generated], 121 depend_files: [hex_common_py, attribs_def], 122 command: [python, files('gen_op_attribs.py'), semantics_generated, attribs_def, '@OUTPUT@'], 123 ) 124 hexagon_ss.add(op_attribs_generated) 125 126 opcodes_def_generated = custom_target( 127 'opcodes_def_generated.h.inc', 128 output: 'opcodes_def_generated.h.inc', 129 depends: [semantics_generated], 130 depend_files: [hex_common_py, attribs_def], 131 command: [python, files('gen_opcodes_def.py'), semantics_generated, attribs_def, '@OUTPUT@'], 132 ) 133 hexagon_ss.add(opcodes_def_generated) 134 135 # 136 # Step 3 137 # We use a C program to create iset.py which is imported into dectree.py 138 # to create the decode tree 139 # 140 gen_dectree_import = executable( 141 'gen_dectree_import', 142 'gen_dectree_import.c', opcodes_def_generated, op_regs_generated, 143 native: true, build_by_default: false) 144 145 iset_py = custom_target( 146 'iset.py', 147 output: 'iset.py', 148 command: [gen_dectree_import, '@OUTPUT@'], 149 ) 150 hexagon_ss.add(iset_py) 151 152 # 153 # Step 4 154 # We use the dectree.py script to generate the decode tree header file 155 # 156 dectree_generated = custom_target( 157 'dectree_generated.h.inc', 158 output: 'dectree_generated.h.inc', 159 depends: [iset_py], 160 env: {'PYTHONPATH': meson.current_build_dir()}, 161 command: [python, files('dectree.py'), '@OUTPUT@'], 162 ) 163 hexagon_ss.add(dectree_generated) 164 165 hexagon_ss.add(files( 166 'cpu.c', 167 'translate.c', 168 'op_helper.c', 169 'gdbstub.c', 170 'genptr.c', 171 'reg_fields.c', 172 'decode.c', 173 'iclass.c', 174 'opcodes.c', 175 'printinsn.c', 176 'arch.c', 177 'fma_emu.c', 178 'mmvec/decode_ext_mmvec.c', 179 'mmvec/system_ext_mmvec.c', 180 )) 181 182 target_arch += {'hexagon': hexagon_ss}