qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: ltaylorsimpson@gmail.com,
	'Matheus Tavares Bernardino' <quic_mathbern@quicinc.com>,
	qemu-devel@nongnu.org
Cc: bcain@quicinc.com, quic_mliebel@quicinc.com
Subject: Re: [PATCH v2] Hexagon: move GETPC() calls to top level helpers
Date: Thu, 6 Jul 2023 07:44:03 +0100	[thread overview]
Message-ID: <ed3d829a-b592-909c-c358-acdeab65df17@linaro.org> (raw)
In-Reply-To: <00a701d9af8e$7de644c0$79b2ce40$@gmail.com>

On 7/5/23 23:17, ltaylorsimpson@gmail.com wrote:
> 
> 
>> -----Original Message-----
>> From: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
>> Sent: Wednesday, July 5, 2023 12:35 PM
>> To: qemu-devel@nongnu.org
>> Cc: quic_mathbern@quicinc.com; bcain@quicinc.com;
>> ltaylorsimpson@gmail.com; quic_mliebel@quicinc.com;
>> richard.henderson@linaro.org
>> Subject: [PATCH v2] Hexagon: move GETPC() calls to top level helpers
>>
>> As docs/devel/loads-stores.rst states:
>>
>>    ``GETPC()`` should be used with great care: calling
>>    it in other functions that are *not* the top level
>>    ``HELPER(foo)`` will cause unexpected behavior. Instead, the
>>    value of ``GETPC()`` should be read from the helper and passed
>>    if needed to the functions that the helper calls.
>>
>> Let's fix the GETPC() usage in Hexagon, making sure it's always called
> from
>> top level helpers and passed down to the places where it's needed. There
>> are two snippets where that is not currently the case:
>>
>> - probe_store(), which is only called from two helpers, so it's easy to
>>    move GETPC() up.
>>
>> - mem_load*() functions, which are also called directly from helpers,
>>    but through the MEM_LOAD*() set of macros. Note that this are only
>>    used when compiling with --disable-hexagon-idef-parser.
>>
>>    In this case, we also take this opportunity to simplify the code,
>>    unifying the mem_load*() functions.
>>
>> Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
>> ---
>> v1:
>> d40fabcf9d6e92e4cd8d6a144e9b2a9acf4580dc.1688420966.git.quic_mathber
>> n@quicinc.com
>>
>> Changes in v2:
>> - Fixed wrong cpu_ld* unification from previous version.
>> - Passed retaddr down to check_noshuf() and further, as Taylor
>>    suggested.
>> - Reorganized macros for simplification.
>>
>>   target/hexagon/macros.h    | 19 ++++++------
>>   target/hexagon/op_helper.h | 11 ++-----  target/hexagon/op_helper.c | 62
>> +++++++++++---------------------------
>>   3 files changed, 29 insertions(+), 63 deletions(-)
>>
>> diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index
>> 5451b061ee..e44a932434 100644
>> --- a/target/hexagon/macros.h
>> +++ b/target/hexagon/macros.h
>> @@ -173,15 +173,6 @@
>>   #define fLOAD(NUM, SIZE, SIGN, EA, DST) \
>> -    DST = (size##SIZE##SIGN##_t)MEM_LOAD##SIZE##SIGN(EA)
>> +    DST =  (size##SIZE##SIGN##_t)({ \
>> +        check_noshuf(env, pkt_has_store_s1, slot, EA, SIZE, GETPC()); \
>> +        MEM_LOAD##SIZE(env, EA, GETPC()); \
>> +    })
>>   #endif
> 
> This should be formatted as
> #define fLOAD(...) \
>      do { \
>          check_noshuf(...); \
>          DST = ...; \
>      } while (0)

Alternately,

     DST = (size##SIZE##SIGN##_t)mem_load##SIZE(env, pkt_has_store_s1, slot, EA, GETPC())

and retain the mem_loadN functions with an extra argument.

>> +void check_noshuf(CPUHexagonState *env, bool pkt_has_store_s1,
>> +                  uint32_t slot, target_ulong vaddr, int size,
>> +uintptr_t ra);
> 
> Are you sure this needs to be non-static?

I think only if the mem_loadN functions are retained may it be static.
But perhaps the macro magic is actually limited to the same compilation unit?


r~



  reply	other threads:[~2023-07-06  6:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 18:34 [PATCH v2] Hexagon: move GETPC() calls to top level helpers Matheus Tavares Bernardino
2023-07-05 22:17 ` ltaylorsimpson
2023-07-06  6:44   ` Richard Henderson [this message]
2023-07-06 11:22   ` Matheus Tavares Bernardino
2023-07-11  0:40     ` ltaylorsimpson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed3d829a-b592-909c-c358-acdeab65df17@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=bcain@quicinc.com \
    --cc=ltaylorsimpson@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quic_mathbern@quicinc.com \
    --cc=quic_mliebel@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).