| ... |
... |
@@ -443,6 +443,11 @@ pprExpr platform e |
|
443
|
443
|
CmmLit lit -> pprLit platform lit
|
|
444
|
444
|
_other -> pprExpr1 platform e
|
|
445
|
445
|
|
|
|
446
|
+-- `exp` usually, but (expr[width]) with -dppr-debug
|
|
|
447
|
+withDebugWidth :: Width -> SDoc -> SDoc
|
|
|
448
|
+withDebugWidth w exp =
|
|
|
449
|
+ ifPprDebug (parens (exp <> brackets (ppr w))) exp
|
|
|
450
|
+
|
|
446
|
451
|
-- Here's the precedence table from GHC.Cmm.Parser:
|
|
447
|
452
|
-- %nonassoc '>=' '>' '<=' '<' '!=' '=='
|
|
448
|
453
|
-- %left '|'
|
| ... |
... |
@@ -465,15 +470,17 @@ pprExpr1 platform e = pprExpr7 platform e |
|
465
|
470
|
|
|
466
|
471
|
infixMachOp1, infixMachOp7, infixMachOp8 :: MachOp -> Maybe SDoc
|
|
467
|
472
|
|
|
468
|
|
-infixMachOp1 (MO_Eq _) = Just (text "==")
|
|
469
|
|
-infixMachOp1 (MO_Ne _) = Just (text "!=")
|
|
470
|
|
-infixMachOp1 (MO_Shl _) = Just (text "<<")
|
|
471
|
|
-infixMachOp1 (MO_U_Shr _) = Just (text ">>")
|
|
472
|
|
-infixMachOp1 (MO_U_Ge _) = Just (text ">=")
|
|
473
|
|
-infixMachOp1 (MO_U_Le _) = Just (text "<=")
|
|
474
|
|
-infixMachOp1 (MO_U_Gt _) = Just (char '>')
|
|
475
|
|
-infixMachOp1 (MO_U_Lt _) = Just (char '<')
|
|
476
|
|
-infixMachOp1 _ = Nothing
|
|
|
473
|
+infixMachOp1 mop = case mop of
|
|
|
474
|
+ (MO_Eq w) -> Just $ withDebugWidth w (text "==")
|
|
|
475
|
+ (MO_Ne w) -> Just $ withDebugWidth w (text "!=")
|
|
|
476
|
+ (MO_Shl w) -> Just $ withDebugWidth w (text "<<")
|
|
|
477
|
+ (MO_U_Shr w) -> Just $ withDebugWidth w (text ">>")
|
|
|
478
|
+ (MO_U_Ge w) -> Just $ withDebugWidth w (text ">=")
|
|
|
479
|
+ (MO_U_Le w) -> Just $ withDebugWidth w (text "<=")
|
|
|
480
|
+ (MO_U_Gt w) -> Just $ withDebugWidth w (char '>')
|
|
|
481
|
+ (MO_U_Lt w) -> Just $ withDebugWidth w (char '<')
|
|
|
482
|
+ _ -> Nothing
|
|
|
483
|
+ where
|
|
477
|
484
|
|
|
478
|
485
|
-- %left '-' '+'
|
|
479
|
486
|
pprExpr7 platform (CmmMachOp (MO_Add rep1) [x, CmmLit (CmmInt i rep2)]) | i < 0
|
| ... |
... |
@@ -483,8 +490,8 @@ pprExpr7 platform (CmmMachOp op [x,y]) |
|
483
|
490
|
= pprExpr7 platform x <+> doc <+> pprExpr8 platform y
|
|
484
|
491
|
pprExpr7 platform e = pprExpr8 platform e
|
|
485
|
492
|
|
|
486
|
|
-infixMachOp7 (MO_Add _) = Just (char '+')
|
|
487
|
|
-infixMachOp7 (MO_Sub _) = Just (char '-')
|
|
|
493
|
+infixMachOp7 (MO_Add w) = Just $ withDebugWidth w (char '+')
|
|
|
494
|
+infixMachOp7 (MO_Sub w) = Just $ withDebugWidth w (char '-')
|
|
488
|
495
|
infixMachOp7 _ = Nothing
|
|
489
|
496
|
|
|
490
|
497
|
-- %left '/' '*' '%'
|
| ... |
... |
@@ -493,9 +500,9 @@ pprExpr8 platform (CmmMachOp op [x,y]) |
|
493
|
500
|
= pprExpr8 platform x <+> doc <+> pprExpr9 platform y
|
|
494
|
501
|
pprExpr8 platform e = pprExpr9 platform e
|
|
495
|
502
|
|
|
496
|
|
-infixMachOp8 (MO_U_Quot _) = Just (char '/')
|
|
497
|
|
-infixMachOp8 (MO_Mul _) = Just (char '*')
|
|
498
|
|
-infixMachOp8 (MO_U_Rem _) = Just (char '%')
|
|
|
503
|
+infixMachOp8 (MO_U_Quot w) = Just $ withDebugWidth w (char '/')
|
|
|
504
|
+infixMachOp8 (MO_Mul w) = Just $ withDebugWidth w (char '*')
|
|
|
505
|
+infixMachOp8 (MO_U_Rem w) = Just $ withDebugWidth w (char '%')
|
|
499
|
506
|
infixMachOp8 _ = Nothing
|
|
500
|
507
|
|
|
501
|
508
|
pprExpr9 :: Platform -> CmmExpr -> SDoc
|