From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id 92FBD3858024; Thu, 1 Apr 2021 19:47:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92FBD3858024 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: Add functions for matching types, part 3 of 3 X-Act-Checkin: gcc X-Git-Author: Bill Schmidt X-Git-Refname: refs/users/wschmidt/heads/builtins10 X-Git-Oldrev: 714be7f0b297be9c546c0a72209402e71f53a806 X-Git-Newrev: b262671e1c5f073f9ea306c03bdadd7fd2784be3 Message-Id: <20210401194733.92FBD3858024@sourceware.org> Date: Thu, 1 Apr 2021 19:47:33 +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, 01 Apr 2021 19:47:33 -0000 https://gcc.gnu.org/g:b262671e1c5f073f9ea306c03bdadd7fd2784be3 commit b262671e1c5f073f9ea306c03bdadd7fd2784be3 Author: Bill Schmidt Date: Wed Mar 24 13:08:37 2021 -0500 rs6000: Add functions for matching types, part 3 of 3 2021-03-24 Bill Schmidt gcc/ * config/rs6000/rs6000-gen-builtins.c (restriction): New enum. (typeinfo): Add restr field. (match_const_restriction): Implement. Diff: --- gcc/config/rs6000/rs6000-gen-builtins.c | 136 ++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index ec40ad4c25e..fd1753c2935 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -217,6 +217,21 @@ enum basetype { BT_VQUAD }; +/* Ways in which a const int value can be restricted. RES_BITS indicates + that the integer is restricted to val1 bits, interpreted as an unsigned + number. RES_RANGE indicates that the integer is restricted to values + between val1 and val2, inclusive. RES_VAR_RANGE is like RES_RANGE, but + the argument may be variable, so it can only be checked if it is constant. + RES_VALUES indicates that the integer must have one of the values val1 + or val2. */ +enum restriction { + RES_NONE, + RES_BITS, + RES_RANGE, + RES_VAR_RANGE, + RES_VALUES +}; + /* Type modifiers for an argument or return type. */ struct typeinfo { char isvoid; @@ -228,6 +243,7 @@ struct typeinfo { char ispixel; char ispointer; basetype base; + restriction restr; int val1; int val2; }; @@ -480,6 +496,126 @@ match_basetype (typeinfo *typedata) 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 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] != ',') + { + (*diag) ("missing comma at column %d.\n", pos + 1); + return 0; + } + safe_inc_pos (); + 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 (); + } + 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; + } + safe_inc_pos (); + 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_VAR_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 (); + } + return 1; }