diff mbox

[PR,57195] Allow mode iterators inside angle brackets

Message ID 55DC37D4.9050900@linaro.org
State New
Headers show

Commit Message

Michael Collison Aug. 25, 2015, 9:39 a.m. UTC
This patch allow mode iterators inside angle brackets in machine 
description files. I
discovered the issue when attempting to use iterators on match_operand's 
as follows:

match_operand:<VW:V_widen> 0 "s_register_operand" "=w")

The function 'read_name' is nor properly handling ':' inside angle brackets.

Bootstrapped on arm-linux.

OK for trunk?

2015-08-25  Michael Collison  <michael.collison@linaro.org>

     PR other/57195
     * read-md.c (read_name): Allow mode iterators inside angle
     brackets in rtl expressions.

Comments

Richard Sandiford Sept. 7, 2015, 9:46 a.m. UTC | #1
Michael Collison <michael.collison@linaro.org> writes:
> This patch allow mode iterators inside angle brackets in machine
> description files. I discovered the issue when attempting to use
> iterators on match_operand's as follows:
>
> match_operand:<VW:V_widen> 0 "s_register_operand" "=w")
>
> The function 'read_name' is nor properly handling ':' inside angle brackets.
>
> Bootstrapped on arm-linux.

Sorry for the slow review.

> diff --git a/gcc/read-md.c b/gcc/read-md.c
> index 9f158ec..0171fb0 100644
> --- a/gcc/read-md.c
> +++ b/gcc/read-md.c
> @@ -399,17 +399,25 @@ read_name (struct md_name *name)
>   {
>     int c;
>     size_t i;
> +  bool in_angle_bracket;
>
>     c = read_skip_spaces ();
>
>     i = 0;
> +  in_angle_bracket = false;
>     while (1)
>       {
> +      if (c == '<')
> +    in_angle_bracket = true;
> +
> +      if (c == '>')
> +    in_angle_bracket = false;
> +
>         if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r'
>         || c == EOF)
>       break;
> -      if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
> -      || c == '(' || c == '[')
> +      if (((c == ':') and (!in_angle_bracket)) || c == ')' || c == ']'
> +      || c == '"' || c == '/' || c == '(' || c == '[')
>       {
>         unread_char (c);
>         break;

I think we should have a nesting depth rather than a boolean.
It also seems more natural to skip the final "if" statement above when
inside an angle bracket, rather than treating ':' as a special case.
(We'd still break at the end of the line in the case of a missing '>',
so the error reporting shouldn't be too bad.)

I suppose logically '>' with a nesting depth of 0 should also break
the loop.

Thanks for fixing this.

Richard
diff mbox

Patch

diff --git a/gcc/read-md.c b/gcc/read-md.c
index 9f158ec..0171fb0 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -399,17 +399,25 @@  read_name (struct md_name *name)
  {
    int c;
    size_t i;
+  bool in_angle_bracket;

    c = read_skip_spaces ();

    i = 0;
+  in_angle_bracket = false;
    while (1)
      {
+      if (c == '<')
+    in_angle_bracket = true;
+
+      if (c == '>')
+    in_angle_bracket = false;
+
        if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r'
        || c == EOF)
      break;
-      if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
-      || c == '(' || c == '[')
+      if (((c == ':') and (!in_angle_bracket)) || c == ')' || c == ']'
+      || c == '"' || c == '/' || c == '(' || c == '[')
      {
        unread_char (c);
        break;