On Tue, Nov 4, 2025 at 4:25 PM Taylor Simpson <[email protected]> wrote:
> Signed-off-by: Taylor Simpson <[email protected]> > --- > tests/tcg/hexagon/usr.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/tests/tcg/hexagon/usr.c b/tests/tcg/hexagon/usr.c > index f0b23d312b..8becd8195d 100644 > --- a/tests/tcg/hexagon/usr.c > +++ b/tests/tcg/hexagon/usr.c > @@ -608,6 +608,30 @@ TEST_CMP_xx(uint32_t, uint32_t, FUNC, SRC1, SRC2, > RES, USR_RES) > #define TEST_CMP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \ > TEST_CMP_xx(uint64_t, uint64_t, FUNC, SRC1, SRC2, RES, USR_RES) > > +static void test_usr_packets(void) > +{ > + uint32_t usr; > + /* Test setting USR bits inside and outside packets */ > + asm(CLEAR_USRBITS \ > + "r10 = satub(%1) /* Set usr.OVF */\n\t" > + "{\n\t" > + " r11 = convert_uw2sf(%4) /* Set usr.FPINPF */\n\t" > + " r10 = memw(%5) /* Force pkt commit */\n\t" > + "}\n\t" > + "{\n\t" > + " r11 = sfadd(%2, %3) /* Set usr.FPINVF */\n\t" > + " r10 = add(r10, #1) /* Doesn't force pkt commit */\n\t" > + "}\n\t" > + "%0 = usr\n\t" > + : "=r"(usr) > + : "r"(0xfff), > + "r"(SF_one), "r"(SF_SNaN), > + "r"(0x010020a5), > + "m"(err) > + : "r2", "r10", "r11", "usr"); > For the inline asm, how about using the symbolic/named operands instead of the enumerated ones? Should be easier to read. Something like: uint32_t usr; /* Test setting USR bits inside and outside packets */ asm(CLEAR_USRBITS "r10 = satub(%[val]) /* Set usr.OVF */\n\t" "{\n\t" " r11 = convert_uw2sf(%[fp_input]) /* Set usr.FPINPF */\n\t" " r10 = memw(%[err_mem]) /* Force pkt commit */\n\t" "}\n\t" "{\n\t" " r11 = sfadd(%[sf_one], %[sf_snan]) /* Set usr.FPINVF */\n\t" " r10 = add(r10, #1) /* Doesn't force pkt commit */\n\t" "}\n\t" "%[usr_out] = usr\n\t" : [usr_out] "=r" (usr) : [val] "r" (0xfff), [sf_one] "r" (SF_one), [sf_snan] "r" (SF_SNaN), [fp_input] "r" (0x010020a5), [err_mem] "m" (err) : "r2", "r10", "r11", "usr"); > + check32(usr & 0x3f, USR_OVF | USR_FPINVF | USR_FPINPF); > +} > + > int main() > { > TEST_R_OP_R(satub, 0, 0, USR_CLEAR); > @@ -1097,6 +1121,8 @@ int main() > TEST_Rp_OP_R(sfinvsqrta, SF_small_neg, SF_HEX_NaN, 0x00, > USR_FPINVF); > TEST_Rp_OP_R(sfinvsqrta, SF_SNaN, SF_HEX_NaN, 0x00, > USR_FPINVF); > > + test_usr_packets(); > + > puts(err ? "FAIL" : "PASS"); > return err; > } > -- > 2.43.0 > >
