[project @ 2005-03-21 10:50:22 by simonmar]
[ghc-hetmet.git] / ghc / compiler / nativeGen / AsmCodeGen.lhs
index 7f0bd45..e790991 100644 (file)
@@ -33,13 +33,11 @@ import UniqFM
 import Unique          ( Unique, getUnique )
 import UniqSupply
 import FastTypes
-#if darwin_TARGET_OS || (powerpc_TARGET_ARCH && linux_TARGET_OS)
 import List            ( groupBy, sortBy )
 import CLabel           ( pprCLabel )
-#endif
 import ErrUtils                ( dumpIfSet_dyn )
-import CmdLineOpts     ( DynFlags, DynFlag(..), dopt, opt_Static,
-                         opt_EnsureSplittableC, opt_PIC )
+import DynFlags                ( DynFlags, DynFlag(..), dopt )
+import StaticFlags     ( opt_Static, opt_PIC )
 
 import Digraph
 import qualified Pretty
@@ -123,17 +121,23 @@ nativeCodeGen dflags cmms us
           returnUs (Cmm cmms, my_vcat docs, concat imps)
     in do
     dumpIfSet_dyn dflags Opt_D_dump_opt_cmm "Optimised Cmm" (pprCmms [ppr_cmms])
-    return (insn_sdoc Pretty.$$ dyld_stubs imports)
+    return (insn_sdoc Pretty.$$ dyld_stubs imports
+#if HAVE_SUBSECTIONS_VIA_SYMBOLS
+                -- On recent versions of Darwin, the linker supports
+                -- dead-stripping of code and data on a per-symbol basis.
+                -- There's a hack to make this work in PprMach.pprNatCmmTop.
+            Pretty.$$ Pretty.text ".subsections_via_symbols"
+#endif
+            )
 
   where
 
     add_split (Cmm tops)
-       | opt_EnsureSplittableC = split_marker : tops
-       | otherwise             = tops
+       | dopt Opt_SplitObjs dflags = split_marker : tops
+       | otherwise                 = tops
 
     split_marker = CmmProc [] mkSplitMarkerLabel [] []
 
-#if darwin_TARGET_OS || (powerpc_TARGET_ARCH && linux_TARGET_OS)
         -- Generate "symbol stubs" for all external symbols that might
         -- come from a dynamic library.
 {-    dyld_stubs imps = Pretty.vcat $ map pprDyldSymbolStub $
@@ -155,9 +159,6 @@ nativeCodeGen dflags cmms us
         
         where doPpr lbl = (lbl, Pretty.render $ pprCLabel lbl astyle)
               astyle = mkCodeStyle AsmStyle
-#else
-    dyld_stubs imps = Pretty.empty
-#endif
 
 #ifndef NCG_DEBUG
     my_vcat sds = Pretty.vcat sds
@@ -803,6 +804,9 @@ lookForInline u expr (stmt@(CmmAssign (CmmLocal (LocalReg u' _)) rhs) : rest)
                     Nothing    -> Nothing
                     Just stmts -> Just (stmt:stmts)
 
+lookForInline u expr (CmmNop : rest)
+  = lookForInline u expr rest
+
 lookForInline u expr (stmt:stmts)
   = case lookupUFM (getStmtUses stmt) u of
        Just 1 -> Just (inlineStmt u expr stmt : stmts)