Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MoveInitializers splits start state for parsers that do not need this #4901

Closed
oleg-ran-amd opened this issue Sep 6, 2024 · 0 comments · Fixed by #4902
Closed

MoveInitializers splits start state for parsers that do not need this #4901

oleg-ran-amd opened this issue Sep 6, 2024 · 0 comments · Fixed by #4902
Assignees
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)

Comments

@oleg-ran-amd
Copy link

If MoveInitializers detects that a parser needs a start state split, start also gets split for all the other parsers that follow that first parser in the P4 IR, even if they do not need this.

Parser2 in the code below does not need start split:

parser Parser1() {
  bit<8> l = 0;
  state start {
    transition next;
  }
  state next {
    transition select(l) {
        default: accept;
    }
  }
}

parser Parser2() {
  state start {
    transition  accept;
  }
}

parser proto();
package top(proto p1, proto p2);
top(Parser1(), Parser2()) main;

However, the frontend's output is:

parser Parser1() {
    @name("Parser1.l") bit<8> l_0;
    state start {
        l_0 = 8w0;
        transition start_0;
    }
    state start_0 {
        transition select(l_0) {
            default: accept;
        }
    }
}

parser Parser2() {
    state start {
        transition start_0;
    }
    state start_0 {  <==================
        transition accept;
    }
}

The midend is able to squash start_0 and start for Parser2 above, but there is still no reason to split.

@kfcripps kfcripps added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Sep 6, 2024
@kfcripps kfcripps self-assigned this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants