pprExpr :: CmmExpr -> SDoc
pprExpr e = case e of
    CmmLit lit -> pprLit lit


    CmmLoad e ty -> sdocWithDynFlags $ \dflags -> pprLoad dflags e ty
    CmmReg reg      -> pprCastReg reg
    CmmRegOff reg 0 -> pprCastReg reg

    CmmRegOff reg i
        | i < 0 && negate_ok -> pprRegOff (char '-') (-i)
        | otherwise          -> pprRegOff (char '+') i
      where
        pprRegOff op i' = pprCastReg reg <> op <> int i'
        negate_ok = negate (fromIntegral i :: Integer) <
                    fromIntegral (maxBound::Int)
                     -- overflow is undefined; see #7620

    CmmMachOp mop args -> pprMachOpApp mop args

    CmmStackSlot _ _   -> panic "pprExpr: CmmStackSlot not supported!"
pprExpr :: CmmExpr -> SDoc
pprExpr e = case e of
    CmmLit lit -> pprLit lit


    CmmLoad e ty -> sdocWithDynFlags $ \dflags -> pprLoad dflags e ty
    CmmReg reg      -> pprCastReg reg
    CmmRegOff reg 0 -> pprCastReg reg

    CmmRegOff reg i
        | i < 0 && negate_ok -> pprRegOff (char '-') (-i)
        | otherwise          -> pprRegOff (char '+') i
      where
        pprRegOff op i' = pprCastReg reg <> op <> int i'
        negate_ok = negate (fromIntegral i :: Integer) <
                    fromIntegral (maxBound::Int)
                     -- overflow is undefined; see #7620

    CmmMachOp mop args -> pprMachOpApp mop args

    CmmStackSlot _ _   -> panic "pprExpr: CmmStackSlot not supported!"
pprExpr e = case e of
    CmmLit lit -> pprLit lit


    CmmLoad e ty -> sdocWithDynFlags $ \dflags -> pprLoad dflags e ty
    CmmReg reg      -> pprCastReg reg
    CmmRegOff reg 0 -> pprCastReg reg

    CmmRegOff reg i
        | i < 0 && negate_ok -> pprRegOff (char '-') (-i)
        | otherwise          -> pprRegOff (char '+') i
      where
        pprRegOff op i' = pprCastReg reg <> op <> int i'
        negate_ok = negate (fromIntegral i :: Integer) <
                    fromIntegral (maxBound::Int)
                     -- overflow is undefined; see #7620

    CmmMachOp mop args -> pprMachOpApp mop args

    CmmStackSlot _ _   -> panic "pprExpr: CmmStackSlot not supported!"