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

Use blocks/successors instead of symbols #5

Open
thegoldgoat opened this issue Jul 20, 2023 · 0 comments
Open

Use blocks/successors instead of symbols #5

thegoldgoat opened this issue Jul 20, 2023 · 0 comments

Comments

@thegoldgoat
Copy link
Owner

For example, regex ab|cd now is compiled to:

module {
  "cicero.flat_split"() {splitTarget = @FLATTEN_0} : () -> ()
  "cicero.match_char"() {targetChar = 99 : i8} : () -> ()
  "cicero.match_char"() {targetChar = 100 : i8} : () -> ()
  "cicero.accept"() {sym_name = "S0"} : () -> ()
  "cicero.match_char"() {sym_name = "FLATTEN_0", targetChar = 97 : i8} : () -> ()
  "cicero.match_char"() {targetChar = 98 : i8} : () -> ()
  "cicero.jump"() {target = @S0} : () -> ()
}

But it would be more efficient (and more idiomatic for MLIR) to use blocks/successors in this way:

cicero.match {
  cicero.flat_split ^bb1, ^FLATTEN_0
^bb1:
  "cicero.match_char"() {targetChar = 99 : i8} : () -> ()
  "cicero.match_char"() {targetChar = 100 : i8} : () -> ()
  cicero.jump ^S0
^FLATTEN_0:
  "cicero.match_char"() {targetChar = 97 : i8} : () -> ()
  "cicero.match_char"() {targetChar = 98 : i8} : () -> ()
  cicero.jump ^S0
^S0:
  cicero.accept
}

with jumps as block terminators, that specify its successor which essentially is the jump target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant