xref: /qemu/target/hexagon/gen_tcg_func_table.py (revision a4696661)
1793958c9STaylor Simpson#!/usr/bin/env python3
2793958c9STaylor Simpson
3793958c9STaylor Simpson##
4a4696661STaylor Simpson##  Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
5793958c9STaylor Simpson##
6793958c9STaylor Simpson##  This program is free software; you can redistribute it and/or modify
7793958c9STaylor Simpson##  it under the terms of the GNU General Public License as published by
8793958c9STaylor Simpson##  the Free Software Foundation; either version 2 of the License, or
9793958c9STaylor Simpson##  (at your option) any later version.
10793958c9STaylor Simpson##
11793958c9STaylor Simpson##  This program is distributed in the hope that it will be useful,
12793958c9STaylor Simpson##  but WITHOUT ANY WARRANTY; without even the implied warranty of
13793958c9STaylor Simpson##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14793958c9STaylor Simpson##  GNU General Public License for more details.
15793958c9STaylor Simpson##
16793958c9STaylor Simpson##  You should have received a copy of the GNU General Public License
17793958c9STaylor Simpson##  along with this program; if not, see <http://www.gnu.org/licenses/>.
18793958c9STaylor Simpson##
19793958c9STaylor Simpson
20793958c9STaylor Simpsonimport sys
21793958c9STaylor Simpsonimport re
22793958c9STaylor Simpsonimport string
23793958c9STaylor Simpsonimport hex_common
24793958c9STaylor Simpson
255bb322e2SMarco Liebel
26793958c9STaylor Simpsondef main():
27793958c9STaylor Simpson    hex_common.read_semantics_file(sys.argv[1])
28793958c9STaylor Simpson    hex_common.calculate_attribs()
29793958c9STaylor Simpson    tagregs = hex_common.get_tagregs()
30793958c9STaylor Simpson    tagimms = hex_common.get_tagimms()
31793958c9STaylor Simpson
32a4696661STaylor Simpson    with open(sys.argv[-1], "w") as f:
33793958c9STaylor Simpson        f.write("#ifndef HEXAGON_FUNC_TABLE_H\n")
34793958c9STaylor Simpson        f.write("#define HEXAGON_FUNC_TABLE_H\n\n")
35793958c9STaylor Simpson
36793958c9STaylor Simpson        f.write("const SemanticInsn opcode_genptr[XX_LAST_OPCODE] = {\n")
37793958c9STaylor Simpson        for tag in hex_common.tags:
38793958c9STaylor Simpson            ## Skip the priv instructions
395bb322e2SMarco Liebel            if "A_PRIV" in hex_common.attribdict[tag]:
40793958c9STaylor Simpson                continue
41793958c9STaylor Simpson            ## Skip the guest instructions
425bb322e2SMarco Liebel            if "A_GUEST" in hex_common.attribdict[tag]:
43793958c9STaylor Simpson                continue
44793958c9STaylor Simpson            ## Skip the diag instructions
455bb322e2SMarco Liebel            if tag == "Y6_diag":
46793958c9STaylor Simpson                continue
475bb322e2SMarco Liebel            if tag == "Y6_diag0":
48793958c9STaylor Simpson                continue
495bb322e2SMarco Liebel            if tag == "Y6_diag1":
50793958c9STaylor Simpson                continue
51793958c9STaylor Simpson
52cd6c4edfSMarco Liebel            f.write(f"    [{tag}] = generate_{tag},\n")
53793958c9STaylor Simpson        f.write("};\n\n")
54793958c9STaylor Simpson
55793958c9STaylor Simpson        f.write("#endif    /* HEXAGON_FUNC_TABLE_H */\n")
56793958c9STaylor Simpson
575bb322e2SMarco Liebel
58793958c9STaylor Simpsonif __name__ == "__main__":
59793958c9STaylor Simpson    main()
60