public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Michael Meissner <meissner@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/meissner/heads/work093)] Revert patch.
Date: Fri,  8 Jul 2022 20:09:58 +0000 (GMT)	[thread overview]
Message-ID: <20220708200958.CBEC5384F016@sourceware.org> (raw)

https://gcc.gnu.org/g:48c6fae5b924e12954298b948033d4baa84c8e89

commit 48c6fae5b924e12954298b948033d4baa84c8e89
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Fri Jul 8 16:09:28 2022 -0400

    Revert patch.
    
    Rework setting 128-bit complex multiply and divide.
    
    2022-07-08   Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            Revert patch.
            * config/rs6000/rs600.cc (create_complex_muldiv_inner): New
            function.
            (create_complex_muldiv): Rewrite function to handle both multiply
            and divide.  Set the decl assembler name to change the name to the
            external function.
    
    gcc/testsuite/
    
            Revert patch.
            * gcc.target/powerpc/mulkc3-2.c: Revert patch #7.
            * gcc.target/powerpc/divkc3-2.c: Likewise.
    
    libgcc/
    
            Revert patch.
            * config/rs6000/float128-ifunc.c: Revert patch #7.
            * config/rs6000/quad-float128.h: Likewise.

Diff:
---
 gcc/config/rs6000/rs6000.cc                 | 160 +++++++++-------------------
 gcc/testsuite/gcc.target/powerpc/divkc3-2.c |   2 +-
 gcc/testsuite/gcc.target/powerpc/mulkc3-2.c |   2 +-
 libgcc/config/rs6000/float128-ifunc.c       |   6 ++
 libgcc/config/rs6000/quad-float128.h        |   5 +
 5 files changed, 61 insertions(+), 114 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 9017f9c4876..541b4679907 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -11031,6 +11031,26 @@ init_float128_ibm (machine_mode mode)
     }
 }
 
+/* Create a decl for either complex long double multiply or complex long double
+   divide when long double is IEEE 128-bit floating point.  We can't use
+   __multc3 and __divtc3 because the original long double using IBM extended
+   double used those names.  The complex multiply/divide functions are encoded
+   as builtin functions with a complex result and 4 scalar inputs.  */
+
+static void
+create_complex_muldiv (const char *name, built_in_function fncode, tree fntype)
+{
+  tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL,
+				      name, NULL_TREE);
+
+  set_builtin_decl (fncode, fndecl, true);
+
+  if (TARGET_DEBUG_BUILTIN)
+    fprintf (stderr, "create complex %s, fncode: %d\n", name, (int) fncode);
+
+  return;
+}
+
 /* Set up IEEE 128-bit floating point routines.  Use different names if the
    arguments can be passed in a vector register.  The historical PowerPC
    implementation of IEEE 128-bit floating point used _q_<op> for the names, so
@@ -11126,107 +11146,6 @@ init_float128_ieee (machine_mode mode)
     }
 }
 
-/* Create a decls for complex long double multiply and complex long double
-   divide for the 128-bit floating point types.
-
-   When long double is IEEE 128-bit floating point, we can't use __multc3 and
-   __divtc3 because the original long double using IBM extended double used
-   those names.
-
-   Similarly for __ibm128, we want to use __multc3 and __divtc3.
-
-   For these cases, we create a decl with a different name, and then set the
-   ASM name so that we don't have to change libgcc to provide these extra
-   names.  We can't just use the same name because we will get an abort if a
-   built-in function uses the same name.
-
-   The complex multiply/divide functions are encoded as builtin functions with
-   a complex result and 4 scalar inputs.  */
-
-/* Inner function to create a single complex multiply or complex divide
-   function.
-
-   Mul_or_div is either "mul" or "div" depending on whether we are creating
-   multiply or divide.
-
-   Lib_mode_name is "ic", "kc", or "tc" (i.e. the 2 letter mode for the complex
-   type being created).
-
-   Asm_mode_name is "kc" or "tc" (i.e. the 2 letter mode for the function that
-   will be called).
-
-   Fncode is the function code of the multiply/divide built-in function.
-
-   Fntype is the tree type node of the function.  */
-
-static void
-create_complex_muldiv_inner (const char *mul_or_div,
-			     const char *lib_mode_name,
-			     const char *asm_mode_name,
-			     built_in_function fncode,
-			     tree fntype)
-{
-  char *asm_name = ACONCAT (("__", mul_or_div, asm_mode_name, "3", NULL));
-  char *name = ACONCAT (("__", mul_or_div, lib_mode_name, "3_", asm_mode_name,
-			 NULL));
-
-  tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL,
-				      asm_name, NULL_TREE);
-
-  set_builtin_decl (fncode, fndecl, true);
-
-  if (1 || TARGET_DEBUG_BUILTIN)
-    fprintf (stderr, "create complex %s (%s), fncode: %d\n", name, asm_name,
-	     (int) fncode);
-
-  return;
-}
-
-/* Create both complex multiply and complex divide for a given 128-bit floating
-   point type.
-
-   Lib_mode_name is "ic", "kc", or "tc" (i.e. the 2 letter mode for the complex
-   type being created).
-
-   Asm_mode_name is "kc" or "tc" (i.e. the 2 letter mode for the function that
-   will be called).
-
-   Complex_mode is the mode of the complex type (i.e. KCmode, ICmode, or
-   TCmode).
-
-   Arg_type is the type of scalar 128-bit floating point type (i.e. the
-   _Float128, __ibm128, or long double type nodes).  */
-
-static void
-create_complex_muldiv (const char *lib_mode_name,
-		       const char *asm_mode_name,
-		       machine_mode complex_mode,
-		       tree arg_type)
-{
-  tree complex_type = (arg_type == long_double_type_node
-		       ? complex_long_double_type_node
-		       : build_complex_type (arg_type));
-  tree fntype = build_function_type_list (complex_type, arg_type, arg_type,
-					  arg_type, arg_type, NULL_TREE);
-
-  /* Build complex multiply.  */
-  built_in_function mul_fncode =
-    (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + complex_mode
-			 - MIN_MODE_COMPLEX_FLOAT);
-
-  create_complex_muldiv_inner ("mul", lib_mode_name, asm_mode_name, mul_fncode,
-			       fntype);
-
-  /* Build complex divide.  */
-  built_in_function div_fncode =
-    (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + complex_mode
-			 - MIN_MODE_COMPLEX_FLOAT);
-
-  create_complex_muldiv_inner ("div", lib_mode_name, asm_mode_name, div_fncode,
-			       fntype);
-  return;
-}
-
 static void
 rs6000_init_libfuncs (void)
 {
@@ -11249,27 +11168,44 @@ rs6000_init_libfuncs (void)
 	init_float128_ieee (TFmode);
     }
 
-  /* Set up to call the appropriate __mul{kc,tc}3 and __div{kc,tc}3 for the
-     128-bit floating point types, using kc3 for IEEE 128-bit and tc3 for IBM
-     128-bit.  We only call this for the functions that don't use the default
-     names.
+  /* Set up to call __mulkc3 and __divkc3 when long double uses the IEEE
+     128-bit encoding.  We cannot use the same name (__mulkc3 or __divkc3 for
+     both IEEE long double and for explicit _Float128/__float128) because
+     c_builtin_function will complain if we create two built-in functions with
+     the same name.  Instead we use an alias name for the case when long double
+     uses the IEEE 128-bit encoding.  Libgcc will create a weak alias reference
+     for this name.
 
      We need to only execute this once.  If we have clone or target attributes,
      this will be called a second time.  We need to create the built-in
      function only once.  */
   static bool complex_muldiv_init_p = false;
 
-  if (!complex_muldiv_init_p
-      && (TARGET_FLOAT128_TYPE || TARGET_LONG_DOUBLE_128))
+  if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128
+      && !complex_muldiv_init_p)
     {
       complex_muldiv_init_p = true;
 
-      /* Create __ibm128 complex multiply divide.  */
-      create_complex_muldiv ("ic", "tc", ICmode, ibm128_float_type_node);
+      tree fntype = build_function_type_list (complex_long_double_type_node,
+					      long_double_type_node,
+					      long_double_type_node,
+					      long_double_type_node,
+					      long_double_type_node,
+					      NULL_TREE);
+
+      /* Create complex multiply.  */
+      built_in_function mul_fncode =
+	(built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + TCmode
+			     - MIN_MODE_COMPLEX_FLOAT);
+
+      create_complex_muldiv ("__multc3_ieee128", mul_fncode, fntype);
+
+      /* Create complex divide.  */
+      built_in_function div_fncode =
+	(built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + TCmode
+			     - MIN_MODE_COMPLEX_FLOAT);
 
-      if (TARGET_LONG_DOUBLE_128 && TARGET_IEEEQUAD)
-	/* Create long double (IEEE 128-bit) complex multiply/divide.  */
-	create_complex_muldiv ("tc", "kc", TCmode, long_double_type_node);
+      create_complex_muldiv ("__divtc3_ieee128", div_fncode, fntype);
     }
 }
 
diff --git a/gcc/testsuite/gcc.target/powerpc/divkc3-2.c b/gcc/testsuite/gcc.target/powerpc/divkc3-2.c
index e34ed40bac2..0cfcea837ed 100644
--- a/gcc/testsuite/gcc.target/powerpc/divkc3-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/divkc3-2.c
@@ -14,4 +14,4 @@ divide (cld_t *p, cld_t *q, cld_t *r)
   *p = *q / *r;
 }
 
-/* { dg-final { scan-assembler "bl __divkc3" } } */
+/* { dg-final { scan-assembler "bl __divtc3_ieee128" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c b/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c
index eee6de9e2a5..78ef1dc00f0 100644
--- a/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c
@@ -14,4 +14,4 @@ multiply (cld_t *p, cld_t *q, cld_t *r)
   *p = *q * *r;
 }
 
-/* { dg-final { scan-assembler "bl __mulkc3" } } */
+/* { dg-final { scan-assembler "bl __multc3_ieee128" } } */
diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c
index 73cbca2fc9a..30d46bcb233 100644
--- a/libgcc/config/rs6000/float128-ifunc.c
+++ b/libgcc/config/rs6000/float128-ifunc.c
@@ -359,3 +359,9 @@ TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype)
 
 TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype)
   __attribute__ ((__ifunc__ ("__divkc3_resolve")));
+
+TCtype __multc3_ieee128 (TFtype, TFtype, TFtype, TFtype)
+  __attribute__ ((__ifunc__ ("__mulkc3_resolve")));
+
+TCtype __divtc3_ieee128 (TFtype, TFtype, TFtype, TFtype)
+  __attribute__ ((__ifunc__ ("__divkc3_resolve")));
diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h
index ae0622c744c..a684d0e1bcf 100644
--- a/libgcc/config/rs6000/quad-float128.h
+++ b/libgcc/config/rs6000/quad-float128.h
@@ -191,6 +191,11 @@ extern TFtype __trunctfkf2 (IBM128_TYPE);
 extern TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype);
 extern TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype);
 
+/* Complex long double multiply/divide if long double uses the IEEE 128-bit
+   encoding.  */
+extern TCtype __multc3_ieee128 (TFtype, TFtype, TFtype, TFtype);
+extern TCtype __divtc3_ieee128 (TFtype, TFtype, TFtype, TFtype);
+
 /* Convert IEEE 128-bit floating point to/from string.  We explicitly use
    _Float128 instead of TFmode because _strtokf and _strfromkf must be compiled
    with long double being IBM 128.  */


             reply	other threads:[~2022-07-08 20:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08 20:09 Michael Meissner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-08 20:41 Michael Meissner
2022-07-08 20:18 Michael Meissner
2022-07-07 20:14 Michael Meissner
2022-07-06 22:04 Michael Meissner
2022-07-01  7:09 Michael Meissner
2022-07-01  6:33 Michael Meissner
2022-06-30 20:25 Michael Meissner
2022-06-30 18:34 Michael Meissner

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=20220708200958.CBEC5384F016@sourceware.org \
    --to=meissner@gcc.gnu.org \
    --cc=gcc-cvs@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).