From: Edwin Lu <ewlu@rivosinc.com>
To: Vineet Gupta <vineetg@rivosinc.com>, gcc-patches@gcc.gnu.org
Cc: gnu-toolchain@rivosinc.com
Subject: Re: [PATCH V2] riscv: generate builtin macro for compilation with strict alignment:
Date: Wed, 9 Aug 2023 14:40:09 -0700 [thread overview]
Message-ID: <5e8de8e3-a1ff-4174-85b4-d67b3c59ac5a@rivosinc.com> (raw)
In-Reply-To: <e88b22bc-0d38-5bcc-499d-f892d84ad8b3@rivosinc.com>
Hi Vineet,
On 8/8/2023 2:02 PM, Vineet Gupta wrote:
>
> Maybe add a comment that in absence of -m[no-]strict-align, we use the
> cpu tune param -> slow_unaligned_access and that default mcpu is rocket
> which has that set to _slow.
>
That sounds good to me!
>> +#if defined(__riscv_unaligned_avoid)
>> +#error "__riscv_unaligned_avoid is unexpectedly set"
>> +#endif
>
> Lets first check what is really expected.
> #if !defined (_slow) #error
>
>> +
>> +/* Check __riscv_unaligned_slow xor __riscv_unaligned_fast is set. */
>> +#if !defined(__riscv_unaligned_slow) && !defined(__riscv_unaligned_fast)
>> +#error "either __riscv_unaligned_slow or__riscv_unaligned_fast is not
>> set"
>> +#endif
>> +
>> +#if defined(__riscv_unaligned_slow) && defined(__riscv_unaligned_fast)
>> +#error "both __riscv_unaligned_slow and__riscv_unaligned_fast are set"
>> +#endif
>> +
>
> I think we can simplify this a bit (sorry I if wasn't clear enough in
> our off-list discussions).
> We now need to ensure that unexpected toggles are NOT defined: #if
> defined(_avoid) || defined(_fast) #error
> I don't think we need to check for the combinations as that is covered
> by first one and this.
>
> While separate #error prints for 2 failures are ideal, personally it
> feels excessive given that the current implementation will only ever
> generate 1 of them. If a future code change breaks that assumption, the
> onus is on that change to fix/update the errors.
>
That makes sense to me. I was thinking that adding some more checks
would help clarify the assumptions but it did just make things overly
verbose.
>
> Same as my comment for attribute-1. Please recheck all of them.
>
Thanks for the feedback! I will be sure to update all of them in the
next iteration.
Edwin
WARNING: multiple messages have this Message-ID
From: Edwin Lu <ewlu@rivosinc.com>
To: gcc-patches@gcc.gnu.org
Cc: gnu-toolchain@rivosinc.com
Subject: Re: [PATCH V2] riscv: generate builtin macro for compilation with strict alignment:
Date: Wed, 9 Aug 2023 14:40:09 -0700 [thread overview]
Message-ID: <5e8de8e3-a1ff-4174-85b4-d67b3c59ac5a@rivosinc.com> (raw)
Message-ID: <20230809214009.gUZn4qvYPF0474M6WOhi9S3bmEgYIh9WZMLJERYVs6w@z> (raw)
In-Reply-To: <e88b22bc-0d38-5bcc-499d-f892d84ad8b3@rivosinc.com>
Hi Vineet,
On 8/8/2023 2:02 PM, Vineet Gupta wrote:
>
> Maybe add a comment that in absence of -m[no-]strict-align, we use the
> cpu tune param -> slow_unaligned_access and that default mcpu is rocket
> which has that set to _slow.
>
That sounds good to me!
>> +#if defined(__riscv_unaligned_avoid)
>> +#error "__riscv_unaligned_avoid is unexpectedly set"
>> +#endif
>
> Lets first check what is really expected.
> #if !defined (_slow) #error
>
>> +
>> +/* Check __riscv_unaligned_slow xor __riscv_unaligned_fast is set. */
>> +#if !defined(__riscv_unaligned_slow) && !defined(__riscv_unaligned_fast)
>> +#error "either __riscv_unaligned_slow or__riscv_unaligned_fast is not
>> set"
>> +#endif
>> +
>> +#if defined(__riscv_unaligned_slow) && defined(__riscv_unaligned_fast)
>> +#error "both __riscv_unaligned_slow and__riscv_unaligned_fast are set"
>> +#endif
>> +
>
> I think we can simplify this a bit (sorry I if wasn't clear enough in
> our off-list discussions).
> We now need to ensure that unexpected toggles are NOT defined: #if
> defined(_avoid) || defined(_fast) #error
> I don't think we need to check for the combinations as that is covered
> by first one and this.
>
> While separate #error prints for 2 failures are ideal, personally it
> feels excessive given that the current implementation will only ever
> generate 1 of them. If a future code change breaks that assumption, the
> onus is on that change to fix/update the errors.
>
That makes sense to me. I was thinking that adding some more checks
would help clarify the assumptions but it did just make things overly
verbose.
>
> Same as my comment for attribute-1. Please recheck all of them.
>
Thanks for the feedback! I will be sure to update all of them in the
next iteration.
Edwin
next prev parent reply other threads:[~2023-08-09 21:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230808202458.3094615-1-ewlu@rivosinc.com>
2023-08-08 21:02 ` Vineet Gupta
2023-08-09 21:40 ` Edwin Lu [this message]
2023-08-09 21:40 ` Edwin Lu
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=5e8de8e3-a1ff-4174-85b4-d67b3c59ac5a@rivosinc.com \
--to=ewlu@rivosinc.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gnu-toolchain@rivosinc.com \
--cc=vineetg@rivosinc.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 read-only IMAP folder(s) and NNTP newsgroup(s).