On Wed, Oct 21, 2026 at 5:44 PM Brian Cain <[email protected]> wrote:
>
> Add decode and translation for trap2 and the vallocframe and vdeallocframe
> instruction forms introduced with v83. Model vector stack overflow as a
> precise exception and report it to linux-user as SIGSEGV.
>
> Teach the IDEF parser about VSP and vector frame checks. Describe the
> vallocframe and vdeallocframe instruction semantics in system.idef, and move
> the vector stack overflow check into a shared TCG generator helper.
>
> Reviewed-by: Pierrick Bouvier <[email protected]>
> Signed-off-by: Brian Cain <[email protected]>
> ---
> target/hexagon/cpu_bits.h | 2 +
> target/hexagon/gen_tcg.h | 51 +++++++++++++++++++++
> target/hexagon/genptr.h | 1 +
> target/hexagon/hex_regs.h | 2 +
> target/hexagon/idef-parser/parser-helpers.h | 1 +
> target/hexagon/translate.h | 1 +
> linux-user/hexagon/cpu_loop.c | 5 ++
> target/hexagon/cpu.c | 2 +-
> target/hexagon/decode.c | 1 +
> target/hexagon/genptr.c | 21 +++++++++
> target/hexagon/hexswi.c | 25 +++++++++-
> target/hexagon/iclass.c | 1 +
> target/hexagon/idef-parser/parser-helpers.c | 14 ++++++
> target/hexagon/translate.c | 2 +-
> target/hexagon/tag_rev_info.c.inc | 10 ++++
> target/hexagon/gen_idef_parser_funcs.py | 2 +-
> target/hexagon/idef-parser/idef-parser.lex | 8 ++++
> target/hexagon/idef-parser/idef-parser.y | 9 +++-
> target/hexagon/imported/encode_pp.def | 5 ++
> target/hexagon/imported/system.idef | 8 ++++
> 20 files changed, 166 insertions(+), 5 deletions(-)
>
> +#ifdef CONFIG_USER_ONLY
> +#define fGEN_TCG_V2_CHECK_AND_WRITE_VSP(VSP) \
> + do { \
> + TCGLabel *write_vsp = gen_new_label(); \
> + tcg_gen_brcond_tl(TCG_COND_GEU, VSP, \
> + hex_gpr[HEX_REG_VFRAMELIMIT], write_vsp); \
> + gen_precise_exception(HEX_CAUSE_VECTOR_STACK_OVERFLOW, ctx->pkt.pc);
> \
> + gen_set_label(write_vsp); \
> + tcg_gen_mov_tl(hex_gpr[HEX_REG_VSP], VSP); \
> + } while (0)
> +#else
> +#define fGEN_TCG_V2_CHECK_AND_WRITE_VSP(VSP) \
> + do { \
> + TCGLabel *write_vsp = gen_new_label(); \
> + TCGv mode = tcg_temp_new(); \
> + tcg_gen_andi_tl(mode, hex_t_sreg[HEX_SREG_SSR], \
> + 1 << reg_field_info[SSR_EX].offset); \
> + tcg_gen_brcondi_tl(TCG_COND_NE, mode, 0, write_vsp); \
> + tcg_gen_andi_tl(mode, hex_t_sreg[HEX_SREG_SSR], \
> + 1 << reg_field_info[SSR_UM].offset); \
> + tcg_gen_brcondi_tl(TCG_COND_EQ, mode, 0, write_vsp); \
> + tcg_gen_brcond_tl(TCG_COND_GEU, VSP, \
> + hex_gpr[HEX_REG_VFRAMELIMIT], write_vsp); \
> + gen_precise_exception(HEX_CAUSE_VECTOR_STACK_OVERFLOW, ctx->pkt.pc);
> \
> + gen_set_label(write_vsp); \
> + tcg_gen_mov_tl(hex_gpr[HEX_REG_VSP], VSP); \
> + } while (0)
> +#endif
The definitions of fGEN_TCG_V2_CHECK_AND_WRITE_VSP exactly
match gen_vframecheck from genptr.c. Maybe we should call the function
from the macros (and remove one of the macro definitions)