diff mbox series

[07/20] target/arm: Fix is_a64 for user-only

Message ID 20180809042206.15726-8-richard.henderson@linaro.org
State New
Headers show
Series target/arm: sve system mode patches | expand

Commit Message

Richard Henderson Aug. 9, 2018, 4:21 a.m. UTC
Saves about 8k code size in qemu-aarch64.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/arm/cpu.h | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.17.1

Comments

Peter Maydell Aug. 17, 2018, 4:03 p.m. UTC | #1
On 9 August 2018 at 05:21, Richard Henderson
<richard.henderson@linaro.org> wrote:
> Saves about 8k code size in qemu-aarch64.

>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  target/arm/cpu.h | 8 ++++++++

>  1 file changed, 8 insertions(+)

>

> diff --git a/target/arm/cpu.h b/target/arm/cpu.h

> index aedaf2631e..ed51a2f5aa 100644

> --- a/target/arm/cpu.h

> +++ b/target/arm/cpu.h

> @@ -918,7 +918,15 @@ void aarch64_sync_64_to_32(CPUARMState *env);

>

>  static inline bool is_a64(CPUARMState *env)

>  {

> +#ifdef CONFIG_USER_ONLY

> +# ifdef TARGET_AARCH64

> +    return true;

> +# else

> +    return false;

> +# endif

> +#else

>      return env->aarch64;

> +#endif

>  }


And again. I don't want to pepper the code with ifdefs if
we can do the right thing without them.

thanks
-- PMM
Laurent Desnogues Aug. 17, 2018, 4:10 p.m. UTC | #2
Hello,

On Fri, Aug 17, 2018 at 6:04 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>

> On 9 August 2018 at 05:21, Richard Henderson

> <richard.henderson@linaro.org> wrote:

> > Saves about 8k code size in qemu-aarch64.

> >

> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> > ---

> >  target/arm/cpu.h | 8 ++++++++

> >  1 file changed, 8 insertions(+)

> >

> > diff --git a/target/arm/cpu.h b/target/arm/cpu.h

> > index aedaf2631e..ed51a2f5aa 100644

> > --- a/target/arm/cpu.h

> > +++ b/target/arm/cpu.h

> > @@ -918,7 +918,15 @@ void aarch64_sync_64_to_32(CPUARMState *env);

> >

> >  static inline bool is_a64(CPUARMState *env)

> >  {

> > +#ifdef CONFIG_USER_ONLY

> > +# ifdef TARGET_AARCH64

> > +    return true;

> > +# else

> > +    return false;

> > +# endif

> > +#else

> >      return env->aarch64;

> > +#endif

> >  }

>

> And again. I don't want to pepper the code with ifdefs if

> we can do the right thing without them.


FWIW I find it more readable with the ifdef's (here and in the
previous patches) and I guess that helps the compiler too.

Thanks,

Laurent
Peter Maydell Aug. 17, 2018, 4:23 p.m. UTC | #3
On 17 August 2018 at 17:10, Laurent Desnogues
<laurent.desnogues@gmail.com> wrote:
> Hello,

>

> On Fri, Aug 17, 2018 at 6:04 PM Peter Maydell <peter.maydell@linaro.org> wrote:

>> And again. I don't want to pepper the code with ifdefs if

>> we can do the right thing without them.

>

> FWIW I find it more readable with the ifdef's (here and in the

> previous patches) and I guess that helps the compiler too.


Hmm. I prefer to think of user-mode as a funny variant on
system emulation where we make the minimal changes required,
and mostly work just by having the CPU being in the state it
would be for system-emulation EL0 and not being able to get out
of it.

thanks
-- PMM
diff mbox series

Patch

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index aedaf2631e..ed51a2f5aa 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -918,7 +918,15 @@  void aarch64_sync_64_to_32(CPUARMState *env);
 
 static inline bool is_a64(CPUARMState *env)
 {
+#ifdef CONFIG_USER_ONLY
+# ifdef TARGET_AARCH64
+    return true;
+# else
+    return false;
+# endif
+#else
     return env->aarch64;
+#endif
 }
 
 /* you can call this signal handler from your SIGBUS and SIGSEGV