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-aarch32: Define shorthand for ARM registers #374

Open
RyanGlScott opened this issue Mar 21, 2024 · 0 comments
Open

macaw-aarch32: Define shorthand for ARM registers #374

RyanGlScott opened this issue Mar 21, 2024 · 0 comments

Comments

@RyanGlScott
Copy link
Contributor

RyanGlScott commented Mar 21, 2024

Currently, lots of places in macaw-aarch32 refer to ARM registers in an extremely verbose way:

$ git grep -n "knownGlobalRef" macaw-aarch32
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:102:      [| ARMGlobalBool (ASL.knownGlobalRef :: ASL.GlobalRef $(return (TH.LitT (TH.StrTyLit refName)))) |]
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:104:      [| ARMGlobalBV (ASL.knownGlobalRef :: ASL.GlobalRef $(return (TH.LitT (TH.StrTyLit refName)))) |]
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:111:arm_LR = ARMGlobalBV (ASL.knownGlobalRef @"_R14")
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:114:branchTaken = ARMGlobalBool (ASL.knownGlobalRef @"__BranchTaken")
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:155:      sp_reg = ARMGlobalBV (ASL.knownGlobalRef @"_R13")
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:156:      ip_reg = ARMGlobalBV (ASL.knownGlobalRef @"_PC")
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:188:  Set.fromList [ Some (ARMGlobalBV (ASL.knownGlobalRef @"_R8"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:189:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R9"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:190:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R10"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:191:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R11"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:192:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R12"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:193:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R13"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:194:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_R14"))
macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs:195:               , Some (ARMGlobalBV (ASL.knownGlobalRef @"_PC"))
...

Having to type ARMGlobalBV (ASL.knownGlobalRef @...) every time is a real drag. It would be nicer if we could just type, for example, arm_R0 to refer to ARMGlobalBV (ASL.knownGlobalRef @"_R0") without needing any extra faff. Similarly for arm_R1, arm_R2, etc. To my knowledge, there is only one such definition in macaw-aarch32 at the moment:

-- | GPR14 is the link register for ARM
arm_LR :: (w ~ MC.RegAddrWidth ARMReg, 1 <= w) => ARMReg (MT.BVType w)
arm_LR = ARMGlobalBV (ASL.knownGlobalRef @"_R14")

We should add shorthand for the other ARM registers as well.

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

No branches or pull requests

1 participant