Remove a duplicate case
[ghc-hetmet.git] / compiler / cmm / CmmParse.y
index 68bc26d..c2dd22f 100644 (file)
@@ -294,7 +294,7 @@ decl        :: { ExtCode }
        | STRING type names ';'         {% do k <- parseKind $1;
                                              return $ mapM_ (newLocal k $2) $3 }
 
-       | 'import' names ';'            { return () }  -- ignore imports
+       | 'import' names ';'            { mapM_ newImport $2 }
        | 'export' names ';'            { return () }  -- ignore exports
 
 names  :: { [FastString] }
@@ -770,9 +770,12 @@ instance Monad ExtFCode where
 -- an environment, which is looped back into the computation.  In this
 -- way, we can have embedded declarations that scope over the whole
 -- procedure, and imports that scope over the entire module.
+-- Discards the local declaration contained within decl'
 loopDecls :: ExtFCode a -> ExtFCode a
-loopDecls (EC fcode) = 
-   EC $ \e s -> fixC (\ ~(decls,a) -> fcode (addListToUFM e decls) [])
+loopDecls (EC fcode) =
+      EC $ \e globalDecls -> do
+       (decls', a) <- fixC (\ ~(decls,a) -> fcode (addListToUFM e (decls ++ globalDecls)) globalDecls)
+       return (globalDecls, a)
 
 getEnv :: ExtFCode Env
 getEnv = EC $ \e s -> return (s, e)
@@ -790,6 +793,13 @@ newLocal kind ty name = do
    addVarDecl name (CmmReg (CmmLocal reg))
    return reg
 
+-- Creates a foreign label in the import. CLabel's labelDynamic
+-- classifies these labels as dynamic, hence the code generator emits the
+-- PIC code for them.
+newImport :: FastString -> ExtFCode ()
+newImport name =
+       addVarDecl name (CmmLit (CmmLabel (mkForeignLabel name Nothing True)))
+
 newLabel :: FastString -> ExtFCode BlockId
 newLabel name = do
    u <- code newUnique
@@ -867,17 +877,17 @@ foreignCall conv_string results_code expr_code args_code vols safety
          results <- sequence results_code
          expr <- expr_code
          args <- sequence args_code
-         --code (stmtC (CmmCall (CmmForeignCall expr convention) results args safety))
+         --code (stmtC (CmmCall (CmmCallee expr convention) results args safety))
           case convention of
             -- Temporary hack so at least some functions are CmmSafe
-            CmmCallConv -> code (stmtC (CmmCall (CmmForeignCall expr convention) results args safety))
+            CmmCallConv -> code (stmtC (CmmCall (CmmCallee expr convention) results args safety))
             _ -> case safety of
              CmmUnsafe ->
                 code (emitForeignCall' PlayRisky results 
-                   (CmmForeignCall expr convention) args vols NoC_SRT)
+                   (CmmCallee expr convention) args vols NoC_SRT)
               CmmSafe srt ->
                 code (emitForeignCall' (PlaySafe unused) results 
-                   (CmmForeignCall expr convention) args vols NoC_SRT) where
+                   (CmmCallee expr convention) args vols NoC_SRT) where
                unused = panic "not used by emitForeignCall'"
 
 primCall