hex queue
The following changes since commit 08ed97c33c3818ef51a7c852347a28e9f66807b5:
tests/tcg/i386: compile test-i386-blendv.c with -msse4.1 (2026-11-19 13:54:13 -0800)
are available in the Git repository at:
https://github.com/qualcomm/qemu tags/pull-hex-20261119
for you to fetch changes up to 2bf4854e7924883223fccfa139dbc87427c7f758:
linux-user: copy nanosleep's remaining time on EINTR (2026-11-19 19:50:03 -0800)
----------------------------------------------------------------
hexagon: HLX fixes, h2 git, gprel
* Fixes for HLX
* nanosleep() fix (impacted musl)
* h2: don't depend on git
* noidef fix for gp-rel instructions
----------------------------------------------------------------
Anton Johansson (5):
target/hexagon: Explicitly pass GP to helpers target/hexagon: HLX, preserve scalar :mem_noshuf ordering target/hexagon: HLX, search for .new values in pair high register target/hexagon: Forward return address to HLX load/store helpers linux-user/hexagon: Reset hlx_ctx pointer on cpu clone
Brian Cain (3):
roms: record the H2 commit in a file
target/hexagon: Fix disassembly of extended GP-relative accesses
linux-user: copy nanosleep's remaining time on EINTR
MAINTAINERS | 1 + linux-user/hexagon/target_cpu.h | 1 + target/hexagon/hlx_helper.h | 19 +++++++++++++++++++ target/hexagon/insn.h | 1 + target/hexagon/macros.h | 21 ++++++++++----------- target/hexagon/attribs_def.h.inc | 1 + linux-user/syscall.c | 2 +- target/hexagon/decode.c | 29 +++++++++++++++++++++++------ target/hexagon/hlx_helper.c | 31 ++++++++++++++++++++++--------- target/hexagon/translate.c | 7 ++++--- tests/tcg/hexagon/hlx_assign_conv.c | 35 +++++++++++++++++++++++++++++++++++ tests/tcg/hexagon/hlx_mem.c | 22 ++++++++++++++++++++++ roms/Makefile | 22 ++++++++++++++++++---- roms/hexagon-hypervisor-version | 1 + target/hexagon/gen_printinsn.py | 7 +++++++ target/hexagon/gen_trans_funcs.py | 5 +++++ target/hexagon/hex_common.py | 13 +++++++++++++ 17 files changed, 184 insertions(+), 34 deletions(-) create mode 100644 target/hexagon/hlx_helper.h create mode 100644 roms/hexagon-hypervisor-version
[PULL 4/8] target/hexagon: HLX, preserve scalar :mem_noshuf ordering
From: Anton Johansson <[email protected]>
A packet containing HLX instructions currently defers all stores to the end of the packet, this breaks scalar :mem_noshuf ordering. Only reorder HLX stores.
--- target/hexagon/translate.c | 7 ++++--- tests/tcg/hexagon/hlx_mem.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-)
target/hexagon/translate.c +4 -3
@@ -1533,8 +1533,10 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)for (int pass =0 ; pass <3 ; pass++) {for (i =0 ; i < ctx->pkt.num_insns; i++) {Insn *insn = &ctx->pkt.insn[i]; +bool hlx =GET_ATTRIB (insn->opcode,A_HLX );bool tmp =GET_ATTRIB (insn->opcode,A_HLX_TMP ); -bool store = !tmp &&GET_ATTRIB (insn->opcode,A_STORE ); +bool store = !tmp && hlx && +GET_ATTRIB (insn->opcode,A_STORE );if (pass != (tmp ?0 : store ?2 :1 )) {continue ; }
@@ -1542,8 +1544,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)if (insn->hlx_new_zero) {gen_hlx_new_zero (insn); } -if (GET_ATTRIB (insn->opcode,A_HLX ) && -trace_event_get_state_backends ( +if (hlx &&trace_event_get_state_backends (TRACE_HEXAGON_HLX_OP )) {gen_helper_hlx_trace_op (tcg_env,tcg_constant_i32 (insn->opcode));
tests/tcg/hexagon/hlx_mem.c +22 -0
@@ -229,6 +229,25 @@ static void test_store_fault(void)check_h ("LX_S16b_new (fault)" , buf_out, expected,HLX_HALF_ELEMS ); } +static void test_preserve_scalar_noshuf (void ) +{ +uint32_t ret =0 ; +uint32_t ptr =0 ; +uint32_t val =0x1234 ; + asmvolatile ("{\n" +".word 0xe5007822\n" +" memw(%[ptr]) = %[val]\n" +" %[ret] = memw(%[ptr])\n" +"}:mem_noshuf\n" + : [ret]"=r" (ret) + : [ptr]"r" (&ptr), [val]"r" (val) + :"memory" ); +if (ret != val) { +printf ("FAIL broken scalar :mem_noshuf ordering\n" ); + err++; + } +} +int main (void ) {init_vtcm ();
@@ -253,6 +272,9 @@ int main(void)/* Store in a faulting packet */ test_store_fault (); +/* Make sure HLX packets preserve scalar :mem_noshuf ordering */ +test_preserve_scalar_noshuf (); +puts (err ?"FAIL" :"PASS" );return err; }
Signature · 1 line
2.34.1
[PULL 1/8] roms: record the H2 commit in a file
In reply to Brian CainThe H2 build ID was derived by running git rev-parse, which fails when building from a source tarball. Leaving H2K_GIT_COMMIT as "0x" does not compile.
Instead, keep the commit in a tracked file and always build from it. When the submodule is checked out, fail the H2 build if its HEAD does not match the recorded commit, so a submodule update without a matching update of the file is caught.
--- MAINTAINERS | 1 + roms/Makefile | 22 ++++++++++++++++++---- roms/hexagon-hypervisor-version | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 roms/hexagon-hypervisor-version
MAINTAINERS +1 -0
@@ -1400,6 +1400,7 @@ F: tests/qtest/qcom-dsp-test.c F: docs/devel/hexagon-sys.rst F: pc-bios/hexagon* F: roms/hexagon-hypervisor +F: roms/hexagon-hypervisor-version LoongArch Machines ------------------
roms/Makefile +18 -4
@@ -226,11 +226,25 @@ hexagon_h2_booters := hexagon-booter-qcs6490-cdsp \ hexagon_h2_loadlinux := hexagon-loadlinux-qcs6490-cdsp \ hexagon-loadlinux-sm8975-nsp hexagon-loadlinux-sa8775p-cdsp \ hexagon-loadlinux-sc8480xp-nsp0 hexagon-loadlinux-sa8797p-nsp0 +include hexagon-hypervisor-version + +.PHONY: hexagon-hypervisor-check +hexagon-hypervisor-check: + @if test -e hexagon-hypervisor/.git; then \ + h2_head=$$(git -C hexagon-hypervisor rev-parse HEAD); \ + if test "$$h2_head" != "$(H2K_COMMIT)"; then \ + echo "hexagon-hypervisor is at $$h2_head, but" \ + "roms/hexagon-hypervisor-version has" \ + "$(H2K_COMMIT)" >&2; \ + exit 1; \ + fi; \ + fi + hexagon_h2_common_flags = USE_PKW=0 TARGET=opt NULL_ANGEL_TRAP=1 \ HMX_HLX_SUPPORT=1 \ H2K_LOAD_ADDR=0x9b800000 H2K_GUEST_START=0xa2000000 \ - H2K_GIT_COMMIT=0x$(shell git -C hexagon-hypervisor rev-parse --short=8 HEAD) \ - H2K_GIT_COMMIT_LONG=0x$(shell git -C hexagon-hypervisor rev-parse HEAD) \ + H2K_GIT_COMMIT=0x$(shell echo $(H2K_COMMIT) | cut -c1-8) \ + H2K_GIT_COMMIT_LONG=0x$(H2K_COMMIT) \ JFLAG=-j$(shell nproc) .PHONY: hexagon-qcs6490-cdsp hexagon-sm8975-nsp \
@@ -264,7 +278,7 @@ hexagon-loadlinux-sm8975-nsp hexagon-loadlinux-sa8775p-cdsp \ hexagon-loadlinux-sc8480xp-nsp0 hexagon-loadlinux-sa8797p-nsp0: \ hexagon_h2_linux_flags = LINUX_LINK_ADDR=0xa0000000 -$(hexagon_h2_booters): hexagon-booter-%: +$(hexagon_h2_booters): hexagon-booter-%: hexagon-hypervisor-check rm -rf $(hexagon_h2_out)/booter-$* $(MAKE) -C hexagon-hypervisor $(hexagon_h2_common_flags) \ $(hexagon_h2_machine_flags) \
@@ -273,7 +287,7 @@ $(hexagon_h2_booters): hexagon-booter-%: $(hexagon_h2_build)/booter-$*/install/bin/booter chmod -x ../pc-bios/hexagon_booter_$(subst -,_,$*) -$(hexagon_h2_loadlinux): hexagon-loadlinux-%: +$(hexagon_h2_loadlinux): hexagon-loadlinux-%: hexagon-hypervisor-check rm -rf $(hexagon_h2_out)/loadlinux-$* $(MAKE) -C hexagon-hypervisor $(hexagon_h2_common_flags) \ $(hexagon_h2_machine_flags) \
roms/hexagon-hypervisor-version new file +1 -0
@@ -0,0 +1 @@ +H2K_COMMIT = 23d5bde4313c1e63ba64dd5d7f542b1055188ef8
Signature · 1 line
2.34.1
[PULL 2/8] target/hexagon: Fix disassembly of extended GP-relative accesses
In reply to Brian CainA GP-relative load or store with a constant extender is an absolute
access: the semantics read GP as 0 when insn->extension_valid is set, and the extended immediate is the full address. The printed form kept the "gp+" base, so for example
R0 = memw(gp+##0x48c30)
was shown for an instruction that accesses 0x48c30 and does not use GP.
Only print the "gp+" base when there is no extender.
--- target/hexagon/gen_printinsn.py | 7 +++++++ 1 file changed, 7 insertions(+)
target/hexagon/gen_printinsn.py +7 -0
@@ -125,6 +125,10 @@ def main(): beh = hex_common.absimmre.sub(r"#%s0x%x", beh) beh = hex_common.relimmre.sub(r"PC+%s%d", beh) beh = spacify(beh) + + gp_relative = "(gp+" in beh + if gp_relative: + beh = beh.replace("(gp+", "(%s") # Print out a literal "%s" at the end, used to match empty string # so C won't complain at us if "A_VECX" in hex_common.attribdict[tag]:
@@ -158,6 +162,9 @@ def main(): ri += 1 else: # immediate + if gp_relative: + f.write(', insn->extension_valid ? "" : "gp+"') + gp_relative = False if immlett.isupper(): if extendable_upper_imm: if immlett in "rR":
Signature · 1 line
2.34.1
[PULL 7/8] linux-user/hexagon: Reset hlx_ctx pointer on cpu clone
In reply to Brian CainFrom: Anton Johansson <[email protected]>
Currently hlx_ctx retains the pointer to the hlx_user_ctx of its parent. Another way to go is similar to hvx_ctx, which in user-mode, is just the struct itself rather than a pointer to the struct.
--- linux-user/hexagon/target_cpu.h | 1 + 1 file changed, 1 insertion(+)
linux-user/hexagon/target_cpu.h +1 -0
@@ -25,6 +25,7 @@ static inline void cpu_clone_regs_child(CPUHexagonState *env, env->gpr[HEX_REG_SP ] = newsp; } env->gpr[0 ] =0 ; + env->hlx_ctx = &env->hlx_user_ctx; }static inline void cpu_clone_regs_parent (CPUHexagonState *env,unsigned flags)
Signature · 1 line
2.34.1
[PULL 3/8] target/hexagon: Explicitly pass GP to helpers
In reply to Brian CainFrom: Anton Johansson <[email protected]>
helpers using fREAD_GP() are broken and do not account for the presence of extenders which change the addressing mode from GP-relative to absolute. Explicitly pass GP to helpers and check for expanders at the call-site.
--- target/hexagon/macros.h | 8 +------- target/hexagon/attribs_def.h.inc | 1 + target/hexagon/hex_common.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 7 deletions(-)
target/hexagon/macros.h +1 -7
@@ -347,13 +347,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#define fREAD_SA0 (env->gpr[HEX_REG_SA0])#define fREAD_SA1 (env->gpr[HEX_REG_SA1])#define fREAD_FP () (env->gpr[HEX_REG_FP]) -#ifdef FIXME -/* Figure out how to get insn->extension_valid to helper */ -#define fREAD_GP () \ - (insn->extension_valid ? 0 : env->gpr[HEX_REG_GP]) -#else -#define fREAD_GP () (env->gpr[HEX_REG_GP]) -#endif +#define fREAD_GP () (GP)#define fREAD_PC () (PC)#define fREAD_P0 () (P0)
target/hexagon/attribs_def.h.inc +1 -0
@@ -133,6 +133,7 @@ DEF_ATTRIB(IMPLICIT_WRITES_LR, "Writes the link register", "", "UREG.LR") DEF_ATTRIB(IMPLICIT_READS_PC, "Reads the program counter", "UREG.PC", "") DEF_ATTRIB(IMPLICIT_WRITES_SP, "Writes the stack pointer", "", "UREG.SP") DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the stack pointer", "UREG.SP", "") +DEF_ATTRIB(IMPLICIT_READS_GP, "Reads the global pointer", "UREG.GP", "") DEF_ATTRIB(IMPLICIT_WRITES_FP, "Writes the frame pointer", "", "UREG.FP") DEF_ATTRIB(IMPLICIT_WRITES_LC0, "Writes loop count for loop 0", "", "UREG.LC0") DEF_ATTRIB(IMPLICIT_WRITES_LC1, "Writes loop count for loop 1", "", "UREG.LC1")
target/hexagon/hex_common.py +11 -0
@@ -142,6 +142,7 @@ def calculate_attribs(): 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') + add_qemu_macro_attrib('fREAD_GP', 'A_IMPLICIT_READS_GP') # Recurse down macros, find attributes from sub-macros macroValues = list(macros.values())
@@ -246,6 +247,10 @@ def need_sp(tag): return "A_IMPLICIT_READS_SP" in attribdict[tag] +def need_gp(tag): + return "A_IMPLICIT_READS_GP" in attribdict[tag] + + def is_hvx_insn(tag): return "A_CVI" in attribdict[tag]
@@ -2210,6 +2215,12 @@ def helper_args(tag, regs, imms): "hex_gpr[HEX_REG_SP]", "uint32_t SP" )) + if need_gp(tag): + args.append(HelperArg( + "i32", + "insn->extension_valid ? tcg_constant_tl(0) : hex_gpr[HEX_REG_GP]", + "uint32_t GP" + )) if need_slot(tag): args.append(HelperArg( "i32",
Signature · 1 line
2.34.1
[PULL 8/8] linux-user: copy nanosleep's remaining time on EINTR
In reply to Brian Caindo_syscall1() copies the host's "rem" timespec back to the guest whenever safe_nanosleep() fails. But the kernel only fills in rem when the sleep was interrupted (-EINTR). When a signal arrives just before the host call, safe_syscall returns -QEMU_ERESTARTSYS without running the syscall at all, so rem is uninitialized stack.
That is harmless for a guest that passes distinct request and remainder buffers, but musl's usleep() calls nanosleep(&ts, &ts). The garbage then overwrites the guest's request before the syscall is restarted, so the restarted sleep can last arbitrarily long.
Match clock_nanosleep(), which already only copies the remainder back on -TARGET_EINTR.
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -12249,7 +12249,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,return -TARGET_EFAULT ; } ret =get_errno (safe_nanosleep (&req, &rem)); -if (is_error (ret) && arg2) { +if (ret == -TARGET_EINTR && arg2) {if (host_to_target_timespec (arg2, &rem)) {return -TARGET_EFAULT ; }
Signature · 1 line
2.34.1
[PULL 6/8] target/hexagon: Forward return address to HLX load/store helpers
In reply to Brian CainFrom: Anton Johansson <[email protected]>
--- target/hexagon/hlx_helper.h | 19 +++++++++++++++++++ target/hexagon/macros.h | 13 +++++++++---- target/hexagon/hlx_helper.c | 31 ++++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 target/hexagon/hlx_helper.h
target/hexagon/hlx_helper.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HLX_HELPER_H +#define HEXAGON_HLX_HELPER_H + +#include "cpu.h" + +void hlx_load_vec_ra (CPUHexagonState *env,void *dst_void, +target_ulong ea,uint32_t above,uint32_t below, +uintptr_t ra); + +void hlx_store_vec_ra (CPUHexagonState *env,target_ulong ea, +void *src_void,uint32_t above,uint32_t below, +uintptr_t ra); + +#endif
target/hexagon/macros.h +9 -4
@@ -22,6 +22,7 @@#include "hex_regs.h" #include "reg_fields.h" #include "accel/tcg/getpc.h" +#include "hlx_helper.h" #define GET_FIELD (FIELD ,REGIN ) \ fEXTRACTU_BITS(REGIN, reg_field_info[FIELD].width, \
@@ -732,8 +733,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift) EA, tcg_constant_i32(ABOVE), \ tcg_constant_i32(BELOW))#else -#define fLOADMML (EA ,DST ,ABOVE ,BELOW ) \ - do { HELPER(hlx_load_vec)(env, &(DST), (EA), (ABOVE), (BELOW)); } while (0) +#define fLOADMML (EA ,DST ,ABOVE ,BELOW ) \ + do { \ + hlx_load_vec_ra(env, &(DST), (EA), (ABOVE), (BELOW), GETPC()); \ + } while (0)#endif /* The helper logs the store for packet commit. */
@@ -742,8 +745,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)gen_helper_hlx_store_vec (tcg_env,EA ,tcg_constant_ptr ((intptr_t )&(SRC )), \ tcg_constant_i32(ABOVE), tcg_constant_i32(BELOW))#else -#define fSTOREMML (EA ,SRC ,ABOVE ,BELOW ) \ - do { HELPER(hlx_store_vec)(env, (EA), &(SRC), (ABOVE), (BELOW)); } while (0) +#define fSTOREMML (EA ,SRC ,ABOVE ,BELOW ) \ + do { \ + hlx_store_vec_ra(env, (EA), &(SRC), (ABOVE), (BELOW), GETPC()); \ + } while (0)#endif /* Helpers receive .new registers in future_LRegs. */
target/hexagon/hlx_helper.c +22 -9
@@ -7,6 +7,7 @@#include "cpu.h" #include "accel/tcg/cpu-ldst.h" #include "exec/helper-proto.h" +#include "hlx_helper.h" #include "hlx/hlx.h" #include "hw/hexagon/hexagon_hlx.h" #include "accel/tcg/probe.h"
@@ -15,40 +16,52 @@#define HLX_MEM_ALIGN_MASK (~(HLX_VEC_SIZE_BYTES - 1))/* Align down to 2KB. Above and below are unused in V85. */ -void HELPER (hlx_load_vec )(CPUHexagonState *env,void *dst_void, -target_ulong ea,uint32_t above,uint32_t below) +void hlx_load_vec_ra (CPUHexagonState *env,void *dst_void, +target_ulong ea,uint32_t above,uint32_t below, +uintptr_t ra) {HLXVector *dst = (HLXVector *)dst_void;target_ulong aligned_ea = ea &HLX_MEM_ALIGN_MASK ; -uintptr_t raddr =GETPC ();int mmu_idx =cpu_mmu_index (env_cpu (env), false);/* A 2KB-aligned access stays within one page. */ -void *host =probe_read (env, aligned_ea,HLX_VEC_SIZE_BYTES , mmu_idx, - raddr); +void *host =probe_read (env, aligned_ea,HLX_VEC_SIZE_BYTES , mmu_idx, ra);if (host) {memcpy (dst, host,HLX_VEC_SIZE_BYTES ); }else {for (int i =0 ; i <HLX_VEC_SIZE_BYTES ; i +=8 ) { -uint64_t val =cpu_ldq_le_data_ra (env, aligned_ea + i, raddr); +uint64_t val =cpu_ldq_le_data_ra (env, aligned_ea + i, ra);memcpy (&dst->ub[i], &val,8 ); } } } -void HELPER (hlx_store_vec )(CPUHexagonState *env,target_ulong ea, -void *src_void,uint32_t above,uint32_t below) +void hlx_store_vec_ra (CPUHexagonState *env,target_ulong ea, +void *src_void,uint32_t above,uint32_t below, +uintptr_t ra) {target_ulong aligned_ea = ea &HLX_MEM_ALIGN_MASK ;int mmu_idx =cpu_mmu_index (env_cpu (env), false); -probe_write (env, aligned_ea,HLX_VEC_SIZE_BYTES , mmu_idx,GETPC ()); +probe_write (env, aligned_ea,HLX_VEC_SIZE_BYTES , mmu_idx, ra);memcpy (&env->hlx_store_data, src_void,sizeof (HLXVector)); env->hlx_store_va = aligned_ea; env->hlx_store_pending = true; } +void HELPER (hlx_load_vec )(CPUHexagonState *env,void *dst_void, +target_ulong ea,uint32_t above,uint32_t below) +{ +hlx_load_vec_ra (env, dst_void, ea, above, below,GETPC ()); +} + +void HELPER (hlx_store_vec )(CPUHexagonState *env,target_ulong ea, +void *src_void,uint32_t above,uint32_t below) +{ +hlx_store_vec_ra (env, ea, src_void, above, below,GETPC ()); +} +void HELPER (hlx_commit_store )(CPUHexagonState *env) {target_ulong va = env->hlx_store_va;
Signature · 1 line
2.34.1
[PULL 5/8] target/hexagon: HLX, search for .new values in pair high register
In reply to Brian CainFrom: Anton Johansson <[email protected]>
Otherwise, the following packet
{
L7:6 = combine(L0, L2)
mem(R7) = L7.new
}results in mem(R7) being zero-initialized, compared to L6.new which would correctly write the lower bytes of the pair.
Compared to scalar and HVX .new instructions, HLX encodes the register number rather than an offset to the producing instruction + an odd/even bit. In order to find possible producers which write to register pairs without the odd/even bit, a Instruction::has_pair_dest field is added for scalar, HVX, and HLX registers.
Lastly, we move the new-regno patching in decode_fill_newvalue_regno() to the non-HLX scalar path to avoid overwriting the consumer L7 with the base register L6 of the producer destination L7:6. This is safe as the patching is only required for replacing the scalar offset+odd/even bit with the actual producer.
--- target/hexagon/insn.h | 1 + target/hexagon/decode.c | 29 +++++++++++++++++++----- tests/tcg/hexagon/hlx_assign_conv.c | 35 +++++++++++++++++++++++++++++ target/hexagon/gen_trans_funcs.py | 5 +++++ target/hexagon/hex_common.py | 2 ++ 5 files changed, 66 insertions(+), 6 deletions(-)
target/hexagon/insn.h +1 -0
@@ -42,6 +42,7 @@ struct Instruction {int32_t new_read_idx;int32_t dest_idx;bool has_pred_dest; +bool has_pair_dest;bool part1;/* * cmp-jumps are split into two insns.
target/hexagon/decode.c +23 -6
@@ -110,9 +110,25 @@ static int hlx_find_new_value_producer(Packet *packet, int consumer, {for (int i =0 ; i < packet->num_insns; i++) {Insn *insn = &packet->insn[i]; +uint8_t regno; -if (i != consumer &&GET_ATTRIB (insn->opcode,A_HLX ) && - insn->dest_idx !=-1 && insn->regno[insn->dest_idx] == lreg) { +/* +* Skip ourselves, instructions without return values, and +* any non-HLX instructions. +*/ +if (i == consumer || !GET_ATTRIB (insn->opcode,A_HLX ) || + insn->dest_idx ==-1 ) { +continue ; + } + + regno = insn->regno[insn->dest_idx]; + +/* +* Compare against the base register number, and against the top +* register for instructions returning pairs. +*/ +if (regno == lreg || + (insn->has_pair_dest && regno +1 == lreg)) {return i; } }
@@ -172,12 +188,13 @@ decode_fill_newvalue_regno(Packet *packet)if (def_idx <0 || packet->insn[def_idx].dest_idx ==-1 ) {return false; } + +/* Now patch up the consumer with the register number */ + dst_idx = packet->insn[def_idx].dest_idx; + packet->insn[i].regno[use_regidx] = + packet->insn[def_idx].regno[dst_idx]; } -/* Now patch up the consumer with the register number */ - dst_idx = packet->insn[def_idx].dest_idx; - packet->insn[i].regno[use_regidx] = - packet->insn[def_idx].regno[dst_idx];/* * We need to remember who produces this value to later * check if it was dynamically cancelled
tests/tcg/hexagon/hlx_assign_conv.c +35 -0
@@ -120,6 +120,40 @@ static void test_assign_rw(void)check_wp ("LX_assign_rw" , pw_out_lo, pw_out_hi, expected_w,HLX_HALF_ELEMS ); } +static void test_combine_assign_hi (void ) +{ +/* +* Tests that a combine operation acts as a producer of a .new value for +* the high vector in a pair. +*/ +HLX_Vector l_lo; +HLX_Vector l_hi; + +fill_w (pw_a_lo, pw_a_hi,VAL_W ); + + l_lo =Q6_L_tmp_mem_A (pw_a_lo); + l_hi =Q6_L_tmp_mem_A (pw_a_hi); + +hlx_put_v (0 , l_lo); +hlx_put_v (2 , l_hi); +/* +* { +* L7:6 = combine(L0, L2) +* mem(R7) = L7.new +* } +*/ + asm volatile(HLX_PTRS HLX_LD0 HLX_LD2 +".word 0xef24602d\n" +".word 0xa487c007\n" + : : [stage] "r"(hlx_stage) : HLX_CLOBBERS); +Q6_mem_Ku16_new_AL (buf_a,hlx_get_v (7 )); + +for (int j =0 ; j <HLX_HALF_ELEMS ; j++) { + expected[j] =VAL_B ; + } +check_h ("LX_assign_w (hi only)" , buf_a, expected,HLX_HALF_ELEMS ); +} +static void test_combine_w (void ) {
@@ -336,6 +370,7 @@ int main(void)test_assign_s ();test_assign_u ();test_assign_rw (); +test_combine_assign_hi ();/* Combine and mux */ test_combine_w ();
target/hexagon/gen_trans_funcs.py +5 -0
@@ -74,6 +74,7 @@ def mark_which_imm_extended(f, tag): ## insn->new_read_idx = -1; ## insn->dest_idx = 0; ## insn->has_pred_dest = false; +## insn->has_pair_dest = false; ## return true; ## } ##
@@ -94,6 +95,7 @@ def gen_trans_funcs(f): dest_idx = -1 dest_idx_reg_id = None has_pred_dest = "false" + has_pair_dest = "false" for regno, (reg_type, reg_id, *_) in enumerate(regs): reg = hex_common.get_register(tag, reg_type, reg_id) f.write(code_fmt(f"""\
@@ -108,6 +110,8 @@ def gen_trans_funcs(f): dest_idx_reg_id = reg_id if reg_type == "P" and reg.is_written() and not reg.is_read(): has_pred_dest = "true" + if reg.is_written() and reg.is_pair(): + has_pair_dest = "true" if len(imms) != 0: mark_which_imm_extended(f, tag)
@@ -132,6 +136,7 @@ def gen_trans_funcs(f): insn->new_read_idx = {new_read_idx}; insn->dest_idx = {dest_idx}; insn->has_pred_dest = {has_pred_dest}; + insn->has_pair_dest = {has_pair_dest}; """)) f.write(textwrap.dedent(f"""\ return true;
target/hexagon/hex_common.py +2 -0
@@ -810,6 +810,8 @@ def is_hvx_reg(self): return True def is_hlx_reg(self): return False + def is_pair(self): + return len(self.regid) == 2 def hvx_off(self): return f"{self.reg_tcg()}_off" def hvx_base(self):
Signature · 1 line
2.34.1
Richard Henderson
AppliedQuoted 12 lines · Brian Cain
The following changes since commit
08ed97c33c3818ef51a7c852347a28e9f66807b5:tests/tcg/i386: compile test-i386-blendv.c with -msse4.1 (2026-11-19 13:54:13 -0800)are available in the Git repository at:
https://github.com/qualcomm/qemu tags/pull-hex-20261119for you to fetch changes up to
2bf4854e7924883223fccfa139dbc87427c7f758:linux-user: copy nanosleep's remaining time on EINTR (2026-11-19 19:50:03 -0800)
Quoted 7 lines
----------------------------------------------------------------
hexagon: HLX fixes, h2 git, gprel* Fixes for HLX
*nanosleep()fix (impacted musl)
* h2: don't depend on git
* noidef fix for gp-rel instructions
Applied, thanks.
r~