public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] riscv: generate builtin macro for compilation with strict alignment
Date: Thu, 20 Apr 2023 10:56:59 -0600	[thread overview]
Message-ID: <3dbcefe5-5b62-eb89-442a-abebe621f3bc@gmail.com> (raw)
In-Reply-To: <20230117225908.1604948-1-vineetg@rivosinc.com>



On 1/17/23 15:59, Vineet Gupta wrote:
> This could be useful for library writers who want to write code variants
> for fast vs. slow unaligned accesses.
> 
> We distinguish explicit -mstrict-align (1) vs. slow_unaligned_access
> cpu tune param (2) for even more code divesity.
> 
> gcc/ChangeLog:
> 
> 	* config/riscv-c.cc (riscv_cpu_cpp_builtins):
> 	  Generate __riscv_strict_align with value 1 or 2.
> 	* config/riscv/riscv.cc: Define riscv_user_wants_strict_align.
> 	  (riscv_option_override) Set riscv_user_wants_strict_align to
> 	  TARGET_STRICT_ALIGN.
> 	* config/riscv/riscv.h: Declare riscv_user_wants_strict_align.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/riscv/attribute.c: Check for
> 	  __riscv_strict_align=1.
> 	* gcc.target/riscv/predef-align-1.c: New test.
> 	* gcc.target/riscv/predef-align-2.c: New test.
> 	* gcc.target/riscv/predef-align-3.c: New test.
> 	* gcc.target/riscv/predef-align-4.c: New test.
> 	* gcc.target/riscv/predef-align-5.c: New test.
> 
> Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
> ---
>   gcc/config/riscv/riscv-c.cc                     | 11 +++++++++++
>   gcc/config/riscv/riscv.cc                       |  9 +++++++++
>   gcc/config/riscv/riscv.h                        |  1 +
>   gcc/testsuite/gcc.target/riscv/attribute-4.c    |  9 +++++++++
>   gcc/testsuite/gcc.target/riscv/predef-align-1.c | 12 ++++++++++++
>   gcc/testsuite/gcc.target/riscv/predef-align-2.c | 11 +++++++++++
>   gcc/testsuite/gcc.target/riscv/predef-align-3.c | 15 +++++++++++++++
>   gcc/testsuite/gcc.target/riscv/predef-align-4.c | 16 ++++++++++++++++
>   gcc/testsuite/gcc.target/riscv/predef-align-5.c | 16 ++++++++++++++++
>   9 files changed, 100 insertions(+)
>   create mode 100644 gcc/testsuite/gcc.target/riscv/predef-align-1.c
>   create mode 100644 gcc/testsuite/gcc.target/riscv/predef-align-2.c
>   create mode 100644 gcc/testsuite/gcc.target/riscv/predef-align-3.c
>   create mode 100644 gcc/testsuite/gcc.target/riscv/predef-align-4.c
>   create mode 100644 gcc/testsuite/gcc.target/riscv/predef-align-5.c
> 
> diff --git a/gcc/config/riscv/riscv-c.cc b/gcc/config/riscv/riscv-c.cc
> index 826ae0067bb8..47a396501d74 100644
> --- a/gcc/config/riscv/riscv-c.cc
> +++ b/gcc/config/riscv/riscv-c.cc
> @@ -102,6 +102,17 @@ riscv_cpu_cpp_builtins (cpp_reader *pfile)
>   
>       }
>   
> +  /* TARGET_STRICT_ALIGN does not cover all cases.  */
> +  if (riscv_slow_unaligned_access_p)
> +    {
> +      /* Explicit -mstruct-align preceedes cpu tune param
> +         slow_unaligned_access=true.  */
Did you mean "-mstrict-align" above?


> +      if (riscv_user_wants_strict_align)
> +        builtin_define_with_int_value ("__riscv_strict_align", 1);
> +      else
> +        builtin_define_with_int_value ("__riscv_strict_align", 2);
So I don't understand why we're testing "riscv_user_wants_strict_align" 
instead of TARGET_STRICT_ALIGN here.  AFAICT they're equivalent.  But 
maybe there's something subtle I'm missing.

Jeff

  reply	other threads:[~2023-04-20 16:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 22:59 Vineet Gupta
2023-04-20 16:56 ` Jeff Law [this message]
2023-04-28 21:37   ` Vineet Gupta

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=3dbcefe5-5b62-eb89-442a-abebe621f3bc@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).