public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
@ 2020-02-04  2:26 ` Bill Schmidt
  2020-02-04 18:27   ` Segher Boessenkool
  2020-02-04  2:26 ` [PATCH 02/14] Add stubs for input files. These will grow much larger Bill Schmidt
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

Includes header documentation and initial set of include directives.

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c: New file.
---
 gcc/config/rs6000/rs6000-genbif.c | 124 ++++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100644 gcc/config/rs6000/rs6000-genbif.c

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
new file mode 100644
index 00000000000..a53209ed040
--- /dev/null
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -0,0 +1,124 @@
+/* Generate built-in function initialization and recognition for Power.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Bill Schmidt, IBM <wschmidt@linux.ibm.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* This program generates built-in function initialization and
+   recognition code for Power targets, based on text files that
+   describe the built-in functions and vector overloads:
+
+     rs6000-bif.def       Table of built-in functions
+     rs6000-overload.def  Table of overload functions
+
+   Both files group similar functions together in "stanzas," as
+   described below.
+
+   Each stanza in the built-in function file starts with a line
+   identifying the target mask for which the group of functions is
+   permitted, with the mask in square brackets.  This is the only
+   information allowed on the stanza header line, other than
+   whitespace.  Following the stanza header are two lines for each
+   function: the prototype line and the attributes line.  The
+   prototype line has this format, where the square brackets
+   indicate optional information and angle brackets indicate
+   required information:
+
+     [kind] <return-type> <bif-name> (<argument-list>);
+
+   Here [kind] can be one of "const", "pure", or "math";
+   <return-type> is a legal type for a built-in function result;
+   <bif-name> is the name by which the function can be called;
+   and <argument-list> is a comma-separated list of legal types
+   for built-in function arguments.  The argument list may be
+   empty, but the parentheses and semicolon are required.
+
+   The attributes line looks like this:
+
+     <bif-id> <bif-pattern> {<attribute-list>}
+
+   Here <bif-id> is a unique internal identifier for the built-in
+   function that will be used as part of an enumeration of all
+   built-in functions; <bif-pattern> is the define_expand or
+   define_insn that will be invoked when the call is expanded;
+   and <attribute-list> is a comma-separated list of special
+   conditions that apply to the built-in function.  The attribute
+   list may be empty, but the braces are required.
+
+   Attributes are strings, such as these:
+
+     init    Process as a vec_init function
+     set     Process as a vec_set function
+     ext     Process as a vec_extract function
+     nosoft  Not valid with -msoft-float
+     ldv     Needs special handling for vec_ld semantics
+     stv     Needs special handling for vec_st semantics
+     reve    Needs special handling for element reversal
+     abs     Needs special handling for absolute value
+     pred    Needs special handling for comparison predicates
+     htm     Needs special handling for transactional memory
+
+   An example stanza might look like this:
+
+[TARGET_ALTIVEC]
+  const vector signed char __builtin_altivec_abs_v16qi (vector signed char);
+    ABS_V16QI absv16qi2 {abs}
+  const vector signed short __builtin_altivec_abs_v8hi (vector signed short);
+    ABS_V8HI absv8hi2 {abs}
+
+   Note the use of indentation, which is recommended but not required.
+
+   The overload file has more complex stanza headers.  Here the stanza
+   represents all functions with the same overloaded function name:
+
+     [<overload-id>, <external-name>, <internal-name>]
+
+   Here the square brackets are part of the syntax, <overload-id> is a
+   unique internal identifier for the overload that will be used as part
+   of an enumeration of all overloaded functions; <external-name> is the
+   name that will appear as a #define in altivec.h; and <internal-name>
+   is the name that is overloaded in the back end.
+
+   Each function entry again has two lines.  The first line is again a
+   prototype line (this time without [kind]):
+
+     <return-type> <internal-name> (<argument-list>);
+
+   The second line contains only one token: the <bif-id> that this
+   particular instance of the overloaded function maps to.  It must
+   match a token that appears in the bif file.
+
+   An example stanza might look like this:
+
+[VEC_ABS, vec_abs, __builtin_vec_abs]
+  vector signed char __builtin_vec_abs (vector signed char);
+    ABS_V16QI
+  vector signed short __builtin_vec_abs (vector signed short);
+    ABS_V8HI
+
+  Blank lines may be used as desired in these files.  If it's desirable,
+  C-style comments are allowable provided that the file is run through
+  the preprocessor by the build system prior to feeding it to this
+  program.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 02/14] Add stubs for input files.  These will grow much larger.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
  2020-02-04  2:26 ` [PATCH 01/14] Initial create of rs6000-genbif.c Bill Schmidt
@ 2020-02-04  2:26 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 06/14] Red-black tree implementation for balanced tree search Bill Schmidt
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

This patch adds a subset of the builtin and overload descriptions.
I've also started annotating the old-style descriptions in rs6000-c.c
where I'm deliberately not planning to support new versions of them.
We may have to have some discussion around these at some point, but
this helps me track this as I move through the transition.

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-bif.def: New file.
        * config/rs6000/rs6000-call.c (altivec_overloaded_builtins):
	Annotate some deprecated and bogus entries.
        * config/rs6000/rs6000-overload.def: New file.
---
 gcc/config/rs6000/rs6000-bif.def      | 187 ++++++++++++++++++++++++++
 gcc/config/rs6000/rs6000-call.c       |  35 +++++
 gcc/config/rs6000/rs6000-overload.def |   5 +
 3 files changed, 227 insertions(+)
 create mode 100644 gcc/config/rs6000/rs6000-bif.def
 create mode 100644 gcc/config/rs6000/rs6000-overload.def

diff --git a/gcc/config/rs6000/rs6000-bif.def b/gcc/config/rs6000/rs6000-bif.def
new file mode 100644
index 00000000000..85196400993
--- /dev/null
+++ b/gcc/config/rs6000/rs6000-bif.def
@@ -0,0 +1,187 @@
+[TARGET_ALTIVEC]
+  math vf __builtin_altivec_vmaddfp (vf, vf, vf);
+    VMADDFP fmav4sf4 {}
+  vss __builtin_altivec_vmhaddshs (vss, vss, vss);
+    VMHADDSHS altivec_vmhaddshs {}
+  vss __builtin_altivec_vmhraddshs (vss, vss, vss);
+    VMHRADDSHS altivec_vmhraddshs {}
+  const vss __builtin_altivec_vmladduhm (vss, vss, vss);
+    VMLADDUHM fmav8hi4 {}
+  const vui __builtin_altivec_vmsumubm (vuc, vuc, vui);
+    VMSUMUBM altivec_vmsumubm {}
+  const vsi __builtin_altivec_vmsummbm (vsc, vuc, vsi);
+    VMSUMMBM altivec_vmsummbm {}
+  const vui __builtin_altivec_vmsumuhm (vus, vus, vui);
+    VMSUMUHM altivec_vmsumuhm {}
+  const vsi __builtin_altivec_vmsumshm (vss, vss, vsi);
+    VMSUMSHM altivec_vmsumshm {}
+  vui __builtin_altivec_vmsumuhs (vus, vus, vui);
+    VMSUMUHS altivec_vmsumuhs {}
+  vsi __builtin_altivec_vmsumshs (vss, vss, vsi);
+    VMSUMSHS altivec_vmsumshs {}
+  math vf __builtin_altivec_vnmsubfp (vf, vf, vf);
+    VNMSUBFP nfmsv4sf4 {}
+  const vsq __builtin_altivec_vperm_1ti (vsq, vsq, vuc);
+    VPERM_1TI altivec_vperm_v1ti {}
+  const vf __builtin_altivec_vperm_4sf (vf, vf, vuc);
+    VPERM_4SF altivec_vperm_v4sf {}
+  const vsi __builtin_altivec_vperm_4si (vsi, vsi, vuc);
+    VPERM_4SI altivec_vperm_v4si {}
+  const vss __builtin_altivec_vperm_8hi (vss, vss, vuc);
+    VPERM_8HI altivec_vperm_v8hi {}
+  const vsc __builtin_altivec_vperm_16qi (vsc, vsc, vuc);
+    VPERM_16QI altivec_vperm_v16qi {}
+  const vuq __builtin_altivec_vperm_1ti_uns (vuq, vuq, vuc);
+    VPERM_1TI_UNS altivec_vperm_v1ti_uns {}
+  const vui __builtin_altivec_vperm_4si_uns (vui, vui, vuc);
+    VPERM_4SI_UNS altivec_vperm_v4si_uns {}
+  const vus __builtin_altivec_vperm_8hi_uns (vus, vus, vuc);
+    VPERM_8HI_UNS altivec_vperm_v8hi_uns {}
+  const vuc __builtin_altivec_vperm_16qi_uns (vuc, vuc, vuc);
+    VPERM_16QI_UNS altivec_vperm_v16qi_uns {}
+  const vf __builtin_altivec_vsel_4sf (vf, vf, vbi);
+    VSEL_4SF_B vector_select_v4sf {}
+  const vf __builtin_altivec_vsel_4sf (vf, vf, vui);
+    VSEL_4SF_U vector_select_v4sf {}
+  const vsi __builtin_altivec_vsel_4si (vsi, vsi, vbi);
+    VSEL_4SI_B vector_select_v4si {}
+  const vsi __builtin_altivec_vsel_4si (vsi, vsi, vui);
+    VSEL_4SI_U vector_select_v4si {}
+  const vui __builtin_altivec_vsel_4si (vui, vui, vbi);
+    VSEL_4SI_UB vector_select_v4si {}
+  const vui __builtin_altivec_vsel_4si (vui, vui, vui);
+    VSEL_4SI_UU vector_select_v4si {}
+  const vbi __builtin_altivec_vsel_4si (vbi, vbi, vbi);
+    VSEL_4SI_BB vector_select_v4si {}
+  const vbi __builtin_altivec_vsel_4si (vbi, vbi, vui);
+    VSEL_4SI_BU vector_select_v4si {}
+  const vss __builtin_altivec_vsel_8hi (vss, vss, vbs);
+    VSEL_8HI_B vector_select_v8hi {}
+  const vss __builtin_altivec_vsel_8hi (vss, vss, vus);
+    VSEL_8HI_U vector_select_v8hi {}
+  const vus __builtin_altivec_vsel_8hi (vus, vus, vbs);
+    VSEL_8HI_UB vector_select_v8hi {}
+  const vus __builtin_altivec_vsel_8hi (vus, vus, vus);
+    VSEL_8HI_UU vector_select_v8hi {}
+  const vbs __builtin_altivec_vsel_8hi (vbs, vbs, vbs);
+    VSEL_8HI_BB vector_select_v8hi {}
+  const vbs __builtin_altivec_vsel_8hi (vbs, vbs, vus);
+    VSEL_8HI_BU vector_select_v8hi {}
+  const vsc __builtin_altivec_vsel_16qi (vsc, vsc, vbc);
+    VSEL_16QI_B vector_select_v16qi {}
+  const vsc __builtin_altivec_vsel_16qi (vsc, vsc, vuc);
+    VSEL_16QI_U vector_select_v16qi {}
+  const vuc __builtin_altivec_vsel_16qi (vuc, vuc, vbc);
+    VSEL_16QI_UB vector_select_v16qi {}
+  const vuc __builtin_altivec_vsel_16qi (vuc, vuc, vuc);
+    VSEL_16QI_UU vector_select_v16qi {}
+  const vbc __builtin_altivec_vsel_16qi (vbc, vbc, vbc);
+    VSEL_16QI_BB vector_select_v16qi {}
+  const vbc __builtin_altivec_vsel_16qi (vbc, vbc, vuc);
+    VSEL_16QI_BU vector_select_v16qi {}
+  const vsq __builtin_altivec_vsel_1ti (vsq, vsq, vuq);
+    VSEL_1TI vector_select_v1ti {}
+  const vui __builtin_altivec_vsel_4si_uns (vui, vui, vui);
+    VSEL_4SI_UNS vector_select_v4si_uns {}
+  const vus __builtin_altivec_vsel_8hi_uns (vus, vus, vus);
+    VSEL_8HI_UNS vector_select_v8hi_uns {}
+  const vuc __builtin_altivec_vsel_16qi_uns (vuc, vuc, vuc);
+    VSEL_16QI_UNS vector_select_v16qi_uns {}
+  const vsc __builtin_altivec_vsldoi_16qi (vsc, vsc, const int<4>);
+    VSLDOI_16QI altivec_vsldoi_v16qi {}
+  const vuc __builtin_altivec_vsldoi_16qi (vuc, vuc, const int<4>);
+    VSLDOI_16QI_U altivec_vsldoi_v16qi {}
+  const vbc __builtin_altivec_vsldoi_16qi (vbc, vbc, const int<4>);
+    VSLDOI_16QI_B altivec_vsldoi_v16qi {}
+  const vss __builtin_altivec_vsldoi_8hi (vss, vss, const int<4>);
+    VSLDOI_8HI altivec_vsldoi_v8hi {}
+  const vus __builtin_altivec_vsldoi_8hi (vus, vus, const int<4>);
+    VSLDOI_8HI_U altivec_vsldoi_v8hi {}
+  const vbs __builtin_altivec_vsldoi_8hi (vbs, vbs, const int<4>);
+    VSLDOI_8HI_B altivec_vsldoi_v8hi {}
+  const vp __builtin_altivec_vsldoi_8hi (vp, vp, const int<4>);
+    VSLDOI_8HI_P altivec_vsldoi_v8hi {}
+  const vsi __builtin_altivec_vsldoi_4si (vsi, vsi, const int<4>);
+    VSLDOI_4SI altivec_vsldoi_v4si {}
+  const vui __builtin_altivec_vsldoi_4si (vui, vui, const int<4>);
+    VSLDOI_4SI_U altivec_vsldoi_v4si {}
+  const vbi __builtin_altivec_vsldoi_4si (vbi, vbi, const int<4>);
+    VSLDOI_4SI_B altivec_vsldoi_v4si {}
+  const vuq __builtin_altivec_vsel_1ti_uns (vuq, vuq, vuq);
+    VSEL_1TI_UNS vector_select_v1ti_uns {}
+  const vf __builtin_altivec_vsldoi_4sf (vf, vf, const int<4>);
+    VSLDOI_4SF altivec_vsldoi_v4sf {}
+  void __builtin_altivec_dst (void *, const int, const int<2>);
+    DST altivec_dst {}
+  void __builtin_altivec_dstt (void *, const int, const int<2>);
+    DSTT altivec_dstt {}
+  void __builtin_altivec_dstst (void *, const int, const int<2>);
+    DSTST altivec_dstst {}
+  void __builtin_altivec_dststt (void *, const int, const int<2>);
+    DSTSTT altivec_dststt {}
+  const vsc __builtin_altivec_vaddubm (vsc, vsc);
+    VADDUBM addv16qi3 {}
+  const vuc __builtin_altivec_vaddubm (vuc, vuc);
+    VADDUBM_U addv16qi3 {}
+  const vss __builtin_altivec_vadduhm (vss, vss);
+    VADDUHM addv8hi3 {}
+  const vus __builtin_altivec_vadduhm (vus, vus);
+    VADDUHM_U addv8hi3 {}
+  const vsi __builtin_altivec_vadduwm (vsi, vsi);
+    VADDUWM addv4si3 {}
+  const vui __builtin_altivec_vadduwm (vui, vui);
+    VADDUWM_U addv4si3 {}
+  const vf __builtin_altivec_vaddfp (vf, vf);
+    VADDFP addv4sf3 {}
+  const vsi __builtin_altivec_vaddcuw (vsi, vsi);
+    VADDCUW altivec_vaddcuw {}
+  const vui __builtin_altivec_vaddcuw (vui, vui);
+    VADDCUW_U altivec_vaddcuw {}
+  const vuc __builtin_altivec_vaddubs (vuc, vuc);
+    VADDUBS altivec_vaddubs {}
+  const vsc __builtin_altivec_vaddsbs (vsc, vsc);
+    VADDSBS altivec_vaddsbs {}
+  const vus __builtin_altivec_vadduhs (vus, vus);
+    VADDUHS altivec_vadduhs {}
+  const vss __builtin_altivec_vaddshs (vss, vss);
+    VADDSHS altivec_vaddshs {}
+  const vui __builtin_altivec_vadduws (vui, vui);
+    VADDUWS altivec_vadduws {}
+  const vsi __builtin_altivec_vaddsws (vsi, vsi);
+    VADDSWS altivec_vaddsws {}
+  const vbc __builtin_altivec_vand_v16qi_uns (vbc, vbc);
+    VAND_V16QI_UNS_B andv16qi3 {}
+  const vuc __builtin_altivec_vand_v16qi_uns (vuc, vuc);
+    VAND_V16QI_UNS andv16qi3 {}
+  const vbc __builtin_altivec_vand_v16qi (vbc, vbc);
+    VAND_V16QI_B andv16qi3 {}
+  const vsc __builtin_altivec_vand_v16qi (vsc, vsc);
+    VAND_V16QI andv16qi3 {}
+  const vsc __builtin_altivec_abs_v16qi (vsc);
+    ABS_V16QI absv16qi2 {abs}
+  const vss __builtin_altivec_abs_v8hi (vss);
+    ABS_V8HI absv8hi2 {abs}
+
+[VSX]
+  const vd __builtin_altivec_vperm_2df (vd, vd, vuc);
+    VPERM_2DF altivec_vperm_v2df {}
+  const vsll __builtin_altivec_vperm_2di (vsll, vsll, vuc);
+    VPERM_2DI altivec_vperm_v2di {}
+  const vull __builtin_altivec_vperm_2di_uns (vull, vull, vuc);
+    VPERM_2DI_UNS altivec_vperm_v2di_uns {}
+  const vd __builtin_altivec_vsel_2df (vd, vd, vbll);
+    VSEL_2DF_B vector_select_v2df {}
+  const vd __builtin_altivec_vsel_2df (vd, vd, vull);
+    VSEL_2DF_U vector_select_v2df {}
+  const vsll __builtin_altivec_vsel_2di (vsll, vsll, vsll, vbll);
+    VSEL_2DI_B vector_select_v2di {}
+  const vull __builtin_altivec_vsel_2di_uns (vull, vull, vull);
+    VSEL_2DI_UNS vector_select_v2di_uns {}
+  const vsll __builtin_altivec_vsldoi_2di (vsll, vsll, const int<4>);
+    VSLDOI_2DI altivec_vsldoi_v2di {}
+  const vull __builtin_altivec_vsldoi_2di (vull, vull, const int<4>);
+    VSLDOI_2DI_U altivec_vsldoi_v2di {}
+  const vbll __builtin_altivec_vsldoi_2di (vbll, vbll, const int<4>);
+    VSLDOI_2DI_B altivec_vsldoi_v2di {}
+  const vd __builtin_altivec_vsldoi_2df (vd, vd, const int<4>);
+    VSLDOI_2DF altivec_vsldoi_v2df {}
diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 59060647431..57b0e07898e 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -429,36 +429,42 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
 
   /* Binary AltiVec/VSX builtins.  */
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
@@ -490,12 +496,14 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
+  /* Next 4 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
     RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWM, ALTIVEC_BUILTIN_VADDUWM,
@@ -506,12 +514,14 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+  /* Next 4 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
     RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHM, ALTIVEC_BUILTIN_VADDUHM,
@@ -522,12 +532,14 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+  /* Next 24 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
     RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBM, ALTIVEC_BUILTIN_VADDUBM,
@@ -551,18 +563,21 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_unsigned_V1TI, RS6000_BTI_unsigned_V1TI },
   { ALTIVEC_BUILTIN_VEC_ADDEC, P8V_BUILTIN_VADDECUQ,
     RS6000_BTI_V1TI, RS6000_BTI_V1TI, RS6000_BTI_V1TI, RS6000_BTI_V1TI },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUHS,
@@ -571,10 +586,12 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDUWS,
@@ -583,54 +600,64 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_ADDS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSWS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDSWS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSWS, ALTIVEC_BUILTIN_VADDSWS,
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUWS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUWS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUWS, ALTIVEC_BUILTIN_VADDUWS,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSHS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDSHS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSHS, ALTIVEC_BUILTIN_VADDSHS,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUHS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUHS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUHS, ALTIVEC_BUILTIN_VADDUHS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSBS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDSBS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDSBS, ALTIVEC_BUILTIN_VADDSBS,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUBS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_VADDUBS, ALTIVEC_BUILTIN_VADDUBS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_VADDUBS, ALTIVEC_BUILTIN_VADDUBS,
@@ -684,20 +711,24 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V8HI,
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V8HI_UNS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V8HI_UNS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V8HI_UNS,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+  /* Next one deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI,
     RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI_UNS,
     RS6000_BTI_bool_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_bool_V16QI, 0 },
+  /* Next one deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI,
     RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+  /* Next 2 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI_UNS,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
   { ALTIVEC_BUILTIN_VEC_AND, ALTIVEC_BUILTIN_VAND_V16QI_UNS,
@@ -3145,6 +3176,7 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_bool_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DF,
     RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_unsigned_V2DI },
+  /* Next 2 appear bogus, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DF,
     RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DF,
@@ -3153,12 +3185,14 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
     RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI },
+  /* Next 1 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
     RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
     RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
     RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI },
+  /* Next 1 deprecated, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
     RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_V2DI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_2DI,
@@ -3171,6 +3205,7 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_bool_V4SI },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_4SF,
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_unsigned_V4SI },
+  /* Next 2 appear bogues, not in rs6000-bif.def.  */
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_4SI,
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF },
   { ALTIVEC_BUILTIN_VEC_SEL, ALTIVEC_BUILTIN_VSEL_4SI,
diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def
new file mode 100644
index 00000000000..e3149d661fa
--- /dev/null
+++ b/gcc/config/rs6000/rs6000-overload.def
@@ -0,0 +1,5 @@
+[VEC_ABS, vec_abs, __builtin_vec_abs]
+  vsc __builtin_vec_abs (vsc);
+    ABS_V16QI
+  vss __builtin_vec_abs (vss);
+    ABS_V8HI
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 00/14] rs6000: Begin replacing built-in support
@ 2020-02-04  2:26 Bill Schmidt
  2020-02-04  2:26 ` [PATCH 01/14] Initial create of rs6000-genbif.c Bill Schmidt
                   ` (14 more replies)
  0 siblings, 15 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

The current built-in support in the rs6000 back end requires at least
a master's degree in spelunking to comprehend.  It's full of cruft,
redundancy, and unused bits of code, and long overdue for a
replacement.  This is the first part of my project to do that.

My intent is to make adding new built-in functions as simple as adding
a few lines to a couple of files, and automatically generating as much
of the initialization, overload resolution, and expansion logic as
possible.  This patch series establishes the format of the input files
and creates a new program (rs6000-genbif) to:

 * Parse the input files into an internal representation;
 * Generate a file of #defines (rs6000-vecdefines.h) for eventual
   inclusion into altivec.h; and
 * Generate an initialization file to create and initialize tables of
   built-in functions and overloads.

Note that none of the code in this patch set affects GCC's operation
at all, with the exception of patch #14.  Patch 14 causes the program
rs6000-genbif to be built and executed, producing the output files,
and linking rs6000-bif.o into the executable.  However, none of the
code in rs6000-bif.o is called, so the only effect is to make the gcc
executable larger.

I'd like to consider at least patches 1-13 as stage 4 material for the
current release.  I'd prefer to also include patch 14 for convenience,
but I understand if that's not deemed acceptable.

I've attempted to break this up into logical pieces for easy
consumption, but some of the patches may still be a bit large.  Please
let me know if you'd like me to break any of them up.

Thanks in advance for the review!

Bill Schmidt (14):
  Initial create of rs6000-genbif.c.
  Add stubs for input files.  These will grow much larger.
  Add file support and functions for diagnostic support.
  Support functions to parse whitespace, lines, identifiers, integers.
  Add support functions for matching types.
  Red-black tree implementation for balanced tree search.
  Add main function with stub functions for parsing and output.
  Add support for parsing rs6000-bif.def.
  Add parsing support for rs6000-overload.def.
  Build function type identifiers and store them.
  Write #defines to rs6000-vecdefines.h.
  Write code to rs6000-bif.h.
  Write code to rs6000-bif.c.
  Incorporate new code into the build machinery.

 gcc/config.gcc                        |    3 +-
 gcc/config/rs6000/rbtree.c            |  233 +++
 gcc/config/rs6000/rbtree.h            |   51 +
 gcc/config/rs6000/rs6000-bif.def      |  187 ++
 gcc/config/rs6000/rs6000-call.c       |   35 +
 gcc/config/rs6000/rs6000-genbif.c     | 2295 +++++++++++++++++++++++++
 gcc/config/rs6000/rs6000-overload.def |    5 +
 gcc/config/rs6000/t-rs6000            |   22 +
 8 files changed, 2830 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/rs6000/rbtree.c
 create mode 100644 gcc/config/rs6000/rbtree.h
 create mode 100644 gcc/config/rs6000/rs6000-bif.def
 create mode 100644 gcc/config/rs6000/rs6000-genbif.c
 create mode 100644 gcc/config/rs6000/rs6000-overload.def

-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 13/14] Write code to rs6000-bif.c.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (11 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 10/14] Build function type identifiers and store them Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 12/14] Write code to rs6000-bif.h Bill Schmidt
  2020-02-04 17:40 ` [PATCH 00/14] rs6000: Begin replacing built-in support Segher Boessenkool
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (typemap): New struct.
        (TYPE_MAP_SIZE): New defined constant.
        (type_map): New	filescope variable.
        (write_fntype):	New callback function.
        (map_token_to_type_node): New function.
        (write_type_node): New function.
        (write_fntype_init): New function.
        (write_init_bif_table):	New function.
        (write_init_ovld_table): New function.
        (write_init_file): Implement.
---
 gcc/config/rs6000/rs6000-genbif.c | 367 ++++++++++++++++++++++++++++++
 1 file changed, 367 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index c84df1aa30f..ac640e14def 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -311,6 +311,52 @@ static rbt_strings bif_rbt;
 static rbt_strings ovld_rbt;
 static rbt_strings fntype_rbt;
 
+/* Mapping from type tokens to type node names.  */
+struct typemap
+{
+  const char *key;
+  const char *value;
+};
+
+/* This table must be kept in alphabetical order, as we use binary
+   search for table lookups in map_token_to_type_node.  */
+#define TYPE_MAP_SIZE 32
+static typemap type_map[TYPE_MAP_SIZE] =
+  {
+    { "df",	"double" },
+    { "di",	"intDI" },
+    { "hi",	"intHI" },
+    { "pv",	"ptr" },
+    { "qi",	"intQI" },
+    { "sf",	"float" },
+    { "si",	"intSI" },
+    { "tf",	"long_double" },
+    { "ti",	"intTI" },
+    { "udi",	"unsigned_intDI" },
+    { "uhi",	"unsigned_intHI" },
+    { "uqi",	"unsigned_intQI" },
+    { "usi",	"unsigned_intSI" },
+    { "uti",	"unsigned_intTI" },
+    { "uv16qi",	"unsigned_V16QI" },
+    { "uv1ti",	"unsigned_V1TI" },
+    { "uv2di",	"unsigned_V2DI" },
+    { "uv4si",	"unsigned_V4SI" },
+    { "uv8hi",	"unsigned_V8HI" },
+    { "v",	"void" },
+    { "v16qi",	"V16QI" },
+    { "v1ti",	"V1TI" },
+    { "v2df",	"V2DF" },
+    { "v2di",	"V2DI" },
+    { "v4sf",	"V4SF" },
+    { "v4si",	"V4SI" },
+    { "v8hi",	"V8HI" },
+    { "vb16qi",	"bool_V16QI" },
+    { "vb2di",	"bool_V2DI" },
+    { "vb4si",	"bool_V4SI" },
+    { "vb8hi",	"bool_V8HI" },
+    { "vp8hi",	"pixel_V8HI" },
+  };
+
 /* Pointer to a diagnostic function.  */
 void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
   = NULL;
@@ -1761,6 +1807,80 @@ write_extern_fntype (char *str)
   fprintf (header_file, "extern tree %s;\n", str);
 }
 
+void
+write_fntype (char *str)
+{
+  fprintf (init_file, "tree %s;\n", str);
+}
+
+/* Look up TOK in the type map and return the corresponding string used
+   to build the type node.  */
+static const char *
+map_token_to_type_node (char *tok)
+{
+  int low = 0;
+  int high = TYPE_MAP_SIZE - 1;
+  int mid = (low + high) >> 1;
+  int cmp;
+
+  while ((cmp = strcmp (type_map[mid].key, tok)) && low < high)
+    {
+      if (cmp < 0)
+	low = (low == mid ? mid + 1 : mid);
+      else
+	high = (high == mid ? mid - 1: mid);
+      mid = (low + high) >> 1;
+    }
+
+  if (low > high)
+    {
+      (*diag) ("token '%s' doesn't appear in the type map!\n", tok);
+      exit (EC_INTERR);
+    }
+
+  return type_map[mid].value;
+}
+
+/* Write the type node corresponding to TOK.  */
+static void
+write_type_node (char *tok)
+{
+  const char *str = map_token_to_type_node (tok);
+  fprintf (init_file, "%s_type_node", str);
+}
+
+/* Write an initializer for a function type identified by STR.  */
+void
+write_fntype_init (char *str)
+{
+  char *tok;
+
+  /* Avoid side effects of strtok on the original string by using a copy.  */
+  char *buf = (char *) malloc (strlen (str) + 1);
+  strcpy (buf, str);
+
+  fprintf (init_file, "  %s\n    = build_function_type_list (", buf);
+  tok = strtok (buf, "_");
+  write_type_node (tok);
+  tok = strtok (0, "_");
+  assert (tok);
+  assert (!strcmp (tok, "ftype"));
+
+  tok = strtok (0, "_");
+  if (tok)
+    fprintf (init_file, ",\n\t\t\t\t");
+
+  /* Note:  A function with no arguments ends with '_ftype_v'.  */
+  while (tok && strcmp (tok, "v"))
+    {
+      write_type_node (tok);
+      tok = strtok (0, "_");
+      fprintf (init_file, ",\n\t\t\t\t");
+    }
+  fprintf (init_file, "NULL_TREE);\n");
+  free (buf);
+}
+
 /* Write everything to the header file (rs6000-bif.h).  */
 static int
 write_header_file ()
@@ -1784,10 +1904,257 @@ write_header_file ()
   return 1;
 }
 
+/* Write code to initialize the built-in function table.  */
+static void
+write_init_bif_table ()
+{
+  int last_stanza = -1;
+
+  for (int i = 0; i <= curr_bif; i++)
+    {
+      if (last_stanza != bifs[i].stanza)
+	{
+	  if (last_stanza != -1)
+	    fprintf (init_file, "    }\n");
+	  fprintf (init_file, "  if (%s)\n    {\n",
+		   bif_stanzas[bifs[i].stanza]);
+	  last_stanza = bifs[i].stanza;
+	}
+      fprintf (init_file,
+	       "      rs6000_builtin_info_x[RS6000_BIF_%s].bifname"
+	       "\n        = \"%s\";\n",
+	       bifs[i].idname, bifs[i].proto.bifname);
+      fprintf (init_file,
+	       "      rs6000_builtin_info_x[RS6000_BIF_%s].fntype"
+	       "\n        = %s;\n",
+	       bifs[i].idname, bifs[i].fndecl);
+      fprintf (init_file,
+	       "      rs6000_builtin_info_x[RS6000_BIF_%s].icode"
+	       "\n        = CODE_FOR_%s;\n",
+	       bifs[i].idname, bifs[i].patname);
+      fprintf (init_file,
+	       "      rs6000_builtin_info_x[RS6000_BIF_%s].bifattrs"
+	       "\n        = 0",
+	       bifs[i].idname);
+      if (bifs[i].kind == FNK_CONST)
+	fprintf (init_file, " | bif_const_bit");
+      else if (bifs[i].kind == FNK_PURE)
+	fprintf (init_file, " | bif_pure_bit");
+      else if (bifs[i].kind == FNK_MATH)
+	fprintf (init_file, " | bif_round_bit");
+      if (bifs[i].attrs.isinit)
+	fprintf (init_file, " | bif_init_bit");
+      if (bifs[i].attrs.isset)
+	fprintf (init_file, " | bif_set_bit");
+      if (bifs[i].attrs.isext)
+	fprintf (init_file, " | bif_ext_bit");
+      if (bifs[i].attrs.isnosoft)
+	fprintf (init_file, " | bif_nosoft_bit");
+      if (bifs[i].attrs.isldv)
+	fprintf (init_file, " | bif_ldv_bit");
+      if (bifs[i].attrs.isstv)
+	fprintf (init_file, " | bif_stv_bit");
+      if (bifs[i].attrs.isreve)
+	fprintf (init_file, " | bif_reve_bit");
+      if (bifs[i].attrs.isabs)
+	fprintf (init_file, " | bif_abs_bit");
+      if (bifs[i].attrs.ispred)
+	fprintf (init_file, " | bif_pred_bit");
+      if (bifs[i].attrs.ishtm)
+	fprintf (init_file, " | bif_htm_bit");
+      fprintf (init_file, ";\n");
+      fprintf (init_file,
+	       "      rs6000_builtin_info_x[RS6000_BIF_%s].restr_opnd"
+	       "\n        = %d;\n",
+	       bifs[i].idname, bifs[i].proto.restr_opnd);
+      if (bifs[i].proto.restr_opnd)
+	{
+	  const char *res
+	    = (bifs[i].proto.restr == RES_BITS ? "RES_BITS"
+	       : (bifs[i].proto.restr == RES_RANGE ? "RES_RANGE"
+		  : (bifs[i].proto.restr == RES_VALUES ? "RES_VALUES"
+		     : "ERROR")));
+	  fprintf (init_file,
+		   "      rs6000_builtin_info_x[RS6000_BIF_%s].restr"
+		   "\n        = %s;\n",
+		   bifs[i].idname, res);
+	  fprintf (init_file,
+		   "      rs6000_builtin_info_x[RS6000_BIF_%s].restr_val1"
+		   "\n        = %d;\n",
+		   bifs[i].idname, bifs[i].proto.restr_val1);
+	  fprintf (init_file,
+		   "      rs6000_builtin_info_x[RS6000_BIF_%s].restr_val2"
+		   "\n        = %d;\n",
+		   bifs[i].idname, bifs[i].proto.restr_val2);
+	}
+      fprintf (init_file, "\n");
+
+      fprintf (init_file,
+	       "      bifaddr = &rs6000_builtin_info_x[RS6000_BIF_%s];\n",
+	       bifs[i].idname);
+      fprintf (init_file,
+	       "      hash = rs6000_bif_hasher::hash (bifaddr);\n");
+      fprintf (init_file,
+	       "      slot = bif_hash.find_slot_with_hash (\n");
+      fprintf (init_file,
+	       "               \"%s\", hash, INSERT\n",
+	       bifs[i].proto.bifname);
+      fprintf (init_file,
+	       "             );\n");
+      fprintf (init_file,
+	       "      *slot = bifaddr;\n\n");
+
+      fprintf (init_file,
+	       "#ifdef NEW_BUILTINS_ARE_LIVE\n");
+      fprintf (init_file,
+	       "      rs6000_builtin_decls[(int)RS6000_BIF_%s]\n",
+	       bifs[i].idname);
+      fprintf (init_file,
+	       "        = add_builtin_function (\"%s\",\n",
+	       bifs[i].proto.bifname);
+      fprintf (init_file,
+	       "                                %s,\n",
+	       bifs[i].fndecl);
+      fprintf (init_file,
+	       "                                (int)RS6000_BIF_%s, NULL,"
+	       " NULL_TREE);\n",
+	       bifs[i].idname);
+      fprintf (init_file,
+	       "#endif\n");
+
+      if (i < curr_bif)
+	fprintf (init_file, "\n");
+    }
+  fprintf (init_file, "    }\n\n");
+}
+
+/* Write code to initialize the overload table.  */
+static void
+write_init_ovld_table ()
+{
+  fprintf (init_file, "  int base = RS6000_BIF_MAX;\n\n");
+
+  for (int i = 0; i <= curr_ovld; i++)
+    {
+      fprintf (init_file,
+	       "  rs6000_overload_info[RS6000_OVLD_%s - base].bifname"
+	       "\n    = \"%s\";\n",
+	       ovlds[i].idname, ovlds[i].proto.bifname);
+      fprintf (init_file,
+	       "  rs6000_overload_info[RS6000_OVLD_%s - base].bifid"
+	       "\n    = RS6000_BIF_%s;\n",
+	       ovlds[i].idname, ovlds[i].idname);
+      fprintf (init_file,
+	       "  rs6000_overload_info[RS6000_OVLD_%s - base].fntype"
+	       "\n    = %s;\n",
+	       ovlds[i].idname, ovlds[i].fndecl);
+      fprintf (init_file,
+	       "  rs6000_overload_info[RS6000_OVLD_%s - base].next"
+	       "\n    = ", ovlds[i].idname);
+      if (i < curr_ovld
+	  && !strcmp (ovlds[i+1].proto.bifname, ovlds[i].proto.bifname))
+	fprintf (init_file,
+		 "&rs6000_overload_info[RS6000_OVLD_%s - base];\n",
+		 ovlds[i+1].idname);
+      else
+	fprintf (init_file, "NULL;\n");
+
+      if (i == 0 || ovlds[i].stanza != ovlds[i-1].stanza)
+	{
+	  fprintf (init_file, "\n");
+
+	  fprintf (init_file,
+		   "  ovldaddr = &rs6000_overload_info"
+		   "[RS6000_OVLD_%s - base];\n",
+		   ovlds[i].idname);
+	  fprintf (init_file,
+		   "  hash = rs6000_ovld_hasher::hash (ovldaddr);\n");
+	  fprintf (init_file,
+		   "  oslot = ovld_hash.find_slot_with_hash (\n");
+	  fprintf (init_file,
+		   "            \"%s\", hash, INSERT\n",
+		   ovlds[i].proto.bifname);
+	  fprintf (init_file,
+		   "         );\n");
+	  fprintf (init_file,
+		   "  *oslot = ovldaddr;\n");
+	}
+
+      if (i < curr_ovld)
+	fprintf (init_file, "\n");
+    }
+}
+
 /* Write everything to the initialization file (rs6000-bif.c).  */
 static int
 write_init_file ()
 {
+  write_autogenerated_header (init_file);
+
+  fprintf (init_file, "#include \"config.h\"\n");
+  fprintf (init_file, "#include \"system.h\"\n");
+  fprintf (init_file, "#include \"coretypes.h\"\n");
+  fprintf (init_file, "#include \"backend.h\"\n");
+  fprintf (init_file, "#include \"rtl.h\"\n");
+  fprintf (init_file, "#include \"tree.h\"\n");
+  fprintf (init_file, "#include \"insn-codes.h\"\n");
+  fprintf (init_file, "#include \"rs6000-bif.h\"\n");
+  fprintf (init_file, "\n");
+
+  fprintf (init_file,
+	   "bifdata rs6000_builtin_info_x[RS6000_BIF_MAX];\n\n");
+  fprintf (init_file,
+	   "ovlddata rs6000_overload_info[RS6000_OVLD_MAX"
+	   " - RS6000_BIF_MAX];\n\n");
+
+  rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype);
+  fprintf (init_file, "\n");
+
+  fprintf (init_file, "hashval_t\n");
+  fprintf (init_file, "rs6000_bif_hasher::hash (bifdata *bd)\n");
+  fprintf (init_file, "{\n");
+  fprintf (init_file, "  return htab_hash_string (bd->bifname);\n");
+  fprintf (init_file, "}\n\n");
+
+  fprintf (init_file, "bool\n");
+  fprintf (init_file,
+	   "rs6000_bif_hasher::equal (bifdata *bd, const char *name)\n");
+  fprintf (init_file, "{\n");
+  fprintf (init_file, "  return bd && name && !strcmp (bd->bifname, name);\n");
+  fprintf (init_file, "}\n\n");
+
+  fprintf (init_file, "hash_table<rs6000_bif_hasher> bif_hash (1024);\n\n");
+
+  fprintf (init_file, "hashval_t\n");
+  fprintf (init_file, "rs6000_ovld_hasher::hash (ovlddata *od)\n");
+  fprintf (init_file, "{\n");
+  fprintf (init_file, "  return htab_hash_string (od->bifname);\n");
+  fprintf (init_file, "}\n\n");
+
+  fprintf (init_file, "bool\n");
+  fprintf (init_file,
+	   "rs6000_ovld_hasher::equal (ovlddata *od, const char *name)\n");
+  fprintf (init_file, "{\n");
+  fprintf (init_file, "  return od && name && !strcmp (od->bifname, name);\n");
+  fprintf (init_file, "}\n\n");
+
+  fprintf (init_file, "hash_table<rs6000_ovld_hasher> ovld_hash (512);\n\n");
+
+  fprintf (init_file, "void\n");
+  fprintf (init_file, "rs6000_autoinit_builtins ()\n");
+  fprintf (init_file, "{\n");
+  fprintf (init_file, "  bifdata **slot;\n");
+  fprintf (init_file, "  bifdata *bifaddr;\n");
+  fprintf (init_file, "  hashval_t hash;\n");
+  fprintf (init_file, "  ovlddata **oslot;\n");
+  fprintf (init_file, "  ovlddata *ovldaddr;\n\n");
+  rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype_init);
+  fprintf (init_file, "\n");
+
+  write_init_bif_table ();
+  write_init_ovld_table ();
+
+  fprintf (init_file, "}\n");
   return 1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 11/14] Write #defines to rs6000-vecdefines.h.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (8 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 08/14] Add support for parsing rs6000-bif.def Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 04/14] Support functions to parse whitespace, lines, identifiers, integers Bill Schmidt
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (write_defines_file): Implement.
---
 gcc/config/rs6000/rs6000-genbif.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 7bb7d2b24a4..0bcd035060d 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -1635,6 +1635,10 @@ write_init_file ()
 static int
 write_defines_file ()
 {
+  for (int i = 0; i < num_ovld_stanzas; i++)
+    fprintf (defines_file, "#define %s %s\n",
+	     ovld_stanzas[i].extern_name,
+	     ovld_stanzas[i].intern_name);
   return 1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 04/14] Support functions to parse whitespace, lines, identifiers, integers.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (9 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 11/14] Write #defines to rs6000-vecdefines.h Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 10/14] Build function type identifiers and store them Bill Schmidt
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c	(MININT): New defined constant.
        (exit_codes): New enum.
        (consume_whitespace): New function.
        (advance_line):	New function.
        (safe_inc_pos):	New function.
        (match_identifier): New	function.
        (match_integer): New function.
---
 gcc/config/rs6000/rs6000-genbif.c | 99 +++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 3fb13cb11d6..197059cc2d2 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -123,6 +123,10 @@ along with GCC; see the file COPYING3.  If not see
 #include <string.h>
 #include <assert.h>
 
+/* Used as a sentinel for range constraints on integer fields.  No field can
+   be 32 bits wide, so this is a safe sentinel value.  */
+#define MININT INT32_MIN
+
 /* Input and output file descriptors and pathnames.  */
 static FILE *bif_file;
 static FILE *ovld_file;
@@ -145,6 +149,11 @@ static char linebuf[LINELEN];
 static int line;
 static int pos;
 
+/* Exit codes for the shell.  */
+enum exit_codes {
+  EC_INTERR
+};
+
 /* Pointer to a diagnostic function.  */
 void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
   = NULL;
@@ -169,3 +178,93 @@ ovld_diag (const char * fmt, ...)
   vfprintf (stderr, fmt, args);
   va_end (args);
 }
+
+/* Pass over unprintable characters and whitespace (other than a newline,
+   which terminates the scan).  */
+static void
+consume_whitespace ()
+{
+  while (pos < LINELEN && isspace(linebuf[pos]) && linebuf[pos] != '\n')
+    pos++;
+  return;
+}
+
+/* Get the next nonblank line, returning 0 on EOF, 1 otherwise.  */
+static int
+advance_line (FILE *file)
+{
+  while (1)
+    {
+      /* Read ahead one line and check for EOF.  */
+      if (!fgets (linebuf, sizeof(linebuf), file))
+	return 0;
+      line++;
+      pos = 0;
+      consume_whitespace ();
+      if (linebuf[pos] != '\n')
+	return 1;
+    }
+}
+
+static inline void
+safe_inc_pos ()
+{
+  if (pos++ >= LINELEN)
+    {
+      (*diag) ("line length overrun.\n");
+      exit (EC_INTERR);
+    }
+}
+
+/* Match an identifier, returning NULL on failure, else a pointer to a
+   buffer containing the identifier.  */
+static char *
+match_identifier ()
+{
+  int lastpos = pos - 1;
+  while (isalnum (linebuf[lastpos + 1]) || linebuf[lastpos + 1] == '_')
+    if (++lastpos >= LINELEN - 1)
+      {
+	(*diag) ("line length overrun.\n");
+	exit (EC_INTERR);
+      }
+
+  if (lastpos < pos)
+    return 0;
+
+  char *buf = (char *) malloc (lastpos - pos + 2);
+  memcpy (buf, &linebuf[pos], lastpos - pos + 1);
+  buf[lastpos - pos + 1] = '\0';
+
+  pos = lastpos + 1;
+  return buf;
+}
+
+/* Match an integer and return its value, or MININT on failure.  */
+static int
+match_integer ()
+{
+  int startpos = pos;
+  if (linebuf[pos] == '-')
+    safe_inc_pos ();
+
+  int lastpos = pos - 1;
+  while (isdigit (linebuf[lastpos + 1]))
+    if (++lastpos >= LINELEN - 1)
+      {
+	(*diag) ("line length overrun in match_integer.\n");
+	exit (EC_INTERR);
+      }
+
+  if (lastpos < pos)
+    return MININT;
+
+  pos = lastpos + 1;
+  char *buf = (char *) malloc (lastpos - startpos + 2);
+  memcpy (buf, &linebuf[startpos], lastpos - startpos + 1);
+  buf[lastpos - startpos + 1] = '\0';
+
+  int x;
+  sscanf (buf, "%d", &x);
+  return x;
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 03/14] Add file support and functions for diagnostic support.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (6 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 05/14] Add support functions for matching types Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 08/14] Add support for parsing rs6000-bif.def Bill Schmidt
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c	(bif_file): New	filescope
	variable.
        (ovld_file): Likewise.
        (header_file): Likewise.
        (init_file): Likewise.
        (defines_file):	Likewise.
        (pgm_path): Likewise.
        (bif_path): Likewise.
	(ovld_path): Likewise.
        (header_path): Likewise.
        (init_path): Likewise.
        (defines_path):	Likewise.
        (LINELEN): New defined constant.
        (linebuf): New filescope variable.
        (line):	Likewise.
        (pos): Likewise.
        (diag):	Likewise.
        (bif_diag): New	function.
        (ovld_diag): New function.
---
 gcc/config/rs6000/rs6000-genbif.c | 47 +++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index a53209ed040..3fb13cb11d6 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -122,3 +122,50 @@ along with GCC; see the file COPYING3.  If not see
 #include <ctype.h>
 #include <string.h>
 #include <assert.h>
+
+/* Input and output file descriptors and pathnames.  */
+static FILE *bif_file;
+static FILE *ovld_file;
+static FILE *header_file;
+static FILE *init_file;
+static FILE *defines_file;
+
+static const char *pgm_path;
+static const char *bif_path;
+static const char *ovld_path;
+static const char *header_path;
+static const char *init_path;
+static const char *defines_path;
+
+/* Position information.  Note that "pos" is zero-indexed, but users
+   expect one-indexed column information, so representations of "pos"
+   as columns in diagnostic messages must be adjusted.  */
+#define LINELEN 1024
+static char linebuf[LINELEN];
+static int line;
+static int pos;
+
+/* Pointer to a diagnostic function.  */
+void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
+  = NULL;
+
+/* Custom diagnostics.  */
+static void __attribute__ ((format (printf, 1, 2)))
+bif_diag (const char * fmt, ...)
+{
+  va_list args;
+  fprintf (stderr, "%s:%d: ", bif_path, line);
+  va_start (args, fmt);
+  vfprintf (stderr, fmt, args);
+  va_end (args);
+}
+
+static void __attribute__ ((format (printf, 1, 2)))
+ovld_diag (const char * fmt, ...)
+{
+  va_list args;
+  fprintf (stderr, "%s:%d: ", ovld_path, line);
+  va_start (args, fmt);
+  vfprintf (stderr, fmt, args);
+  va_end (args);
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 07/14] Add main function with stub functions for parsing and output.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (2 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 06/14] Red-black tree implementation for balanced tree search Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 14/14] Incorporate new code into the build machinery Bill Schmidt
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (rbtree.h): New	include.
        (num_bif_stanzas): New filescope variable.
        (num_bifs): Likewise.
        (num_ovld_stanzas): Likewise.
        (num_ovlds): Likewise.
        (exit_codes): Add more enum values.
        (bif_rbt): New filescope variable.
        (ovld_rbt): Likewise.
	(fntype_rbt): Likewise.
        (parse_bif): New function stub.
        (parse_ovld): Likewise.
        (write_header_file): Likewise.
        (write_init_file): Likewise.
        (write_defines_file): Likewise.
        (main):	New function.
---
 gcc/config/rs6000/rs6000-genbif.c | 185 ++++++++++++++++++++++++++++++
 1 file changed, 185 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 7c1082fbe8f..38401224dce 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -122,6 +122,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <ctype.h>
 #include <string.h>
 #include <assert.h>
+#include "rbtree.h"
 
 /* Used as a sentinel for range constraints on integer fields.  No field can
    be 32 bits wide, so this is a safe sentinel value.  */
@@ -155,6 +156,8 @@ enum void_status {
   VOID_OK
 };
 
+static int num_bif_stanzas;
+
 /* Legal base types for an argument or return type.  */
 enum basetype {
   BT_CHAR,
@@ -196,11 +199,33 @@ struct typeinfo {
   int val2;
 };
 
+static int num_bifs;
+static int num_ovld_stanzas;
+static int num_ovlds;
+
 /* Exit codes for the shell.  */
 enum exit_codes {
+  EC_OK,
+  EC_BADARGS,
+  EC_NOBIF,
+  EC_NOOVLD,
+  EC_NOHDR,
+  EC_NOINIT,
+  EC_NODEFINES,
+  EC_PARSEBIF,
+  EC_PARSEOVLD,
+  EC_WRITEHDR,
+  EC_WRITEINIT,
+  EC_WRITEDEFINES,
   EC_INTERR
 };
 
+/* The red-black trees for built-in function identifiers, built-in
+   overload identifiers, and function type descriptors.  */
+static rbt_strings bif_rbt;
+static rbt_strings ovld_rbt;
+static rbt_strings fntype_rbt;
+
 /* Pointer to a diagnostic function.  */
 void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
   = NULL;
@@ -721,3 +746,163 @@ match_type (typeinfo *typedata, int voidok)
   consume_whitespace ();
   return match_basetype (typedata);
 }
+
+/* Parse the built-in file.  Return 1 for success, 5 for a parsing failure.  */
+static int
+parse_bif ()
+{
+  return 1;
+}
+
+/* Parse the overload file.  Return 1 for success, 6 for a parsing error.  */
+static int
+parse_ovld ()
+{
+  return 1;
+}
+
+/* Write everything to the header file (rs6000-bif.h).  */
+static int
+write_header_file ()
+{
+  return 1;
+}
+
+/* Write everything to the initialization file (rs6000-bif.c).  */
+static int
+write_init_file ()
+{
+  return 1;
+}
+
+/* Write everything to the include file (rs6000-vecdefines.h).  */
+static int
+write_defines_file ()
+{
+  return 1;
+}
+
+/* Main program to convert flat files into built-in initialization code.  */
+int
+main (int argc, const char **argv)
+{
+  if (argc != 6)
+    {
+      fprintf (stderr,
+	       "Five arguments required: two input file and three output"
+	       "files.\n");
+      exit (EC_BADARGS);
+    }
+
+  pgm_path = argv[0];
+  bif_path = argv[1];
+  ovld_path = argv[2];
+  header_path = argv[3];
+  init_path = argv[4];
+  defines_path = argv[5];
+
+  bif_file = fopen (bif_path, "r");
+  if (!bif_file)
+    {
+      fprintf (stderr, "Cannot find input built-in file '%s'.\n", bif_path);
+      exit (EC_NOBIF);
+    }
+  ovld_file = fopen (ovld_path, "r");
+  if (!ovld_file)
+    {
+      fprintf (stderr, "Cannot find input overload file '%s'.\n", ovld_path);
+      exit (EC_NOOVLD);
+    }
+  header_file = fopen (header_path, "w");
+  if (!header_file)
+    {
+      fprintf (stderr, "Cannot open header file '%s' for output.\n",
+	       header_path);
+      exit (EC_NOHDR);
+    }
+  init_file = fopen (init_path, "w");
+  if (!init_file)
+    {
+      fprintf (stderr, "Cannot open init file '%s' for output.\n", init_path);
+      exit (EC_NOINIT);
+    }
+  defines_file = fopen (defines_path, "w");
+  if (!defines_file)
+    {
+      fprintf (stderr, "Cannot open defines file '%s' for output.\n",
+	       defines_path);
+      exit (EC_NODEFINES);
+    }
+
+  /* Initialize the balanced trees containing built-in function ids,
+     overload function ids, and function type declaration ids.  */
+  bif_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node));
+  bif_rbt.rbt_nil->color = RBT_BLACK;
+  bif_rbt.rbt_root = bif_rbt.rbt_nil;
+
+  ovld_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node));
+  ovld_rbt.rbt_nil->color = RBT_BLACK;
+  ovld_rbt.rbt_root = ovld_rbt.rbt_nil;
+
+  fntype_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node));
+  fntype_rbt.rbt_nil->color = RBT_BLACK;
+  fntype_rbt.rbt_root = fntype_rbt.rbt_nil;
+
+  /* Parse the built-in function file.  */
+  num_bif_stanzas = 0;
+  num_bifs = 0;
+  line = 0;
+  if (parse_bif () != 1)
+    {
+      fprintf (stderr, "Parsing of '%s' failed, aborting.\n", bif_path);
+      exit (EC_PARSEBIF);
+    }
+  fclose (bif_file);
+
+#ifdef DEBUG
+  fprintf (stderr, "\nFunction ID list:\n");
+  rbt_dump (&bif_rbt, bif_rbt.rbt_root);
+  fprintf (stderr, "\n");
+#endif
+
+  /* Parse the overload file.  */
+  num_ovld_stanzas = 0;
+  num_ovlds = 0;
+  line = 0;
+  if (parse_ovld () != 1)
+    {
+      fprintf (stderr, "Parsing of '%s' failed, aborting.\n", ovld_path);
+      exit (EC_PARSEOVLD);
+    }
+  fclose (ovld_file);
+
+#ifdef DEBUG
+  fprintf (stderr, "\nFunction type decl list:\n");
+  rbt_dump (&fntype_rbt, fntype_rbt.rbt_root);
+  fprintf (stderr, "\n");
+#endif
+
+  /* Write the header file and the file containing initialization code.  */
+  if (!write_header_file ())
+    {
+      fprintf (stderr, "Output to '%s' failed, aborting.\n", header_path);
+      exit (EC_WRITEHDR);
+    }
+  fclose (header_file);
+  if (!write_init_file ())
+    {
+      fprintf (stderr, "Output to '%s' failed, aborting.\n", init_path);
+      exit (EC_WRITEINIT);
+    }
+  fclose (init_file);
+
+  /* Write the defines file to be included into altivec.h.  */
+  if (!write_defines_file ())
+    {
+      fprintf (stderr, "Output to '%s' failed, aborting.\n", defines_path);
+      exit (EC_WRITEDEFINES);
+    }
+  fclose (defines_file);
+
+  return EC_OK;
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 06/14] Red-black tree implementation for balanced tree search.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
  2020-02-04  2:26 ` [PATCH 01/14] Initial create of rs6000-genbif.c Bill Schmidt
  2020-02-04  2:26 ` [PATCH 02/14] Add stubs for input files. These will grow much larger Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 07/14] Add main function with stub functions for parsing and output Bill Schmidt
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rbtree.c: New file.
        * config/rs6000/rbtree.h: New file.
---
 gcc/config/rs6000/rbtree.c | 233 +++++++++++++++++++++++++++++++++++++
 gcc/config/rs6000/rbtree.h |  51 ++++++++
 2 files changed, 284 insertions(+)
 create mode 100644 gcc/config/rs6000/rbtree.c
 create mode 100644 gcc/config/rs6000/rbtree.h

diff --git a/gcc/config/rs6000/rbtree.c b/gcc/config/rs6000/rbtree.c
new file mode 100644
index 00000000000..f6a8cdefaae
--- /dev/null
+++ b/gcc/config/rs6000/rbtree.c
@@ -0,0 +1,233 @@
+/* Partial red-black tree implementation for rs6000-genbif.c.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Bill Schmidt, IBM <wschmidt@linux.ibm.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "rbtree.h"
+
+/* Create a new node to be inserted into the red-black tree.  An inserted
+   node starts out red.  */
+static struct rbt_string_node *
+rbt_create_node (struct rbt_strings *t, char *str)
+{
+  struct rbt_string_node *nodeptr
+    = (struct rbt_string_node *) malloc (sizeof (struct rbt_string_node));
+  nodeptr->str = str;
+  nodeptr->left = t->rbt_nil;
+  nodeptr->right = t->rbt_nil;
+  nodeptr->par = NULL;
+  nodeptr->color = RBT_RED;
+  return nodeptr;
+}
+
+/* Perform a left-rotate operation on NODE in the red-black tree.  */
+static void
+rbt_left_rotate (struct rbt_strings *t, struct rbt_string_node *node)
+{
+  struct rbt_string_node *right = node->right;
+  assert (right);
+
+  /* Turn RIGHT's left subtree into NODE's right subtree.  */
+  node->right = right->left;
+  if (right->left != t->rbt_nil)
+    right->left->par = node;
+
+  /* Link NODE's parent to RIGHT.  */
+  right->par = node->par;
+
+  if (node->par == t->rbt_nil)
+    t->rbt_root = right;
+  else if (node == node->par->left)
+    node->par->left = right;
+  else
+    node->par->right = right;
+
+  /* Put NODE on RIGHT's left.  */
+  right->left = node;
+  node->par = right;
+}
+
+/* Perform a right-rotate operation on NODE in the red-black tree.  */
+static void
+rbt_right_rotate (struct rbt_strings *t, struct rbt_string_node *node)
+{
+  struct rbt_string_node *left = node->left;
+  assert (left);
+
+  /* Turn LEFT's right subtree into NODE's left subtree.  */
+  node->left = left->right;
+  if (left->right != t->rbt_nil)
+    left->right->par = node;
+
+  /* Link NODE's parent to LEFT.  */
+  left->par = node->par;
+
+  if (node->par == t->rbt_nil)
+    t->rbt_root = left;
+  else if (node == node->par->right)
+    node->par->right = left;
+  else
+    node->par->left = left;
+
+  /* Put NODE on LEFT's right.  */
+  left->right = node;
+  node->par = left;
+}
+
+/* Insert STR into the tree, returning 1 for success and 0 if STR already
+   appears in the tree.  */
+int
+rbt_insert (struct rbt_strings *t, char *str)
+{
+  struct rbt_string_node *curr = t->rbt_root;
+  struct rbt_string_node *trail = t->rbt_nil;
+
+  while (curr != t->rbt_nil)
+    {
+      trail = curr;
+      int cmp = strcmp (str, curr->str);
+      if (cmp < 0)
+	curr = curr->left;
+      else if (cmp > 0)
+	curr = curr->right;
+      else
+	return 0;
+    }
+
+  struct rbt_string_node *fresh = rbt_create_node (t, str);
+  fresh->par = trail;
+
+  if (trail == t->rbt_nil)
+    t->rbt_root = fresh;
+  else if (strcmp (fresh->str, trail->str) < 0)
+    trail->left = fresh;
+  else
+    trail->right = fresh;
+
+  fresh->left = t->rbt_nil;
+  fresh->right = t->rbt_nil;
+
+  /* FRESH has now been inserted as a red leaf.  If we have invalidated
+     one of the following preconditions, we must fix things up:
+      (a) If a node is red, both of its children are black.
+      (b) The root must be black.
+     Note that only (a) or (b) applies at any given time during the
+     process.  This algorithm works up the tree from NEW looking
+     for a red child with a red parent, and cleaning that up.  If the
+     root ends up red, it gets turned black at the end.  */
+  curr = fresh;
+  while (curr->par->color == RBT_RED)
+    if (curr->par == curr->par->par->left)
+      {
+	struct rbt_string_node *uncle = curr->par->par->right;
+	if (uncle->color == RBT_RED)
+	  {
+	    curr->par->color = RBT_BLACK;
+	    uncle->color = RBT_BLACK;
+	    curr->par->par->color = RBT_RED;
+	    curr = curr->par->par;
+	  }
+	else if (curr == curr->par->right)
+	  {
+	    curr = curr->par;
+	    rbt_left_rotate (t, curr);
+	  }
+	else
+	  {
+	    curr->par->color = RBT_BLACK;
+	    curr->par->par->color = RBT_RED;
+	    rbt_right_rotate (t, curr->par->par);
+	  }
+      }
+    else /* curr->par == curr->par->par->right  */
+      {
+	/* Gender-neutral formations are awkward, so let's be fair. ;-)
+	   ("Parent-sibling" is just awful.)  */
+	struct rbt_string_node *aunt = curr->par->par->left;
+	if (aunt->color == RBT_RED)
+	  {
+	    curr->par->color = RBT_BLACK;
+	    aunt->color = RBT_BLACK;
+	    curr->par->par->color = RBT_RED;
+	    curr = curr->par->par;
+	  }
+	else if (curr == curr->par->left)
+	  {
+	    curr = curr->par;
+	    rbt_right_rotate (t, curr);
+	  }
+	else
+	  {
+	    curr->par->color = RBT_BLACK;
+	    curr->par->par->color = RBT_RED;
+	    rbt_left_rotate (t, curr->par->par);
+	  }
+      }
+
+  t->rbt_root->color = RBT_BLACK;
+  return 1;
+}
+
+/* Return 1 if STR is in the red-black tree, else 0.  */
+int
+rbt_find (struct rbt_strings *t, char *str)
+{
+  struct rbt_string_node *curr = t->rbt_root;
+
+  while (curr != t->rbt_nil)
+    {
+      int cmp = strcmp (str, curr->str);
+      if (cmp < 0)
+	curr = curr->left;
+      else if (cmp > 0)
+	curr = curr->right;
+      else
+	return 1;
+    }
+
+  return 0;
+}
+
+/* Inorder dump of the binary search tree.  */
+void
+rbt_dump (struct rbt_strings *t, struct rbt_string_node *subtree)
+{
+  if (subtree != t->rbt_nil)
+    {
+      rbt_dump (t, subtree->left);
+      fprintf (stderr, "%s\n", subtree->str);
+      rbt_dump (t, subtree->right);
+    }
+}
+
+/* Inorder call-back for iteration over the tree.  */
+void
+rbt_inorder_callback (struct rbt_strings *t, struct rbt_string_node *subtree,
+		      void (*fn) (char *))
+{
+  if (subtree != t->rbt_nil)
+    {
+      rbt_inorder_callback (t, subtree->left, fn);
+      (*fn) (subtree->str);
+      rbt_inorder_callback (t, subtree->right, fn);
+    }
+}
diff --git a/gcc/config/rs6000/rbtree.h b/gcc/config/rs6000/rbtree.h
new file mode 100644
index 00000000000..49fa98596a6
--- /dev/null
+++ b/gcc/config/rs6000/rbtree.h
@@ -0,0 +1,51 @@
+/* Partial red-black tree implementation for rs6000-genbif.c.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Bill Schmidt, IBM <wschmidt@linux.ibm.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Red-black binary search tree on strings.  Presently we don't support
+   deletes; only insert/find operations are implemented.  */
+enum rbt_color
+  {
+    RBT_BLACK,
+    RBT_RED
+  };
+
+struct rbt_string_node {
+  char *str;
+  struct rbt_string_node *left;
+  struct rbt_string_node *right;
+  struct rbt_string_node *par;
+  enum rbt_color color;
+};
+
+/* Root and sentinel nodes of a red-black tree.
+   rbt_nil points to a sentinel node, which is the parent of root
+   and the child of every node without a "real" left or right child.
+   rbt_root points to the root of the tree, if it exists yet.  The
+   root and sentinel nodes are always black.  */
+struct rbt_strings {
+  struct rbt_string_node *rbt_nil;
+  struct rbt_string_node *rbt_root;
+};
+
+int rbt_insert (struct rbt_strings *, char *);
+int rbt_find (struct rbt_strings *, char *);
+void rbt_dump (struct rbt_strings *, struct rbt_string_node *);
+void rbt_inorder_callback (struct rbt_strings *, struct rbt_string_node *,
+			   void (*) (char *));
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 05/14] Add support functions for matching types.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (5 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 09/14] Add parsing support for rs6000-overload.def Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 03/14] Add file support and functions for diagnostic support Bill Schmidt
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c	(void_status): New enum.
        (basetype): Likewise.
        (restriction): Likewise.
        (typeinfo): New	struct.
        (match_basetype): New function.
        (match_const_restriction): New function.
        (match_type): New function.
---
 gcc/config/rs6000/rs6000-genbif.c | 453 ++++++++++++++++++++++++++++++
 1 file changed, 453 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 197059cc2d2..7c1082fbe8f 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -149,6 +149,53 @@ static char linebuf[LINELEN];
 static int line;
 static int pos;
 
+/* Used to determine whether a type can be void (only return types).  */
+enum void_status {
+  VOID_NOTOK,
+  VOID_OK
+};
+
+/* Legal base types for an argument or return type.  */
+enum basetype {
+  BT_CHAR,
+  BT_SHORT,
+  BT_INT,
+  BT_LONGLONG,
+  BT_FLOAT,
+  BT_DOUBLE,
+  BT_INT128,
+  BT_FLOAT128
+};
+
+/* Ways in which a const int value can be restricted.  RES_BITS indicates
+   that the integer is restricted to val1 bits, interpreted as signed or
+   unsigned depending on whether the type is signed or unsigned.  RES_RANGE
+   indicates that the integer is restricted to values between val1 and val2,
+   inclusive.  RES_VALUES indicates that the integer must have one of the
+   values val1 or val2.  */
+enum restriction {
+  RES_NONE,
+  RES_BITS,
+  RES_RANGE,
+  RES_VALUES
+};
+
+/* Type modifiers for an argument or return type.  */
+struct typeinfo {
+  char isvoid;
+  char isconst;
+  char isvector;
+  char issigned;
+  char isunsigned;
+  char isbool;
+  char ispixel;
+  char ispointer;
+  basetype base;
+  restriction restr;
+  int val1;
+  int val2;
+};
+
 /* Exit codes for the shell.  */
 enum exit_codes {
   EC_INTERR
@@ -268,3 +315,409 @@ match_integer ()
   sscanf (buf, "%d", &x);
   return x;
 }
+
+/* Match one of the allowable base types.  Consumes one token unless the
+   token is "long", which must be paired with a second "long".  Return 1
+   for success, 0 for failure.  */
+static int
+match_basetype (typeinfo *typedata)
+{
+  consume_whitespace ();
+  int oldpos = pos;
+  char *token = match_identifier ();
+  if (!token)
+    {
+      (*diag) ("missing base type in return type at column %d\n", pos + 1);
+      return 0;
+    }
+
+  if (!strcmp (token, "char"))
+    typedata->base = BT_CHAR;
+  else if (!strcmp (token, "short"))
+    typedata->base = BT_SHORT;
+  else if (!strcmp (token, "int"))
+    typedata->base = BT_INT;
+  else if (!strcmp (token, "long"))
+    {
+      consume_whitespace ();
+      char *mustbelong = match_identifier ();
+      if (!mustbelong || strcmp (mustbelong, "long"))
+	{
+	  (*diag) ("incomplete 'long long' at column %d\n", oldpos + 1);
+	  return 0;
+	}
+      typedata->base = BT_LONGLONG;
+    }
+  else if (!strcmp (token, "float"))
+    typedata->base = BT_FLOAT;
+  else if (!strcmp (token, "double"))
+    typedata->base = BT_DOUBLE;
+  else if (!strcmp (token, "__int128"))
+    typedata->base = BT_INT128;
+  else if (!strcmp (token, "_Float128"))
+    typedata->base = BT_FLOAT128;
+  else
+    {
+      (*diag) ("unrecognized base type at column %d\n", oldpos + 1);
+      return 0;
+    }
+
+  return 1;
+}
+
+/* A const int argument may be restricted to certain values.  This is
+   indicated by one of the following occurring after the "int' token:
+
+     <x>   restricts the constant to x bits, interpreted as signed or
+	   unsigned according to the argument type
+     <x,y> restricts the constant to the inclusive range [x,y]
+     {x,y} restricts the constant to one of two values, x or y.
+
+   Here x and y are integer tokens.  Return 1 for success, else 0.  */
+static int
+match_const_restriction (typeinfo *typedata)
+{
+  int oldpos = pos;
+  if (linebuf[pos] == '<')
+    {
+      safe_inc_pos ();
+      oldpos = pos;
+      int x = match_integer ();
+      if (x == MININT)
+	{
+	  (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+	  return 0;
+	}
+      consume_whitespace ();
+      if (linebuf[pos] == '>')
+	{
+	  typedata->restr = RES_BITS;
+	  typedata->val1 = x;
+	  safe_inc_pos ();
+	  return 1;
+	}
+      else if (linebuf[pos] != ',')
+	{
+	  (*diag) ("malformed restriction at column %d.\n", pos + 1);
+	  return 0;
+	}
+      safe_inc_pos ();
+      oldpos = pos;
+      int y = match_integer ();
+      if (y == MININT)
+	{
+	  (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+	  return 0;
+	}
+      typedata->restr = RES_RANGE;
+      typedata->val1 = x;
+      typedata->val2 = y;
+
+      consume_whitespace ();
+      if (linebuf[pos] != '>')
+	{
+	  (*diag) ("malformed restriction at column %d.\n", pos + 1);
+	  return 0;
+	}
+      safe_inc_pos ();
+    }
+  else
+    {
+      assert (linebuf[pos] == '{');
+      safe_inc_pos ();
+      oldpos = pos;
+      int x = match_integer ();
+      if (x == MININT)
+	{
+	  (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+	  return 0;
+	}
+      consume_whitespace ();
+      if (linebuf[pos] != ',')
+	{
+	  (*diag) ("missing comma at column %d.\n", pos + 1);
+	  return 0;
+	}
+      consume_whitespace ();
+      oldpos = pos;
+      int y = match_integer ();
+      if (y == MININT)
+	{
+	  (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+	  return 0;
+	}
+      typedata->restr = RES_VALUES;
+      typedata->val1 = x;
+      typedata->val2 = y;
+
+      consume_whitespace ();
+      if (linebuf[pos] != '}')
+	{
+	  (*diag) ("malformed restriction at column %d.\n", pos + 1);
+	  return 0;
+	}
+      safe_inc_pos ();
+    }
+
+  return 1;
+}
+
+/* Look for a type, which can be terminated by a token that is not part of
+   a type, a comma, or a closing parenthesis.  Place information about the
+   type in TYPEDATA.  Return 1 for success, 0 for failure.  */
+static int
+match_type (typeinfo *typedata, int voidok)
+{
+  /* A legal type is of the form:
+
+       [const] [[signed|unsigned] <basetype> | <vectype>] [*]
+
+     where "const" applies only to a <basetype> of "int".  Legal values
+     of <basetype> are (for now):
+
+       char
+       short
+       int
+       long long
+       float
+       double
+       __int128
+       _Float128
+
+     Legal values of <vectype> are as follows, and are shorthand for
+     the associated meaning:
+
+       vsc	vector signed char
+       vuc	vector unsigned char
+       vbc	vector bool char
+       vss	vector signed short
+       vus	vector unsigned short
+       vbs	vector bool short
+       vsi	vector signed int
+       vui	vector unsigned int
+       vbi	vector bool int
+       vsll	vector signed long long
+       vull	vector unsigned long long
+       vbll	vector bool long long
+       vsq	vector signed __int128
+       vuq	vector unsigned __int128
+       vbq	vector bool __int128
+       vp	vector pixel
+       vf	vector float
+       vd	vector double
+
+     For simplicity, We don't support "short int" and "long long int".
+     We don't support a <basetype> of "bool", "long double", or "_Float16",
+     but will add these if builtins require it.  "signed" and "unsigned"
+     only apply to integral base types.  The optional * indicates a pointer
+     type, and can currently only be used with void.  */
+
+  consume_whitespace ();
+  memset (typedata, 0, sizeof(*typedata));
+  int oldpos = pos;
+
+  char *token = match_identifier ();
+  if (!token)
+    return 0;
+
+  if (!strcmp (token, "void"))
+    typedata->isvoid = 1;
+  if (!strcmp (token, "const"))
+    typedata->isconst = 1;
+  else if (!strcmp (token, "vsc"))
+    {
+      typedata->isvector = 1;
+      typedata->issigned = 1;
+      typedata->base = BT_CHAR;
+      return 1;
+    }
+  else if (!strcmp (token, "vuc"))
+    {
+      typedata->isvector = 1;
+      typedata->isunsigned = 1;
+      typedata->base = BT_CHAR;
+      return 1;
+    }
+  else if (!strcmp (token, "vbc"))
+    {
+      typedata->isvector = 1;
+      typedata->isbool = 1;
+      typedata->base = BT_CHAR;
+      return 1;
+    }
+  else if (!strcmp (token, "vss"))
+    {
+      typedata->isvector = 1;
+      typedata->issigned = 1;
+      typedata->base = BT_SHORT;
+      return 1;
+    }
+  else if (!strcmp (token, "vus"))
+    {
+      typedata->isvector = 1;
+      typedata->isunsigned = 1;
+      typedata->base = BT_SHORT;
+      return 1;
+    }
+  else if (!strcmp (token, "vbs"))
+    {
+      typedata->isvector = 1;
+      typedata->isbool = 1;
+      typedata->base = BT_SHORT;
+      return 1;
+    }
+  else if (!strcmp (token, "vsi"))
+    {
+      typedata->isvector = 1;
+      typedata->issigned = 1;
+      typedata->base = BT_INT;
+      return 1;
+    }
+  else if (!strcmp (token, "vui"))
+    {
+      typedata->isvector = 1;
+      typedata->isunsigned = 1;
+      typedata->base = BT_INT;
+      return 1;
+    }
+  else if (!strcmp (token, "vbi"))
+    {
+      typedata->isvector = 1;
+      typedata->isbool = 1;
+      typedata->base = BT_INT;
+      return 1;
+    }
+  else if (!strcmp (token, "vsll"))
+    {
+      typedata->isvector = 1;
+      typedata->issigned = 1;
+      typedata->base = BT_LONGLONG;
+      return 1;
+    }
+  else if (!strcmp (token, "vull"))
+    {
+      typedata->isvector = 1;
+      typedata->isunsigned = 1;
+      typedata->base = BT_LONGLONG;
+      return 1;
+    }
+  else if (!strcmp (token, "vbll"))
+    {
+      typedata->isvector = 1;
+      typedata->isbool = 1;
+      typedata->base = BT_LONGLONG;
+      return 1;
+    }
+  else if (!strcmp (token, "vsq"))
+    {
+      typedata->isvector = 1;
+      typedata->issigned = 1;
+      typedata->base = BT_INT128;
+      return 1;
+    }
+  else if (!strcmp (token, "vuq"))
+    {
+      typedata->isvector = 1;
+      typedata->isunsigned = 1;
+      typedata->base = BT_INT128;
+      return 1;
+    }
+  else if (!strcmp (token, "vbq"))
+    {
+      typedata->isvector = 1;
+      typedata->isbool = 1;
+      typedata->base = BT_INT128;
+      return 1;
+    }
+  else if (!strcmp (token, "vp"))
+    {
+      typedata->isvector = 1;
+      typedata->ispixel = 1;
+      typedata->base = BT_SHORT;
+      return 1;
+    }
+  else if (!strcmp (token, "vf"))
+    {
+      typedata->isvector = 1;
+      typedata->base = BT_FLOAT;
+      return 1;
+    }
+  else if (!strcmp (token, "vd"))
+    {
+      typedata->isvector = 1;
+      typedata->base = BT_DOUBLE;
+      return 1;
+    }
+  else if (!strcmp (token, "signed"))
+    typedata->issigned = 1;
+  else if (!strcmp (token, "unsigned"))
+    typedata->isunsigned = 1;
+  else if (!typedata->isvoid)
+    {
+      pos = oldpos;
+      return match_basetype (typedata);
+    }
+
+  if (typedata->isvoid)
+    {
+      consume_whitespace ();
+      if (linebuf[pos] == '*')
+	{
+	  typedata->ispointer = 1;
+	  safe_inc_pos ();
+	}
+      else if (!voidok)
+	return 0;
+      return 1;
+    }
+
+  if (typedata->isconst)
+    {
+      consume_whitespace ();
+      oldpos = pos;
+      token = match_identifier ();
+      if (!strcmp (token, "signed"))
+	{
+	  typedata->issigned = 1;
+	  consume_whitespace ();
+	  oldpos = pos;
+	  token = match_identifier ();
+	  if (strcmp (token, "int"))
+	    {
+	      (*diag) ("'signed' not followed by 'int' at column %d.\n",
+		       oldpos + 1);
+	      return 0;
+	    }
+	}
+      else if (!strcmp (token, "unsigned"))
+	{
+	  typedata->isunsigned = 1;
+	  consume_whitespace ();
+	  oldpos = pos;
+	  token = match_identifier ();
+	  if (strcmp (token, "int"))
+	    {
+	      (*diag) ("'unsigned' not followed by 'int' at column %d.\n",
+		       oldpos + 1);
+	      return 0;
+	    }
+	}
+      else if (strcmp (token, "int"))
+	{
+	  (*diag) ("'const' not followed by 'int' at column %d.\n",
+		   oldpos + 1);
+	  return 0;
+	}
+
+      typedata->base = BT_INT;
+
+      consume_whitespace ();
+      if (linebuf[pos] == '<' || linebuf[pos] == '{')
+	return match_const_restriction (typedata);
+
+      return 1;
+    }
+
+  consume_whitespace ();
+  return match_basetype (typedata);
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 12/14] Write code to rs6000-bif.h.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (12 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 13/14] Write code to rs6000-bif.c Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04 17:40 ` [PATCH 00/14] rs6000: Begin replacing built-in support Segher Boessenkool
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (write_autogenerated_header): New
        function.
        (write_bif_enum): New callback function.
        (write_ovld_enum): New callback	function.
        (write_decls): New function.
        (write_extern_fntype): New callback function.
        (write_header_file): Implement.
---
 gcc/config/rs6000/rs6000-genbif.c | 160 ++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 0bcd035060d..c84df1aa30f 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -1617,10 +1617,170 @@ parse_ovld ()
   return result;
 }
 
+/* Write a comment at the top of FILE about how the code was generated.  */
+static void
+write_autogenerated_header (FILE *file)
+{
+  fprintf (file, "/* Automatically generated by the program '%s'\n",
+	   pgm_path);
+  fprintf (file, "   from the files '%s' and '%s'.  */\n\n",
+	   bif_path, ovld_path);
+}
+
+/* Callback functions used in creating enumerations.  */
+void write_bif_enum (char *str)
+{
+  fprintf (header_file, "  RS6000_BIF_%s,\n", str);
+}
+
+void write_ovld_enum (char *str)
+{
+  fprintf (header_file, "  RS6000_OVLD_%s,\n", str);
+}
+
+/* Write declarations into the header file.  */
+static void
+write_decls ()
+{
+  fprintf (header_file, "enum rs6000_gen_builtins\n{\n  RS6000_BIF_NONE,\n");
+  rbt_inorder_callback (&bif_rbt, bif_rbt.rbt_root, write_bif_enum);
+  fprintf (header_file, "  RS6000_BIF_MAX\n};\n\n");
+
+  fprintf (header_file, "enum restriction {\n");
+  fprintf (header_file, "  RES_NONE,\n");
+  fprintf (header_file, "  RES_BITS,\n");
+  fprintf (header_file, "  RES_RANGE,\n");
+  fprintf (header_file, "  RES_VALUES\n");
+  fprintf (header_file, "};\n\n");
+
+  fprintf (header_file, "struct bifdata\n");
+  fprintf (header_file, "{\n");
+  fprintf (header_file, "  const char *bifname;\n");
+  fprintf (header_file, "  tree fntype;\n");
+  fprintf (header_file, "  insn_code icode;\n");
+  fprintf (header_file, "  int  bifattrs;\n");
+  fprintf (header_file, "  int  restr_opnd;\n");
+  fprintf (header_file, "  restriction restr;\n");
+  fprintf (header_file, "  int  restr_val1;\n");
+  fprintf (header_file, "  int  restr_val2;\n");
+  fprintf (header_file, "};\n\n");
+
+  fprintf (header_file, "#define bif_const_bit\t(0x0000001)\n");
+  fprintf (header_file, "#define bif_pure_bit\t(0x0000002)\n");
+  fprintf (header_file, "#define bif_round_bit\t(0x0000004)\n");
+  fprintf (header_file, "#define bif_init_bit\t(0x0000008)\n");
+  fprintf (header_file, "#define bif_set_bit\t(0x0000010)\n");
+  fprintf (header_file, "#define bif_ext_bit\t(0x0000020)\n");
+  fprintf (header_file, "#define bif_nosoft_bit\t(0x0000040)\n");
+  fprintf (header_file, "#define bif_ldv_bit\t(0x0000080)\n");
+  fprintf (header_file, "#define bif_stv_bit\t(0x0000100)\n");
+  fprintf (header_file, "#define bif_reve_bit\t(0x0000200)\n");
+  fprintf (header_file, "#define bif_abs_bit\t(0x0000400)\n");
+  fprintf (header_file, "#define bif_pred_bit\t(0x0000800)\n");
+  fprintf (header_file, "#define bif_htm_bit\t(0x0001000)\n");
+  fprintf (header_file, "\n");
+  fprintf (header_file,
+	   "#define bif_is_const(x)\t\t((x).bifattrs & bif_const_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_pure(x)\t\t((x).bifattrs & bif_pure_bit)\n");
+  fprintf (header_file,
+	   "#define bif_has_rounding(x)\t((x).bifattrs & bif_round_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_init(x)\t\t((x).bifattrs & bif_init_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_extract(x)\t((x).bifattrs & bif_ext_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_nosoft(x)\t((x).bifattrs & bif_nosoft_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_ldv(x)\t\t((x).bifattrs & bif_ldv_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_stv(x)\t\t((x).bifattrs & bif_stv_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_reve(x)\t\t((x).bifattrs & bif_reve_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_abs(x)\t\t((x).bifattrs & bif_abs_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_predicate(x)\t((x).bifattrs & bif_pred_bit)\n");
+  fprintf (header_file,
+	   "#define bif_is_htm(x)\t\t((x).bifattrs & bif_htm_bit)\n");
+  fprintf (header_file, "\n");
+
+  /* #### Note that the _x is added for now to avoid conflict with
+     the existing rs6000_builtin_info[] file while testing.  It will
+     be removed as we progress.  */
+  fprintf (header_file, "extern bifdata rs6000_builtin_info_x[];\n\n");
+
+  fprintf (header_file,
+	   "struct rs6000_bif_hasher : nofree_ptr_hash<bifdata>\n");
+  fprintf (header_file, "{\n");
+  fprintf (header_file, "  typedef const char *compare_type;\n\n");
+  fprintf (header_file, "  static hashval_t hash (bifdata *);\n");
+  fprintf (header_file, "  static bool equal (bifdata *, const char *);\n");
+  fprintf (header_file, "};\n\n");
+
+  fprintf (header_file, "extern hash_table<rs6000_bif_hasher> bif_hash;\n\n");
+
+  /* Right now we use nonoverlapping numbers for rs6000_gen_builtins
+     and rs6000_gen_overloads.  In the old design, these were all in the
+     same enum, and I can't yet prove there isn't a dependency on these
+     numbers being distinct.  Once this is more clear, I may change
+     this to start at zero.  */
+  fprintf (header_file, "enum rs6000_gen_overloads\n{\n");
+  fprintf (header_file, "  RS6000_OVLD_NONE = RS6000_BIF_MAX + 1,\n");
+  rbt_inorder_callback (&ovld_rbt, ovld_rbt.rbt_root, write_ovld_enum);
+  fprintf (header_file, "  RS6000_OVLD_MAX\n};\n\n");
+
+  fprintf (header_file, "struct ovlddata\n");
+  fprintf (header_file, "{\n");
+  fprintf (header_file, "  const char *bifname;\n");
+  fprintf (header_file, "  rs6000_gen_builtins bifid;\n");
+  fprintf (header_file, "  tree fntype;\n");
+  fprintf (header_file, "  ovlddata *next;\n");
+  fprintf (header_file, "};\n\n");
+
+  fprintf (header_file, "extern ovlddata rs6000_overload_info[];\n\n");
+
+  fprintf (header_file,
+	   "struct rs6000_ovld_hasher : nofree_ptr_hash<ovlddata>\n");
+  fprintf (header_file, "{\n");
+  fprintf (header_file, "  typedef const char *compare_type;\n\n");
+  fprintf (header_file, "  static hashval_t hash (ovlddata *);\n");
+  fprintf (header_file, "  static bool equal (ovlddata *, const char *);\n");
+  fprintf (header_file, "};\n\n");
+
+  fprintf (header_file,
+	   "extern hash_table<rs6000_ovld_hasher> ovld_hash;\n\n");
+
+  fprintf (header_file, "extern void rs6000_autoinit_builtins ();\n\n");
+}
+
+/* Callback functions used for generating trees for function types.  */
+void
+write_extern_fntype (char *str)
+{
+  fprintf (header_file, "extern tree %s;\n", str);
+}
+
 /* Write everything to the header file (rs6000-bif.h).  */
 static int
 write_header_file ()
 {
+  write_autogenerated_header (header_file);
+  fprintf (header_file, "#include \"config.h\"\n");
+  fprintf (header_file, "#include \"system.h\"\n");
+  fprintf (header_file, "#include \"coretypes.h\"\n");
+  fprintf (header_file, "#include \"backend.h\"\n");
+  fprintf (header_file, "#include \"rtl.h\"\n");
+  fprintf (header_file, "#include \"tree.h\"\n");
+  fprintf (header_file, "\n");
+  fprintf (header_file, "#undef NEW_BUILTINS_ARE_LIVE\n\n");
+
+  write_decls ();
+
+  /* Write function type list declarators to the header file.  */
+  rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_extern_fntype);
+  fprintf (header_file, "\n");
+
   return 1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 08/14] Add support for parsing rs6000-bif.def.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (7 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 03/14] Add file support and functions for diagnostic support Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 11/14] Write #defines to rs6000-vecdefines.h Bill Schmidt
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (MAXBIFSTANZAS): New defined
	constant.
        (bif_stanzas): New filescope variable.
        (curr_bif_stanza): Likewise.
        (fnkinds): New enum.
        (typelist): New	struct.
        (attrinfo): New	struct.
        (prototype): New struct.
	(MAXBIFS): New defined constant.
        (bifdata): New struct.
        (bifs):	New filescope variable.
        (curr_bif): Likewise.
        (parse_bif_args): New function.
        (parse_bif_attrs): New function.
        (parse_prototype): New function.
        (parse_bif_entry): New function.
        (parse_bif_stanza): New	function.
        (parse_bif): Implement.
---
 gcc/config/rs6000/rs6000-genbif.c | 473 +++++++++++++++++++++++++++++-
 1 file changed, 472 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 38401224dce..e7ce777afbb 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -156,7 +156,23 @@ enum void_status {
   VOID_OK
 };
 
+/* Stanzas are groupings of built-in functions and overloads by some
+   common feature/attribute.  These definitions are for built-in function
+   stanzas.  */
+#define MAXBIFSTANZAS 256
+static char *bif_stanzas[MAXBIFSTANZAS];
 static int num_bif_stanzas;
+static int curr_bif_stanza;
+
+/* Function modifiers provide special handling for const, pure, and math
+   functions.  These are mutually exclusive, and therefore kept separate
+   from other bif attributes.  */
+enum fnkinds {
+  FNK_NONE,
+  FNK_CONST,
+  FNK_PURE,
+  FNK_MATH
+};
 
 /* Legal base types for an argument or return type.  */
 enum basetype {
@@ -199,7 +215,54 @@ struct typeinfo {
   int val2;
 };
 
+/* A list of argument types.  */
+struct typelist {
+  typeinfo info;
+  typelist *next;
+};
+
+/* Attributes of a builtin function.  */
+struct attrinfo {
+  char isinit;
+  char isset;
+  char isext;
+  char isnosoft;
+  char isldv;
+  char isstv;
+  char isreve;
+  char isabs;
+  char ispred;
+  char ishtm;
+};
+
+/* Fields associated with a function prototype (bif or overload).  */
+struct prototype {
+  typeinfo rettype;
+  char *bifname;
+  int nargs;
+  typelist *args;
+  int restr_opnd;
+  restriction restr;
+  int restr_val1;
+  int restr_val2;
+};
+
+/* Data associated with a builtin function, and a table of such data.  */
+#define MAXBIFS 16384
+struct bifdata {
+  int stanza;
+  fnkinds kind;
+  prototype proto;
+  char *idname;
+  char *patname;
+  attrinfo attrs;
+  char *fndecl;
+};
+
+static bifdata bifs[MAXBIFS];
 static int num_bifs;
+static int curr_bif;
+
 static int num_ovld_stanzas;
 static int num_ovlds;
 
@@ -747,11 +810,419 @@ match_type (typeinfo *typedata, int voidok)
   return match_basetype (typedata);
 }
 
+/* Parse the argument list, returning 1 if success or 0 if any
+   malformation is found.  */
+static int
+parse_bif_args (prototype *protoptr)
+{
+  typelist **argptr = &protoptr->args;
+  int *nargs = &protoptr->nargs;
+  int *restr_opnd = &protoptr->restr_opnd;
+  restriction *restr = &protoptr->restr;
+  int *val1 = &protoptr->restr_val1;
+  int *val2 = &protoptr->restr_val2;
+
+  int success;
+  *nargs = 0;
+
+  /* Start the argument list.  */
+  consume_whitespace ();
+  if (linebuf[pos] != '(')
+    {
+      (*diag) ("missing '(' at column %d.\n", pos + 1);
+      return 0;
+    }
+  safe_inc_pos ();
+
+  do {
+    consume_whitespace ();
+    int oldpos = pos;
+    typelist *argentry = (typelist *) malloc (sizeof (typelist));
+    memset (argentry, 0, sizeof (*argentry));
+    typeinfo *argtype = &argentry->info;
+    success = match_type (argtype, VOID_NOTOK);
+    if (success)
+      {
+	if (argtype->restr)
+	  {
+	    if (*restr_opnd)
+	      {
+		(*diag) ("More than one restricted operand\n");
+		return 0;
+	      }
+	    *restr_opnd = *nargs;
+	    *restr = argtype->restr;
+	    *val1 = argtype->val1;
+	    *val2 = argtype->val2;
+	  }
+	(*nargs)++;
+	*argptr = argentry;
+	argptr = &argentry->next;
+	consume_whitespace ();
+	if (linebuf[pos] == ',')
+	  safe_inc_pos ();
+	else if (linebuf[pos] != ')')
+	  {
+	    (*diag) ("arg not followed by ',' or ')' at column %d.\n",
+		     pos + 1);
+	    return 0;
+	  }
+
+#ifdef DEBUG
+	(*diag) ("argument type: isvoid = %d, isconst = %d, isvector = %d, \
+issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, ispointer = %d, \
+base = %d, restr = %d, val1 = %d, val2 = %d, pos = %d.\n",
+		 argtype->isvoid, argtype->isconst, argtype->isvector,
+		 argtype->issigned, argtype->isunsigned, argtype->isbool,
+		 argtype->ispixel, argtype->ispointer, argtype->base,
+		 argtype->restr, argtype->val1, argtype->val2, pos + 1);
+#endif
+      }
+    else
+      {
+	free (argentry);
+	*argptr = NULL;
+	pos = oldpos;
+	if (linebuf[pos] != ')')
+	  {
+	    (*diag) ("badly terminated arg list at column %d.\n", pos + 1);
+	    return 0;
+	  }
+	safe_inc_pos ();
+      }
+  } while (success);
+
+  return 1;
+}
+
+/* Parse the attribute list, returning 1 if success or 0 if any
+   malformation is found.  */
+static int
+parse_bif_attrs (attrinfo *attrptr)
+{
+  consume_whitespace ();
+  if (linebuf[pos] != '{')
+    {
+      (*diag) ("missing attribute set at column %d.\n", pos + 1);
+      return 0;
+    }
+  safe_inc_pos ();
+
+  memset (attrptr, 0, sizeof (*attrptr));
+  char *attrname = NULL;
+
+  do {
+    consume_whitespace ();
+    int oldpos = pos;
+    attrname = match_identifier ();
+    if (attrname)
+      {
+	if (!strcmp (attrname, "init"))
+	  attrptr->isinit = 1;
+	else if (!strcmp (attrname, "set"))
+	  attrptr->isset = 1;
+	else if (!strcmp (attrname, "ext"))
+	  attrptr->isext = 1;
+	else if (!strcmp (attrname, "nosoft"))
+	  attrptr->isnosoft = 1;
+	else if (!strcmp (attrname, "ldv"))
+	  attrptr->isldv = 1;
+	else if (!strcmp (attrname, "stv"))
+	  attrptr->isstv = 1;
+	else if (!strcmp (attrname, "reve"))
+	  attrptr->isreve = 1;
+	else if (!strcmp (attrname, "abs"))
+	  attrptr->isabs = 1;
+	else if (!strcmp (attrname, "pred"))
+	  attrptr->ispred = 1;
+	else if (!strcmp (attrname, "htm"))
+	  attrptr->ishtm = 1;
+	else
+	  {
+	    (*diag) ("unknown attribute at column %d.\n", oldpos + 1);
+	    return 0;
+	  }
+
+	consume_whitespace ();
+	if (linebuf[pos] == ',')
+	  safe_inc_pos ();
+	else if (linebuf[pos] != '}')
+	  {
+	    (*diag) ("arg not followed by ',' or '}' at column %d.\n",
+		     pos + 1);
+	    return 0;
+	  }
+      }
+    else
+      {
+	pos = oldpos;
+	if (linebuf[pos] != '}')
+	  {
+	    (*diag) ("badly terminated attr set at column %d.\n", pos + 1);
+	    return 0;
+	  }
+	safe_inc_pos ();
+      }
+  } while (attrname);
+
+#ifdef DEBUG
+  (*diag) ("attribute set: init = %d, set = %d, ext = %d, \
+nosoft = %d, ldv = %d, stv = %d, reve = %d, abs = %d, pred = %d, \
+htm = %d.\n",
+	   attrptr->isinit, attrptr->isset, attrptr->isext, attrptr->isnosoft,
+	   attrptr->isldv, attrptr->isstv, attrptr->isreve, attrptr->isabs,
+	   attrptr->ispred, attrptr->ishtm);
+#endif
+
+  return 1;
+}
+
+/* Parse a function prototype.  This code is shared by the bif and overload
+   file processing.  Return 1 for success, 0 for failure.  */
+static int
+parse_prototype (prototype *protoptr)
+{
+  typeinfo *ret_type = &protoptr->rettype;
+  char **bifname = &protoptr->bifname;
+
+  /* Get the return type.  */
+  consume_whitespace ();
+  int oldpos = pos;
+  int success = match_type (ret_type, VOID_OK);
+  if (!success)
+    {
+      (*diag) ("missing or badly formed return type at column %d.\n",
+	       oldpos + 1);
+      return 0;
+    }
+
+#ifdef DEBUG
+  (*diag) ("return type: isvoid = %d, isconst = %d, isvector = %d, \
+issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, ispointer = %d, \
+base = %d, restr = %d, val1 = %d, val2 = %d, pos = %d.\n",
+	   ret_type->isvoid, ret_type->isconst, ret_type->isvector,
+	   ret_type->issigned, ret_type->isunsigned, ret_type->isbool,
+	   ret_type->ispixel, ret_type->ispointer, ret_type->base,
+	   ret_type->restr, ret_type->val1, ret_type->val2, pos + 1);
+#endif
+
+  /* Get the bif name.  */
+  consume_whitespace ();
+  oldpos = pos;
+  *bifname = match_identifier ();
+  if (!*bifname)
+    {
+      (*diag) ("missing function name at column %d.\n", oldpos + 1);
+      return 0;
+    }
+
+#ifdef DEBUG
+  (*diag) ("function name is '%s'.\n", *bifname);
+#endif
+
+  /* Process arguments.  */
+  if (!parse_bif_args (protoptr))
+    return 0;
+
+  /* Process terminating semicolon.  */
+  consume_whitespace ();
+  if (linebuf[pos] != ';')
+    {
+      (*diag) ("missing semicolon at column %d.\n", pos + 1);
+      return 0;
+    }
+  safe_inc_pos ();
+  consume_whitespace ();
+  if (linebuf[pos] != '\n')
+    {
+      (*diag) ("garbage at end of line at column %d.\n", pos + 1);
+      return 0;
+    }
+
+  return 1;
+}
+
+/* Parse a two-line entry for a built-in function.  Return 1 for
+   success, 2 for end-of-stanza, and 5 for a parsing error.  */
+static int
+parse_bif_entry ()
+{
+  /* Check for end of stanza.  */
+  pos = 0;
+  consume_whitespace ();
+  if (linebuf[pos] == '[')
+    return 2;
+
+  /* Allocate an entry in the bif table.  */
+  if (num_bifs >= MAXBIFS - 1)
+    {
+      (*diag) ("too many built-in functions.\n");
+      return 5;
+    }
+
+  curr_bif = num_bifs++;
+  bifs[curr_bif].stanza = curr_bif_stanza;
+
+  /* Read the first token and see if it is a function modifier.  */
+  consume_whitespace ();
+  int oldpos = pos;
+  char *token = match_identifier ();
+  if (!token)
+    {
+      (*diag) ("malformed entry at column %d\n", pos + 1);
+      return 5;
+    }
+
+  if (!strcmp (token, "const"))
+    bifs[curr_bif].kind = FNK_CONST;
+  else if (!strcmp (token, "pure"))
+    bifs[curr_bif].kind = FNK_PURE;
+  else if (!strcmp (token, "math"))
+    bifs[curr_bif].kind = FNK_MATH;
+  else
+    {
+      /* No function modifier, so push the token back.  */
+      pos = oldpos;
+      bifs[curr_bif].kind = FNK_NONE;
+    }
+
+  if (!parse_prototype (&bifs[curr_bif].proto))
+    return 5;
+
+  /* Now process line 2.  First up is the builtin id.  */
+  if (!advance_line (bif_file))
+    {
+      (*diag) ("unexpected EOF.\n");
+      return 5;
+    }
+
+  pos = 0;
+  consume_whitespace ();
+  oldpos = pos;
+  bifs[curr_bif].idname = match_identifier ();
+  if (!bifs[curr_bif].idname)
+    {
+      (*diag) ("missing builtin id at column %d.\n", pos + 1);
+      return 5;
+    }
+
+#ifdef DEBUG
+  (*diag) ("ID name is '%s'.\n", bifs[curr_bif].idname);
+#endif
+
+  /* Save the ID in a lookup structure.  */
+  if (!rbt_insert (&bif_rbt, bifs[curr_bif].idname))
+    {
+      (*diag) ("duplicate function ID '%s' at column %d.\n",
+	       bifs[curr_bif].idname, oldpos + 1);
+      return 5;
+    }
+
+  /* Now the pattern name.  */
+  consume_whitespace ();
+  bifs[curr_bif].patname = match_identifier ();
+  if (!bifs[curr_bif].patname)
+    {
+      (*diag) ("missing pattern name at column %d.\n", pos + 1);
+      return 5;
+    }
+
+#ifdef DEBUG
+  (*diag) ("pattern name is '%s'.\n", bifs[curr_bif].patname);
+#endif
+
+  /* Process attributes.  */
+  if (!parse_bif_attrs (&bifs[curr_bif].attrs))
+    return 5;
+
+  return 1;
+}
+
+/* Parse one stanza of the input BIF file.  linebuf already contains the
+   first line to parse.  Return 1 for success, 0 for EOF, 5 for failure.  */
+static int
+parse_bif_stanza ()
+{
+  /* Parse the stanza header.  */
+  pos = 0;
+  consume_whitespace ();
+
+  if (linebuf[pos] != '[')
+    {
+      (*diag) ("ill-formed stanza header at column %d.\n", pos + 1);
+      return 5;
+    }
+  safe_inc_pos ();
+
+  char *stanza_name = match_identifier ();
+  if (!stanza_name)
+    {
+      (*diag) ("no identifier found in stanza header.\n");
+      return 5;
+    }
+
+  /* Add the identifier to a table and set the number to be recorded
+     with subsequent bif entries.  */
+  if (num_bif_stanzas >= MAXBIFSTANZAS)
+    {
+      (*diag) ("too many stanza headers.\n");
+      return 5;
+    }
+
+  curr_bif_stanza = num_bif_stanzas;
+  bif_stanzas[num_bif_stanzas++] = stanza_name;
+
+  if (linebuf[pos] != ']')
+    {
+      (*diag) ("ill-formed stanza header at column %d.\n", pos + 1);
+      return 5;
+    }
+  safe_inc_pos ();
+
+  consume_whitespace ();
+  if (linebuf[pos] != '\n' && pos != LINELEN - 1)
+    {
+      (*diag) ("garbage after stanza header.\n");
+      return 5;
+    }
+
+  int result = 1;
+
+  while (result != 2) /* end of stanza  */
+    {
+      int result;
+      if (!advance_line (bif_file))
+	return 0;
+
+      result = parse_bif_entry();
+      if (!result) /* EOF */
+	return 0;
+      else if (result > 2)
+	return 5;
+    }
+
+  return 1;
+}
+
 /* Parse the built-in file.  Return 1 for success, 5 for a parsing failure.  */
 static int
 parse_bif ()
 {
-  return 1;
+  int result;
+  diag = &bif_diag;
+  while (1)
+    {
+      if (!advance_line (bif_file))
+	return 1;
+
+      /* Parse a stanza beginning at this line.  */
+      result = parse_bif_stanza ();
+      if (result != 1)
+	break;
+    }
+  if (result == 0)
+    return 1;
+  return result;
 }
 
 /* Parse the overload file.  Return 1 for success, 6 for a parsing error.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 09/14] Add parsing support for rs6000-overload.def.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (4 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 14/14] Incorporate new code into the build machinery Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 05/14] Add support functions for matching types Bill Schmidt
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (ovld_stanza): New struct.
        (MAXOVLDSTANZAS): New defined constant.
	(ovld_stanzas):	New filescope variable.
        (curr_ovld_stanza): Likewise.
        (MAXOVLDS): New	defined	constant.
        (ovlddata): New	struct.
        (ovlds): New filescope variable.
        (curr_ovld): Likewise.
        (parse_ovld_entry): New	function.
        (parse_ovld_stanza): New function.
        (parse_ovld): Implement.
---
 gcc/config/rs6000/rs6000-genbif.c | 207 +++++++++++++++++++++++++++++-
 1 file changed, 206 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index e7ce777afbb..22b5b1df3b9 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -263,8 +263,30 @@ static bifdata bifs[MAXBIFS];
 static int num_bifs;
 static int curr_bif;
 
+/* Stanzas are groupings of built-in functions and overloads by some
+   common feature/attribute.  These definitions are for overload stanzas.  */
+struct ovld_stanza {
+  char *stanza_id;
+  char *extern_name;
+  char *intern_name;
+};
+
+#define MAXOVLDSTANZAS 256
+static ovld_stanza ovld_stanzas[MAXOVLDSTANZAS];
 static int num_ovld_stanzas;
+static int curr_ovld_stanza;
+
+#define MAXOVLDS 16384
+struct ovlddata {
+  int stanza;
+  prototype proto;
+  char *idname;
+  char *fndecl;
+};
+
+static ovlddata ovlds[MAXOVLDS];
 static int num_ovlds;
+static int curr_ovld;
 
 /* Exit codes for the shell.  */
 enum exit_codes {
@@ -1225,11 +1247,194 @@ parse_bif ()
   return result;
 }
 
+/* Parse one two-line entry in the overload file.  Return 0 for EOF, 1 for
+   success, 2 for end-of-stanza, and 6 for a parsing failure.  */
+static int
+parse_ovld_entry ()
+{
+  /* Check for end of stanza.  */
+  pos = 0;
+  consume_whitespace ();
+  if (linebuf[pos] == '[')
+    return 2;
+
+  /* Allocate an entry in the overload table.  */
+  if (num_ovlds >= MAXOVLDS - 1)
+    {
+      (*diag) ("too many overloads.\n");
+      return 6;
+    }
+
+  curr_ovld = num_ovlds++;
+  ovlds[curr_ovld].stanza = curr_ovld_stanza;
+
+  if (!parse_prototype (&ovlds[curr_ovld].proto))
+    return 6;
+
+  /* Now process line 2, which just contains the builtin id.  */
+  if (!advance_line (ovld_file))
+    {
+      (*diag) ("unexpected EOF.\n");
+      return 0;
+    }
+
+  pos = 0;
+  consume_whitespace ();
+  int oldpos = pos;
+  char *id = match_identifier ();
+  ovlds[curr_ovld].idname = id;
+  if (!id)
+    {
+      (*diag) ("missing overload id at column %d.\n", pos + 1);
+      return 6;
+    }
+
+#ifdef DEBUG
+  (*diag) ("ID name is '%s'.\n", id);
+#endif
+
+  /* The builtin id has to match one from the bif file.  */
+  if (!rbt_find (&bif_rbt, id))
+    {
+      (*diag) ("builtin ID '%s' not found in bif file.\n", id);
+      return 6;
+    }
+
+  /* Save the ID in a lookup structure.  */
+  if (!rbt_insert (&ovld_rbt, id))
+    {
+      (*diag) ("duplicate function ID '%s' at column %d.\n", id, oldpos + 1);
+      return 6;
+    }
+
+  consume_whitespace ();
+  if (linebuf[pos] != '\n')
+    {
+      (*diag) ("garbage at end of line at column %d.\n", pos + 1);
+      return 6;
+    }
+  return 1;
+}
+
+/* Parse one stanza of the input overload file.  linebuf already contains the
+   first line to parse.  Return 1 for success, 0 for EOF, 6 for failure.  */
+static int
+parse_ovld_stanza ()
+{
+  /* Parse the stanza header.  */
+  pos = 0;
+  consume_whitespace ();
+
+  if (linebuf[pos] != '[')
+    {
+      (*diag) ("ill-formed stanza header at column %d.\n", pos + 1);
+      return 6;
+    }
+  safe_inc_pos ();
+
+  char *stanza_name = match_identifier ();
+  if (!stanza_name)
+    {
+      (*diag) ("no identifier found in stanza header.\n");
+      return 6;
+    }
+
+  /* Add the identifier to a table and set the number to be recorded
+     with subsequent overload entries.  */
+  if (num_ovld_stanzas >= MAXOVLDSTANZAS)
+    {
+      (*diag) ("too many stanza headers.\n");
+      return 6;
+    }
+
+  curr_ovld_stanza = num_ovld_stanzas++;
+  ovld_stanza *stanza = &ovld_stanzas[curr_ovld_stanza];
+  stanza->stanza_id = stanza_name;
+
+  consume_whitespace ();
+  if (linebuf[pos] != ',')
+    {
+      (*diag) ("missing comma at column %d.\n", pos + 1);
+      return 6;
+    }
+  safe_inc_pos ();
+
+  consume_whitespace ();
+  stanza->extern_name = match_identifier ();
+  if (!stanza->extern_name)
+    {
+      (*diag) ("missing external name at column %d.\n", pos + 1);
+      return 6;
+    }
+
+  consume_whitespace ();
+  if (linebuf[pos] != ',')
+    {
+      (*diag) ("missing comma at column %d.\n", pos + 1);
+      return 6;
+    }
+  safe_inc_pos ();
+
+  consume_whitespace ();
+  stanza->intern_name = match_identifier ();
+  if (!stanza->intern_name)
+    {
+      (*diag) ("missing internal name at column %d.\n", pos + 1);
+      return 6;
+    }
+
+  if (linebuf[pos] != ']')
+    {
+      (*diag) ("ill-formed stanza header at column %d.\n", pos + 1);
+      return 6;
+    }
+  safe_inc_pos ();
+
+  consume_whitespace ();
+  if (linebuf[pos] != '\n' && pos != LINELEN - 1)
+    {
+      (*diag) ("garbage after stanza header.\n");
+      return 6;
+    }
+
+  int result = 1;
+
+  while (result != 2) /* end of stanza  */
+    {
+      int result;
+      if (!advance_line (ovld_file))
+	return 0;
+
+      result = parse_ovld_entry ();
+      if (!result) /* EOF */
+	return 0;
+      else if (result > 2)
+	return 6;
+    }
+
+  return 1;
+}
+
 /* Parse the overload file.  Return 1 for success, 6 for a parsing error.  */
 static int
 parse_ovld ()
 {
-  return 1;
+  int result;
+  diag = &ovld_diag;
+  while (1)
+    {
+      /* Read ahead one line and check for EOF.  */
+      if (!advance_line (ovld_file))
+	return 1;
+
+      /* Parse a stanza beginning at this line.  */
+      result = parse_ovld_stanza ();
+      if (result != 1)
+	break;
+    }
+  if (result == 0)
+    return 1;
+  return result;
 }
 
 /* Write everything to the header file (rs6000-bif.h).  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 10/14] Build function type identifiers and store them.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (10 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 04/14] Support functions to parse whitespace, lines, identifiers, integers Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 13/14] Write code to rs6000-bif.c Bill Schmidt
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config/rs6000/rs6000-genbif.c (complete_vector_type):	New
	function.
        (complete_base_type): New function.
        (construct_fntype_id): New function.
        (parse_bif_entry): Call	construct_fntype_id.
        (parse_ovld_entry): Likewise.
---
 gcc/config/rs6000/rs6000-genbif.c | 180 ++++++++++++++++++++++++++++++
 1 file changed, 180 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c
index 22b5b1df3b9..7bb7d2b24a4 100644
--- a/gcc/config/rs6000/rs6000-genbif.c
+++ b/gcc/config/rs6000/rs6000-genbif.c
@@ -999,6 +999,178 @@ htm = %d.\n",
   return 1;
 }
 
+/* Convert a vector type into a mode string.  */
+static void
+complete_vector_type (typeinfo *typeptr, char *buf, int *bufi)
+{
+  buf[(*bufi)++] = 'v';
+  if (typeptr->ispixel)
+    {
+      memcpy (&buf[*bufi], "p8hi", 4);
+      *bufi += 4;
+    }
+  else
+    {
+      if (typeptr->isbool)
+	buf[(*bufi)++] = 'b';
+      switch (typeptr->base)
+	{
+	case BT_CHAR:
+	  memcpy (&buf[*bufi], "16qi", 4);
+	  *bufi += 4;
+	  break;
+	case BT_SHORT:
+	  memcpy (&buf[*bufi], "8hi", 3);
+	  *bufi += 3;
+	  break;
+	case BT_INT:
+	  memcpy (&buf[*bufi], "4si", 3);
+	  *bufi += 3;
+	  break;
+	case BT_LONGLONG:
+	  memcpy (&buf[*bufi], "2di", 3);
+	  *bufi += 3;
+	  break;
+	case BT_FLOAT:
+	  memcpy (&buf[*bufi], "4sf", 3);
+	  *bufi += 3;
+	  break;
+	case BT_DOUBLE:
+	  memcpy (&buf[*bufi], "2df", 3);
+	  *bufi += 3;
+	  break;
+	case BT_INT128:
+	  memcpy (&buf[*bufi], "1ti", 3);
+	  *bufi += 3;
+	  break;
+	case BT_FLOAT128:
+	  memcpy (&buf[*bufi], "1tf", 3);
+	  *bufi += 3;
+	  break;
+	default:
+	  (*diag) ("unhandled basetype %d.\n", typeptr->base);
+	  exit (EC_INTERR);
+	}
+    }
+}
+
+/* Convert a base type into a mode string.  */
+static void
+complete_base_type (typeinfo *typeptr, char *buf, int *bufi)
+{
+  switch (typeptr->base)
+    {
+    case BT_CHAR:
+      memcpy (&buf[*bufi], "qi", 2);
+      break;
+    case BT_SHORT:
+      memcpy (&buf[*bufi], "hi", 2);
+      break;
+    case BT_INT:
+      memcpy (&buf[*bufi], "si", 2);
+      break;
+    case BT_LONGLONG:
+      memcpy (&buf[*bufi], "di", 2);
+      break;
+    case BT_FLOAT:
+      memcpy (&buf[*bufi], "sf", 2);
+      break;
+    case BT_DOUBLE:
+      memcpy (&buf[*bufi], "df", 2);
+      break;
+    case BT_INT128:
+      memcpy (&buf[*bufi], "ti", 2);
+      break;
+    case BT_FLOAT128:
+      memcpy (&buf[*bufi], "tf", 2);
+      break;
+    default:
+      (*diag) ("unhandled basetype %d.\n", typeptr->base);
+      exit (EC_INTERR);
+    }
+
+  *bufi += 2;
+}
+
+/* Build a function type descriptor identifier from the return type
+   and argument types, and store it if it does not already exist.
+   Return the identifier.  */
+static char *
+construct_fntype_id (prototype *protoptr)
+{
+  /* Determine the maximum space for a function type descriptor id.
+     Each type requires at most 8 characters (6 for the mode*, 1 for
+     the optional 'u' preceding the mode, and 1 for an underscore
+     following the mode).  We also need 5 characters for the string
+     "ftype" that separates the return mode from the argument modes.
+     The last argument doesn't need a trailing underscore, but we
+     count that as the one trailing "ftype" instead.  For the special
+     case of zero arguments, we need 8 for the return type and 7
+     for "ftype_v".  Finally, we need one character for the
+     terminating null.  Thus for a function with N arguments, we
+     need at most 8N+14 characters for N>0, otherwise 16.
+     ----
+       *Worst case is vb16qi for "vector bool char".  */
+  int len = protoptr->nargs ? (protoptr->nargs + 1) * 8 + 6 : 16;
+  char *buf = (char *) malloc (len);
+  int bufi = 0;
+
+  if (protoptr->rettype.ispointer)
+    {
+      assert (protoptr->rettype.isvoid);
+      buf[bufi++] = 'p';
+    }
+  if (protoptr->rettype.isvoid)
+    buf[bufi++] = 'v';
+  else
+    {
+      if (protoptr->rettype.isunsigned)
+	buf[bufi++] = 'u';
+      if (protoptr->rettype.isvector)
+	complete_vector_type (&protoptr->rettype, buf, &bufi);
+      else
+	complete_base_type (&protoptr->rettype, buf, &bufi);
+    }
+
+  memcpy (&buf[bufi], "_ftype", 6);
+  bufi += 6;
+
+  if (!protoptr->nargs)
+    {
+      memcpy (&buf[bufi], "_v", 2);
+      bufi += 2;
+    }
+  else
+    {
+      typelist *argptr = protoptr->args;
+      for (int i = 0; i < protoptr->nargs; i++)
+	{
+	  assert (argptr);
+	  buf[bufi++] = '_';
+	  if (argptr->info.isunsigned)
+	    buf[bufi++] = 'u';
+	  if (argptr->info.ispointer)
+	    {
+	      buf[bufi++] = 'p';
+	      buf[bufi++] = 'v';
+	    }
+	  else if (argptr->info.isvector)
+	    complete_vector_type (&argptr->info, buf, &bufi);
+	  else
+	    complete_base_type (&argptr->info, buf, &bufi);
+	  argptr = argptr->next;
+	}
+      assert (!argptr);
+      }
+
+  buf[bufi] = '\0';
+
+  /* Ignore return value, as duplicates are expected.  */
+  (void) rbt_insert (&fntype_rbt, buf);
+
+  return buf;
+}
+
 /* Parse a function prototype.  This code is shared by the bif and overload
    file processing.  Return 1 for success, 0 for failure.  */
 static int
@@ -1111,6 +1283,10 @@ parse_bif_entry ()
   if (!parse_prototype (&bifs[curr_bif].proto))
     return 5;
 
+  /* Build a function type descriptor identifier from the return type
+     and argument types, and store it if it does not already exist.  */
+  bifs[curr_bif].fndecl = construct_fntype_id (&bifs[curr_bif].proto);
+
   /* Now process line 2.  First up is the builtin id.  */
   if (!advance_line (bif_file))
     {
@@ -1271,6 +1447,10 @@ parse_ovld_entry ()
   if (!parse_prototype (&ovlds[curr_ovld].proto))
     return 6;
 
+  /* Build a function type descriptor identifier from the return type
+     and argument types, and store it if it does not already exist.  */
+  ovlds[curr_ovld].fndecl = construct_fntype_id (&ovlds[curr_ovld].proto);
+
   /* Now process line 2, which just contains the builtin id.  */
   if (!advance_line (ovld_file))
     {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 14/14] Incorporate new code into the build machinery.
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (3 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 07/14] Add main function with stub functions for parsing and output Bill Schmidt
@ 2020-02-04  2:27 ` Bill Schmidt
  2020-02-04  2:27 ` [PATCH 09/14] Add parsing support for rs6000-overload.def Bill Schmidt
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04  2:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher

2020-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

        * config.gcc (powerpc-*-*-*): Add rs6000-bif.o to extra_objs.
        * config/rs6000/t-rs6000 (rs6000-genbif.o): New	target.
        (rbtree.o): Likewise.
        (rs6000-genbif): Likewise.
        (rs6000-bif.c):	Likewise.
        (rs6000-bif.o):	Likewise.
---
 gcc/config.gcc             |  3 ++-
 gcc/config/rs6000/t-rs6000 | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index ae5a845fcce..72448e43017 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -504,7 +504,8 @@ or1k*-*-*)
 	;;
 powerpc*-*-*)
 	cpu_type=rs6000
-	extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o rs6000-call.o"
+	extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o"
+	extra_objs="${extra_objs} rs6000-call.o rs6000-bif.o"
 	extra_headers="ppc-asm.h altivec.h htmintrin.h htmxlintrin.h"
 	extra_headers="${extra_headers} bmi2intrin.h bmiintrin.h"
 	extra_headers="${extra_headers} xmmintrin.h mm_malloc.h emmintrin.h"
diff --git a/gcc/config/rs6000/t-rs6000 b/gcc/config/rs6000/t-rs6000
index 170a69591dd..a3a214b2bfb 100644
--- a/gcc/config/rs6000/t-rs6000
+++ b/gcc/config/rs6000/t-rs6000
@@ -47,6 +47,28 @@ rs6000-call.o: $(srcdir)/config/rs6000/rs6000-call.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
+rs6000-genbif.o: $(srcdir)/config/rs6000/rs6000-genbif.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
+rbtree.o: $(srcdir)/config/rs6000/rbtree.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
+rs6000-genbif: rs6000-genbif.o rbtree.o
+	+$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \
+	    $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS)
+
+rs6000-bif.c: rs6000-genbif $(srcdir)/config/rs6000/rs6000-bif.def \
+		$(srcdir)/config/rs6000/rs6000-overload.def
+	./rs6000-genbif $(srcdir)/config/rs6000/rs6000-bif.def \
+		$(srcdir)/config/rs6000/rs6000-overload.def rs6000-bif.h \
+		rs6000-bif.c rs6000-vecdefines.h
+
+rs6000-bif.o: rs6000-bif.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
 $(srcdir)/config/rs6000/rs6000-tables.opt: $(srcdir)/config/rs6000/genopt.sh \
   $(srcdir)/config/rs6000/rs6000-cpus.def
 	$(SHELL) $(srcdir)/config/rs6000/genopt.sh $(srcdir)/config/rs6000 > \
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
                   ` (13 preceding siblings ...)
  2020-02-04  2:27 ` [PATCH 12/14] Write code to rs6000-bif.h Bill Schmidt
@ 2020-02-04 17:40 ` Segher Boessenkool
  2020-02-05  7:57   ` Richard Biener
  2020-02-14 18:34   ` Mike Stump
  14 siblings, 2 replies; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-04 17:40 UTC (permalink / raw)
  To: Bill Schmidt; +Cc: gcc-patches

Hi!

On Mon, Feb 03, 2020 at 08:26:01PM -0600, Bill Schmidt wrote:
> The current built-in support in the rs6000 back end requires at least
> a master's degree in spelunking to comprehend.  It's full of cruft,
> redundancy, and unused bits of code, and long overdue for a
> replacement.  This is the first part of my project to do that.

Woohoo :-)

> My intent is to make adding new built-in functions as simple as adding
> a few lines to a couple of files, and automatically generating as much
> of the initialization, overload resolution, and expansion logic as
> possible.  This patch series establishes the format of the input files
> and creates a new program (rs6000-genbif) to:

Let's call it rs6000-gen-builtins or similar.  Not as cryptic.

> Note that none of the code in this patch set affects GCC's operation
> at all, with the exception of patch #14.  Patch 14 causes the program
> rs6000-genbif to be built and executed, producing the output files,
> and linking rs6000-bif.o into the executable.  However, none of the
> code in rs6000-bif.o is called, so the only effect is to make the gcc
> executable larger.

If it builds at all ;-)

> I'd like to consider at least patches 1-13 as stage 4 material for the
> current release.  I'd prefer to also include patch 14 for convenience,
> but I understand if that's not deemed acceptable.
> 
> I've attempted to break this up into logical pieces for easy
> consumption, but some of the patches may still be a bit large.  Please
> let me know if you'd like me to break any of them up.

I will.  "Large" isn't a problem if it is a lot of the same thing.  If
it is two or more things, having them in separate patches is easier to
review; if there is just one case that is different, put it in a separate
patch if that can be done; otherwise, please point it out in the patch
commit message.

>   Initial create of rs6000-genbif.c.

Subjects do not end in a dot (but do start with a capital).

>   Add stubs for input files.  These will grow much larger.

The second half of this does not belong in the title, but in the body.


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04  2:26 ` [PATCH 01/14] Initial create of rs6000-genbif.c Bill Schmidt
@ 2020-02-04 18:27   ` Segher Boessenkool
  2020-02-04 21:10     ` Bill Schmidt
  0 siblings, 1 reply; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-04 18:27 UTC (permalink / raw)
  To: Bill Schmidt; +Cc: gcc-patches

Hi!

On Mon, Feb 03, 2020 at 08:26:02PM -0600, Bill Schmidt wrote:
> Includes header documentation and initial set of include directives.

Please use full sentences in commit messages.

> +/* This program generates built-in function initialization and
> +   recognition code for Power targets, based on text files that
> +   describe the built-in functions and vector overloads:
> +
> +     rs6000-bif.def       Table of built-in functions
> +     rs6000-overload.def  Table of overload functions

I really don't think using the new acronym "bif" helps; built-in
functions already are often called "builtins" (or "intrinsics", which is
problematic itself).

> +     ext     Process as a vec_extract function

Please spell out "extract"?  There are too many other words starting with
"ext", some of which you could expect here ("extend", "extension", maybe
even "extra");

> +     ldv     Needs special handling for vec_ld semantics
> +     stv     Needs special handling for vec_st semantics

Call those "vec_ld" and "vec_st", then?  Or should I get used to it, the
names aren't obvious, but cut-and-paste always is ;-)

> +[TARGET_ALTIVEC]

Can this be a C expression?  Most gen* programs just copy similar things
to the generated C code, which can be interesting to debug, but works
perfectly well otherwise.

> +  const vector signed char __builtin_altivec_abs_v16qi (vector signed char);
> +    ABS_V16QI absv16qi2 {abs}
> +  const vector signed short __builtin_altivec_abs_v8hi (vector signed short);
> +    ABS_V8HI absv8hi2 {abs}
> +
> +   Note the use of indentation, which is recommended but not required.

It does require a single newline at the end of each such line, right?
Does that work aout almost always, or do you get very long lines?

> +     [<overload-id>, <external-name>, <internal-name>]

Hrm, "internal" suggests "name within the GCC code", but that is not what
it means.  Maybe something like abi-name and builtin-name?

> +  Blank lines may be used as desired in these files.

Between stanzas and stuff only?  There are places where newlines are
significant and not just whitespace, right?

Great docs, thanks!


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04 18:27   ` Segher Boessenkool
@ 2020-02-04 21:10     ` Bill Schmidt
  2020-02-04 22:36       ` Segher Boessenkool
  0 siblings, 1 reply; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04 21:10 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches

On 2/4/20 12:27 PM, Segher Boessenkool wrote:
> Hi!
>
> On Mon, Feb 03, 2020 at 08:26:02PM -0600, Bill Schmidt wrote:
>> Includes header documentation and initial set of include directives.
> Please use full sentences in commit messages.


OK.

>
>> +/* This program generates built-in function initialization and
>> +   recognition code for Power targets, based on text files that
>> +   describe the built-in functions and vector overloads:
>> +
>> +     rs6000-bif.def       Table of built-in functions
>> +     rs6000-overload.def  Table of overload functions
> I really don't think using the new acronym "bif" helps; built-in
> functions already are often called "builtins" (or "intrinsics", which is
> problematic itself).


Until we manage to replace the old methods, we already have 
rs6000-builtin.def, so I am a bit constrained in my choices. Given that 
restriction, what name would you prefer?  I can use rs6000-builtins.def 
(the plural) if you like.

I didn't think I was inventing "bif" as shorthand, but maybe that was an 
LLVM thing...

>
>> +     ext     Process as a vec_extract function
> Please spell out "extract"?  There are too many other words starting with
> "ext", some of which you could expect here ("extend", "extension", maybe
> even "extra");


OK.

>
>> +     ldv     Needs special handling for vec_ld semantics
>> +     stv     Needs special handling for vec_st semantics
> Call those "vec_ld" and "vec_st", then?  Or should I get used to it, the
> names aren't obvious, but cut-and-paste always is ;-)


Hm.  Well, vec_ld is a specific built-in, but this applies to a few more 
than just that one.  But sure, if you want.

>
>> +[TARGET_ALTIVEC]
> Can this be a C expression?  Most gen* programs just copy similar things
> to the generated C code, which can be interesting to debug, but works
> perfectly well otherwise.


I rather prefer the way it is.  I do generate C code from this in the 
subsequent patches.  But I like table-driven code to use things that 
look like tables for input. :-)

>
>> +  const vector signed char __builtin_altivec_abs_v16qi (vector signed char);
>> +    ABS_V16QI absv16qi2 {abs}
>> +  const vector signed short __builtin_altivec_abs_v8hi (vector signed short);
>> +    ABS_V8HI absv8hi2 {abs}
>> +
>> +   Note the use of indentation, which is recommended but not required.
> It does require a single newline at the end of each such line, right?
> Does that work aout almost always, or do you get very long lines?


Yes, for now I am requiring the newline at the end of each line. I found 
that it does indeed get very long (unreadably long) lines for vector 
signatures.  I forgot to update this documentation when I changed my 
format.  I am now using abbreviations for vector types that match those 
we use often in our test cases ("vuc" for "vector unsigned char", "vsll" 
for "vector signed long long", etc.).  This makes for very nicely 
readable inputs (see patch #2).

The above now becomes

   const vsc __builtin_altivec_abs_v16qi (vsc);
     ABS_V16QI absv16qi2 {abs}
   const vss __builtin_altivec_abs_v8hi (vss);
     ABS_V8HI absv8hi2 {abs}

I will fix the documentation!

>
>> +     [<overload-id>, <external-name>, <internal-name>]
> Hrm, "internal" suggests "name within the GCC code", but that is not what
> it means.  Maybe something like abi-name and builtin-name?


OK, that's reasonable.

>
>> +  Blank lines may be used as desired in these files.
> Between stanzas and stuff only?  There are places where newlines are
> significant and not just whitespace, right?


I don't believe so, although there may be places where I forgot to allow 
a line to be advanced -- that would be a bug, though, so let me know if 
you see any.  Blank lines don't have any inherent meaning in the input 
files.

>
> Great docs, thanks!


Thanks for the review!
Bill

>
>
> Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04 21:10     ` Bill Schmidt
@ 2020-02-04 22:36       ` Segher Boessenkool
  2020-02-04 22:44         ` Bill Schmidt
  0 siblings, 1 reply; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-04 22:36 UTC (permalink / raw)
  To: Bill Schmidt; +Cc: gcc-patches

On Tue, Feb 04, 2020 at 03:10:32PM -0600, Bill Schmidt wrote:
> >I really don't think using the new acronym "bif" helps; built-in
> >functions already are often called "builtins" (or "intrinsics", which is
> >problematic itself).
> 
> Until we manage to replace the old methods, we already have 
> rs6000-builtin.def, so I am a bit constrained in my choices. Given that 
> restriction, what name would you prefer?  I can use rs6000-builtins.def 
> (the plural) if you like.

As we discussed (offline), maybe rs6000-builtin-new.def is best (and at
the end of this conversion, just move it).

> >>+     ldv     Needs special handling for vec_ld semantics
> >>+     stv     Needs special handling for vec_st semantics
> >Call those "vec_ld" and "vec_st", then?  Or should I get used to it, the
> >names aren't obvious, but cut-and-paste always is ;-)
> 
> Hm.  Well, vec_ld is a specific built-in, but this applies to a few more 
> than just that one.  But sure, if you want.

"ldv" certainly is shorter and nicer in principle, but it is a bit
cryptic.  As I said, it's probably not too hard to get used to it; and
maybe a better name will present itself?

> >>+[TARGET_ALTIVEC]
> >Can this be a C expression?  Most gen* programs just copy similar things
> >to the generated C code, which can be interesting to debug, but works
> >perfectly well otherwise.
> 
> I rather prefer the way it is.  I do generate C code from this in the 
> subsequent patches.  But I like table-driven code to use things that 
> look like tables for input. :-)

That's not what I meant...  Can you say
  [TARGET_ALTIVEC && TARGET_64BIT]
here?  Or even just
  [!TARGET_ALTIVEC]
or
  [1]
for always, or
  [0]
for never ("commented out").

> >>+  Blank lines may be used as desired in these files.
> >Between stanzas and stuff only?  There are places where newlines are
> >significant and not just whitespace, right?
> 
> I don't believe so, although there may be places where I forgot to allow 
> a line to be advanced -- that would be a bug, though, so let me know if 
> you see any.  Blank lines don't have any inherent meaning in the input 
> files.

Not blank lines, I'm asking about newlines :-)  But those are not allowed
to be inserted just anywhere, a line has to be one line, iiuc?


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04 22:36       ` Segher Boessenkool
@ 2020-02-04 22:44         ` Bill Schmidt
  2020-02-04 23:48           ` Segher Boessenkool
  0 siblings, 1 reply; 27+ messages in thread
From: Bill Schmidt @ 2020-02-04 22:44 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches

On 2/4/20 4:36 PM, Segher Boessenkool wrote:
> On Tue, Feb 04, 2020 at 03:10:32PM -0600, Bill Schmidt wrote:
>>> I really don't think using the new acronym "bif" helps; built-in
>>> functions already are often called "builtins" (or "intrinsics", which is
>>> problematic itself).
>> Until we manage to replace the old methods, we already have
>> rs6000-builtin.def, so I am a bit constrained in my choices. Given that
>> restriction, what name would you prefer?  I can use rs6000-builtins.def
>> (the plural) if you like.
> As we discussed (offline), maybe rs6000-builtin-new.def is best (and at
> the end of this conversion, just move it).
+1
>
>>>> +     ldv     Needs special handling for vec_ld semantics
>>>> +     stv     Needs special handling for vec_st semantics
>>> Call those "vec_ld" and "vec_st", then?  Or should I get used to it, the
>>> names aren't obvious, but cut-and-paste always is ;-)
>> Hm.  Well, vec_ld is a specific built-in, but this applies to a few more
>> than just that one.  But sure, if you want.
> "ldv" certainly is shorter and nicer in principle, but it is a bit
> cryptic.  As I said, it's probably not too hard to get used to it; and
> maybe a better name will present itself?
Maybe ldvec and stvec would serve without introducing specific builtin 
confusion.
>
>>>> +[TARGET_ALTIVEC]
>>> Can this be a C expression?  Most gen* programs just copy similar things
>>> to the generated C code, which can be interesting to debug, but works
>>> perfectly well otherwise.
>> I rather prefer the way it is.  I do generate C code from this in the
>> subsequent patches.  But I like table-driven code to use things that
>> look like tables for input. :-)
> That's not what I meant...  Can you say
>    [TARGET_ALTIVEC && TARGET_64BIT]
> here?  Or even just
>    [!TARGET_ALTIVEC]
> or
>    [1]
> for always, or
>    [0]
> for never ("commented out").
Ah!  Sorry for misunderstanding.  Right now just an identifier is 
allowed, but we could certainly grab the whole string between the [] and 
drop it in with no concerns.  Hopefully we both remember when we get to 
the patch that reads the stanzas...
>
>>>> +  Blank lines may be used as desired in these files.
>>> Between stanzas and stuff only?  There are places where newlines are
>>> significant and not just whitespace, right?
>> I don't believe so, although there may be places where I forgot to allow
>> a line to be advanced -- that would be a bug, though, so let me know if
>> you see any.  Blank lines don't have any inherent meaning in the input
>> files.
> Not blank lines, I'm asking about newlines :-)  But those are not allowed
> to be inserted just anywhere, a line has to be one line, iiuc?

Yes.  Additional newlines can follow a newline, but the individual lines 
must contain everything that's expected in them.

Bill

>
>
> Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/14] Initial create of rs6000-genbif.c.
  2020-02-04 22:44         ` Bill Schmidt
@ 2020-02-04 23:48           ` Segher Boessenkool
  0 siblings, 0 replies; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-04 23:48 UTC (permalink / raw)
  To: Bill Schmidt; +Cc: gcc-patches

On Tue, Feb 04, 2020 at 04:44:04PM -0600, Bill Schmidt wrote:
> >"ldv" certainly is shorter and nicer in principle, but it is a bit
> >cryptic.  As I said, it's probably not too hard to get used to it; and
> >maybe a better name will present itself?
> Maybe ldvec and stvec would serve without introducing specific builtin 
> confusion.

Let's go with that, if nothing better shows up.

> >That's not what I meant...  Can you say
> >   [TARGET_ALTIVEC && TARGET_64BIT]
> >here?  Or even just
> >   [!TARGET_ALTIVEC]
> >or
> >   [1]
> >for always, or
> >   [0]
> >for never ("commented out").
> Ah!  Sorry for misunderstanding.  Right now just an identifier is 
> allowed, but we could certainly grab the whole string between the [] and 
> drop it in with no concerns.  Hopefully we both remember when we get to 
> the patch that reads the stanzas...

:-)


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-04 17:40 ` [PATCH 00/14] rs6000: Begin replacing built-in support Segher Boessenkool
@ 2020-02-05  7:57   ` Richard Biener
  2020-02-05 12:30     ` Segher Boessenkool
  2020-02-14 18:34   ` Mike Stump
  1 sibling, 1 reply; 27+ messages in thread
From: Richard Biener @ 2020-02-05  7:57 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Bill Schmidt, GCC Patches

On Tue, Feb 4, 2020 at 6:40 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> Hi!
>
> On Mon, Feb 03, 2020 at 08:26:01PM -0600, Bill Schmidt wrote:
> > The current built-in support in the rs6000 back end requires at least
> > a master's degree in spelunking to comprehend.  It's full of cruft,
> > redundancy, and unused bits of code, and long overdue for a
> > replacement.  This is the first part of my project to do that.
>
> Woohoo :-)

Indeed.

> > My intent is to make adding new built-in functions as simple as adding
> > a few lines to a couple of files, and automatically generating as much
> > of the initialization, overload resolution, and expansion logic as
> > possible.  This patch series establishes the format of the input files
> > and creates a new program (rs6000-genbif) to:
>
> Let's call it rs6000-gen-builtins or similar.  Not as cryptic.

I believe we talked about this a few years ago.  Any reason this is powerpc
specific?  If sufficiently generic most targets would benefit and maybe even
frontends and the middle-end could make use of this.  The generator
program, that is.  (disclaimer: I didn't look into the patches at all)

I always wondered if we can make our C frontend spit out things from
C declarations (with maybe extra #pragmas for some of the more obscure
details) and how to fit that into the bootstrap.

> > Note that none of the code in this patch set affects GCC's operation
> > at all, with the exception of patch #14.  Patch 14 causes the program
> > rs6000-genbif to be built and executed, producing the output files,
> > and linking rs6000-bif.o into the executable.  However, none of the
> > code in rs6000-bif.o is called, so the only effect is to make the gcc
> > executable larger.
>
> If it builds at all ;-)
>
> > I'd like to consider at least patches 1-13 as stage 4 material for the
> > current release.  I'd prefer to also include patch 14 for convenience,
> > but I understand if that's not deemed acceptable.
> >
> > I've attempted to break this up into logical pieces for easy
> > consumption, but some of the patches may still be a bit large.  Please
> > let me know if you'd like me to break any of them up.
>
> I will.  "Large" isn't a problem if it is a lot of the same thing.  If
> it is two or more things, having them in separate patches is easier to
> review; if there is just one case that is different, put it in a separate
> patch if that can be done; otherwise, please point it out in the patch
> commit message.
>
> >   Initial create of rs6000-genbif.c.
>
> Subjects do not end in a dot (but do start with a capital).
>
> >   Add stubs for input files.  These will grow much larger.
>
> The second half of this does not belong in the title, but in the body.
>
>
> Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-05  7:57   ` Richard Biener
@ 2020-02-05 12:30     ` Segher Boessenkool
  2020-02-05 13:01       ` Bill Schmidt
  0 siblings, 1 reply; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-05 12:30 UTC (permalink / raw)
  To: Richard Biener; +Cc: Bill Schmidt, GCC Patches

Hi!

On Wed, Feb 05, 2020 at 08:57:16AM +0100, Richard Biener wrote:
> On Tue, Feb 4, 2020 at 6:40 PM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > On Mon, Feb 03, 2020 at 08:26:01PM -0600, Bill Schmidt wrote:
> > > My intent is to make adding new built-in functions as simple as adding
> > > a few lines to a couple of files, and automatically generating as much
> > > of the initialization, overload resolution, and expansion logic as
> > > possible.  This patch series establishes the format of the input files
> > > and creates a new program (rs6000-genbif) to:
> >
> > Let's call it rs6000-gen-builtins or similar.  Not as cryptic.
> 
> I believe we talked about this a few years ago.  Any reason this is powerpc
> specific?  If sufficiently generic most targets would benefit and maybe even
> frontends and the middle-end could make use of this.  The generator
> program, that is.  (disclaimer: I didn't look into the patches at all)

Absolutely, but we first want to solve the urgent problem for Power
(because that is what it is); it's a huge job with that reduction of
scope, already.  After *that* is done, it will be clearer how to do
things for what is wanted generically, will be clearer what is wanted
in the first place :-)

> I always wondered if we can make our C frontend spit out things from
> C declarations (with maybe extra #pragmas for some of the more obscure
> details) and how to fit that into the bootstrap.

I think there will be too many problem cases, a direct description of
the builtins will work better (but is more verbose of course).

In any case, Bill's patches keep the exact same approach in rs6000 as
we had before, just with some more pre-processing and macros etc.;
which results in a much shorter description, many cases folded into one,
which as a bonus also fixes bugs (directly, when two things you fold
should be the same but are not, at least one of them is wrong; and maybe
more importantly indirectly: a reader of the tables will spot errors
much more easily if they fit on one screen, if you have similar entries
on the screen at the same time so you *can* compare; and there will be
more readers as well even, people are actually scared of having to look
at it currently).

So, yes, this same approach might be a good fit generically, but we'll
do it for rs6000 only, in the interest of ever getting it done ;-)
The generator programs etc. can move to generic code later, if that
helps and there is interest in it, there isn't much (if anything) in
here that is specific to our arch.


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-05 12:30     ` Segher Boessenkool
@ 2020-02-05 13:01       ` Bill Schmidt
  0 siblings, 0 replies; 27+ messages in thread
From: Bill Schmidt @ 2020-02-05 13:01 UTC (permalink / raw)
  To: Segher Boessenkool, Richard Biener; +Cc: GCC Patches


On 2/5/20 6:30 AM, Segher Boessenkool wrote:
> Hi!
>
> On Wed, Feb 05, 2020 at 08:57:16AM +0100, Richard Biener wrote:
>> On Tue, Feb 4, 2020 at 6:40 PM Segher Boessenkool
>> <segher@kernel.crashing.org> wrote:
>>> On Mon, Feb 03, 2020 at 08:26:01PM -0600, Bill Schmidt wrote:
>>>> My intent is to make adding new built-in functions as simple as adding
>>>> a few lines to a couple of files, and automatically generating as much
>>>> of the initialization, overload resolution, and expansion logic as
>>>> possible.  This patch series establishes the format of the input files
>>>> and creates a new program (rs6000-genbif) to:
>>> Let's call it rs6000-gen-builtins or similar.  Not as cryptic.
>> I believe we talked about this a few years ago.  Any reason this is powerpc
>> specific?  If sufficiently generic most targets would benefit and maybe even
>> frontends and the middle-end could make use of this.  The generator
>> program, that is.  (disclaimer: I didn't look into the patches at all)


One thing that's powerpc-unique (I believe) is our peculiar overloading 
infrastructure for the original AltiVec interface (extended to cover 
quite a bit more territory since).  But that's largely an extra level of 
abstraction that could eventually be optional.

There's also some specificity to our vector types (things like vector 
bool and vector pixel) that would need to be abstracted away.

Finally, there's a set of flags for special handling that are definitely 
Power-specific and would have to be abstracted away also.

Nothing that couldn't be dealt with given enough attention, so far as I 
can see.  But honestly I have not looked a great deal into other 
targets' built-in handling to see what other landmines might be present.

> Absolutely, but we first want to solve the urgent problem for Power
> (because that is what it is); it's a huge job with that reduction of
> scope, already.  After *that* is done, it will be clearer how to do
> things for what is wanted generically, will be clearer what is wanted
> in the first place :-)


Yes, this is a necessary first step to even be able to see what's going 
on...

>
>> I always wondered if we can make our C frontend spit out things from
>> C declarations (with maybe extra #pragmas for some of the more obscure
>> details) and how to fit that into the bootstrap.
> I think there will be too many problem cases, a direct description of
> the builtins will work better (but is more verbose of course).
>
> In any case, Bill's patches keep the exact same approach in rs6000 as
> we had before, just with some more pre-processing and macros etc.;
> which results in a much shorter description, many cases folded into one,
> which as a bonus also fixes bugs (directly, when two things you fold
> should be the same but are not, at least one of them is wrong; and maybe
> more importantly indirectly: a reader of the tables will spot errors
> much more easily if they fit on one screen, if you have similar entries
> on the screen at the same time so you *can* compare; and there will be
> more readers as well even, people are actually scared of having to look
> at it currently).
>
> So, yes, this same approach might be a good fit generically, but we'll
> do it for rs6000 only, in the interest of ever getting it done ;-)
> The generator programs etc. can move to generic code later, if that
> helps and there is interest in it, there isn't much (if anything) in
> here that is specific to our arch.


I'll keep this possibility in mind as we move forward.  It's probably a 
matter of months to get everything converted over just for Power.  But 
this set of patches is the most generic; the remaining patches will all 
be quite Power-specific.

Thanks,
Bill

>
> Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-04 17:40 ` [PATCH 00/14] rs6000: Begin replacing built-in support Segher Boessenkool
  2020-02-05  7:57   ` Richard Biener
@ 2020-02-14 18:34   ` Mike Stump
  2020-02-14 21:27     ` Segher Boessenkool
  1 sibling, 1 reply; 27+ messages in thread
From: Mike Stump @ 2020-02-14 18:34 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Bill Schmidt, gcc-patches

On Feb 4, 2020, at 9:40 AM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>> My intent is to make adding new built-in functions as simple as adding
>> a few lines to a couple of files, and automatically generating as much
>> of the initialization, overload resolution, and expansion logic as
>> possible.  This patch series establishes the format of the input files
>> and creates a new program (rs6000-genbif) to:
> 
> Let's call it rs6000-gen-builtins or similar.  Not as cryptic.

Or, config/gen-builtins.  :-)  We have one around here, and there are things that a generator can have that are really, generally useful.  It's better to share support for common thing and for very target specific things, of course, they can go down in the rs6000 area.  Our generators are written in python, and for this type of code, python is nice.  My workflow with my generators let's me validate changes to the generator easily, as I can compare a before and after of the generated content.

Once you push the common parts down and invite others to join the party, the next port can reuse the bits you have, and add the 1 or 5 things they need, and presto, you now have more beef, should you need it in the future.  Around here, we have more beef than anyone, as we always hit things no one else has.  In/out rtl parameters, out parameters, overloading, test case generation, early, late expansion, type fun, vector fun, architecture fun, optional parameters, gosh, the list just goes on and on...  Anyway, as a new port comes on line, it's easier for them to retrofit the 3 new things they need into a nice infrastructure that sings and dances.

Indeed, some of the older gcc port interfaces, for example, registers (FIXED_REGISTERS, CALL_REALLY_USED_REGISTERS, REG_ALLOC_ORDER, HARD_REGNO_CALLER_SAVE_MODE, REG_CLASS_NAMES, REG_CLASS_CONTENTS, REGISTER_NAMES), I think would be a nice area for a generator as well.  Every port has registers, and yet, those interfaces are too clunky.  But, now I guess I digress.

Just wanted to say, I like your plan.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-14 18:34   ` Mike Stump
@ 2020-02-14 21:27     ` Segher Boessenkool
  2020-02-15  0:14       ` Mike Stump
  0 siblings, 1 reply; 27+ messages in thread
From: Segher Boessenkool @ 2020-02-14 21:27 UTC (permalink / raw)
  To: Mike Stump; +Cc: Bill Schmidt, gcc-patches

Hi!

On Fri, Feb 14, 2020 at 10:34:40AM -0800, Mike Stump wrote:
> On Feb 4, 2020, at 9:40 AM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
> >> My intent is to make adding new built-in functions as simple as adding
> >> a few lines to a couple of files, and automatically generating as much
> >> of the initialization, overload resolution, and expansion logic as
> >> possible.  This patch series establishes the format of the input files
> >> and creates a new program (rs6000-genbif) to:
> > 
> > Let's call it rs6000-gen-builtins or similar.  Not as cryptic.
> 
> Or, config/gen-builtins.  :-)

As explained before, to get somewhere in a reasonable time, we first need
to do it for rs6000 only.  This patchset is solving an acute problem for
us, too, that is the *purpose* of it.

It remains to be seen how much of it can be used by other targets.
Pretending something is generic while it in fact is just a mass of
special cases isn't useful, it's just costly.

> Indeed, some of the older gcc port interfaces, for example, registers (FIXED_REGISTERS, CALL_REALLY_USED_REGISTERS, REG_ALLOC_ORDER, HARD_REGNO_CALLER_SAVE_MODE, REG_CLASS_NAMES, REG_CLASS_CONTENTS, REGISTER_NAMES), I think would be a nice area for a generator as well.  Every port has registers, and yet, those interfaces are too clunky.

Yes...  Like, last year I renumbered the rs6000 registers.  Things have
to be changed in a bunch of tables, but also in a few other places that
you cannot generate the code for.  So on one hand a generator for this
certainly would have helped, but on the other hand, it isn't the holy
grail you might be after either.

> Just wanted to say, I like your plan.

:-)  It'll be a lot of work still, let's hope we can make it for GCC 11.


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/14] rs6000: Begin replacing built-in support
  2020-02-14 21:27     ` Segher Boessenkool
@ 2020-02-15  0:14       ` Mike Stump
  0 siblings, 0 replies; 27+ messages in thread
From: Mike Stump @ 2020-02-15  0:14 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Bill Schmidt, gcc-patches

On Feb 14, 2020, at 1:26 PM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
> It remains to be seen how much of it can be used by other targets.
> Pretending something is generic while it in fact is just a mass of
> special cases isn't useful, it's just costly.

Oh, yeah, of course.  Ours was designed in two pieces, the target bits, which were 100% target specific, and then the infrastructure to make those target bits go.  5,661 lines in the generator, and around 11 lines per builtin on the target side.  The generator was 100% free of target things.


(define_code_attr cond_name
        [(unordered "Unordered")
         (ordered "Ordered")
         (unlt "Less Than or Unordered")
         (unge "Greater Than or Equal or Unordered")
         (uneq "Equal or Unordered")
         (ltgt "Not Equal or Unordered")
         (unle "Less Than or Equal or Unorderd")
         (ungt "Greater Than or Unordered")
         (eq "Equal")
         (ne "Not Equal")
         (gt "Greater Than")
         (ge "Greater Equal")
         (lt "Less Than")
         (le "Less Equal")
         (gtu "Greater Than Unsigned")
         (geu "Greater Than Unsigned")
         (ltu "Less Than Unsigned")
         (leu "Less Than Unsigned")])



(define_builtin "arch_cmp<icond>" "arch_cmp<icond>_<type>"
  [
    (define_desc    "Compare <cond_name>")
    (define_outputs [(var_operand:<T_ALL_INT:TU_TYPE> 0)])
    (define_inputs  [(var_operand:T_ALL_INT 1)
                     (var_operand:T_ALL_INT 2)])
    (code_iterator icond)
    (define_rtl_pattern "arch_cmp<icond>_<mode>" [0 1 2])
    (attributes [pure])
    (use_note "<GCCOP>")
  ]
)

was the typical sort of thing for the target side.  We've since moved on and now generate even more from way less.  3 lines of input for an instruction, and even the 3 lines are auto extracted from the documentation for the instruction.  So, roughly zero lines of input per builtin.  About 5600 lines in the generator code, but that generator, oh my, it does a ton more.  The new one doesn't have the nice clean split between target and non-target code, however.  The later does significantly more work however, so, I don't feel bad.

The one thing missing I think more from modern compiler port development is the sharing of the commonalities between ports that would make the port writing even easier.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-02-15  0:14 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04  2:26 [PATCH 00/14] rs6000: Begin replacing built-in support Bill Schmidt
2020-02-04  2:26 ` [PATCH 01/14] Initial create of rs6000-genbif.c Bill Schmidt
2020-02-04 18:27   ` Segher Boessenkool
2020-02-04 21:10     ` Bill Schmidt
2020-02-04 22:36       ` Segher Boessenkool
2020-02-04 22:44         ` Bill Schmidt
2020-02-04 23:48           ` Segher Boessenkool
2020-02-04  2:26 ` [PATCH 02/14] Add stubs for input files. These will grow much larger Bill Schmidt
2020-02-04  2:27 ` [PATCH 06/14] Red-black tree implementation for balanced tree search Bill Schmidt
2020-02-04  2:27 ` [PATCH 07/14] Add main function with stub functions for parsing and output Bill Schmidt
2020-02-04  2:27 ` [PATCH 14/14] Incorporate new code into the build machinery Bill Schmidt
2020-02-04  2:27 ` [PATCH 09/14] Add parsing support for rs6000-overload.def Bill Schmidt
2020-02-04  2:27 ` [PATCH 05/14] Add support functions for matching types Bill Schmidt
2020-02-04  2:27 ` [PATCH 03/14] Add file support and functions for diagnostic support Bill Schmidt
2020-02-04  2:27 ` [PATCH 08/14] Add support for parsing rs6000-bif.def Bill Schmidt
2020-02-04  2:27 ` [PATCH 11/14] Write #defines to rs6000-vecdefines.h Bill Schmidt
2020-02-04  2:27 ` [PATCH 04/14] Support functions to parse whitespace, lines, identifiers, integers Bill Schmidt
2020-02-04  2:27 ` [PATCH 10/14] Build function type identifiers and store them Bill Schmidt
2020-02-04  2:27 ` [PATCH 13/14] Write code to rs6000-bif.c Bill Schmidt
2020-02-04  2:27 ` [PATCH 12/14] Write code to rs6000-bif.h Bill Schmidt
2020-02-04 17:40 ` [PATCH 00/14] rs6000: Begin replacing built-in support Segher Boessenkool
2020-02-05  7:57   ` Richard Biener
2020-02-05 12:30     ` Segher Boessenkool
2020-02-05 13:01       ` Bill Schmidt
2020-02-14 18:34   ` Mike Stump
2020-02-14 21:27     ` Segher Boessenkool
2020-02-15  0:14       ` Mike Stump

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).