Skip to content

Commit

Permalink
Add names for mnemonic suffixes
Browse files Browse the repository at this point in the history
Some instruction groups combinatorically construct mnemonics with various
suffixes:
```
mapping clause assembly = LOAD(imm, rs1, rd, is_unsigned, size, aq, rl)
  <-> "l" ^ size_mnemonic(size) ^ maybe_u(is_unsigned) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_signed_12(imm) ^ "(" ^ reg_name(rs1) ^ ")"
```
Here, the mnemonic is constructed from
"l" + { "b", "h", "w", "d" } + { "", "u" } + { "", ".aq" } + { "", ".rl" }.

These mnemonic suffixes should be annotated inline for readability.

In addition human-readable names can be similarly constructed, as in
"load word unsigned acquire release", by concatenating the notes.
  • Loading branch information
ThinkOpenly committed Sep 9, 2024
1 parent 0b5ab31 commit 6670d78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions model/riscv_insts_base.sail
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,21 @@ function clause execute(LOAD(imm, rs1, rd, is_unsigned, width, aq, rl)) = {

val maybe_aq : bool <-> string
mapping maybe_aq = {
$[name "acquire"]
true <-> ".aq",
false <-> ""
}

val maybe_rl : bool <-> string
mapping maybe_rl = {
$[name "release"]
true <-> ".rl",
false <-> ""
}

val maybe_u : bool <-> string
mapping maybe_u = {
$[name "unsigned"]
true <-> "u",
false <-> ""
}
Expand Down
4 changes: 4 additions & 0 deletions model/riscv_types.sail
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,13 @@ mapping size_enc : word_width <-> bits(2) = {
}

mapping size_mnemonic : word_width <-> string = {
$[name "byte"]
BYTE <-> "b",
$[name "halfword"]
HALF <-> "h",
$[name "word"]
WORD <-> "w",
$[name "doubleword"]
DOUBLE <-> "d"
}

Expand Down

0 comments on commit 6670d78

Please sign in to comment.