Skip to content

Commit

Permalink
Use fm's new matching features for x86 register matching.
Browse files Browse the repository at this point in the history
Instead of using concrete register names, one can refer to a class of
registers e.g. `r.8` is all 8-bit registers. To match a register name
but ignore its value uses `r.8._`: to match a register name use `r.8.x`.
Suffixes: must be unique (i.e. `r.8.x` and `r.8.y` must refer to
different registers); and they refer to the "underlying" register (e.g.
`r.8.x` and `r.64.x` might match `al` and `RAX` which is considered the
same register, but will fail to match against `al` and `RBX`).

To make this concrete these `assert`s all succeed:

```rust
let fmm = fmatcher("r.8.x r.8.y r.64.x");
assert!(fmm.matches("al bl rax").is_ok());
assert!(fmm.matches("al al rax").is_err());
assert!(fmm.matches("al bl rbx").is_err());
assert!(fmm.matches("al bl eax").is_err());
```
  • Loading branch information
ltratt committed Jul 24, 2024
1 parent 8773833 commit adb82e8
Show file tree
Hide file tree
Showing 2 changed files with 260 additions and 107 deletions.
1 change: 1 addition & 0 deletions ykrt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ yk_testing = ["yktracec/yk_testing"]
[dev-dependencies]
cfgrammar = "0.13"
fm = "0.3.0"
lazy_static = "1.5.0"
lrlex = "0.13"
lrpar = "0.13"
regex = { version = "1.9", features = ["std"] }
Loading

0 comments on commit adb82e8

Please sign in to comment.