nodejs / llparse

Generating parsers in LLVM IR
http://llparse.org
Other
584 stars 30 forks source link

Apply `check` optimization more often #15

Closed indutny closed 6 years ago

indutny commented 6 years ago

...and probably rename it to bitcheck.

indutny commented 6 years ago

For example:

p.node('name')
  .match(BIG_LIST, anotherNode)
  .match(FEW_ITEMS, p.error(...))
  .otherwise(p.error(...))

There's no need to kill optimization due to FEW_ITEMS, since they should be rarely called. Split the node in translator, and move FEW_ITEMS matching to otherwise clause of BitCheck.

indutny commented 6 years ago

Alternatively, the table could be made to contain multi-bit values instead of a single "check" bit. This way a switch after lookup could lead to both results.

indutny commented 6 years ago

We support bitfield with value width up to 4 bits now. Seems to be working great!