rems-project / sail

Sail architecture definition language
Other
615 stars 110 forks source link

Feature to list all defined instructions #214

Open kristinbarber opened 1 year ago

kristinbarber commented 1 year ago

A nice feature to have would be an option to list all defined instructions, their opcodes and encodings.

Are there plans to implement something along these lines, or does there exist a WIP branch already?

Alasdair commented 1 year ago

It's not something we have out of the box, because we don't really impose a specific way that instructions must be specified. For example the ARM specification has a combined decode and execute function, whereas for RISC-V we have an intermediate instruction datatype. For ARM I wrote a plugin to extract the decoding information into a file like:

https://github.com/rems-project/isla-snapshots/blob/master/extras/aarch64_opcodes.toml

You could do the same for any Sail architecture, but the exact solution would differ. It's also not the most satisfying solution, because the libsail API is very much unstable, so it's only really useful for one-shot scripts and not things you want to continue to work indefinitely.

PeterSewell commented 1 year ago

On Wed, 15 Mar 2023 at 20:16, Alasdair Armstrong @.***> wrote:

It's not something we have out of the box, because we don't really impose a specific way that instructions must be specified. For example the ARM specification has a combined decode and execute function, whereas for RISC-V we have an intermediate instruction datatype. For ARM I wrote a plugin to extract the decoding information into a file like:

https://github.com/rems-project/isla-snapshots/blob/master/extras/aarch64_opcodes.toml

You could do the same for any Sail architecture, but the exact solution would differ. It's also not the most satisfying solution, because the libsail API is very much unstable, so it's only really useful for one-shot scripts and not things you want to continue to work indefinitely.

It's also worth noting that there often isn't a canonical notion of what a "single instruction" is: the authors of the Sail spec, the authors of the prose parts of the reference manual, and the authors of the assembly-language syntax, each have to choose how to cluster related opcodes - e.g. in clauses of the execute function, in the subsections of the manual, and in the mnemonics and other assembly syntax - and the choices they make often differ. For example, one might have a single execute-function clause for all the binary arithmetic opcodes, or have many radically different opcodes and behaviours sharing a single mnemonic (such as the x86 MOV).

Peter

— Reply to this email directly, view it on GitHub https://github.com/rems-project/sail/issues/214#issuecomment-1470780484, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFMZZXYDONHCZG36ZWGSHTW4IPRXANCNFSM6AAAAAAVZOC2QU . You are receiving this because you are subscribed to this thread.Message ID: @.***>