Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macaw-ppc: Define shorthand for PowerPC registers #402

Open
RyanGlScott opened this issue Jul 22, 2024 · 1 comment
Open

macaw-ppc: Define shorthand for PowerPC registers #402

RyanGlScott opened this issue Jul 22, 2024 · 1 comment
Labels

Comments

@RyanGlScott
Copy link
Contributor

RyanGlScott commented Jul 22, 2024

Currently, lots of places in macaw-ppc refer to PowerPC general-purpose registers in an rather verbose way:

$ git grep -n "PPC_GP" macaw-ppc
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:831:      let r0 = regs ^. MC.boundValue (PPC_GP (D.GPR 0))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:832:      let r3 = regs ^. MC.boundValue (PPC_GP (D.GPR 3))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:833:      let r4 = regs ^. MC.boundValue (PPC_GP (D.GPR 4))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:834:      let r5 = regs ^. MC.boundValue (PPC_GP (D.GPR 5))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:835:      let r6 = regs ^. MC.boundValue (PPC_GP (D.GPR 6))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:836:      let r7 = regs ^. MC.boundValue (PPC_GP (D.GPR 7))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:837:      let r8 = regs ^. MC.boundValue (PPC_GP (D.GPR 8))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:838:      let r9 = regs ^. MC.boundValue (PPC_GP (D.GPR 9))
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:847:      G.setRegVal (PPC_GP (D.GPR 3)) resVal
macaw-ppc/src/Data/Macaw/PPC/Arch.hs:856:              SP.V32Repr -> G.setRegVal (PPC_GP (D.GPR 0)) errorCond
macaw-ppc/src/Data/Macaw/PPC/Eval.hs:117:        s0 & MA.absRegState . boundValue (PPC_GP (D.GPR 2)) .~ tocAddr
macaw-ppc/src/Data/Macaw/PPC/Operand.hs:32:  extractValue regs gpr = regs ^. MC.boundValue (R.PPC_GP gpr)
macaw-ppc/src/Data/Macaw/PPC/Operand.hs:71:  toRegister = R.PPC_GP
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:46:  PPC_GP :: (w ~ PPC.AddrWidth v, 1 <= w) => D.GPR -> PPCReg v (BVType w)
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:62:      PPC_GP (D.GPR gpr) -> 'r':show gpr
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:99:  S.fromList [ Some (PPC_GP (D.GPR rnum)) | rnum <- [14..31] ]
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:105:  S.fromList [ Some (PPC_GP (D.GPR rnum)) | rnum <- [14..31] ]
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:113:      PPC_GP {} -> BVTypeRepr (PPC.addrWidth (PPC.knownVariant @v))
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:129:  sp_reg = PPC_GP (D.GPR 1)
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:131:  syscall_num_reg = PPC_GP (D.GPR 0)
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:132:  syscallArgumentRegs = [ PPC_GP (D.GPR rnum) | rnum <- [3..10] ]
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:145:    gprs = [ Some (PPC_GP (D.GPR rnum))
macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs:158:locToRegTH _ (APPC.LocGPR (D.GPR gpr)) = [| PPC_GP (D.GPR $(lift gpr)) |]
macaw-ppc/src/Data/Macaw/PPC/Semantics/Base.hs:200:locToReg _ (APPC.LocGPR gpr) = PPC_GP gpr

Having to type PPC_GP (GPR ...) every time is a real drag. It would be nicer if we could just type, for example, r0 to refer to PPC_GP (GPR 0) without needing any extra faff. Similarly for r1, r2, etc.

We should add shorthand for the other PPC registers that would benefit from it as well (e.g., f0 as an abbreviation for PPC_FR (VSReg 0)).

This is the PowerPC equivalent of #374.

@langston-barrett
Copy link
Contributor

When implementing this, it may be helpful to look at the following similar definitions on the Crucible side: #445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants