Don't import FastString in HsVersions.h
[ghc-hetmet.git] / compiler / codeGen / CgPrimOp.hs
index 01279b4..207ffe2 100644 (file)
@@ -1,3 +1,10 @@
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
 -----------------------------------------------------------------------------
 --
 -- Code generation for PrimOps.
@@ -20,22 +27,20 @@ import CgBindery
 import CgMonad
 import CgInfoTbls
 import CgUtils
-import ForeignCall
 import Cmm
 import CLabel
 import CmmUtils
 import MachOp
-import SMRep
 import PrimOp
 import SMRep
 import Constants
-import StaticFlags
 import Outputable
+import FastString
 
 -- ---------------------------------------------------------------------------
 -- Code generation for PrimOps
 
-cgPrimOp   :: CmmFormals       -- where to put the results
+cgPrimOp   :: CmmFormalsWithoutKinds   -- where to put the results
           -> PrimOp            -- the op
           -> [StgArg]          -- arguments
           -> StgLiveVars       -- live vars, in case we need to save them
@@ -47,7 +52,7 @@ cgPrimOp results op args live
        emitPrimOp results op non_void_args live
 
 
-emitPrimOp :: CmmFormals       -- where to put the results
+emitPrimOp :: CmmFormalsWithoutKinds   -- where to put the results
           -> PrimOp            -- the op
           -> [CmmExpr]         -- arguments
           -> StgLiveVars       -- live vars, in case we need to save them
@@ -119,11 +124,13 @@ emitPrimOp [res] ParOp [arg] live
        -- later, we might want to inline it.
     vols <- getVolatileRegs live
     emitForeignCall' PlayRisky
-       [(res,NoHint)]
-       (CmmForeignCall newspark CCallConv) 
-       [(CmmReg (CmmGlobal BaseReg), PtrHint), (arg,PtrHint)] 
+       [CmmHinted res NoHint]
+       (CmmCallee newspark CCallConv) 
+       [   (CmmHinted (CmmReg (CmmGlobal BaseReg)) PtrHint)
+          , (CmmHinted arg PtrHint)  ] 
        (Just vols)
         NoC_SRT -- No SRT b/c we do PlayRisky
+        CmmMayReturn
   where
        newspark = CmmLit (CmmLabel (mkRtsCodeLabel SLIT("newSpark")))
 
@@ -136,11 +143,13 @@ emitPrimOp [] WriteMutVarOp [mutv,var] live
        vols <- getVolatileRegs live
        emitForeignCall' PlayRisky
                [{-no results-}]
-               (CmmForeignCall (CmmLit (CmmLabel mkDirty_MUT_VAR_Label))
+               (CmmCallee (CmmLit (CmmLabel mkDirty_MUT_VAR_Label))
                         CCallConv)
-               [(CmmReg (CmmGlobal BaseReg), PtrHint), (mutv,PtrHint)]
+               [   (CmmHinted (CmmReg (CmmGlobal BaseReg)) PtrHint)
+                  , (CmmHinted mutv PtrHint)  ]
                (Just vols)
                 NoC_SRT -- No SRT b/c we do PlayRisky
+                CmmMayReturn
 
 --  #define sizzeofByteArrayzh(r,a) \
 --     r = (((StgArrWords *)(a))->words * sizeof(W_))
@@ -186,8 +195,9 @@ emitPrimOp [res] AddrToHValueOp [arg] live
    = stmtC (CmmAssign (CmmLocal res) arg)
 
 --  #define dataToTagzh(r,a)  r=(GET_TAG(((StgClosure *)a)->header.info))
+--  Note: argument may be tagged!
 emitPrimOp [res] DataToTagOp [arg] live
-   = stmtC (CmmAssign (CmmLocal res) (getConstrTag arg))
+   = stmtC (CmmAssign (CmmLocal res) (getConstrTag (cmmUntag arg)))
 
 {- Freezing arrays-of-ptrs requires changing an info table, for the
    benefit of the generational collector.  It needs to scavenge mutable
@@ -341,11 +351,12 @@ emitPrimOp [res] op args live
    | Just prim <- callishOp op
    = do vols <- getVolatileRegs live
        emitForeignCall' PlayRisky
-          [(res,NoHint)] 
+          [CmmHinted res NoHint] 
           (CmmPrim prim) 
-          [(a,NoHint) | a<-args]  -- ToDo: hints?
+          [CmmHinted a NoHint | a<-args]  -- ToDo: hints?
           (Just vols)
            NoC_SRT -- No SRT b/c we do PlayRisky
+           CmmMayReturn
 
    | Just mop <- translateOp op
    = let stmt = CmmAssign (CmmLocal res) (CmmMachOp mop args) in