diff options
author | Ben Gamari <ben@well-typed.com> | 2023-01-20 07:26:59 -0800 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2023-04-11 10:52:18 +0530 |
commit | 1f8747ca05d79e80d091be718d338e1eb317bd7d (patch) | |
tree | a58c065dfd659fe7985f72b593015c6d988ca360 /compiler | |
parent | dc916697108a0666b56674000d52c9a0eb21d31c (diff) | |
download | haskell-1f8747ca05d79e80d091be718d338e1eb317bd7d.tar.gz |
nativeGen/AArch64: Fix debugging output
Previously various panics would rely on a half-written Show
instance, leading to very unhelpful errors. Fix this.
See #22798.
(cherry picked from commit be417a47c7695998dea0adc05489a7b8838a78b6)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/CmmToAsm/AArch64/Instr.hs | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/compiler/GHC/CmmToAsm/AArch64/Instr.hs b/compiler/GHC/CmmToAsm/AArch64/Instr.hs index 2ac137014a..c7867ed79d 100644 --- a/compiler/GHC/CmmToAsm/AArch64/Instr.hs +++ b/compiler/GHC/CmmToAsm/AArch64/Instr.hs @@ -136,7 +136,7 @@ regUsageOfInstr platform instr = case instr of FCVTZS dst src -> usage (regOp src, regOp dst) FABS dst src -> usage (regOp src, regOp dst) - _ -> panic "regUsageOfInstr" + _ -> panic $ "regUsageOfInstr: " ++ instrCon instr where -- filtering the usage is necessary, otherwise the register @@ -266,8 +266,7 @@ patchRegsOfInstr instr env = case instr of SCVTF o1 o2 -> SCVTF (patchOp o1) (patchOp o2) FCVTZS o1 o2 -> FCVTZS (patchOp o1) (patchOp o2) FABS o1 o2 -> FABS (patchOp o1) (patchOp o2) - - _ -> pprPanic "patchRegsOfInstr" (text $ show instr) + _ -> panic $ "patchRegsOfInstr: " ++ instrCon instr where patchOp :: Operand -> Operand patchOp (OpReg w r) = OpReg w (env r) @@ -323,7 +322,7 @@ patchJumpInstr instr patchF B (TBlock bid) -> B (TBlock (patchF bid)) BL (TBlock bid) ps rs -> BL (TBlock (patchF bid)) ps rs BCOND c (TBlock bid) -> BCOND c (TBlock (patchF bid)) - _ -> pprPanic "patchJumpInstr" (text $ show instr) + _ -> panic $ "patchJumpInstr: " ++ instrCon instr -- ----------------------------------------------------------------------------- -- Note [Spills and Reloads] @@ -635,10 +634,69 @@ data Instr -- Float ABSolute value | FABS Operand Operand -instance Show Instr where - show (LDR _f o1 o2) = "LDR " ++ show o1 ++ ", " ++ show o2 - show (MOV o1 o2) = "MOV " ++ show o1 ++ ", " ++ show o2 - show _ = "missing" +instrCon :: Instr -> String +instrCon i = + case i of + COMMENT{} -> "COMMENT" + MULTILINE_COMMENT{} -> "COMMENT" + ANN{} -> "ANN" + LOCATION{} -> "LOCATION" + LDATA{} -> "LDATA" + NEWBLOCK{} -> "NEWBLOCK" + DELTA{} -> "DELTA" + SXTB{} -> "SXTB" + UXTB{} -> "UXTB" + SXTH{} -> "SXTH" + UXTH{} -> "UXTH" + PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" + POP_STACK_FRAME{} -> "POP_STACK_FRAME" + ADD{} -> "ADD" + CMN{} -> "CMN" + CMP{} -> "CMP" + MSUB{} -> "MSUB" + MUL{} -> "MUL" + NEG{} -> "NEG" + SDIV{} -> "SDIV" + SMULH{} -> "SMULH" + SMULL{} -> "SMULL" + SUB{} -> "SUB" + UDIV{} -> "UDIV" + SBFM{} -> "SBFM" + UBFM{} -> "UBFM" + SBFX{} -> "SBFX" + UBFX{} -> "UBFX" + AND{} -> "AND" + ANDS{} -> "ANDS" + ASR{} -> "ASR" + BIC{} -> "BIC" + BICS{} -> "BICS" + EON{} -> "EON" + EOR{} -> "EOR" + LSL{} -> "LSL" + LSR{} -> "LSR" + MOV{} -> "MOV" + MOVK{} -> "MOVK" + MVN{} -> "MVN" + ORN{} -> "ORN" + ORR{} -> "ORR" + ROR{} -> "ROR" + TST{} -> "TST" + STR{} -> "STR" + LDR{} -> "LDR" + STP{} -> "STP" + LDP{} -> "LDP" + CSET{} -> "CSET" + CBZ{} -> "CBZ" + CBNZ{} -> "CBNZ" + J{} -> "J" + B{} -> "B" + BL{} -> "BL" + BCOND{} -> "BCOND" + DMBSY{} -> "DMBSY" + FCVT{} -> "FCVT" + SCVTF{} -> "SCVTF" + FCVTZS{} -> "FCVTZS" + FABS{} -> "FABS" data Target = TBlock BlockId @@ -766,11 +824,11 @@ opRegUExt W64 r = OpRegExt W64 r EUXTX 0 opRegUExt W32 r = OpRegExt W32 r EUXTW 0 opRegUExt W16 r = OpRegExt W16 r EUXTH 0 opRegUExt W8 r = OpRegExt W8 r EUXTB 0 -opRegUExt w _r = pprPanic "opRegUExt" (text $ show w) +opRegUExt w _r = pprPanic "opRegUExt" (ppr w) opRegSExt :: Width -> Reg -> Operand opRegSExt W64 r = OpRegExt W64 r ESXTX 0 opRegSExt W32 r = OpRegExt W32 r ESXTW 0 opRegSExt W16 r = OpRegExt W16 r ESXTH 0 opRegSExt W8 r = OpRegExt W8 r ESXTB 0 -opRegSExt w _r = pprPanic "opRegSExt" (text $ show w) +opRegSExt w _r = pprPanic "opRegSExt" (ppr w) |