Skip to content

feature: add regex to inst.assembly schema #832

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kbroch-rivosinc
Copy link
Collaborator

relates to #807

@kbroch-rivosinc kbroch-rivosinc self-assigned this Jun 4, 2025
@kbroch-rivosinc kbroch-rivosinc marked this pull request as draft June 4, 2025 20:54
@kbroch-rivosinc
Copy link
Collaborator Author

This regex doesn't try list the exact operand names. (just alphanumeric)
There are still these failures that I'm wondering if they are actual errors:

❯ pre-commit run --all-files check-jsonschema-inst
Validate instruction files with jsonschema...............................Failed
- hook id: check-jsonschema
- exit code: 1

ok -- validation done
ok -- validation done
ok -- validation done
Schema validation errors were encountered.
  arch/inst/Zilsd/sd.yaml::$.assembly: 'xs2, offset(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
ok -- validation done
ok -- validation done
ok -- validation done
ok -- validation done
Schema validation errors were encountered.
  arch/inst/Zfh/fsh.yaml::$.assembly: 'fs2, imm12(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
Schema validation errors were encountered.
  arch/inst/C/c.ebreak.yaml::$.assembly: ' ' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
  arch/inst/Zfh/flh.yaml::$.assembly: 'xd, imm12(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
Schema validation errors were encountered.
  arch/inst/Zcmp/cm.push.yaml::$.assembly: 'reg_list, -stack_adj' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
Schema validation errors were encountered.
  arch/inst/Zilsd/ld.yaml::$.assembly: 'rd, offset(rs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'

@ThinkOpenly
Copy link
Collaborator

  arch/inst/Zilsd/sd.yaml::$.assembly: 'xs2, offset(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
  arch/inst/Zilsd/ld.yaml::$.assembly: 'rd, offset(rs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'

These files shouldn't exist, actually, since we have arch/inst/I/sd.yaml and arch/inst/I/ld.yaml. The Zilsd code should be merged into the I code, like what was done for Zclsd. Need an issue or PR for that.

  arch/inst/Zfh/fsh.yaml::$.assembly: 'fs2, imm12(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'
  arch/inst/Zfh/flh.yaml::$.assembly: 'xd, imm12(xs1)' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'

These will be fixed when #822 is merged.

  arch/inst/C/c.ebreak.yaml::$.assembly: ' ' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'

This is using a space instead of an empty string. Issue/PR warranted.

  arch/inst/Zcmp/cm.push.yaml::$.assembly: 'reg_list, -stack_adj' does not match '^$|^\\(?[a-zA-Z][a-zA-Z0-9_]*\\)?(?:, (imm\\(|\\()?[a-zA-Z][a-zA-Z0-9_]*\\)?)*$'

@kbroch-rivosinc
Copy link
Collaborator Author

Thanks @ThinkOpenly for quick review. I fixed the extra space in ebreak for now.

@dhower-qc
Copy link
Collaborator

arch/inst/Zcmp/cm.push.yaml::$.assembly: 'reg_list, -stack_adj' does not match '^$|^\(?[a-zA-Z][a-zA-Z0-9_]\)?(?:, (imm\(|\()?[a-zA-Z][a-zA-Z0-9_]\)?)*$'

That's valid. But it's also a case highlighting that our simple string is insufficient. The syntax for push/pop includes a register list that determined by a 16-entry LUT.

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

Successfully merging this pull request may close these issues.

3 participants