Implement an HMX accumulator clear instruction - mxclracc.
Signed-off-by: Brian Cain <[email protected]>
---
target/hexagon/gen_tcg_hmx.h | 13 +++++++++++++
target/hexagon/helper.h | 2 ++
target/hexagon/genptr.c | 1 +
target/hexagon/op_helper.c | 10 ++++++++++
target/hexagon/translate.c | 3 ++-
target/hexagon/gen_idef_parser_funcs.py | 6 ++++++
target/hexagon/hex_common.py | 2 ++
target/hexagon/meson.build | 17 +++++++++--------
8 files changed, 45 insertions(+), 9 deletions(-)
create mode 100644 target/hexagon/gen_tcg_hmx.h
diff --git a/target/hexagon/gen_tcg_hmx.h b/target/hexagon/gen_tcg_hmx.h
new file mode 100644
index 00000000000..d53d855af51
--- /dev/null
+++ b/target/hexagon/gen_tcg_hmx.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HEXAGON_GEN_TCG_HMX_H
+#define HEXAGON_GEN_TCG_HMX_H
+
+#define fGEN_TCG_M8_mxclracc(SHORTCODE) \
+ gen_helper_mxclracc(tcg_env)
+
+#endif
diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
index 8c49e798093..70453bae61f 100644
--- a/target/hexagon/helper.h
+++ b/target/hexagon/helper.h
@@ -31,6 +31,8 @@ DEF_HELPER_FLAGS_4(vacsh_pred, TCG_CALL_NO_RWG_SE, s32, env,
s64, s64, s64)
DEF_HELPER_FLAGS_2(cabacdecbin_val, TCG_CALL_NO_RWG_SE, s64, s64, s64)
DEF_HELPER_FLAGS_2(cabacdecbin_pred, TCG_CALL_NO_RWG_SE, s32, s64, s64)
+DEF_HELPER_1(mxclracc, void, env)
+
/* Floating point */
DEF_HELPER_3(conv_sf2df, f64, env, f32, i32)
DEF_HELPER_3(conv_df2sf, f32, env, f64, i32)
diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
index 7ef36e336fa..a90e89e36e5 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -32,6 +32,7 @@
#undef QEMU_GENERATE
#include "gen_tcg.h"
#include "gen_tcg_hvx.h"
+#include "gen_tcg_hmx.h"
#ifndef CONFIG_USER_ONLY
#include "gen_tcg_sys.h"
#endif
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index 6076a5f29fd..0cedc6239a3 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -2138,6 +2138,16 @@ void HELPER(pending_interrupt)(CPUHexagonState *env)
#define BOGUS_HELPER(tag) \
printf("ERROR: bogus helper: " #tag "\n")
+void HELPER(mxclracc)(CPUHexagonState *env)
+{
+ HmxState *hmx = env->hmx_state;
+ int i;
+
+ for (i = 0; i < HMX_NUM_ACC_SETS; i++) {
+ memset(&hmx->acc[i].fxp_primary, 0, sizeof(hmx->acc[i].fxp_primary));
+ }
+}
+
#include "helper_funcs_generated.c.inc"
#define DO_ABSDIFF(NAME, TYPE, UTYPE) \
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 4c84feaeeb5..4fcaca69e7b 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -863,7 +863,8 @@ static void gen_start_packet(DisasContext *ctx)
if (ctx->pkt.pkt_has_hmx) {
for (i = 0; i < ctx->pkt.num_insns; i++) {
- if (GET_ATTRIB(ctx->pkt.insn[i].opcode, A_HMX)) {
+ if (GET_ATTRIB(ctx->pkt.insn[i].opcode, A_HMX) &&
+ ctx->pkt.insn[i].opcode != M8_mxclracc) {
qemu_log_mask(LOG_UNIMP, "'%s' is not implemented\n",
opcode_names[ctx->pkt.insn[i].opcode]);
}
diff --git a/target/hexagon/gen_idef_parser_funcs.py
b/target/hexagon/gen_idef_parser_funcs.py
index 9293be4c398..56e085933f9 100644
--- a/target/hexagon/gen_idef_parser_funcs.py
+++ b/target/hexagon/gen_idef_parser_funcs.py
@@ -48,9 +48,11 @@ def main():
"Emit instruction implementations that can be fed to idef-parser"
)
parser.add_argument("semantics", help="semantics file")
+ parser.add_argument("overrides_hmx", help="HMX overrides file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
+ hex_common.read_overrides_file(args.overrides_hmx)
hex_common.calculate_attribs()
hex_common.init_registers()
tagregs = hex_common.get_tagregs()
@@ -114,6 +116,10 @@ def main():
continue
if tag.startswith("V6_"):
continue
+ ## Skip the HMX instructions implemented by an override
+ if ("A_HMX" in hex_common.attribdict[tag] and
+ hex_common.skip_qemu_helper(tag)):
+ continue
if ( tag.startswith("F") and
tag not in {
"F2_sfimm_p",
diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
index 94e70b8657d..60268d183b3 100755
--- a/target/hexagon/hex_common.py
+++ b/target/hexagon/hex_common.py
@@ -1538,6 +1538,7 @@ def parse_common_args(desc):
parser.add_argument("overrides", help="overrides file")
parser.add_argument("overrides_vec", help="vector overrides file")
parser.add_argument("overrides_sys", help="system overrides file")
+ parser.add_argument("overrides_hmx", help="matrix overrides file")
parser.add_argument("out", help="output file")
parser.add_argument("--idef-parser",
help="file of instructions translated by idef-parser")
@@ -1546,6 +1547,7 @@ def parse_common_args(desc):
read_overrides_file(args.overrides)
read_overrides_file(args.overrides_vec)
read_overrides_file(args.overrides_sys)
+ read_overrides_file(args.overrides_hmx)
if args.idef_parser:
read_idef_parser_enabled_file(args.idef_parser)
calculate_attribs()
diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build
index fe3206ef8b8..3bd63845765 100644
--- a/target/hexagon/meson.build
+++ b/target/hexagon/meson.build
@@ -21,6 +21,7 @@ hex_common_py = 'hex_common.py'
gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h'
gen_tcg_hvx_h = meson.current_source_dir() / 'gen_tcg_hvx.h'
gen_tcg_sys_h = meson.current_source_dir() / 'gen_tcg_sys.h'
+gen_tcg_hmx_h = meson.current_source_dir() / 'gen_tcg_hmx.h'
idef_parser_dir = meson.current_source_dir() / 'idef-parser'
#
@@ -281,8 +282,8 @@ if idef_parser_enabled and ('hexagon-linux-user' in
target_dirs or
'idef_parser_input.h.inc',
output: 'idef_parser_input.h.inc',
depends: [semantics_generated],
- depend_files: [hex_common_py],
- command: [python, files('gen_idef_parser_funcs.py'),
semantics_generated, '@OUTPUT@'],
+ depend_files: [hex_common_py, gen_tcg_hmx_h],
+ command: [python, files('gen_idef_parser_funcs.py'),
semantics_generated, gen_tcg_hmx_h, '@OUTPUT@'],
)
compiler = meson.get_compiler('c').cmd_array()
@@ -352,12 +353,12 @@ if idef_parser_enabled and ('hexagon-linux-user' in
target_dirs or
# Setup input and dependencies for the next step, this depends on whether
or
# not idef-parser is enabled
helper_dep = [semantics_generated, idef_generated_tcg_c,
idef_generated_tcg]
- helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
'--idef-parser', idef_generated_list]
+ helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h, '--idef-parser', idef_generated_list]
else
# Setup input and dependencies for the next step, this depends on whether
or
# not idef-parser is enabled
helper_dep = [semantics_generated]
- helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h]
+ helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h]
endif
#
@@ -371,7 +372,7 @@ helper_protos_generated = custom_target(
'helper_protos_generated.h.inc',
output: 'helper_protos_generated.h.inc',
depends: helper_dep,
- depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h],
+ depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h],
command: [python, files('gen_helper_protos.py'), helper_in, '@OUTPUT@'],
)
hexagon_ss.add(helper_protos_generated)
@@ -380,7 +381,7 @@ helper_funcs_generated = custom_target(
'helper_funcs_generated.c.inc',
output: 'helper_funcs_generated.c.inc',
depends: helper_dep,
- depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h],
+ depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h],
command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'],
)
hexagon_ss.add(helper_funcs_generated)
@@ -389,7 +390,7 @@ tcg_funcs_generated = custom_target(
'tcg_funcs_generated.c.inc',
output: 'tcg_funcs_generated.c.inc',
depends: helper_dep,
- depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h],
+ depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h],
command: [python, files('gen_tcg_funcs.py'), helper_in, '@OUTPUT@'],
)
hexagon_ss.add(tcg_funcs_generated)
@@ -398,7 +399,7 @@ analyze_funcs_generated = custom_target(
'analyze_funcs_generated.c.inc',
output: 'analyze_funcs_generated.c.inc',
depends: helper_dep,
- depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h],
+ depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h,
gen_tcg_hmx_h],
command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'],
)
hexagon_ss.add(analyze_funcs_generated)
--
2.34.1