Skip to content

Allow literal dots in instruction mnemonics? #31

@CSharperMantle

Description

@CSharperMantle

Background and motivation. I am working on contributing a LoongArch641 decoder to this project. Some instructions in LA64 contain underscores (_) in their mnemonics, such as the AMSWAP_DB.W atomic memory access instruction2. In the current approach, underscores are an "escaped" version of dots (.) and are replaced with dots before display. This workaround will break mnemonics with underscores.

let formatted_name = self.name.replace('_', ".");

Possible solution. I can see these possible solutions to this problem.

  • Introduce yet another escape sequence (perhaps double underscore __) to represent a single underscore.
    • Pros
      • No changes to current decoding tables are needed.
      • No visible API/output changes.
    • Cons
      • More complexity in parsing.
      • Not utilizing TOML's quoted key feature3.
  • Quote mnemonics when necessary so that literal dots can be represented. See Allow dot symbols in insn mnemonics by quoting #32 for an implementation.
    • Pros
      • Better scalability.
      • Improved parser simplicity.
      • Conforms to TOML specs.
      • No visible API/output changes.
    • Cons
      • Major changes to existing decoding tables.
  • Do nothing.
    • Pros
      • Zero changes.
    • Cons
      • Please, don't do this. 😉

Which approach can benefit this project most?

Footnotes

  1. https://docs.kernel.org/arch/loongarch/introduction.html

  2. https://github.com/loongson/LoongArch-Documentation/blob/e0d6592229d9e00e512bd28b688a7f20b171714f/docs/LoongArch-Vol1-EN/basic-integer-instructions/overview-of-basic-integer-instructions/atomic-memory-access-instructions.adoc

  3. https://toml.io/en/v1.0.0#keys

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions