X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fcmm%2FPprC.hs;h=824179c0f88edaf9594079bf43a9a8be1bd13c24;hb=e64cdcd1c11f896085923860d67e1b9d02090b3d;hp=51e429b0aeb9cf0b7662faa56f1f4979c3ecdab0;hpb=69cb15e2f6853435602f00ecbccd2598a9e7eea9;p=ghc-hetmet.git diff --git a/ghc/compiler/cmm/PprC.hs b/ghc/compiler/cmm/PprC.hs index 51e429b..824179c 100644 --- a/ghc/compiler/cmm/PprC.hs +++ b/ghc/compiler/cmm/PprC.hs @@ -85,7 +85,8 @@ pprC (Cmm tops) = vcat $ intersperse (text "") $ map pprTop tops pprTop :: CmmTop -> SDoc pprTop (CmmProc info clbl _params blocks) = (if not (null info) - then pprWordArray (entryLblToInfoLbl clbl) info + then pprDataExterns info $$ + pprWordArray (entryLblToInfoLbl clbl) info else empty) $$ (case blocks of [] -> empty @@ -177,7 +178,7 @@ pprStmt stmt = case stmt of CmmAssign dest src -> pprAssign dest src CmmStore dest src - | rep == I64 + | rep == I64 && wordRep /= I64 -> ptext SLIT("ASSIGN_Word64") <> parens (mkP_ <> pprExpr1 dest <> comma <> pprExpr src) <> semi @@ -194,7 +195,7 @@ pprStmt stmt = case stmt of where ppr_fn = case fn of CmmLit (CmmLabel lbl) -> pprCLabel lbl - _other -> parens (cCast (pprCFunType results args) fn) + _other -> parens (cCast (pprCFunType cconv results args) fn) -- for a dynamic call, cast the expression to -- a function of the right type (we hope). @@ -217,9 +218,13 @@ pprStmt stmt = case stmt of CmmJump lbl _params -> mkJMP_(pprExpr lbl) <> semi CmmSwitch arg ids -> pprSwitch arg ids -pprCFunType :: [(CmmReg,MachHint)] -> [(CmmExpr,MachHint)] -> SDoc -pprCFunType ress args = - res_type ress <> parens (char '*') <> parens (commafy (map arg_type args)) +pprCFunType :: CCallConv -> [(CmmReg,MachHint)] -> [(CmmExpr,MachHint)] -> SDoc +pprCFunType cconv ress args + = hcat [ + res_type ress, + parens (text (ccallConvAttribute cconv) <> char '*'), + parens (commafy (map arg_type args)) + ] where res_type [] = ptext SLIT("void") res_type [(one,hint)] = machRepHintCType (cmmRegRep one) hint @@ -265,11 +270,11 @@ pprSwitch e maybe_ids caseify (ix:ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix where do_fallthrough ix = - hsep [ ptext SLIT("case") , pprHexVal ix <> colon , + hsep [ ptext SLIT("case") , pprHexVal ix wordRep <> colon , ptext SLIT("/* fall through */") ] final_branch ix = - hsep [ ptext SLIT("case") , pprHexVal ix <> colon , + hsep [ ptext SLIT("case") , pprHexVal ix wordRep <> colon , ptext SLIT("goto") , (pprBlockId ident) <> semi ] -- --------------------------------------------------------------------- @@ -290,7 +295,7 @@ pprExpr :: CmmExpr -> SDoc pprExpr e = case e of CmmLit lit -> pprLit lit - CmmLoad e I64 + CmmLoad e I64 | wordRep /= I64 -> ptext SLIT("PK_Word64") <> parens (mkP_ <> pprExpr1 e) CmmLoad (CmmReg r) rep @@ -357,13 +362,22 @@ pprMachOpApp mop args pprLit :: CmmLit -> SDoc pprLit lit = case lit of - CmmInt i _rep -> pprHexVal i + CmmInt i rep -> pprHexVal i rep CmmFloat f rep -> parens (machRepCType rep) <> (rational f) CmmLabel clbl -> mkW_ <> pprCLabel clbl CmmLabelOff clbl i -> mkW_ <> pprCLabel clbl <> char '+' <> int i + CmmLabelDiffOff clbl1 clbl2 i + -- WARNING: + -- * the lit must occur in the info table clbl2 + -- * clbl1 must be an SRT, a slow entry point or a large bitmap + -- The Mangler is expected to convert any reference to an SRT, + -- a slow entry point or a large bitmap + -- from an info table to an offset. + -> mkW_ <> pprCLabel clbl1 <> char '+' <> int i pprLit1 :: CmmLit -> SDoc pprLit1 lit@(CmmLabelOff _ _) = parens (pprLit lit) +pprLit1 lit@(CmmLabelDiffOff _ _ _) = parens (pprLit lit) pprLit1 lit@(CmmFloat _ _) = parens (pprLit lit) pprLit1 other = pprLit other @@ -503,7 +517,7 @@ pprCallishMachOp_for_C mop MO_F64_Cosh -> ptext SLIT("cosh") MO_F64_Tanh -> ptext SLIT("tanh") MO_F64_Asin -> ptext SLIT("asin") - MO_F64_Acos -> ptext SLIT("asin") + MO_F64_Acos -> ptext SLIT("acos") MO_F64_Atan -> ptext SLIT("atan") MO_F64_Log -> ptext SLIT("log") MO_F64_Exp -> ptext SLIT("exp") @@ -780,6 +794,8 @@ te_BB (BasicBlock _ ss) = mapM_ te_Stmt ss te_Lit :: CmmLit -> TE () te_Lit (CmmLabel l) = te_lbl l +te_Lit (CmmLabelOff l _) = te_lbl l +te_Lit (CmmLabelDiffOff l1 l2 _) = te_lbl l1 te_Lit _ = return () te_Stmt :: CmmStmt -> TE () @@ -957,12 +973,19 @@ commafy :: [SDoc] -> SDoc commafy xs = hsep $ punctuate comma xs -- Print in C hex format: 0x13fa -pprHexVal :: Integer -> SDoc -pprHexVal 0 = ptext SLIT("0x0") -pprHexVal w - | w < 0 = parens (char '-' <> ptext SLIT("0x") <> go (-w)) - | otherwise = ptext SLIT("0x") <> go w +pprHexVal :: Integer -> MachRep -> SDoc +pprHexVal 0 _ = ptext SLIT("0x0") +pprHexVal w rep + | w < 0 = parens (char '-' <> ptext SLIT("0x") <> go (-w) <> repsuffix rep) + | otherwise = ptext SLIT("0x") <> go w <> repsuffix rep where + -- type suffix for literals: + -- on 32-bit platforms, add "LL" to 64-bit literals + repsuffix I64 | wORD_SIZE == 4 = ptext SLIT("LL") + -- on 64-bit platforms with 32-bit int, add "L" to 64-bit literals + repsuffix I64 | cINT_SIZE == 4 = ptext SLIT("L") + repsuffix _ = empty + go 0 = empty go w' = go q <> dig where