[project @ 2000-03-23 17:45:17 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / CodeOutput.lhs
index e7fb411..47f3b36 100644 (file)
@@ -8,10 +8,17 @@ module CodeOutput( codeOutput ) where
 
 #include "HsVersions.h"
 
-#if ! OMIT_NATIVE_CODEGEN
+#ifndef OMIT_NATIVE_CODEGEN
 import AsmCodeGen      ( nativeCodeGen )
 #endif
+#ifdef ILX
+import IlxGen          ( ilxGen )
+#endif
 
+import TyCon           ( TyCon )
+import Id              ( Id )
+import Class           ( Class )
+import StgSyn          ( StgBinding )
 import AbsCSyn         ( AbstractC, absCNop )
 import PprAbsC         ( dumpRealC, writeRealC )
 import UniqSupply      ( UniqSupply )
@@ -20,28 +27,39 @@ import CmdLineOpts
 import Maybes          ( maybeToBool )
 import ErrUtils                ( doIfSet, dumpIfSet )
 import Outputable
-import IO              ( IOMode(..), hPutStr, hClose, openFile, stderr )
+import IO              ( IOMode(..), hPutStr, hClose, openFile )
 \end{code}
 
 
 \begin{code}
 codeOutput :: Module
+          -> [TyCon] -> [Class]        -- Local tycons and classes
+          -> [(StgBinding,[Id])]       -- The STG program with SRTs
           -> SDoc              -- C stubs for foreign exported functions
           -> SDoc              -- Header file prototype for foreign exported functions
           -> AbstractC         -- Compiled abstract C
           -> UniqSupply
           -> IO ()
-codeOutput mod_name c_code h_code flat_abstractC ncg_uniqs
+codeOutput mod_name tycons classes stg_binds c_code h_code flat_abstractC ncg_uniqs
   = -- You can have C (c_output) or assembly-language (ncg_output),
     -- but not both.  [Allowing for both gives a space leak on
     -- flat_abstractC.  WDP 94/10]
 
-    dumpIfSet opt_D_dump_stix "Final stix code" stix_final >>
-
-    dumpIfSet opt_D_dump_asm "Asm code" ncg_output_d   >>
-    doOutput opt_ProduceS ncg_output_w                         >>
+#ifndef OMIT_NATIVE_CODEGEN
+    let
+       (stix_final, ncg_output_d) = nativeCodeGen flat_absC_ncg ncg_uniqs
+       ncg_output_w = (\ f -> printForUser f ncg_output_d)
+    in
+    dumpIfSet opt_D_dump_stix "Final stix code" stix_final     >>
+    dumpIfSet opt_D_dump_asm "Asm code" ncg_output_d           >>
+    doOutput opt_ProduceS ncg_output_w                                 >>
+#else
+#ifdef ILX
+    doOutput opt_ProduceS (\f -> printForUser f (ilxGen tycons stg_binds))             >>
+#endif
+#endif
 
-    dumpIfSet opt_D_dump_foreign "Foreign export header file" stub_h_output_d >>
+    dumpIfSet opt_D_dump_foreign "Foreign export header file" stub_h_output_d          >>
     outputForeignStubs True{-.h output-} opt_ProduceExportHStubs stub_h_output_w       >>
 
     dumpIfSet opt_D_dump_foreign "Foreign export stubs" stub_c_output_d >>
@@ -70,16 +88,6 @@ codeOutput mod_name c_code h_code flat_abstractC ncg_uniqs
     c_output_d = dumpRealC flat_absC_c
     c_output_w = (\ f -> writeRealC f flat_absC_c)
 
-       -- Native code generation done here!
-#if OMIT_NATIVE_CODEGEN
-    ncg_output_d = error "*** GHC not built with a native-code generator ***"
-    ncg_output_w = ncg_output_d
-#else
-    (stix_final, ncg_output_d)
-       = nativeCodeGen flat_absC_ncg ncg_uniqs
-    ncg_output_w = (\ f -> printForAsm f ncg_output_d)
-#endif
-
 
     -- don't use doOutput for dumping the f. export stubs
     -- since it is more than likely that the stubs file will