X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FCgPrimOp.hs;h=766ad49d872cfc20c789b2d9140b8a2953db9724;hb=f8c52d7fde2d7408b4f734251c373f8d3e2c558e;hp=17ecfa085641b40ab2b96be4e6df76043c670f14;hpb=207802589da0d23c3f16195f453b24a1e46e322d;p=ghc-hetmet.git diff --git a/compiler/codeGen/CgPrimOp.hs b/compiler/codeGen/CgPrimOp.hs index 17ecfa0..766ad49 100644 --- a/compiler/codeGen/CgPrimOp.hs +++ b/compiler/codeGen/CgPrimOp.hs @@ -6,6 +6,13 @@ -- ----------------------------------------------------------------------------- +{-# 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 + module CgPrimOp ( cgPrimOp ) where @@ -13,28 +20,26 @@ module CgPrimOp ( #include "HsVersions.h" import ForeignCall +import ClosureInfo import StgSyn import CgForeignCall 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 -- --------------------------------------------------------------------------- -- 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 @@ -46,7 +51,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,9 +124,11 @@ emitPrimOp [res] ParOp [arg] live vols <- getVolatileRegs live emitForeignCall' PlayRisky [(res,NoHint)] - (CmmForeignCall newspark CCallConv) + (CmmCallee newspark CCallConv) [(CmmReg (CmmGlobal BaseReg), PtrHint), (arg,PtrHint)] (Just vols) + NoC_SRT -- No SRT b/c we do PlayRisky + CmmMayReturn where newspark = CmmLit (CmmLabel (mkRtsCodeLabel SLIT("newSpark"))) @@ -134,10 +141,12 @@ 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)] (Just vols) + NoC_SRT -- No SRT b/c we do PlayRisky + CmmMayReturn -- #define sizzeofByteArrayzh(r,a) \ -- r = (((StgArrWords *)(a))->words * sizeof(W_)) @@ -183,8 +192,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 @@ -342,6 +352,8 @@ emitPrimOp [res] op args live (CmmPrim prim) [(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