ThinkOpenly / sail

Sail architecture definition language
Other
10 stars 11 forks source link

[JSON] Add support for extracting instruction names from mappings #16

Closed ThinkOpenly closed 6 months ago

ThinkOpenly commented 6 months ago

Many instructions are grouped around a similar, common implementation with the mnemonics embedded within a list of mnemonic:name mapping, such as:

mapping utype_mnemonic : uop <-> string = {
  RISCV_LUI   <-> "lui",
  RISCV_AUIPC <-> "auipc"
}

mapping clause assembly = UTYPE(imm, rd, op)
  <-> utype_mnemonic(op) ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_20(imm)

Add support for extracting instruction names from within the mappings if the names are added within as attributes, for example:

mapping utype_mnemonic : uop <-> string = {
  $[name Load Upper Immediate]
    RISCV_LUI   <-> "lui",
  $[name Add Upper Immediate to Program Counter]
    RISCV_AUIPC <-> "auipc"
}