RE: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility functions

2021-01-25 Thread Taylor Simpson


> -Original Message-
> From: Philippe Mathieu-Daudé  On
> Behalf Of Philippe Mathieu-Daudé
> Sent: Monday, January 25, 2021 10:30 AM
> To: Taylor Simpson ; qemu-devel@nongnu.org
> Cc: a...@rev.ng; alex.ben...@linaro.org; richard.hender...@linaro.org;
> laur...@vivier.eu; Brian Cain 
> Subject: Re: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility
> functions
>
> >>> diff --git a/target/hexagon/arch.c b/target/hexagon/arch.c
> >>> new file mode 100644
> >>> index 000..c59cad5
> >>> --- /dev/null
> >>> +++ b/target/hexagon/arch.c
> >> ...
> >>
> >>> +#define RAISE_FP_EXCEPTION \
> >>> +do {} while (0)/* Not modelled in qemu user mode */
> >>
> >> I don't understand why... Can you explain please?
> >
> > Our Linux kernel only sets the relevant bits in USR (user status register).
> The exception isn't raised to user mode.
>
> Hmm while you introduce the linux-user implementation of your port,
> this file is not restricted to user mode. Thinking about avoiding
> head aches to someone wanting to add system mode emulation (or a
> BSD port??), maybe your helpers should consider that.
> Maybe some cheap #ifdef'ry CONFIG_USER_ONLY with a comment
> explaining
> why there is nothing to do in user mode, and g_assert_not_reached()
> else. Not sure, just wondering...

Sorry, I misunderstood the question.  You are correct.  It's a placeholder for 
future work to support system mode.  I'll add the #ifdef and some comments to 
explain.

Thanks,
Taylor



Re: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility functions

2021-01-25 Thread Philippe Mathieu-Daudé
On 1/22/21 10:59 PM, Taylor Simpson wrote:
>> -Original Message-
>> From: Philippe Mathieu-Daudé  On
>> Behalf Of Philippe Mathieu-Daudé
>> Sent: Friday, January 22, 2021 12:09 PM
>> To: Taylor Simpson ; qemu-devel@nongnu.org
>> Cc: richard.hender...@linaro.org; alex.ben...@linaro.org;
>> laur...@vivier.eu; a...@rev.ng; Brian Cain 
>> Subject: Re: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility
>> functions
>>
>> Hi Taylor,
>>
>> On 1/20/21 4:28 AM, Taylor Simpson wrote:
>>> Signed-off-by: Taylor Simpson 
>>> ---
>>>  target/hexagon/arch.h |  35 ++
>>>  target/hexagon/arch.c | 294
>> ++
>>>  2 files changed, 329 insertions(+)
>>>  create mode 100644 target/hexagon/arch.h
>>>  create mode 100644 target/hexagon/arch.c
>>>
>>> diff --git a/target/hexagon/arch.h b/target/hexagon/arch.h
>>> new file mode 100644
>>> index 000..a8374a3
>>> --- /dev/null
>>> +++ b/target/hexagon/arch.h
>>
>> Maybe rename "arch_utils.[ch]"?
> 
> Any particular reason?

I was thinking about not being confused by an architecture specific
file when doing refactors involving multiple architectures. But this
isn't a great improvement neither... No problem.

> 
>>
>>> +extern int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust,
>>> +  float_status *fp_status);
>>
>> (Again, no need for 'extern').
> 
> OK, I will change these.
> 
>>> diff --git a/target/hexagon/arch.c b/target/hexagon/arch.c
>>> new file mode 100644
>>> index 000..c59cad5
>>> --- /dev/null
>>> +++ b/target/hexagon/arch.c
>> ...
>>
>>> +#define RAISE_FP_EXCEPTION \
>>> +do {} while (0)/* Not modelled in qemu user mode */
>>
>> I don't understand why... Can you explain please?
> 
> Our Linux kernel only sets the relevant bits in USR (user status register).  
> The exception isn't raised to user mode.

Hmm while you introduce the linux-user implementation of your port,
this file is not restricted to user mode. Thinking about avoiding
head aches to someone wanting to add system mode emulation (or a
BSD port??), maybe your helpers should consider that.
Maybe some cheap #ifdef'ry CONFIG_USER_ONLY with a comment explaining
why there is nothing to do in user mode, and g_assert_not_reached()
else. Not sure, just wondering...

Regards,

Phil.



RE: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility functions

2021-01-22 Thread Taylor Simpson


> -Original Message-
> From: Philippe Mathieu-Daudé  On
> Behalf Of Philippe Mathieu-Daudé
> Sent: Friday, January 22, 2021 12:09 PM
> To: Taylor Simpson ; qemu-devel@nongnu.org
> Cc: richard.hender...@linaro.org; alex.ben...@linaro.org;
> laur...@vivier.eu; a...@rev.ng; Brian Cain 
> Subject: Re: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility
> functions
>
> Hi Taylor,
>
> On 1/20/21 4:28 AM, Taylor Simpson wrote:
> > Signed-off-by: Taylor Simpson 
> > ---
> >  target/hexagon/arch.h |  35 ++
> >  target/hexagon/arch.c | 294
> ++
> >  2 files changed, 329 insertions(+)
> >  create mode 100644 target/hexagon/arch.h
> >  create mode 100644 target/hexagon/arch.c
> >
> > diff --git a/target/hexagon/arch.h b/target/hexagon/arch.h
> > new file mode 100644
> > index 000..a8374a3
> > --- /dev/null
> > +++ b/target/hexagon/arch.h
>
> Maybe rename "arch_utils.[ch]"?

Any particular reason?

>
> > +extern int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust,
> > +  float_status *fp_status);
>
> (Again, no need for 'extern').

OK, I will change these.

> > diff --git a/target/hexagon/arch.c b/target/hexagon/arch.c
> > new file mode 100644
> > index 000..c59cad5
> > --- /dev/null
> > +++ b/target/hexagon/arch.c
> ...
>
> > +#define RAISE_FP_EXCEPTION \
> > +do {} while (0)/* Not modelled in qemu user mode */
>
> I don't understand why... Can you explain please?

Our Linux kernel only sets the relevant bits in USR (user status register).  
The exception isn't raised to user mode.



Re: [PATCH v7 15/35] Hexagon (target/hexagon/arch.[ch]) utility functions

2021-01-22 Thread Philippe Mathieu-Daudé
Hi Taylor,

On 1/20/21 4:28 AM, Taylor Simpson wrote:
> Signed-off-by: Taylor Simpson 
> ---
>  target/hexagon/arch.h |  35 ++
>  target/hexagon/arch.c | 294 
> ++
>  2 files changed, 329 insertions(+)
>  create mode 100644 target/hexagon/arch.h
>  create mode 100644 target/hexagon/arch.c
> 
> diff --git a/target/hexagon/arch.h b/target/hexagon/arch.h
> new file mode 100644
> index 000..a8374a3
> --- /dev/null
> +++ b/target/hexagon/arch.h

Maybe rename "arch_utils.[ch]"?

> @@ -0,0 +1,35 @@
> +/*
> + *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights 
> Reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, see .
> + */
> +
> +#ifndef HEXAGON_ARCH_H
> +#define HEXAGON_ARCH_H
> +
> +#include "qemu/osdep.h"
> +#include "qemu/int128.h"
> +
> +extern uint64_t interleave(uint32_t odd, uint32_t even);
> +extern uint64_t deinterleave(uint64_t src);
> +extern uint32_t carry_from_add64(uint64_t a, uint64_t b, uint32_t c);
> +extern int32_t conv_round(int32_t a, int n);
> +extern void arch_fpop_start(CPUHexagonState *env);
> +extern void arch_fpop_end(CPUHexagonState *env);
> +extern int arch_sf_recip_common(float32 *Rs, float32 *Rt, float32 *Rd,
> +int *adjust, float_status *fp_status);
> +extern int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust,
> +  float_status *fp_status);

(Again, no need for 'extern').

> +
> +#endif
> diff --git a/target/hexagon/arch.c b/target/hexagon/arch.c
> new file mode 100644
> index 000..c59cad5
> --- /dev/null
> +++ b/target/hexagon/arch.c
...

> +#define RAISE_FP_EXCEPTION \
> +do {} while (0)/* Not modelled in qemu user mode */

I don't understand why... Can you explain please?

> +
> +#define SOFTFLOAT_TEST_FLAG(FLAG, MYF, MYE) \
> +do { \
> +if (flags & FLAG) { \
> +if (GET_USR_FIELD(USR_##MYF) == 0) { \
> +SET_USR_FIELD(USR_##MYF, 1); \
> +if (GET_USR_FIELD(USR_##MYE)) { \
> +RAISE_FP_EXCEPTION; \
> +} \
> +} \
> +} \
> +} while (0)
...