* [PATCH v3 0/3] Hexagon (target/hexagon) Only pass env to generated helper when needed
@ 2024-02-14 4:27 Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it Taylor Simpson
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Taylor Simpson @ 2024-02-14 4:27 UTC (permalink / raw)
To: qemu-devel
Cc: bcain, quic_mathbern, sidneym, quic_mliebel, richard.henderson,
philmd, ale, anjo, ltaylorsimpson
Currently, we pass env to every generated helper. When the semantics of
the instruction only depend on the arguments, this is unnecessary and
adds extra overhead to the helper call.
**** Changes in v3 ****
Update copyright year to 2024
Mark Reviewed-by/Tested-by: Anton Johansson <anjo@rev.ng>
**** Changes in v2 ****
- Separate patches to pass P0 and SP explicitly to helpers that need it
- Add the TCG_CALL_NO_RWG_SE flag to any non-HVX helpers that
don't get ptr to env
Taylor Simpson (3):
Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it
Hexagon (target/hexagon) Pass SP explicitly to helpers that need it
Hexagon (target/hexagon) Only pass env to generated helper when needed
target/hexagon/gen_tcg.h | 5 +++-
target/hexagon/macros.h | 6 ++--
target/hexagon/attribs_def.h.inc | 3 +-
target/hexagon/gen_helper_protos.py | 12 ++++++--
target/hexagon/hex_common.py | 46 +++++++++++++++++++++++++----
5 files changed, 59 insertions(+), 13 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it
2024-02-14 4:27 [PATCH v3 0/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
@ 2024-02-14 4:27 ` Taylor Simpson
2024-02-16 17:21 ` Brian Cain
2024-02-14 4:27 ` [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP " Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 3/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
2 siblings, 1 reply; 7+ messages in thread
From: Taylor Simpson @ 2024-02-14 4:27 UTC (permalink / raw)
To: qemu-devel
Cc: bcain, quic_mathbern, sidneym, quic_mliebel, richard.henderson,
philmd, ale, anjo, ltaylorsimpson
Rather than reading P0 from the env, pass it explicitly
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Tested-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/macros.h | 4 ++--
target/hexagon/hex_common.py | 12 +++++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
index 1376d6ccc1..aedc863fab 100644
--- a/target/hexagon/macros.h
+++ b/target/hexagon/macros.h
@@ -1,5 +1,5 @@
/*
- * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -358,7 +358,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)
#endif
#define fREAD_PC() (PC)
-#define fREAD_P0() (env->pred[0])
+#define fREAD_P0() (P0)
#define fCHECK_PCALIGN(A)
diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
index 195620c7ec..14dcf261b4 100755
--- a/target/hexagon/hex_common.py
+++ b/target/hexagon/hex_common.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
##
-## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+## Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -197,6 +197,10 @@ def get_tagimms():
return dict(zip(tags, list(map(compute_tag_immediates, tags))))
+def need_p0(tag):
+ return "A_IMPLICIT_READS_P0" in attribdict[tag]
+
+
def need_slot(tag):
if (
"A_CVI_SCATTER" not in attribdict[tag]
@@ -1118,6 +1122,12 @@ def helper_args(tag, regs, imms):
"tcg_constant_tl(ctx->next_PC)",
"target_ulong next_PC"
))
+ if need_p0(tag):
+ args.append(HelperArg(
+ "i32",
+ "hex_pred[0]",
+ "uint32_t P0"
+ ))
if need_slot(tag):
args.append(HelperArg(
"i32",
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP explicitly to helpers that need it
2024-02-14 4:27 [PATCH v3 0/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it Taylor Simpson
@ 2024-02-14 4:27 ` Taylor Simpson
2024-02-16 17:22 ` Brian Cain
2024-02-16 17:22 ` Brian Cain
2024-02-14 4:27 ` [PATCH v3 3/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
2 siblings, 2 replies; 7+ messages in thread
From: Taylor Simpson @ 2024-02-14 4:27 UTC (permalink / raw)
To: qemu-devel
Cc: bcain, quic_mathbern, sidneym, quic_mliebel, richard.henderson,
philmd, ale, anjo, ltaylorsimpson
Rather than reading SP from the env, pass it explicitly
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Tested-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/macros.h | 2 +-
target/hexagon/attribs_def.h.inc | 3 ++-
target/hexagon/hex_common.py | 11 +++++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
index aedc863fab..feb798c6c0 100644
--- a/target/hexagon/macros.h
+++ b/target/hexagon/macros.h
@@ -343,7 +343,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)
#define fREAD_LR() (env->gpr[HEX_REG_LR])
-#define fREAD_SP() (env->gpr[HEX_REG_SP])
+#define fREAD_SP() (SP)
#define fREAD_LC0 (env->gpr[HEX_REG_LC0])
#define fREAD_LC1 (env->gpr[HEX_REG_LC1])
#define fREAD_SA0 (env->gpr[HEX_REG_SA0])
diff --git a/target/hexagon/attribs_def.h.inc b/target/hexagon/attribs_def.h.inc
index 87942d46f4..9e3a05f882 100644
--- a/target/hexagon/attribs_def.h.inc
+++ b/target/hexagon/attribs_def.h.inc
@@ -1,5 +1,5 @@
/*
- * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -117,6 +117,7 @@ DEF_ATTRIB(IMPLICIT_READS_P1, "Reads the P1 register", "", "")
DEF_ATTRIB(IMPLICIT_READS_P2, "Reads the P2 register", "", "")
DEF_ATTRIB(IMPLICIT_READS_P3, "Reads the P3 register", "", "")
DEF_ATTRIB(IMPLICIT_WRITES_USR, "May write USR", "", "")
+DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the SP register", "", "")
DEF_ATTRIB(COMMUTES, "The operation is communitive", "", "")
DEF_ATTRIB(DEALLOCRET, "dealloc_return", "", "")
DEF_ATTRIB(DEALLOCFRAME, "deallocframe", "", "")
diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
index 14dcf261b4..b96f67972d 100755
--- a/target/hexagon/hex_common.py
+++ b/target/hexagon/hex_common.py
@@ -101,6 +101,7 @@ def calculate_attribs():
add_qemu_macro_attrib('fLSBNEW1', 'A_IMPLICIT_READS_P1')
add_qemu_macro_attrib('fLSBNEW1NOT', 'A_IMPLICIT_READS_P1')
add_qemu_macro_attrib('fREAD_P3', 'A_IMPLICIT_READS_P3')
+ add_qemu_macro_attrib('fREAD_SP', 'A_IMPLICIT_READS_SP')
# Recurse down macros, find attributes from sub-macros
macroValues = list(macros.values())
@@ -201,6 +202,10 @@ def need_p0(tag):
return "A_IMPLICIT_READS_P0" in attribdict[tag]
+def need_sp(tag):
+ return "A_IMPLICIT_READS_SP" in attribdict[tag]
+
+
def need_slot(tag):
if (
"A_CVI_SCATTER" not in attribdict[tag]
@@ -1128,6 +1133,12 @@ def helper_args(tag, regs, imms):
"hex_pred[0]",
"uint32_t P0"
))
+ if need_sp(tag):
+ args.append(HelperArg(
+ "i32",
+ "hex_gpr[HEX_REG_SP]",
+ "uint32_t SP"
+ ))
if need_slot(tag):
args.append(HelperArg(
"i32",
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] Hexagon (target/hexagon) Only pass env to generated helper when needed
2024-02-14 4:27 [PATCH v3 0/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP " Taylor Simpson
@ 2024-02-14 4:27 ` Taylor Simpson
2 siblings, 0 replies; 7+ messages in thread
From: Taylor Simpson @ 2024-02-14 4:27 UTC (permalink / raw)
To: qemu-devel
Cc: bcain, quic_mathbern, sidneym, quic_mliebel, richard.henderson,
philmd, ale, anjo, ltaylorsimpson
Currently, we pass env to every generated helper. When the semantics of
the instruction only depend on the arguments, this is unnecessary and
adds extra overhead to the helper call.
We add the TCG_CALL_NO_RWG_SE flag to any non-HVX helpers that don't get
the ptr to env.
The A2_nop and SA1_setin1 instructions end up with no arguments. This
results in a "old-style function definition" error from the compiler, so
we write overrides for them.
With this change, the number of helpers with env argument is
idef-parser enabled: 329 total, 23 with env
idef-parser disabled: 1543 total, 550 with env
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Tested-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/gen_tcg.h | 5 ++++-
target/hexagon/gen_helper_protos.py | 12 ++++++++++--
target/hexagon/hex_common.py | 23 ++++++++++++++++++-----
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index 1c4391b415..3fc1f4e281 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -1,5 +1,5 @@
/*
- * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1369,3 +1369,6 @@
gen_helper_raise_exception(tcg_env, excp); \
} while (0)
#endif
+
+#define fGEN_TCG_A2_nop(SHORTCODE) do { } while (0)
+#define fGEN_TCG_SA1_setin1(SHORTCODE) tcg_gen_movi_tl(RdV, -1)
diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helper_protos.py
index c82b0f54e4..f8578d5033 100755
--- a/target/hexagon/gen_helper_protos.py
+++ b/target/hexagon/gen_helper_protos.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
##
-## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+## Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -40,7 +40,15 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
declared.append(arg.proto_arg)
arguments = ", ".join(declared)
- f.write(f"DEF_HELPER_{len(declared) - 1}({tag}, {arguments})\n")
+
+ ## Add the TCG_CALL_NO_RWG_SE flag to helpers that don't take the env
+ ## argument and aren't HVX instructions. Since HVX instructions take
+ ## pointers to their arguments, they will have side effects.
+ if hex_common.need_env(tag) or hex_common.is_hvx_insn(tag):
+ f.write(f"DEF_HELPER_{len(declared) - 1}({tag}, {arguments})\n")
+ else:
+ f.write(f"DEF_HELPER_FLAGS_{len(declared) - 1}({tag}, "
+ f"TCG_CALL_NO_RWG_SE, {arguments})\n")
def main():
diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
index b96f67972d..d3d8560fcf 100755
--- a/target/hexagon/hex_common.py
+++ b/target/hexagon/hex_common.py
@@ -206,6 +206,18 @@ def need_sp(tag):
return "A_IMPLICIT_READS_SP" in attribdict[tag]
+def is_hvx_insn(tag):
+ return "A_CVI" in attribdict[tag]
+
+
+def need_env(tag):
+ return ("A_STORE" in attribdict[tag] or
+ "A_LOAD" in attribdict[tag] or
+ "A_CVI_GATHER" in attribdict[tag] or
+ "A_CVI_SCATTER" in attribdict[tag] or
+ "A_IMPLICIT_WRITES_USR" in attribdict[tag])
+
+
def need_slot(tag):
if (
"A_CVI_SCATTER" not in attribdict[tag]
@@ -1069,11 +1081,12 @@ def helper_args(tag, regs, imms):
args = []
## First argument is the CPU state
- args.append(HelperArg(
- "env",
- "tcg_env",
- "CPUHexagonState *env"
- ))
+ if need_env(tag):
+ args.append(HelperArg(
+ "env",
+ "tcg_env",
+ "CPUHexagonState *env"
+ ))
## For predicated instructions, we pass in the destination register
if is_predicated(tag):
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it
2024-02-14 4:27 ` [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it Taylor Simpson
@ 2024-02-16 17:21 ` Brian Cain
0 siblings, 0 replies; 7+ messages in thread
From: Brian Cain @ 2024-02-16 17:21 UTC (permalink / raw)
To: Taylor Simpson, qemu-devel@nongnu.org
Cc: Matheus Bernardino (QUIC), Sid Manning, Marco Liebel (QUIC),
richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng,
anjo@rev.ng
> -----Original Message-----
> From: Taylor Simpson <ltaylorsimpson@gmail.com>
> Sent: Tuesday, February 13, 2024 10:27 PM
> To: qemu-devel@nongnu.org
> Cc: Brian Cain <bcain@quicinc.com>; Matheus Bernardino (QUIC)
> <quic_mathbern@quicinc.com>; Sid Manning <sidneym@quicinc.com>; Marco
> Liebel (QUIC) <quic_mliebel@quicinc.com>; richard.henderson@linaro.org;
> philmd@linaro.org; ale@rev.ng; anjo@rev.ng; ltaylorsimpson@gmail.com
> Subject: [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers
> that need it
>
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
>
> Rather than reading P0 from the env, pass it explicitly
>
> Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> Reviewed-by: Anton Johansson <anjo@rev.ng>
> Tested-by: Anton Johansson <anjo@rev.ng>
> ---
Reviewed-by: Brian Cain <bcain@quicinc.com>
> target/hexagon/macros.h | 4 ++--
> target/hexagon/hex_common.py | 12 +++++++++++-
> 2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
> index 1376d6ccc1..aedc863fab 100644
> --- a/target/hexagon/macros.h
> +++ b/target/hexagon/macros.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> + * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -358,7 +358,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,
> int shift)
> #endif
> #define fREAD_PC() (PC)
>
> -#define fREAD_P0() (env->pred[0])
> +#define fREAD_P0() (P0)
>
> #define fCHECK_PCALIGN(A)
>
> diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
> index 195620c7ec..14dcf261b4 100755
> --- a/target/hexagon/hex_common.py
> +++ b/target/hexagon/hex_common.py
> @@ -1,7 +1,7 @@
> #!/usr/bin/env python3
>
> ##
> -## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> +## Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> ##
> ## This program is free software; you can redistribute it and/or modify
> ## it under the terms of the GNU General Public License as published by
> @@ -197,6 +197,10 @@ def get_tagimms():
> return dict(zip(tags, list(map(compute_tag_immediates, tags))))
>
>
> +def need_p0(tag):
> + return "A_IMPLICIT_READS_P0" in attribdict[tag]
> +
> +
> def need_slot(tag):
> if (
> "A_CVI_SCATTER" not in attribdict[tag]
> @@ -1118,6 +1122,12 @@ def helper_args(tag, regs, imms):
> "tcg_constant_tl(ctx->next_PC)",
> "target_ulong next_PC"
> ))
> + if need_p0(tag):
> + args.append(HelperArg(
> + "i32",
> + "hex_pred[0]",
> + "uint32_t P0"
> + ))
> if need_slot(tag):
> args.append(HelperArg(
> "i32",
> --
> 2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP explicitly to helpers that need it
2024-02-14 4:27 ` [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP " Taylor Simpson
@ 2024-02-16 17:22 ` Brian Cain
2024-02-16 17:22 ` Brian Cain
1 sibling, 0 replies; 7+ messages in thread
From: Brian Cain @ 2024-02-16 17:22 UTC (permalink / raw)
To: Taylor Simpson, qemu-devel@nongnu.org
Cc: Matheus Bernardino (QUIC), Sid Manning, Marco Liebel (QUIC),
richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng,
anjo@rev.ng
> -----Original Message-----
> From: Taylor Simpson <ltaylorsimpson@gmail.com>
> Sent: Tuesday, February 13, 2024 10:27 PM
> To: qemu-devel@nongnu.org
> Cc: Brian Cain <bcain@quicinc.com>; Matheus Bernardino (QUIC)
> <quic_mathbern@quicinc.com>; Sid Manning <sidneym@quicinc.com>; Marco
> Liebel (QUIC) <quic_mliebel@quicinc.com>; richard.henderson@linaro.org;
> philmd@linaro.org; ale@rev.ng; anjo@rev.ng; ltaylorsimpson@gmail.com
> Subject: [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP explicitly to helpers
> that need it
>
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
>
> Rather than reading SP from the env, pass it explicitly
>
> Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> Reviewed-by: Anton Johansson <anjo@rev.ng>
> Tested-by: Anton Johansson <anjo@rev.ng>
> ---
Reviewed-by: Brian Cain <bcain@quicinc.com>
> target/hexagon/macros.h | 2 +-
> target/hexagon/attribs_def.h.inc | 3 ++-
> target/hexagon/hex_common.py | 11 +++++++++++
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
> index aedc863fab..feb798c6c0 100644
> --- a/target/hexagon/macros.h
> +++ b/target/hexagon/macros.h
> @@ -343,7 +343,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,
> int shift)
>
> #define fREAD_LR() (env->gpr[HEX_REG_LR])
>
> -#define fREAD_SP() (env->gpr[HEX_REG_SP])
> +#define fREAD_SP() (SP)
> #define fREAD_LC0 (env->gpr[HEX_REG_LC0])
> #define fREAD_LC1 (env->gpr[HEX_REG_LC1])
> #define fREAD_SA0 (env->gpr[HEX_REG_SA0])
> diff --git a/target/hexagon/attribs_def.h.inc b/target/hexagon/attribs_def.h.inc
> index 87942d46f4..9e3a05f882 100644
> --- a/target/hexagon/attribs_def.h.inc
> +++ b/target/hexagon/attribs_def.h.inc
> @@ -1,5 +1,5 @@
> /*
> - * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> + * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -117,6 +117,7 @@ DEF_ATTRIB(IMPLICIT_READS_P1, "Reads the P1
> register", "", "")
> DEF_ATTRIB(IMPLICIT_READS_P2, "Reads the P2 register", "", "")
> DEF_ATTRIB(IMPLICIT_READS_P3, "Reads the P3 register", "", "")
> DEF_ATTRIB(IMPLICIT_WRITES_USR, "May write USR", "", "")
> +DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the SP register", "", "")
> DEF_ATTRIB(COMMUTES, "The operation is communitive", "", "")
> DEF_ATTRIB(DEALLOCRET, "dealloc_return", "", "")
> DEF_ATTRIB(DEALLOCFRAME, "deallocframe", "", "")
> diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
> index 14dcf261b4..b96f67972d 100755
> --- a/target/hexagon/hex_common.py
> +++ b/target/hexagon/hex_common.py
> @@ -101,6 +101,7 @@ def calculate_attribs():
> add_qemu_macro_attrib('fLSBNEW1', 'A_IMPLICIT_READS_P1')
> add_qemu_macro_attrib('fLSBNEW1NOT', 'A_IMPLICIT_READS_P1')
> add_qemu_macro_attrib('fREAD_P3', 'A_IMPLICIT_READS_P3')
> + add_qemu_macro_attrib('fREAD_SP', 'A_IMPLICIT_READS_SP')
>
> # Recurse down macros, find attributes from sub-macros
> macroValues = list(macros.values())
> @@ -201,6 +202,10 @@ def need_p0(tag):
> return "A_IMPLICIT_READS_P0" in attribdict[tag]
>
>
> +def need_sp(tag):
> + return "A_IMPLICIT_READS_SP" in attribdict[tag]
> +
> +
> def need_slot(tag):
> if (
> "A_CVI_SCATTER" not in attribdict[tag]
> @@ -1128,6 +1133,12 @@ def helper_args(tag, regs, imms):
> "hex_pred[0]",
> "uint32_t P0"
> ))
> + if need_sp(tag):
> + args.append(HelperArg(
> + "i32",
> + "hex_gpr[HEX_REG_SP]",
> + "uint32_t SP"
> + ))
> if need_slot(tag):
> args.append(HelperArg(
> "i32",
> --
> 2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP explicitly to helpers that need it
2024-02-14 4:27 ` [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP " Taylor Simpson
2024-02-16 17:22 ` Brian Cain
@ 2024-02-16 17:22 ` Brian Cain
1 sibling, 0 replies; 7+ messages in thread
From: Brian Cain @ 2024-02-16 17:22 UTC (permalink / raw)
To: Taylor Simpson, qemu-devel@nongnu.org
Cc: Matheus Bernardino (QUIC), Sid Manning, Marco Liebel (QUIC),
richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng,
anjo@rev.ng
> -----Original Message-----
> From: Taylor Simpson <ltaylorsimpson@gmail.com>
> Sent: Tuesday, February 13, 2024 10:27 PM
> To: qemu-devel@nongnu.org
> Cc: Brian Cain <bcain@quicinc.com>; Matheus Bernardino (QUIC)
> <quic_mathbern@quicinc.com>; Sid Manning <sidneym@quicinc.com>; Marco
> Liebel (QUIC) <quic_mliebel@quicinc.com>; richard.henderson@linaro.org;
> philmd@linaro.org; ale@rev.ng; anjo@rev.ng; ltaylorsimpson@gmail.com
> Subject: [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP explicitly to helpers
> that need it
>
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
>
> Rather than reading SP from the env, pass it explicitly
>
> Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> Reviewed-by: Anton Johansson <anjo@rev.ng>
> Tested-by: Anton Johansson <anjo@rev.ng>
> ---
Reviewed-by: Brian Cain <bcain@quicinc.com>
> target/hexagon/macros.h | 2 +-
> target/hexagon/attribs_def.h.inc | 3 ++-
> target/hexagon/hex_common.py | 11 +++++++++++
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
> index aedc863fab..feb798c6c0 100644
> --- a/target/hexagon/macros.h
> +++ b/target/hexagon/macros.h
> @@ -343,7 +343,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,
> int shift)
>
> #define fREAD_LR() (env->gpr[HEX_REG_LR])
>
> -#define fREAD_SP() (env->gpr[HEX_REG_SP])
> +#define fREAD_SP() (SP)
> #define fREAD_LC0 (env->gpr[HEX_REG_LC0])
> #define fREAD_LC1 (env->gpr[HEX_REG_LC1])
> #define fREAD_SA0 (env->gpr[HEX_REG_SA0])
> diff --git a/target/hexagon/attribs_def.h.inc b/target/hexagon/attribs_def.h.inc
> index 87942d46f4..9e3a05f882 100644
> --- a/target/hexagon/attribs_def.h.inc
> +++ b/target/hexagon/attribs_def.h.inc
> @@ -1,5 +1,5 @@
> /*
> - * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> + * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights
> Reserved.
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -117,6 +117,7 @@ DEF_ATTRIB(IMPLICIT_READS_P1, "Reads the P1
> register", "", "")
> DEF_ATTRIB(IMPLICIT_READS_P2, "Reads the P2 register", "", "")
> DEF_ATTRIB(IMPLICIT_READS_P3, "Reads the P3 register", "", "")
> DEF_ATTRIB(IMPLICIT_WRITES_USR, "May write USR", "", "")
> +DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the SP register", "", "")
> DEF_ATTRIB(COMMUTES, "The operation is communitive", "", "")
> DEF_ATTRIB(DEALLOCRET, "dealloc_return", "", "")
> DEF_ATTRIB(DEALLOCFRAME, "deallocframe", "", "")
> diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
> index 14dcf261b4..b96f67972d 100755
> --- a/target/hexagon/hex_common.py
> +++ b/target/hexagon/hex_common.py
> @@ -101,6 +101,7 @@ def calculate_attribs():
> add_qemu_macro_attrib('fLSBNEW1', 'A_IMPLICIT_READS_P1')
> add_qemu_macro_attrib('fLSBNEW1NOT', 'A_IMPLICIT_READS_P1')
> add_qemu_macro_attrib('fREAD_P3', 'A_IMPLICIT_READS_P3')
> + add_qemu_macro_attrib('fREAD_SP', 'A_IMPLICIT_READS_SP')
>
> # Recurse down macros, find attributes from sub-macros
> macroValues = list(macros.values())
> @@ -201,6 +202,10 @@ def need_p0(tag):
> return "A_IMPLICIT_READS_P0" in attribdict[tag]
>
>
> +def need_sp(tag):
> + return "A_IMPLICIT_READS_SP" in attribdict[tag]
> +
> +
> def need_slot(tag):
> if (
> "A_CVI_SCATTER" not in attribdict[tag]
> @@ -1128,6 +1133,12 @@ def helper_args(tag, regs, imms):
> "hex_pred[0]",
> "uint32_t P0"
> ))
> + if need_sp(tag):
> + args.append(HelperArg(
> + "i32",
> + "hex_gpr[HEX_REG_SP]",
> + "uint32_t SP"
> + ))
> if need_slot(tag):
> args.append(HelperArg(
> "i32",
> --
> 2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-02-16 17:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-14 4:27 [PATCH v3 0/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
2024-02-14 4:27 ` [PATCH v3 1/3] Hexagon (target/hexagon) Pass P0 explicitly to helpers that need it Taylor Simpson
2024-02-16 17:21 ` Brian Cain
2024-02-14 4:27 ` [PATCH v3 2/3] Hexagon (target/hexagon) Pass SP " Taylor Simpson
2024-02-16 17:22 ` Brian Cain
2024-02-16 17:22 ` Brian Cain
2024-02-14 4:27 ` [PATCH v3 3/3] Hexagon (target/hexagon) Only pass env to generated helper when needed Taylor Simpson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).