public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-06-15 17:16 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-06-15 17:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:071f491c883d3effbd3eb0ae49783ccec3fc6921
commit 071f491c883d3effbd3eb0ae49783ccec3fc6921
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Mon Jun 7 12:03:49 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-06-07 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
(typeinfo): Add restr field.
(match_bracketed_pair): New function.
(match_const_restriction): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 115 +++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 1 deletion(-)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index f850ea86a39..b964dc2298f 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -216,6 +216,22 @@ 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
{
@@ -228,6 +244,7 @@ struct typeinfo
char ispixel;
char ispointer;
basetype base;
+ restriction restr;
char *val1;
char *val2;
};
@@ -453,6 +470,53 @@ match_basetype (typeinfo *typedata)
return 1;
}
+/* Helper routine for match_const_restriction. */
+static int
+match_bracketed_pair (typeinfo *typedata, char open, char close,
+ restriction restr)
+{
+ if (linebuf[pos] == open)
+ {
+ safe_inc_pos ();
+ int oldpos = pos;
+ char *x = match_integer ();
+ if (x == NULL)
+ {
+ (*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;
+ char *y = match_integer ();
+ if (y == NULL)
+ {
+ (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+ return 0;
+ }
+ typedata->restr = restr;
+ typedata->val1 = x;
+ typedata->val2 = y;
+
+ consume_whitespace ();
+ if (linebuf[pos] != close)
+ {
+ (*diag) ("malformed restriction at column %d.\n", pos + 1);
+ return 0;
+ }
+ safe_inc_pos ();
+ return 1;
+ }
+
+ return 0;
+}
+
/* A const int argument may be restricted to certain values. This is
indicated by one of the following occurring after the "int' token:
@@ -470,7 +534,56 @@ match_basetype (typeinfo *typedata)
static int
match_const_restriction (typeinfo *typedata)
{
- return 1;
+ int oldpos = pos;
+ if (linebuf[pos] == '<')
+ {
+ safe_inc_pos ();
+ oldpos = pos;
+ char *x = match_integer ();
+ if (x == NULL)
+ {
+ (*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;
+ char *y = match_integer ();
+ if (y == NULL)
+ {
+ (*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 ();
+ return 1;
+ }
+ else if (match_bracketed_pair (typedata, '{', '}', RES_VALUES)
+ || match_bracketed_pair (typedata, '[', ']', RES_VAR_RANGE))
+ return 1;
+
+ return 0;
}
/* Look for a type, which can be terminated by a token that is not part of
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-06-25 16:15 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-06-25 16:15 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cf0fab7c1d59917cd5932929bf4734eb5e5acf33
commit cf0fab7c1d59917cd5932929bf4734eb5e5acf33
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Mon Jun 7 12:03:49 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-06-07 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-gen-builtins.c (restriction): New enum.
(typeinfo): Add restr field.
(match_bracketed_pair): New function.
(match_const_restriction): Implement.
Diff:
---
gcc/config/rs6000/rs6000-gen-builtins.c | 115 +++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 1 deletion(-)
diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index f850ea86a39..b964dc2298f 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -216,6 +216,22 @@ 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
{
@@ -228,6 +244,7 @@ struct typeinfo
char ispixel;
char ispointer;
basetype base;
+ restriction restr;
char *val1;
char *val2;
};
@@ -453,6 +470,53 @@ match_basetype (typeinfo *typedata)
return 1;
}
+/* Helper routine for match_const_restriction. */
+static int
+match_bracketed_pair (typeinfo *typedata, char open, char close,
+ restriction restr)
+{
+ if (linebuf[pos] == open)
+ {
+ safe_inc_pos ();
+ int oldpos = pos;
+ char *x = match_integer ();
+ if (x == NULL)
+ {
+ (*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;
+ char *y = match_integer ();
+ if (y == NULL)
+ {
+ (*diag) ("malformed integer at column %d.\n", oldpos + 1);
+ return 0;
+ }
+ typedata->restr = restr;
+ typedata->val1 = x;
+ typedata->val2 = y;
+
+ consume_whitespace ();
+ if (linebuf[pos] != close)
+ {
+ (*diag) ("malformed restriction at column %d.\n", pos + 1);
+ return 0;
+ }
+ safe_inc_pos ();
+ return 1;
+ }
+
+ return 0;
+}
+
/* A const int argument may be restricted to certain values. This is
indicated by one of the following occurring after the "int' token:
@@ -470,7 +534,56 @@ match_basetype (typeinfo *typedata)
static int
match_const_restriction (typeinfo *typedata)
{
- return 1;
+ int oldpos = pos;
+ if (linebuf[pos] == '<')
+ {
+ safe_inc_pos ();
+ oldpos = pos;
+ char *x = match_integer ();
+ if (x == NULL)
+ {
+ (*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;
+ char *y = match_integer ();
+ if (y == NULL)
+ {
+ (*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 ();
+ return 1;
+ }
+ else if (match_bracketed_pair (typedata, '{', '}', RES_VALUES)
+ || match_bracketed_pair (typedata, '[', ']', RES_VAR_RANGE))
+ return 1;
+
+ return 0;
}
/* Look for a type, which can be terminated by a token that is not part of
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-04-26 20:48 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-26 20:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4cecf1cf86aae210b878f8c9b997f9eeea035fb0
commit 4cecf1cf86aae210b878f8c9b997f9eeea035fb0
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 24 13:08:37 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-03-24 Bill Schmidt <wschmidt@linux.ibm.com>
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 96e74e6048a..1c4bf20bf3b 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -218,6 +218,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;
@@ -229,6 +244,7 @@ struct typeinfo {
char ispixel;
char ispointer;
basetype base;
+ restriction restr;
int val1;
int val2;
};
@@ -477,6 +493,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] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-04-02 22:09 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-02 22:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7e394be0c16c30757a3e592d10c2e14cee508b6e
commit 7e394be0c16c30757a3e592d10c2e14cee508b6e
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 24 13:08:37 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-03-24 Bill Schmidt <wschmidt@linux.ibm.com>
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 96e74e6048a..1c4bf20bf3b 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -218,6 +218,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;
@@ -229,6 +244,7 @@ struct typeinfo {
char ispixel;
char ispointer;
basetype base;
+ restriction restr;
int val1;
int val2;
};
@@ -477,6 +493,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] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-04-01 19:47 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-04-01 19:47 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b262671e1c5f073f9ea306c03bdadd7fd2784be3
commit b262671e1c5f073f9ea306c03bdadd7fd2784be3
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 24 13:08:37 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-03-24 Bill Schmidt <wschmidt@linux.ibm.com>
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3
@ 2021-03-25 15:45 William Schmidt
0 siblings, 0 replies; 6+ messages in thread
From: William Schmidt @ 2021-03-25 15:45 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:584812bb99825d0d91cad68c365aa75a124144df
commit 584812bb99825d0d91cad68c365aa75a124144df
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Mar 24 13:08:37 2021 -0500
rs6000: Add functions for matching types, part 3 of 3
2021-03-24 Bill Schmidt <wschmidt@linux.ibm.com>
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-25 16:15 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:16 [gcc(refs/users/wschmidt/heads/builtins10)] rs6000: Add functions for matching types, part 3 of 3 William Schmidt
-- strict thread matches above, loose matches on Subject: below --
2021-06-25 16:15 William Schmidt
2021-04-26 20:48 William Schmidt
2021-04-02 22:09 William Schmidt
2021-04-01 19:47 William Schmidt
2021-03-25 15:45 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).