public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-06-15 17:17 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-06-15 17:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:bb35b5f7cf5846bc0dd98ba71b852ce09e1d7532
commit bb35b5f7cf5846bc0dd98ba71b852ce09e1d7532
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Tue Jun 15 09:52:33 2021 -0500
rs6000: Write output to the builtins init file, part 3 of 3
2021-06-15 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New macro.
(type_map): New initialized variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 182 ++++++++++++++++++++++++++++++++
1 file changed, 182 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index a261da88097..06040cf6778 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -460,6 +460,108 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 86
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv1ti", "bool_V1TI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv1ti", "ptr_bool_V1TI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
static void (*diag) (const char *, ...)
__attribute__ ((format (printf, 1, 2)));
@@ -2208,10 +2310,90 @@ 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 (1);
+ }
+
+ return type_map[mid].value;
+}
+
+/* Write the type node corresponding to TOK. */
+static void
+write_type_node (char *tok, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Similarly, look for decimal float tokens. */
+ int dfp_found = (strstr (str, "dd") != NULL
+ || strstr (str, "td") != NULL
+ || strstr (str, "sd") != NULL);
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+ else if (dfp_found)
+ fprintf (init_file, " if (dfloat64_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found || dfp_found);
+ 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, tf_found || dfp_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-06-25 16:16 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-06-25 16:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b0e8849cac27e62ec809d4597450c1e9c9319c50
commit b0e8849cac27e62ec809d4597450c1e9c9319c50
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Tue Jun 15 09:52:33 2021 -0500
rs6000: Write output to the builtins init file, part 3 of 3
2021-06-15 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New macro.
(type_map): New initialized variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 182 ++++++++++++++++++++++++++++++++
1 file changed, 182 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index a261da88097..06040cf6778 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -460,6 +460,108 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 86
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv1ti", "bool_V1TI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv1ti", "ptr_bool_V1TI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
static void (*diag) (const char *, ...)
__attribute__ ((format (printf, 1, 2)));
@@ -2208,10 +2310,90 @@ 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 (1);
+ }
+
+ return type_map[mid].value;
+}
+
+/* Write the type node corresponding to TOK. */
+static void
+write_type_node (char *tok, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Similarly, look for decimal float tokens. */
+ int dfp_found = (strstr (str, "dd") != NULL
+ || strstr (str, "td") != NULL
+ || strstr (str, "sd") != NULL);
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+ else if (dfp_found)
+ fprintf (init_file, " if (dfloat64_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found || dfp_found);
+ 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, tf_found || dfp_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-04-26 20:49 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-26 20:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0871ae2385f8ba813623940667ffccd0ee2ee2bd
commit 0871ae2385f8ba813623940667ffccd0ee2ee2bd
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 3 17:16:59 2021 -0600
rs6000: Write output to the builtins init file, part 3 of 3
2021-03-03 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New defined constant.
(type_map): New initialized filescope variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 173 ++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index 82c0567756b..7ef297d04f5 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -468,6 +468,106 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 84
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
= NULL;
@@ -2242,10 +2342,83 @@ 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, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found);
+ 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, tf_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-04-02 22:10 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-02 22:10 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:eddb676c89a752f5e18b0dc7a970ae0ab8e49b4e
commit eddb676c89a752f5e18b0dc7a970ae0ab8e49b4e
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 3 17:16:59 2021 -0600
rs6000: Write output to the builtins init file, part 3 of 3
2021-03-03 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New defined constant.
(type_map): New initialized filescope variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 173 ++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index 82c0567756b..7ef297d04f5 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -468,6 +468,106 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 84
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
= NULL;
@@ -2242,10 +2342,83 @@ 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, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found);
+ 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, tf_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-04-01 19:48 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-01 19:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f1350178f61c886a29971e5a426ecb4611a3779e
commit f1350178f61c886a29971e5a426ecb4611a3779e
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 3 17:16:59 2021 -0600
rs6000: Write output to the builtins init file, part 3 of 3
2021-03-03 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New defined constant.
(type_map): New initialized filescope variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 173 ++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index 9395820b6c2..be9774a65ac 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -467,6 +467,106 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 84
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
= NULL;
@@ -2241,10 +2341,83 @@ 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, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found);
+ 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, tf_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3
@ 2021-03-25 15:46 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-03-25 15:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c6c531dda74088fac65972c9bc7c9ee09f139ecc
commit c6c531dda74088fac65972c9bc7c9ee09f139ecc
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 3 17:16:59 2021 -0600
rs6000: Write output to the builtins init file, part 3 of 3
2021-03-03 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (typemap): New struct.
(TYPE_MAP_SIZE): New defined constant.
(type_map): New initialized filescope variable.
(map_token_to_type_node): New function.
(write_type_node): Likewise.
(write_fntype_init): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 173 ++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index 93589750ee7..7db30bc28f4 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -467,6 +467,106 @@ static rbt_strings fntype_rbt;
identifiers to the order in which they were encountered. */
static rbt_strings bifo_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. The table
+ maps tokens from a fntype string to a tree type. For example,
+ in "si_ftype_hi" we would map "si" to "intSI_type_node" and
+ map "hi" to "intHI_type_node". */
+#define TYPE_MAP_SIZE 84
+static typemap type_map[TYPE_MAP_SIZE] =
+ {
+ { "bi", "bool_int" },
+ { "bv16qi", "bool_V16QI" },
+ { "bv2di", "bool_V2DI" },
+ { "bv4si", "bool_V4SI" },
+ { "bv8hi", "bool_V8HI" },
+ { "ci", "integer" },
+ { "dd", "dfloat64" },
+ { "df", "double" },
+ { "di", "long_long_integer" },
+ { "hi", "intHI" },
+ { "if", "ibm128_float" },
+ { "ld", "long_double" },
+ { "lg", "long_integer" },
+ { "pbv16qi", "ptr_bool_V16QI" },
+ { "pbv2di", "ptr_bool_V2DI" },
+ { "pbv4si", "ptr_bool_V4SI" },
+ { "pbv8hi", "ptr_bool_V8HI" },
+ { "pcvoid", "pcvoid" },
+ { "pdd", "ptr_dfloat64" },
+ { "pdf", "ptr_double" },
+ { "pdi", "ptr_long_long_integer" },
+ { "phi", "ptr_intHI" },
+ { "pif", "ptr_ibm128_float" },
+ { "pld", "ptr_long_double" },
+ { "plg", "ptr_long_integer" },
+ { "pqi", "ptr_intQI" },
+ { "psf", "ptr_float" },
+ { "psi", "ptr_intSI" },
+ { "ptd", "ptr_dfloat128" },
+ { "ptf", "ptr_float128" },
+ { "pti", "ptr_intTI" },
+ { "pudi", "ptr_long_long_unsigned" },
+ { "puhi", "ptr_uintHI" },
+ { "pulg", "ptr_long_unsigned" },
+ { "puqi", "ptr_uintQI" },
+ { "pusi", "ptr_uintSI" },
+ { "puti", "ptr_uintTI" },
+ { "puv16qi", "ptr_unsigned_V16QI" },
+ { "puv1ti", "ptr_unsigned_V1TI" },
+ { "puv2di", "ptr_unsigned_V2DI" },
+ { "puv4si", "ptr_unsigned_V4SI" },
+ { "puv8hi", "ptr_unsigned_V8HI" },
+ { "pv", "ptr" },
+ { "pv16qi", "ptr_V16QI" },
+ { "pv1poi", "ptr_vector_pair" },
+ { "pv1pxi", "ptr_vector_quad" },
+ { "pv1ti", "ptr_V1TI" },
+ { "pv2df", "ptr_V2DF" },
+ { "pv2di", "ptr_V2DI" },
+ { "pv4sf", "ptr_V4SF" },
+ { "pv4si", "ptr_V4SI" },
+ { "pv8hi", "ptr_V8HI" },
+ { "pvp8hi", "ptr_pixel_V8HI" },
+ { "qi", "intQI" },
+ { "sd", "dfloat32" },
+ { "sf", "float" },
+ { "si", "intSI" },
+ { "st", "const_str" },
+ { "td", "dfloat128" },
+ { "tf", "float128" },
+ { "ti", "intTI" },
+ { "udi", "long_long_unsigned" },
+ { "uhi", "unsigned_intHI" },
+ { "ulg", "long_unsigned" },
+ { "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" },
+ { "v1poi", "vector_pair" },
+ { "v1pxi", "vector_quad" },
+ { "v1ti", "V1TI" },
+ { "v2df", "V2DF" },
+ { "v2di", "V2DI" },
+ { "v4sf", "V4SF" },
+ { "v4si", "V4SI" },
+ { "v8hi", "V8HI" },
+ { "vp8hi", "pixel_V8HI" },
+ };
+
/* Pointer to a diagnostic function. */
void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2)))
= NULL;
@@ -2241,10 +2341,83 @@ 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, bool indent)
+{
+ if (indent)
+ fprintf (init_file, " ");
+ 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;
+
+ /* Check whether we have a "tf" token in this string, representing
+ a float128_type_node. It's possible that float128_type_node is
+ undefined (occurs for -maltivec -mno-vsx, for example), so we
+ must guard against that. */
+ int tf_found = strstr (str, "tf") != NULL;
+
+ /* Avoid side effects of strtok on the original string by using a copy. */
+ char *buf = (char *) malloc (strlen (str) + 1);
+ strcpy (buf, str);
+
+ if (tf_found)
+ fprintf (init_file, " if (float128_type_node)\n ");
+
+ fprintf (init_file, " %s\n = build_function_type_list (", buf);
+ tok = strtok (buf, "_");
+ write_type_node (tok, tf_found);
+ 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, tf_found);
+ 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-builtins.h). */
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-25 16:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 17:17 [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Write output to the builtins init file, part 3 of 3 William Schmidt
-- strict thread matches above, loose matches on Subject: below --
2021-06-25 16:16 William Schmidt
2021-04-26 20:49 William Schmidt
2021-04-02 22:10 William Schmidt
2021-04-01 19:48 William Schmidt
2021-03-25 15:46 William Schmidt
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).