From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id D20C2385802D; Thu, 25 Mar 2021 15:45:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D20C2385802D 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: Parsing built-in input file, part 2 of 3 X-Act-Checkin: gcc X-Git-Author: Bill Schmidt X-Git-Refname: refs/users/wschmidt/heads/builtins10 X-Git-Oldrev: 8946c1e5289af4a023a116a66e8afc1a45e9a938 X-Git-Newrev: 9ee7fad36263b1592c2449d1220ead991ea0428b Message-Id: <20210325154524.D20C2385802D@sourceware.org> Date: Thu, 25 Mar 2021 15:45:24 +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: Thu, 25 Mar 2021 15:45:24 -0000 https://gcc.gnu.org/g:9ee7fad36263b1592c2449d1220ead991ea0428b commit 9ee7fad36263b1592c2449d1220ead991ea0428b Author: Bill Schmidt Date: Wed Mar 24 13:50:17 2021 -0500 rs6000: Parsing built-in input file, part 2 of 3 2021-03-24 Bill Schmidt gcc/ * config/rs6000/rs6000-gen-builtins.c (parse_args): New function. (parse_prototype): Implement. Diff: --- gcc/config/rs6000/rs6000-gen-builtins.c | 143 ++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index 4e13f0342dd..fd893bdc85a 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -1093,6 +1093,91 @@ match_type (typeinfo *typedata, int voidok) return 1; } +/* Parse the argument list. */ +static parse_codes +parse_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 restr_cnt = 0; + + int success; + *nargs = 0; + + /* Start the argument list. */ + consume_whitespace (); + if (linebuf[pos] != '(') + { + (*diag) ("missing '(' at column %d.\n", pos + 1); + return PC_PARSEFAIL; + } + 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_cnt >= MAXRESTROPNDS) + { + (*diag) ("More than two %d operands\n", MAXRESTROPNDS); + return PC_PARSEFAIL; + } + restr_opnd[restr_cnt] = *nargs + 1; + restr[restr_cnt] = argtype->restr; + val1[restr_cnt] = argtype->val1; + val2[restr_cnt++] = 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 PC_PARSEFAIL; + } + +#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 PC_PARSEFAIL; + } + safe_inc_pos (); + } + } while (success); + + return PC_OK; +} + /* Parse the attribute list. */ static parse_codes parse_bif_attrs (attrinfo *attrptr) @@ -1105,6 +1190,64 @@ parse_bif_attrs (attrinfo *attrptr) static parse_codes 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 PC_PARSEFAIL; + } + +#ifdef DEBUG + (*diag) ("return type: isvoid = %d, isconst = %d, isvector = %d, \ +issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, ispointer = %d, \ +base = %d, restr[0] = %d, val1[0] = %d, val2[0] = %d, restr1[1] = %d, \ +val1[1] = %d, val2[1] = %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 PC_PARSEFAIL; + } + +#ifdef DEBUG + (*diag) ("function name is '%s'.\n", *bifname); +#endif + + /* Process arguments. */ + if (parse_args (protoptr) == PC_PARSEFAIL) + return PC_PARSEFAIL; + + /* Process terminating semicolon. */ + consume_whitespace (); + if (linebuf[pos] != ';') + { + (*diag) ("missing semicolon at column %d.\n", pos + 1); + return PC_PARSEFAIL; + } + safe_inc_pos (); + consume_whitespace (); + if (linebuf[pos] != '\n') + { + (*diag) ("garbage at end of line at column %d.\n", pos + 1); + return PC_PARSEFAIL; + } + return PC_OK; }