X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FnativeGen%2FAsmCodeGen.lhs;h=1e297add572a6882e25d31e266ebe6df941d4e3f;hb=7e602b0a11e567fcb035d1afd34015aebcf9a577;hp=b94efa4cf46600ec0a935a730764829c2a075cb7;hpb=62dfd96cf8239ceb7cb65e955c29c57f6c798517;p=ghc-hetmet.git diff --git a/ghc/compiler/nativeGen/AsmCodeGen.lhs b/ghc/compiler/nativeGen/AsmCodeGen.lhs index b94efa4..1e297ad 100644 --- a/ghc/compiler/nativeGen/AsmCodeGen.lhs +++ b/ghc/compiler/nativeGen/AsmCodeGen.lhs @@ -1,14 +1,13 @@ % -% (c) The AQUA Project, Glasgow University, 1993-1996 +% (c) The AQUA Project, Glasgow University, 1993-1998 % \begin{code} -#include "HsVersions.h" - module AsmCodeGen ( writeRealAsm, dumpRealAsm ) where -IMP_Ubiq(){-uitous-} -IMPORT_1_3(IO(Handle)) +#include "HsVersions.h" + +import IO ( Handle ) import MachMisc import MachRegs @@ -20,12 +19,10 @@ import AbsCSyn ( AbstractC, MagicId ) import AsmRegAlloc ( runRegAllocate ) import OrdList ( OrdList ) 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), UniqSupply ) -import Outputable ( printDoc ) -import Pretty ( Doc, vcat, Mode(..) ) +import Stix ( StixTree(..), StixReg(..) ) +import UniqSupply ( returnUs, thenUs, mapUs, initUs, UniqSM, UniqSupply ) +import Outputable \end{code} The 96/03 native-code generator has machine-independent and @@ -77,10 +74,11 @@ So, here we go: \begin{code} writeRealAsm :: Handle -> AbstractC -> UniqSupply -> IO () writeRealAsm handle absC us - = _scc_ "writeRealAsm" (printDoc LeftMode handle (runNCG absC us)) + = -- _scc_ "writeRealAsm" + printForAsm handle (initUs us (runNCG absC)) -dumpRealAsm :: AbstractC -> UniqSupply -> Doc -dumpRealAsm = runNCG +dumpRealAsm :: AbstractC -> UniqSupply -> SDoc +dumpRealAsm absC us = initUs us (runNCG absC) runNCG absC = genCodeAbstractC absC `thenUs` \ treelists -> @@ -92,7 +90,7 @@ runNCG absC @codeGen@ is the top-level code-generation function: \begin{code} -codeGen :: [[StixTree]] -> UniqSM Doc +codeGen :: [[StixTree]] -> UniqSM SDoc codeGen trees = mapUs genMachCode trees `thenUs` \ dynamic_codes -> @@ -158,8 +156,8 @@ genericOpt (StJump addr) = StJump (genericOpt addr) genericOpt (StCondJump addr test) = StCondJump addr (genericOpt test) -genericOpt (StCall fn pk args) - = StCall fn pk (map genericOpt args) +genericOpt (StCall fn cconv pk args) + = StCall fn cconv pk (map genericOpt args) \end{code} Fold indices together when the types match: @@ -226,6 +224,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} @@ -250,7 +249,6 @@ primOpt op args@[x, y@(StInt 0)] OrOp -> x XorOp -> x SllOp -> x - SraOp -> x SrlOp -> x ISllOp -> x ISraOp -> x @@ -272,10 +270,10 @@ primOpt op args@[x, y@(StInt n)] = case op of IntMulOp -> case exactLog2 n of Nothing -> StPrim op args - Just p -> StPrim SllOp [x, StInt p] + Just p -> StPrim ISllOp [x, StInt p] IntQuotOp -> case exactLog2 n of Nothing -> StPrim op args - Just p -> StPrim SraOp [x, StInt p] + Just p -> StPrim ISrlOp [x, StInt p] _ -> StPrim op args \end{code}