4 ## Copyright(c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
27 ## Generate the code to analyze the instruction
28 ## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;}
30 ## static void analyze_A2_add(DisasContext *ctx)
32 ## Insn *insn G_GNUC_UNUSED = ctx->insn;
33 ## const int RdN = insn->regno[0];
34 ## ctx_log_reg_write(ctx, RdN, false);
35 ## const int RsN = insn->regno[1];
36 ## ctx_log_reg_read(ctx, RsN);
37 ## const int RtN = insn->regno[2];
38 ## ctx_log_reg_read(ctx, RtN);
41 def gen_analyze_func(f
, tag
, regs
, imms
):
42 f
.write(f
"static void analyze_{tag}(DisasContext *ctx)\n")
45 f
.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n")
46 if (hex_common
.is_hvx_insn(tag
)):
47 if hex_common
.has_hvx_helper(tag
):
49 " const bool G_GNUC_UNUSED insn_has_hvx_helper = true;\n"
51 f
.write(" ctx_start_hvx_insn(ctx);\n")
54 " const bool G_GNUC_UNUSED insn_has_hvx_helper = false;\n"
57 ## Declare all the registers
58 for regno
, register
in enumerate(regs
):
59 reg_type
, reg_id
= register
60 reg
= hex_common
.get_register(tag
, reg_type
, reg_id
)
61 reg
.decl_reg_num(f
, regno
)
63 ## Analyze the register reads
64 for regno
, register
in enumerate(regs
):
65 reg_type
, reg_id
= register
66 reg
= hex_common
.get_register(tag
, reg_type
, reg_id
)
68 reg
.analyze_read(f
, regno
)
70 ## Analyze the register writes
71 for regno
, register
in enumerate(regs
):
72 reg_type
, reg_id
= register
73 reg
= hex_common
.get_register(tag
, reg_type
, reg_id
)
75 reg
.analyze_write(f
, tag
, regno
)
81 hex_common
.read_common_files()
82 tagregs
= hex_common
.get_tagregs()
83 tagimms
= hex_common
.get_tagimms()
85 with
open(sys
.argv
[-1], "w") as f
:
86 f
.write("#ifndef HEXAGON_ANALYZE_FUNCS_C_INC\n")
87 f
.write("#define HEXAGON_ANALYZE_FUNCS_C_INC\n\n")
89 for tag
in hex_common
.tags
:
90 gen_analyze_func(f
, tag
, tagregs
[tag
], tagimms
[tag
])
92 f
.write("#endif /* HEXAGON_ANALYZE_FUNCS_C_INC */\n")
95 if __name__
== "__main__":