X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FPprCmm.hs;h=cb2adf7dc1f69a0078257a472bdc7e140cde17c0;hb=200d2b8bd462a8356e5cf731a99055d4c7461959;hp=6e8367d66280b3c3dce48521f0d64974dc66cccf;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/cmm/PprCmm.hs b/compiler/cmm/PprCmm.hs index 6e8367d..cb2adf7 100644 --- a/compiler/cmm/PprCmm.hs +++ b/compiler/cmm/PprCmm.hs @@ -2,7 +2,7 @@ -- -- Pretty-printing of Cmm as (a superset of) C-- -- --- (c) The University of Glasgow 2004 +-- (c) The University of Glasgow 2004-2006 -- ----------------------------------------------------------------------------- @@ -39,19 +39,19 @@ module PprCmm ( #include "HsVersions.h" import Cmm -import CmmUtils ( isTrivialCmmExpr ) -import MachOp ( MachOp(..), pprMachOp, MachRep(..), wordRep ) -import CLabel ( pprCLabel, mkForeignLabel, entryLblToInfoLbl ) +import CmmUtils +import MachOp +import CLabel -import ForeignCall ( CCallConv(..) ) -import Unique ( getUnique ) +import ForeignCall +import Unique import Outputable -import FastString ( mkFastString ) +import FastString -import Data.List ( intersperse, groupBy ) -import IO ( Handle ) -import Maybe ( isJust ) -import Data.Char ( chr ) +import Data.List +import System.IO +import Data.Maybe +import Data.Char pprCmms :: [Cmm] -> SDoc pprCmms cmms = pprCode CStyle (vcat (intersperse separator $ map ppr cmms)) @@ -292,6 +292,8 @@ infixMachOp1 (MO_U_Lt _) = Just (char '<') infixMachOp1 _ = Nothing -- %left '-' '+' +pprExpr7 (CmmMachOp (MO_Add rep1) [x, CmmLit (CmmInt i rep2)]) | i < 0 + = pprExpr7 (CmmMachOp (MO_Sub rep1) [x, CmmLit (CmmInt (negate i) rep2)]) pprExpr7 (CmmMachOp op [x,y]) | Just doc <- infixMachOp7 op = pprExpr7 x <+> doc <+> pprExpr8 y pprExpr7 e = pprExpr8 e @@ -337,7 +339,10 @@ genMachOp mop args || isJust (infixMachOp7 mop) || isJust (infixMachOp8 mop) = parens (pprExpr (CmmMachOp mop args)) - | otherwise = char '%' <> pprMachOp mop <> parens (commafy (map pprExpr args)) + | otherwise = char '%' <> ppr_op <> parens (commafy (map pprExpr args)) + where ppr_op = text (map (\c -> if c == ' ' then '_' else c) + (show mop)) + -- replace spaces in (show mop) with underscores, -- -- Unsigned ops on the word size of the machine get nice symbols.