From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id A8F063851C21; Fri, 21 May 2021 22:17:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8F063851C21 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: William Schmidt To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: **squash me** for 0006 X-Act-Checkin: gcc X-Git-Author: Bill Schmidt X-Git-Refname: refs/users/wschmidt/heads/builtins10 X-Git-Oldrev: 2da22300a3ac7b1e65bea8da3512b5bbf073f573 X-Git-Newrev: 1bd4d27faf4681c7e9d2fe5275025e171383b402 Message-Id: <20210521221719.A8F063851C21@sourceware.org> Date: Fri, 21 May 2021 22:17:19 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 22:17:19 -0000 https://gcc.gnu.org/g:1bd4d27faf4681c7e9d2fe5275025e171383b402 commit 1bd4d27faf4681c7e9d2fe5275025e171383b402 Author: Bill Schmidt Date: Fri May 21 17:17:00 2021 -0500 rs6000: **squash me** for 0006 2021-05-21 Bill Schmidt gcc/ * config/rs6000/rs6000-gen-builtins.c (limits.h): New include. (MININT): Redefine. (exit_codes): Remove. (consume_whitespace): Void arglist, sizeof operator, line overruns. (safe_inc_pos): Void arglist, exit codes. (match_identifier): Void arglist, line overruns. (match_integer): Likewise. (match_to_right_bracket): Function note, void arglist, line overruns. (match_type): sizeof operator. (parse_args): Likewise. (parse_bif_attrs): Likewise. (complete_vector_type): Exit codes. (complete_base_type): Likewise. (parse_bif_entry): Void arglist. (parse_bif_stanza): Likewise. (parse_bif): Likewise. (create_bif_order): Likewise. (parse_ovld_entry): Likewise. (parse_ovld_stanza): Likewise. (parse_ovld): Likewise. (write_decls): Likewise. (write_header_file): Likewise. (write_bif_static_init): Likewise. (write_ovld_static_init): Likewise. (write_init_bif_table): Likewise. (write_init_ovld_table): Likewise. (write_init_file): Likewise. (write_defines_file): Likewise. (delete_output_files): Likewise. (main): Exit codes. Diff: --- gcc/config/rs6000/rs6000-gen-builtins.c | 135 ++++++++++++++------------------ 1 file changed, 60 insertions(+), 75 deletions(-) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index dd23fc8b010..d377c91c96b 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -159,6 +159,7 @@ along with GCC; see the file COPYING3. If not see #include #include #include +#include #include #include #include @@ -166,8 +167,8 @@ along with GCC; see the file COPYING3. If not see #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. */ -#define MININT INT32_MIN + be 64 bits wide, so this is a safe sentinel value. */ +#define MININT INT_MIN /* Input and output file descriptors and pathnames. */ static FILE *bif_file; @@ -433,23 +434,6 @@ static int num_ovlds; static int curr_ovld; static int max_ovld_args = 0; -/* 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 -}; - /* Return codes for parsing routines. */ enum parse_codes { PC_OK, @@ -596,7 +580,7 @@ ovld_diag (const char * fmt, ...) /* Pass over unprintable characters and whitespace (other than a newline, which terminates the scan). */ static void -consume_whitespace () +consume_whitespace (void) { while (pos < LINELEN && isspace(linebuf[pos]) && linebuf[pos] != '\n') pos++; @@ -610,9 +594,12 @@ advance_line (FILE *file) while (1) { /* Read ahead one line and check for EOF. */ - if (!fgets (linebuf, sizeof(linebuf), file)) + if (!fgets (linebuf, sizeof linebuf, file)) return 0; line++; + size_t len = strlen (linebuf); + if (linebuf[len - 1] != '\n') + (*diag) ("line doesn't terminate with newline\n"); pos = 0; consume_whitespace (); if (linebuf[pos] != '\n' && linebuf[pos] != ';') @@ -621,27 +608,23 @@ advance_line (FILE *file) } static inline void -safe_inc_pos () +safe_inc_pos (void) { if (pos++ >= LINELEN) { (*diag) ("line length overrun.\n"); - exit (EC_INTERR); + exit (1); } } /* Match an identifier, returning NULL on failure, else a pointer to a buffer containing the identifier. */ static char * -match_identifier () +match_identifier (void) { int lastpos = pos - 1; while (isalnum (linebuf[lastpos + 1]) || linebuf[lastpos + 1] == '_') - if (++lastpos >= LINELEN - 1) - { - (*diag) ("line length overrun.\n"); - exit (EC_INTERR); - } + ++lastpos; if (lastpos < pos) return 0; @@ -656,7 +639,7 @@ match_identifier () /* Match an integer and return its value, or MININT on failure. */ static int -match_integer () +match_integer (void) { int startpos = pos; if (linebuf[pos] == '-') @@ -664,11 +647,7 @@ match_integer () int lastpos = pos - 1; while (isdigit (linebuf[lastpos + 1])) - if (++lastpos >= LINELEN - 1) - { - (*diag) ("line length overrun in match_integer.\n"); - exit (EC_INTERR); - } + ++lastpos; if (lastpos < pos) return MININT; @@ -683,16 +662,22 @@ match_integer () return x; } +/* Match a string up to but not including a ']', and return its value, + or zero if there is nothing before the ']'. Error if we don't find + such a character. */ static const char * -match_to_right_bracket () +match_to_right_bracket (void) { int lastpos = pos - 1; while (linebuf[lastpos + 1] != ']') - if (++lastpos >= LINELEN - 1) - { - (*diag) ("line length overrun.\n"); - exit (EC_INTERR); - } + { + if (linebuf[lastpos + 1] == '\n') + { + (*diag) ("no ']' found before end of line.\n"); + exit (1); + } + ++lastpos; + } if (lastpos < pos) return 0; @@ -998,7 +983,7 @@ match_type (typeinfo *typedata, int voidok) indicates a pointer type. */ consume_whitespace (); - memset (typedata, 0, sizeof(*typedata)); + memset (typedata, 0, sizeof *typedata); int oldpos = pos; char *token = match_identifier (); @@ -1247,7 +1232,7 @@ parse_args (prototype *protoptr) consume_whitespace (); int oldpos = pos; typelist *argentry = (typelist *) malloc (sizeof (typelist)); - memset (argentry, 0, sizeof (*argentry)); + memset (argentry, 0, sizeof *argentry); typeinfo *argtype = &argentry->info; success = match_type (argtype, VOID_NOTOK); if (success) @@ -1316,7 +1301,7 @@ parse_bif_attrs (attrinfo *attrptr) } safe_inc_pos (); - memset (attrptr, 0, sizeof (*attrptr)); + memset (attrptr, 0, sizeof *attrptr); char *attrname = NULL; do { @@ -1471,7 +1456,7 @@ complete_vector_type (typeinfo *typeptr, char *buf, int *bufi) break; default: (*diag) ("unhandled basetype %d.\n", typeptr->base); - exit (EC_INTERR); + exit (1); } } } @@ -1532,7 +1517,7 @@ complete_base_type (typeinfo *typeptr, char *buf, int *bufi) break; default: (*diag) ("unhandled basetype %d.\n", typeptr->base); - exit (EC_INTERR); + exit (1); } *bufi += 2; @@ -1706,7 +1691,7 @@ val1[1] = %d, val2[1] = %d, pos = %d.\n", /* Parse a two-line entry for a built-in function. */ static parse_codes -parse_bif_entry () +parse_bif_entry (void) { /* Check for end of stanza. */ pos = 0; @@ -1819,7 +1804,7 @@ parse_bif_entry () /* Parse one stanza of the input BIF file. linebuf already contains the first line to parse. */ static parse_codes -parse_bif_stanza () +parse_bif_stanza (void) { /* Parse the stanza header. */ pos = 0; @@ -1871,7 +1856,7 @@ parse_bif_stanza () /* Parse the built-in file. */ static parse_codes -parse_bif () +parse_bif (void) { parse_codes result; diag = &bif_diag; @@ -1899,7 +1884,7 @@ void set_bif_order (char *str) /* Create a mapping from function IDs in their final order to the order they appear in the built-in function file. */ static void -create_bif_order () +create_bif_order (void) { bif_order = (int *) malloc ((curr_bif + 1) * sizeof (int)); rbt_inorder_callback (&bifo_rbt, bifo_rbt.rbt_root, set_bif_order); @@ -1907,7 +1892,7 @@ create_bif_order () /* Parse one two-line entry in the overload file. */ static parse_codes -parse_ovld_entry () +parse_ovld_entry (void) { /* Check for end of stanza. */ pos = 0; @@ -1995,7 +1980,7 @@ parse_ovld_entry () /* Parse one stanza of the input overload file. linebuf already contains the first line to parse. */ static parse_codes -parse_ovld_stanza () +parse_ovld_stanza (void) { /* Parse the stanza header. */ pos = 0; @@ -2106,7 +2091,7 @@ parse_ovld_stanza () /* Parse the overload file. */ static parse_codes -parse_ovld () +parse_ovld (void) { parse_codes result = PC_OK; diag = &ovld_diag; @@ -2134,7 +2119,7 @@ write_autogenerated_header (FILE *file) /* Write declarations into the header file. */ static void -write_decls () +write_decls (void) { fprintf (header_file, "enum rs6000_gen_builtins\n{\n RS6000_BIF_NONE,\n"); for (int i = 0; i <= curr_bif; i++) @@ -2364,7 +2349,7 @@ map_token_to_type_node (char *tok) if (low > high) { (*diag) ("token '%s' doesn't appear in the type map!\n", tok); - exit (EC_INTERR); + exit (1); } return type_map[mid].value; @@ -2430,7 +2415,7 @@ write_fntype_init (char *str) /* Write everything to the header file (rs6000-builtins.h). */ static int -write_header_file () +write_header_file (void) { write_autogenerated_header (header_file); @@ -2450,7 +2435,7 @@ write_header_file () /* Write the decl and initializer for rs6000_builtin_info_x[]. */ static void -write_bif_static_init () +write_bif_static_init (void) { const char *res[3]; fprintf (init_file, "bifdata rs6000_builtin_info_x[RS6000_BIF_MAX] =\n"); @@ -2553,7 +2538,7 @@ write_bif_static_init () /* Write the decls and initializers for rs6000_overload_info[] and rs6000_instance_info[]. */ static void -write_ovld_static_init () +write_ovld_static_init (void) { fprintf (init_file, "ovldrecord rs6000_overload_info[RS6000_OVLD_MAX " @@ -2604,7 +2589,7 @@ write_ovld_static_init () /* Write code to initialize the built-in function table. */ static void -write_init_bif_table () +write_init_bif_table (void) { for (int i = 0; i <= curr_bif; i++) { @@ -2691,7 +2676,7 @@ write_init_bif_table () /* Write code to initialize the overload table. */ static void -write_init_ovld_table () +write_init_ovld_table (void) { fprintf (init_file, " int base = RS6000_OVLD_NONE;\n\n"); @@ -2770,7 +2755,7 @@ write_init_ovld_table () /* Write everything to the initialization file (rs6000-builtins.c). */ static int -write_init_file () +write_init_file (void) { write_autogenerated_header (init_file); @@ -2846,7 +2831,7 @@ write_init_file () /* Write everything to the include file (rs6000-vecdefines.h). */ static int -write_defines_file () +write_defines_file (void) { fprintf (defines_file, "#ifndef _RS6000_VECDEFINES_H\n"); fprintf (defines_file, "#define _RS6000_VECDEFINES_H 1\n\n"); @@ -2871,7 +2856,7 @@ write_defines_file () /* Close and delete output files after any failure, so that subsequent build dependencies will fail. */ static void -delete_output_files () +delete_output_files (void) { /* Depending on whence we're called, some of these may already be closed. Don't check for errors. */ @@ -2893,7 +2878,7 @@ main (int argc, const char **argv) fprintf (stderr, "Five arguments required: two input file and three output " "files.\n"); - exit (EC_BADARGS); + exit (1); } pgm_path = argv[0]; @@ -2907,33 +2892,33 @@ main (int argc, const char **argv) if (!bif_file) { fprintf (stderr, "Cannot find input built-in file '%s'.\n", bif_path); - exit (EC_NOBIF); + exit (1); } ovld_file = fopen (ovld_path, "r"); if (!ovld_file) { fprintf (stderr, "Cannot find input overload file '%s'.\n", ovld_path); - exit (EC_NOOVLD); + exit (1); } header_file = fopen (header_path, "w"); if (!header_file) { fprintf (stderr, "Cannot open header file '%s' for output.\n", header_path); - exit (EC_NOHDR); + exit (1); } init_file = fopen (init_path, "w"); if (!init_file) { fprintf (stderr, "Cannot open init file '%s' for output.\n", init_path); - exit (EC_NOINIT); + exit (1); } defines_file = fopen (defines_path, "w"); if (!defines_file) { fprintf (stderr, "Cannot open defines file '%s' for output.\n", defines_path); - exit (EC_NODEFINES); + exit (1); } /* Initialize the balanced trees containing built-in function ids, @@ -2963,7 +2948,7 @@ main (int argc, const char **argv) { fprintf (stderr, "Parsing of '%s' failed, aborting.\n", bif_path); delete_output_files (); - exit (EC_PARSEBIF); + exit (1); } fclose (bif_file); @@ -2985,7 +2970,7 @@ main (int argc, const char **argv) { fprintf (stderr, "Parsing of '%s' failed, aborting.\n", ovld_path); delete_output_files (); - exit (EC_PARSEOVLD); + exit (1); } fclose (ovld_file); @@ -3000,14 +2985,14 @@ main (int argc, const char **argv) { fprintf (stderr, "Output to '%s' failed, aborting.\n", header_path); delete_output_files (); - exit (EC_WRITEHDR); + exit (1); } fclose (header_file); if (!write_init_file ()) { fprintf (stderr, "Output to '%s' failed, aborting.\n", init_path); delete_output_files (); - exit (EC_WRITEINIT); + exit (1); } fclose (init_file); @@ -3016,9 +3001,9 @@ main (int argc, const char **argv) { fprintf (stderr, "Output to '%s' failed, aborting.\n", defines_path); delete_output_files (); - exit (EC_WRITEDEFINES); + exit (1); } fclose (defines_file); - return EC_OK; + return 0; }