macaw-riscv
: Add ABI mnemonics for floating-point registers
#454
Labels
macaw-riscv
: Add ABI mnemonics for floating-point registers
#454
Per the official RISC-V Calling Conventions document, RISC-V registers can sometimes go by two names:
x2
)sp
)It is common to refer to registers by their ABI mnemonics rather than their full names, so it is nice for
macaw-riscv
to let users refer to registers by either name.macaw-riscv
already does this for integer registers: inData.Macaw.RISCV.RISCVReg
, we can see that:GPR
newtype that wraps the integer suffix used in an integer register (e.g., the2
inx2
).GPR
's ABI mnemonic (e.g., we havepattern SP = BuildGPR 2
for thesp
mnemonic forx2
).GPR
value to a fullRISCVReg
value (e.g., we havepattern GPR_SP = RISCV_GPR (BuildGPR bv)
).Show
instance forRISCVReg
displays the ABI mnemonics rather than thex*
names, as tools likeobjdump
will typically display the ABI mnemonics by default.This is great. Unfortunately,
macaw-riscv
's ABI mnemonic support is currently incomplete. While it supports the ABI mnemonics for integer registers, it does not support the ABI mnemonics for floating-point registers. Currently, we simply have:macaw/macaw-riscv/src/Data/Macaw/RISCV/RISCVReg.hs
Lines 246 to 247 in 03fc41f
Which means that users have to write something like, say,
FPR 8
in order to refer to the register namedf8
, which also goes by the ABI mnemonicfs0
. I argue that users should also be able to achieve this by writing something likeFPR_FS0
, which would mirror the existing treatment for integer register ABI mnemonics. To that end, we should:FPR
newtype and defineRISCVReg
'sFPR
data constructor in terms of it.FPR
pattern synonyms for each ABI mnemonic listed in this table.FPR
pattern synonym to a fullRISCVReg
.Show
instance forRISCVReg
to display the ABI mnemonics for each floating-point register.The text was updated successfully, but these errors were encountered: