summaryrefslogtreecommitdiff
path: root/compiler/codeGen/StgCmmPrim.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/codeGen/StgCmmPrim.hs')
-rw-r--r--compiler/codeGen/StgCmmPrim.hs40
1 files changed, 21 insertions, 19 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index fb5acde956..c11df7009c 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -36,7 +36,6 @@ import CLabel
import CmmUtils
import PrimOp
import SMRep
-import Module
import FastString
import Outputable
import Util
@@ -108,15 +107,6 @@ cgOpApp (StgPrimOp primop) args res_ty
cgPrimOp regs primop args
emitReturn (map (CmmReg . CmmLocal) regs)
- | ReturnsAlg tycon <- result_info
- , isEnumerationTyCon tycon
- -- c.f. cgExpr (...TagToEnumOp...)
- = do dflags <- getDynFlags
- tag_reg <- newTemp (bWord dflags)
- cgPrimOp [tag_reg] primop args
- emitReturn [tagToClosure dflags tycon
- (CmmReg (CmmLocal tag_reg))]
-
| otherwise = panic "cgPrimop"
where
result_info = getPrimOpResultInfo primop
@@ -214,7 +204,7 @@ emitPrimOp _ [res] ParOp [arg]
-- later, we might want to inline it.
emitCCall
[(res,NoHint)]
- (CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "newSpark"))))
+ (CmmLit (CmmLabel (mkForeignLabel (fsLit "newSpark") Nothing ForeignLabelInExternalPackage IsFunction)))
[(CmmReg (CmmGlobal BaseReg), AddrHint), (arg,AddrHint)]
emitPrimOp dflags [res] SparkOp [arg]
@@ -226,7 +216,7 @@ emitPrimOp dflags [res] SparkOp [arg]
tmp2 <- newTemp (bWord dflags)
emitCCall
[(tmp2,NoHint)]
- (CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "newSpark"))))
+ (CmmLit (CmmLabel (mkForeignLabel (fsLit "newSpark") Nothing ForeignLabelInExternalPackage IsFunction)))
[(CmmReg (CmmGlobal BaseReg), AddrHint), ((CmmReg (CmmLocal tmp)), AddrHint)]
emitAssign (CmmLocal res) (CmmReg (CmmLocal tmp))
@@ -542,6 +532,11 @@ emitPrimOp _ [] CopyMutableByteArrayOp [src,src_off,dst,dst_off,n] =
emitPrimOp _ [] SetByteArrayOp [ba,off,len,c] =
doSetByteArrayOp ba off len c
+emitPrimOp _ [res] BSwap16Op [w] = emitBSwapCall res w W16
+emitPrimOp _ [res] BSwap32Op [w] = emitBSwapCall res w W32
+emitPrimOp _ [res] BSwap64Op [w] = emitBSwapCall res w W64
+emitPrimOp dflags [res] BSwapOp [w] = emitBSwapCall res w (wordWidth dflags)
+
-- Population count
emitPrimOp _ [res] PopCnt8Op [w] = emitPopCntCall res w W8
emitPrimOp _ [res] PopCnt16Op [w] = emitPopCntCall res w W16
@@ -1043,7 +1038,7 @@ doIndexOffAddrOp _ _ _ _
doIndexOffAddrOpAs :: Maybe MachOp
-> CmmType
- -> CmmType
+ -> CmmType
-> [LocalReg]
-> [CmmExpr]
-> FCode ()
@@ -1060,19 +1055,19 @@ doIndexByteArrayOp :: Maybe MachOp
doIndexByteArrayOp maybe_post_read_cast rep [res] [addr,idx]
= do dflags <- getDynFlags
mkBasicIndexedRead (arrWordsHdrSize dflags) maybe_post_read_cast rep res addr rep idx
-doIndexByteArrayOp _ _ _ _
+doIndexByteArrayOp _ _ _ _
= panic "StgCmmPrim: doIndexByteArrayOp"
doIndexByteArrayOpAs :: Maybe MachOp
-> CmmType
- -> CmmType
+ -> CmmType
-> [LocalReg]
-> [CmmExpr]
-> FCode ()
doIndexByteArrayOpAs maybe_post_read_cast rep idx_rep [res] [addr,idx]
= do dflags <- getDynFlags
mkBasicIndexedRead (arrWordsHdrSize dflags) maybe_post_read_cast rep res addr idx_rep idx
-doIndexByteArrayOpAs _ _ _ _ _
+doIndexByteArrayOpAs _ _ _ _ _
= panic "StgCmmPrim: doIndexByteArrayOpAs"
doReadPtrArrayOp :: LocalReg
@@ -1217,7 +1212,7 @@ doVecPackOp maybe_pre_write_cast ty z es res = do
Just cast -> CmmMachOp cast [val]
len :: Length
- len = vecLength ty
+ len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
@@ -1251,7 +1246,7 @@ doVecUnpackOp maybe_post_read_cast ty e res =
Just cast -> CmmMachOp cast [val]
len :: Length
- len = vecLength ty
+ len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
@@ -1278,7 +1273,7 @@ doVecInsertOp maybe_pre_write_cast ty src e idx res = do
Just cast -> CmmMachOp cast [val]
len :: Length
- len = vecLength ty
+ len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
@@ -1569,6 +1564,13 @@ emitAllocateCall res cap n = do
allocate = CmmLit (CmmLabel (mkForeignLabel (fsLit "allocate") Nothing
ForeignLabelInExternalPackage IsFunction))
+emitBSwapCall :: LocalReg -> CmmExpr -> Width -> FCode ()
+emitBSwapCall res x width = do
+ emitPrimCall
+ [ res ]
+ (MO_BSwap width)
+ [ x ]
+
emitPopCntCall :: LocalReg -> CmmExpr -> Width -> FCode ()
emitPopCntCall res x width = do
emitPrimCall