public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-09-14 13:57 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-09-14 13:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf8a1da52de1375652140ff1b5af4bb6e18f030a

commit bf8a1da52de1375652140ff1b5af4bb6e18f030a
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-10-29 19:49 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-10-29 19:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1c6c4b400435d13ab73a9cd6de0465ca3922197a

commit 1c6c4b400435d13ab73a9cd6de0465ca3922197a
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-10-27 16:27 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-10-27 16:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:084b7efa74b17ee0846c9330e869083293d1ceaf

commit 084b7efa74b17ee0846c9330e869083293d1ceaf
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-09-16 21:28 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-09-16 21:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:06380a1c2f67751852a56d0765686de887e84a7c

commit 06380a1c2f67751852a56d0765686de887e84a7c
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-08-28 20:06 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-08-28 20:06 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7ad4e3b983a02435f356f032667e49120a6435b1

commit 7ad4e3b983a02435f356f032667e49120a6435b1
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-08-20 16:38 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-08-20 16:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:126d879aa06ee6b080a506e2ef8f2720b475a76d

commit 126d879aa06ee6b080a506e2ef8f2720b475a76d
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-08-18 18:43 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-08-18 18:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1b05d2212ec7fb7afab15326388730c4165ebaab

commit 1b05d2212ec7fb7afab15326388730c4165ebaab
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-07-27 18:47 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-07-27 18:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f7edc01b3b97b527a1143fc2ec485e0f0ee8a9df

commit f7edc01b3b97b527a1143fc2ec485e0f0ee8a9df
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-07-26  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 efc0b2dec65..18c67ce2202 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -188,6 +188,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -200,6 +215,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -433,6 +449,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-07-17 17:21 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-07-17 17:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c485ed2a65f55270123ba61310211afd477b7a35

commit c485ed2a65f55270123ba61310211afd477b7a35
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-06-17  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 e38f3af9c7a..e4b08ee5036 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -189,6 +189,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -201,6 +216,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -434,6 +450,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;
 }


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

* [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3
@ 2020-06-17 20:04 William Schmidt
  0 siblings, 0 replies; 10+ messages in thread
From: William Schmidt @ 2020-06-17 20:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a068e4442e85e1fb1cabd2bf5013a4914a055d63

commit a068e4442e85e1fb1cabd2bf5013a4914a055d63
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Wed Jun 17 10:47:23 2020 -0500

    rs6000: Add functions for matching types, part 3 of 3
    
    2020-06-17  Bill Schmidt  <wschmidt@linux.ibm.com>
    
            * config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
            (typeinfo): Add restriction 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 e38f3af9c7a..e4b08ee5036 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -189,6 +189,21 @@ enum basetype {
   BT_IBM128
 };
 
+/* 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;
@@ -201,6 +216,7 @@ struct typeinfo {
   char ispointer;
   char isopaque;
   basetype base;
+  restriction restr;
   int val1;
   int val2;
 };
@@ -434,6 +450,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;
 }


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

end of thread, other threads:[~2020-10-29 19:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 13:57 [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Add functions for matching types, part 3 of 3 William Schmidt
  -- strict thread matches above, loose matches on Subject: below --
2020-10-29 19:49 William Schmidt
2020-10-27 16:27 William Schmidt
2020-09-16 21:28 William Schmidt
2020-08-28 20:06 William Schmidt
2020-08-20 16:38 William Schmidt
2020-08-18 18:43 William Schmidt
2020-07-27 18:47 William Schmidt
2020-07-17 17:21 William Schmidt
2020-06-17 20:04 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).