[project @ 1997-11-05 16:11:17 by simonm]
[ghc-hetmet.git] / ghc / compiler / nativeGen / AsmCodeGen.lhs
index ac259c4..b94efa4 100644 (file)
@@ -7,7 +7,8 @@
 
 module AsmCodeGen ( writeRealAsm, dumpRealAsm ) where
 
-import Ubiq{-uitous-}
+IMP_Ubiq(){-uitous-}
+IMPORT_1_3(IO(Handle))
 
 import MachMisc
 import MachRegs
@@ -22,8 +23,9 @@ import PrimOp         ( commutableOp, PrimOp(..) )
 import PrimRep         ( PrimRep{-instance Eq-} )
 import RegAllocInfo    ( mkMRegsState, MRegsState )
 import Stix            ( StixTree(..), StixReg(..), CodeSegment )
-import UniqSupply      ( returnUs, thenUs, mapUs, UniqSM(..) )
-import Unpretty                ( uppAppendFile, uppShow, uppAboves, Unpretty(..) )
+import UniqSupply      ( returnUs, thenUs, mapUs, SYN_IE(UniqSM), UniqSupply )
+import Outputable      ( printDoc )
+import Pretty          ( Doc, vcat, Mode(..) )
 \end{code}
 
 The 96/03 native-code generator has machine-independent and
@@ -58,7 +60,7 @@ The machine-dependent bits break down as follows:
     machine instructions.
 
 \item[@PprMach@:] @pprInstr@ turns an @Instr@ into text (well, really
-    an @Unpretty@).
+    an @Doc@).
 
 \item[@RegAllocInfo@:] In the register allocator, we manipulate
     @MRegsState@s, which are @BitSet@s, one bit per machine register.
@@ -73,14 +75,12 @@ The machine-dependent bits break down as follows:
 
 So, here we go:
 \begin{code}
-writeRealAsm :: _FILE -> AbstractC -> UniqSupply -> IO ()
+writeRealAsm :: Handle -> AbstractC -> UniqSupply -> IO ()
+writeRealAsm handle absC us
+  = _scc_ "writeRealAsm" (printDoc LeftMode handle (runNCG absC us))
 
-writeRealAsm file absC us
-  = uppAppendFile file 80 (runNCG absC us)
-
-dumpRealAsm :: AbstractC -> UniqSupply -> String
-
-dumpRealAsm absC us = uppShow 80 (runNCG absC us)
+dumpRealAsm :: AbstractC -> UniqSupply -> Doc
+dumpRealAsm = runNCG
 
 runNCG absC
   = genCodeAbstractC absC      `thenUs` \ treelists ->
@@ -92,14 +92,14 @@ runNCG absC
 
 @codeGen@ is the top-level code-generation function:
 \begin{code}
-codeGen :: [[StixTree]] -> UniqSM Unpretty
+codeGen :: [[StixTree]] -> UniqSM Doc
 
 codeGen trees
   = mapUs genMachCode trees    `thenUs` \ dynamic_codes ->
     let
        static_instrs = scheduleMachCode dynamic_codes
     in
-    returnUs (uppAboves (map pprInstr static_instrs))
+    returnUs (vcat (map pprInstr static_instrs))
 \end{code}
 
 Top level code generator for a chunk of stix code:
@@ -248,6 +248,7 @@ primOpt op args@[x, y@(StInt 0)]
        IntMulOp -> y
        AndOp    -> y
        OrOp     -> x
+       XorOp    -> x
        SllOp    -> x
        SraOp    -> x
        SrlOp    -> x