X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fcompiler%2FnativeGen%2FAsmCodeGen.lhs;h=5e1243e64d31ca6cdf24acdbc0a9c9871786ed85;hb=814e402f24569ca7a8a02e8b54a38abfd6b0b59e;hp=d88986893c0e2638534456ff34e59380d87b4e3c;hpb=9d4c03805bafb6b1e1d47306b6a6c591c998e517;p=ghc-hetmet.git diff --git a/ghc/compiler/nativeGen/AsmCodeGen.lhs b/ghc/compiler/nativeGen/AsmCodeGen.lhs index d889868..5e1243e 100644 --- a/ghc/compiler/nativeGen/AsmCodeGen.lhs +++ b/ghc/compiler/nativeGen/AsmCodeGen.lhs @@ -23,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, SYN_IE(UniqSM) ) -import Unpretty ( uppPutStr, uppShow, uppAboves, SYN_IE(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 @@ -59,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. @@ -75,13 +76,11 @@ The machine-dependent bits break down as follows: 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" (printDoc LeftMode handle (runNCG absC us)) -dumpRealAsm absC us = uppShow 80 (runNCG absC us) +dumpRealAsm :: AbstractC -> UniqSupply -> Doc +dumpRealAsm = runNCG runNCG absC = genCodeAbstractC absC `thenUs` \ treelists -> @@ -93,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: @@ -227,6 +226,7 @@ primOpt op args@[StInt x, StInt y] 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} @@ -249,6 +249,7 @@ primOpt op args@[x, y@(StInt 0)] IntMulOp -> y AndOp -> y OrOp -> x + XorOp -> x SllOp -> x SraOp -> x SrlOp -> x