[commit: ghc] master: Remove unused arg field of CmmReturn (419af4e)

David Terei davidterei at gmail.com
Fri Jan 6 03:16:01 CET 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/419af4e718b3c79ee814fb36bd6f5da5e06e7001

>---------------------------------------------------------------

commit 419af4e718b3c79ee814fb36bd6f5da5e06e7001
Author: David Terei <davidterei at gmail.com>
Date:   Thu Dec 22 14:48:56 2011 -0800

    Remove unused arg field of CmmReturn

>---------------------------------------------------------------

 compiler/cmm/CmmLint.hs                 |    4 ++--
 compiler/cmm/CmmOpt.hs                  |    2 +-
 compiler/cmm/CmmParse.y                 |    5 ++---
 compiler/cmm/OldCmm.hs                  |    3 +--
 compiler/cmm/OldPprCmm.hs               |   11 ++++-------
 compiler/cmm/PprC.hs                    |    2 +-
 compiler/codeGen/CgMonad.lhs            |    2 +-
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs |    2 +-
 compiler/nativeGen/PPC/CodeGen.hs       |    2 +-
 compiler/nativeGen/SPARC/CodeGen.hs     |    2 +-
 compiler/nativeGen/X86/CodeGen.hs       |    2 +-
 11 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/compiler/cmm/CmmLint.hs b/compiler/cmm/CmmLint.hs
index db6dd2f..a99e5a5 100644
--- a/compiler/cmm/CmmLint.hs
+++ b/compiler/cmm/CmmLint.hs
@@ -144,8 +144,8 @@ lintCmmStmt platform labels = lint
               else cmmLintErr (text "switch scrutinee is not a word: " <> pprPlatform platform e <>
                                text " :: " <> ppr erep)
           lint (CmmJump e) = lintCmmExpr platform e >> return ()
-          lint (CmmReturn ress) = mapM_ (lintCmmExpr platform . hintlessCmm) ress
-          lint (CmmBranch id)    = checkTarget id
+          lint (CmmReturn) = return ()
+          lint (CmmBranch id) = checkTarget id
           checkTarget id = if setMember id labels then return ()
                            else cmmLintErr (text "Branch to nonexistent id" <+> ppr id)
 
diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs
index 649dbb5..84f1069 100644
--- a/compiler/cmm/CmmOpt.hs
+++ b/compiler/cmm/CmmOpt.hs
@@ -66,7 +66,7 @@ cmmEliminateDeadBlocks blocks@(BasicBlock base_id _:_) =
                 stmt m (CmmCondBranch e b) = b:(expr m e)
                 stmt m (CmmSwitch e bs) = catMaybes bs ++ expr m e
                 stmt m (CmmJump e) = expr m e
-                stmt m (CmmReturn as) = actuals m as
+                stmt m (CmmReturn) = m
                 actuals m as = foldl' (\m h -> expr m (hintlessCmm h)) m as
                 -- We have to do a deep fold into CmmExpr because
                 -- there may be a BlockId in the CmmBlock literal.
diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y
index 6660a0c..f20a05f 100644
--- a/compiler/cmm/CmmParse.y
+++ b/compiler/cmm/CmmParse.y
@@ -413,8 +413,8 @@ stmt	:: { ExtCode }
 		{ do l <- lookupLabel $2; stmtEC (CmmBranch l) }
 	| 'jump' expr ';'
 		{ do e <- $2; stmtEC (CmmJump e) }
-        | 'return' maybe_actuals ';'
-		{ do e <- sequence $2; stmtEC (CmmReturn e) }
+        | 'return' ';'
+		{ stmtEC CmmReturn }
 	| 'if' bool_expr 'goto' NAME
 		{ do l <- lookupLabel $4; cmmRawIf $2 l }
 	| 'if' bool_expr '{' body '}' else 	
@@ -946,7 +946,6 @@ emitRetUT args = do
                            -- simultaneous assignments here (#3546)
   when (sp /= 0) $ stmtC (CmmAssign spReg (cmmRegOffW spReg (-sp)))
   stmtC $ CmmJump (entryCode (CmmLoad (cmmRegOffW spReg sp) bWord))
-  -- TODO (when using CPS): emitStmt (CmmReturn (map snd args))
 
 -- -----------------------------------------------------------------------------
 -- If-then-else and boolean expressions
diff --git a/compiler/cmm/OldCmm.hs b/compiler/cmm/OldCmm.hs
index fae6c8d..d3dc374 100644
--- a/compiler/cmm/OldCmm.hs
+++ b/compiler/cmm/OldCmm.hs
@@ -164,7 +164,6 @@ data CmmStmt    -- Old-style
   | CmmJump CmmExpr  -- Jump to another C-- function,
 
   | CmmReturn        -- Return from a native C-- function,
-      [HintedCmmActual]        -- with these return values. (parameters never used)
 
 data CmmHinted a = CmmHinted { hintlessCmm :: a, cmmHint :: New.ForeignHint }
                  deriving( Eq )
@@ -188,7 +187,7 @@ instance UserOfLocalRegs CmmStmt where
       stmt (CmmCondBranch e _)       = gen e
       stmt (CmmSwitch e _)           = gen e
       stmt (CmmJump e)               = gen e
-      stmt (CmmReturn es)            = gen es
+      stmt (CmmReturn)               = id
 
       gen :: UserOfLocalRegs a => a -> b -> b
       gen a set = foldRegsUsed f set a
diff --git a/compiler/cmm/OldPprCmm.hs b/compiler/cmm/OldPprCmm.hs
index d6db11b..a0c2fc3 100644
--- a/compiler/cmm/OldPprCmm.hs
+++ b/compiler/cmm/OldPprCmm.hs
@@ -154,7 +154,7 @@ pprStmt platform stmt = case stmt of
     CmmBranch ident          -> genBranch ident
     CmmCondBranch expr ident -> genCondBranch platform expr ident
     CmmJump expr             -> genJump platform expr
-    CmmReturn params         -> genReturn platform params
+    CmmReturn                -> genReturn platform
     CmmSwitch arg ids        -> genSwitch platform arg ids
 
 -- Just look like a tuple, since it was a tuple before
@@ -220,12 +220,9 @@ genJump platform expr =
 --
 --     return (a, b, c);
 --
-genReturn :: Platform -> [CmmHinted CmmExpr] -> SDoc
-genReturn platform args =
-    hcat [ ptext (sLit "return")
-         , space
-         , parens  ( commafy $ map (pprPlatform platform) args )
-         , semi ]
+genReturn :: Platform -> SDoc
+genReturn platform =
+    hcat [ ptext (sLit "return") , semi ]
 
 -- --------------------------------------------------------------------------
 -- Tabled jump to local label
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index e4a5c5f..330d090 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -172,7 +172,7 @@ pprLocalness lbl | not $ externallyVisibleCLabel lbl = ptext (sLit "static ")
 pprStmt :: Platform -> CmmStmt -> SDoc
 
 pprStmt platform stmt = case stmt of
-    CmmReturn _  -> panic "pprStmt: return statement should have been cps'd away"
+    CmmReturn    -> panic "pprStmt: return statement should have been cps'd away"
     CmmNop       -> empty
     CmmComment _ -> empty -- (hang (ptext (sLit "/*")) 3 (ftext s)) $$ ptext (sLit "*/")
                           -- XXX if the string contains "*/", we need to fix it
diff --git a/compiler/codeGen/CgMonad.lhs b/compiler/codeGen/CgMonad.lhs
index 4617aaa..c05019e 100644
--- a/compiler/codeGen/CgMonad.lhs
+++ b/compiler/codeGen/CgMonad.lhs
@@ -252,7 +252,7 @@ isJump :: CmmStmt -> Bool
 isJump (CmmJump   _  ) = True
 isJump (CmmBranch _  ) = True
 isJump (CmmSwitch _ _) = True
-isJump (CmmReturn _  ) = True
+isJump (CmmReturn    ) = True
 isJump _               = False
 
 isOrdinaryStmt :: CgStmt -> Bool
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index 821ef5b..b8a4444 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -132,7 +132,7 @@ stmtToInstrs env stmt = case stmt of
     -- CPS, only tail calls, no return's
     -- Actually, there are a few return statements that occur because of hand
     -- written Cmm code.
-    CmmReturn _
+    CmmReturn
         -> return (env, unitOL $ Return Nothing, [])
 
 
diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs
index 6d91bac..8b96f71 100644
--- a/compiler/nativeGen/PPC/CodeGen.hs
+++ b/compiler/nativeGen/PPC/CodeGen.hs
@@ -142,7 +142,7 @@ stmtToInstrs stmt = do
     CmmCondBranch arg id  -> genCondJump id arg
     CmmSwitch arg ids     -> genSwitch arg ids
     CmmJump arg           -> genJump arg
-    CmmReturn _           ->
+    CmmReturn             ->
       panic "stmtToInstrs: return statement should have been cps'd away"
 
 
diff --git a/compiler/nativeGen/SPARC/CodeGen.hs b/compiler/nativeGen/SPARC/CodeGen.hs
index c37cdd6..0022e04 100644
--- a/compiler/nativeGen/SPARC/CodeGen.hs
+++ b/compiler/nativeGen/SPARC/CodeGen.hs
@@ -143,7 +143,7 @@ stmtToInstrs stmt = case stmt of
     CmmSwitch	arg ids		-> genSwitch arg ids
     CmmJump	arg  		-> genJump arg
 
-    CmmReturn	_		
+    CmmReturn	 		
      -> panic "stmtToInstrs: return statement should have been cps'd away"
 
 
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
index 9ddcf46..b7356ea 100644
--- a/compiler/nativeGen/X86/CodeGen.hs
+++ b/compiler/nativeGen/X86/CodeGen.hs
@@ -167,7 +167,7 @@ stmtToInstrs stmt = do
     CmmCondBranch arg id  -> genCondJump id arg
     CmmSwitch arg ids     -> genSwitch arg ids
     CmmJump arg           -> genJump arg
-    CmmReturn _           ->
+    CmmReturn             ->
       panic "stmtToInstrs: return statement should have been cps'd away"
 
 





More information about the Cvs-ghc mailing list