Andrea Corallo <andrea.cora...@arm.com> writes:
> +/* Initialize all builtins in the AARCH64_BUILTIN_GENERAL group.  */
> +
> +void
> +aarch64_general_init_builtins (void)
> +{
> +

Excess blank line here.

> +  aarch64_init_fpsr_fpcr_builtins ();
> +
>    aarch64_init_fp16_types ();
>  
>    aarch64_init_bf16_types ();
> @@ -1876,6 +1913,14 @@ aarch64_expand_builtin_memtag (int fcode, tree exp, 
> rtx target)
>    return target;
>  }
>  
> +static void
> +aarch64_expand_fpsr_fpcr_setter (int unspec, machine_mode mode, tree exp)

Should have a function comment here, even though the function is tiny.

> +{
> +  tree arg = CALL_EXPR_ARG (exp, 0);
> +  rtx op = force_reg (mode, expand_normal (arg));
> +  emit_insn (gen_aarch64_set (unspec, mode, op));
> +}
> +
>  /* Expand an expression EXP that calls built-in function FCODE,
>     with result going to TARGET if that's convenient.  IGNORE is true
>     if the result of the builtin is ignored.  */
> […]
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index deca0004fedc..75f9e9e97e8b 100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -7230,37 +7230,21 @@
>    [(set_attr "length" "12")
>     (set_attr "type" "multiple")])
>  
> -;; Write Floating-point Control Register.
> -(define_insn "set_fpcr"
> -  [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 
> UNSPECV_SET_FPCR)]
> +;; Write into Floating-point Status Register.

“Status or Control”.  IMO reads better with “the” added.

> +(define_insn "@aarch64_set_<fpscr_name><GPI:mode>"
> +  [(unspec_volatile [(match_operand:GPI 0 "register_operand" "r")] 
> SET_FPSCR)]
>    ""
> -  "msr\\tfpcr, %0"
> +  "msr\\t<fpscr_name>, %0"
>    [(set_attr "type" "mrs")])
>  
>  ;; Read Floating-point Control Register.

Same here.

> -(define_insn "get_fpcr"
> -  [(set (match_operand:SI 0 "register_operand" "=r")
> -        (unspec_volatile:SI [(const_int 0)] UNSPECV_GET_FPCR))]
> -  ""
> -  "mrs\\t%0, fpcr"
> -  [(set_attr "type" "mrs")])
> -
> -;; Write Floating-point Status Register.
> -(define_insn "set_fpsr"
> -  [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 
> UNSPECV_SET_FPSR)]
> -  ""
> -  "msr\\tfpsr, %0"
> -  [(set_attr "type" "mrs")])
> -
> -;; Read Floating-point Status Register.
> -(define_insn "get_fpsr"
> -  [(set (match_operand:SI 0 "register_operand" "=r")
> -        (unspec_volatile:SI [(const_int 0)] UNSPECV_GET_FPSR))]
> +(define_insn "@aarch64_get_<fpscr_name><GPI:mode>"
> +  [(set (match_operand:GPI 0 "register_operand" "=r")
> +        (unspec_volatile:GPI [(const_int 0)] GET_FPSCR))]
>    ""
> -  "mrs\\t%0, fpsr"
> +  "mrs\\t%0, <fpscr_name>"
>    [(set_attr "type" "mrs")])
>  
> -
>  ;; Define the subtract-one-and-jump insns so loop.c
>  ;; knows what to generate.
>  (define_expand "doloop_end"
> diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
> index a568cf21b99d..9a5191689634 100644
> --- a/gcc/config/aarch64/iterators.md
> +++ b/gcc/config/aarch64/iterators.md
> @@ -3453,3 +3453,17 @@
>  
>  (define_int_attr unspec [(UNSPEC_WHILERW "UNSPEC_WHILERW")
>                        (UNSPEC_WHILEWR "UNSPEC_WHILEWR")])
> +
> +;; Iterators and attributes for fpcr fpsr getter setters
> +
> +(define_int_iterator GET_FPSCR
> +  [UNSPECV_GET_FPSR UNSPECV_GET_FPCR])
> +
> +(define_int_iterator SET_FPSCR
> +  [UNSPECV_SET_FPSR UNSPECV_SET_FPCR])
> +
> +(define_int_attr fpscr_name
> +  [(UNSPECV_GET_FPSR "fpsr")
> +   (UNSPECV_SET_FPSR "fpsr")
> +   (UNSPECV_GET_FPCR "fpcr")
> +   (UNSPECV_SET_FPCR "fpcr")])
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 10dc32e6d2d4..29a6635ad134 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -13880,6 +13880,12 @@ unsigned int __builtin_aarch64_get_fpcr ()
>  void __builtin_aarch64_set_fpcr (unsigned int)
>  unsigned int __builtin_aarch64_get_fpsr ()
>  void __builtin_aarch64_set_fpsr (unsigned int)
> +
> +unsigned long long __builtin_aarch64_get_fpcr64 ()
> +void __builtin_aarch64_set_fpcr64 (unsigned long long)
> +unsigned long long __builtin_aarch64_get_fpsr64 ()
> +void __builtin_aarch64_set_fpsr64 (unsigned long long)
> +

Excess blank line.

>  @end smallexample
>  
>  @node Alpha Built-in Functions
> diff --git a/gcc/testsuite/gcc.target/aarch64/get_fpcr64.c 
> b/gcc/testsuite/gcc.target/aarch64/get_fpcr64.c

Very minor, but it's probably more future-proof to add _1 to the filenames
of the tests.

> new file mode 100644
> index 000000000000..9fed91fe2053
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/get_fpcr64.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +long long unsigned
> +get_fpcr64 ()
> +{
> +  return __builtin_aarch64_get_fpcr64 ();
> +}
> +
> +/* { dg-final { scan-assembler-times "mrs.*fpcr" 1 } } */

Probably safer as: {\tmrs\t[^\n]*fpcr}

(“.” matches newlines in this context.)

Although since the test is running at -O2, we should be able to rely on
x0 being chosen, so I think we should just use: {\tmrs\tx0, fpcr\n}

Same idea for the other tests.

OK with those changes, thanks.

Richard

Reply via email to