Added "C--" foreign calling convention
authorMichael D. Adams <t-madams@microsoft.com>
Wed, 16 May 2007 15:57:58 +0000 (15:57 +0000)
committerMichael D. Adams <t-madams@microsoft.com>
Wed, 16 May 2007 15:57:58 +0000 (15:57 +0000)
compiler/cmm/CmmParse.y
compiler/cmm/Dataflow.hs
compiler/prelude/ForeignCall.lhs

index 38c30b2..3842e65 100644 (file)
@@ -767,15 +767,17 @@ foreignCall
        -> ExtFCode CmmExpr
        -> [ExtFCode (CmmExpr,MachHint)]
        -> Maybe [GlobalReg] -> P ExtCode
-foreignCall "C" results_code expr_code args_code vols
-  = return $ do
-       results <- sequence results_code
-       expr <- expr_code
-       args <- sequence args_code
-        code (emitForeignCall' PlayRisky results 
-                 (CmmForeignCall expr CCallConv) args vols)
-foreignCall conv _ _ _ _
-  = fail ("unknown calling convention: " ++ conv)
+foreignCall conv_string results_code expr_code args_code vols
+  = do  convention <- case conv_string of
+          "C" -> return CCallConv
+          "C--" -> return CmmCallConv
+          _ -> fail ("unknown calling convention: " ++ conv_string)
+       return $ do
+         results <- sequence results_code
+         expr <- expr_code
+         args <- sequence args_code
+          code (emitForeignCall' PlayRisky results 
+                 (CmmForeignCall expr convention) args vols) where
 
 primCall
        :: [ExtFCode (CmmReg,MachHint)]
index 5001cc8..939d67d 100644 (file)
@@ -73,7 +73,9 @@ cmmStmtLive other_live (CmmSwitch expr targets) =
     cmmExprLive expr .
     (foldr ((.) . (addLive . lookupWithDefaultUFM other_live emptyUniqSet)) id (mapCatMaybes id targets))
 cmmStmtLive _ (CmmJump expr params) =
-    const (cmmExprLive expr (mkUniqSet params))
+    const (cmmExprLive expr $ foldr ((.) . cmmExprLive) id (map fst params) $ emptyUniqSet)
+cmmStmtLive _ (CmmReturn params) =
+    const (foldr ((.) . cmmExprLive) id (map fst params) $ emptyUniqSet)
 
 --------
 
index 2c90a7d..2f44e05 100644 (file)
@@ -128,13 +128,14 @@ so perhaps we should emit a warning if it's being used on other
 platforms.
 
 \begin{code}
-data CCallConv = CCallConv | StdCallConv
+data CCallConv = CCallConv | StdCallConv | CmmCallConv
   deriving (Eq)
   {-! derive: Binary !-}
 
 instance Outputable CCallConv where
   ppr StdCallConv = ptext SLIT("stdcall")
   ppr CCallConv   = ptext SLIT("ccall")
+  ppr CmmCallConv = ptext SLIT("C--")
 
 defaultCCallConv :: CCallConv
 defaultCCallConv = CCallConv