On Fri, 2 Jun 2023 at 21:51, Philippe Mathieu-Daudé <phi...@linaro.org> wrote: > > Hi Peter, > > On 2/6/23 17:52, Peter Maydell wrote: > > Convert the LDR and STR instructions which use a 12-bit immediate > > offset to decodetree. We can reuse the existing LDR and STR > > trans functions for these. > > > > Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> > > --- > > target/arm/tcg/a64.decode | 25 ++++++++ > > target/arm/tcg/translate-a64.c | 103 +++++---------------------------- > > 2 files changed, 41 insertions(+), 87 deletions(-) > > > > diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode > > index 4dfb7bbdc2e..c3a6d0b740a 100644 > > --- a/target/arm/tcg/a64.decode > > +++ b/target/arm/tcg/a64.decode > > > > +# Load/store with an unsigned 12 bit immediate, which is scaled by the > > +# element size. The function gets the sz:imm and returns the scaled > > immediate. > > +%uimm_scaled 10:12 sz:3 !function=uimm_scaled > > + > > +@ldst_uimm .. ... . .. .. ............ rn:5 rt:5 &ldst_imm unpriv=0 > > p=0 w=0 imm=%uimm_scaled > > + > > +STR_i sz:2 111 0 01 00 ............ ..... ..... @ldst_uimm > > sign=0 ext=0 > > +LDR_i 00 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 > > ext=1 sz=0 > > +LDR_i 01 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 > > ext=1 sz=1 > > +LDR_i 10 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 > > ext=1 sz=2 > > +LDR_i 11 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 > > ext=0 sz=3 > > +LDR_i 00 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 > > ext=0 sz=0 > > +LDR_i 01 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 > > ext=0 sz=1 > > +LDR_i 10 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 > > ext=0 sz=2 > > +LDR_i 00 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 > > ext=1 sz=0 > > +LDR_i 01 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 > > ext=1 sz=1 > > Why not use "sz:2 111 0 01 sign:1 ext:1", returning false for the > cases not covered?
That would also catch the PRFM case (which is size=0b11 sign=1 ext=0 in your pattern); and it gives the wrong ext value for 11 111 0 01 01. You could do more of the decode in the trans_ functions and less here; but my impression is that we tend to prefer decoding in the .decode file where we can. thanks -- PMM