%
\begin{code}
-#include "HsVersions.h"
-
module AsmCodeGen ( writeRealAsm, dumpRealAsm ) where
-IMP_Ubiq(){-uitous-}
+#include "HsVersions.h"
+
+import IO ( Handle )
import MachMisc
import MachRegs
import PrimRep ( PrimRep{-instance Eq-} )
import RegAllocInfo ( mkMRegsState, MRegsState )
import Stix ( StixTree(..), StixReg(..), CodeSegment )
-import UniqSupply ( returnUs, thenUs, mapUs, SYN_IE(UniqSM) )
-import Unpretty ( uppPutStr, uppShow, uppAboves, Unpretty(..) )
+import UniqSupply ( returnUs, thenUs, mapUs, UniqSM, UniqSupply )
+import Outputable
\end{code}
The 96/03 native-code generator has machine-independent and
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.
So, here we go:
\begin{code}
writeRealAsm :: Handle -> AbstractC -> UniqSupply -> IO ()
-
writeRealAsm handle absC us
- = uppPutStr handle 80 (runNCG absC us)
-
-dumpRealAsm :: AbstractC -> UniqSupply -> String
+ = _scc_ "writeRealAsm" (printForAsm handle (runNCG absC us))
-dumpRealAsm absC us = uppShow 80 (runNCG absC us)
+dumpRealAsm :: AbstractC -> UniqSupply -> SDoc
+dumpRealAsm = runNCG
runNCG absC
= genCodeAbstractC absC `thenUs` \ treelists ->
@codeGen@ is the top-level code-generation function:
\begin{code}
-codeGen :: [[StixTree]] -> UniqSM Unpretty
+codeGen :: [[StixTree]] -> UniqSM SDoc
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:
IntNeOp -> StInt (if x /= y then 1 else 0)
IntLtOp -> StInt (if x < y then 1 else 0)
IntLeOp -> StInt (if x <= y then 1 else 0)
+ -- ToDo: WordQuotOp, WordRemOp.
_ -> StPrim op args
\end{code}
IntMulOp -> y
AndOp -> y
OrOp -> x
+ XorOp -> x
SllOp -> x
SraOp -> x
SrlOp -> x