diff options
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index 4400d72639..5d3b94f090 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/compiler/codeGen/StgCmmPrim.hs @@ -824,6 +824,10 @@ callishPrimOpSupported dflags op || llvm -> Left (MO_Add2 (wordWidth dflags)) | otherwise -> Right genericWordAdd2Op + WordSubCOp | (ncg && x86ish) + || llvm -> Left (MO_SubWordC (wordWidth dflags)) + | otherwise -> Right genericWordSubCOp + IntAddCOp | (ncg && x86ish) || llvm -> Left (MO_AddIntC (wordWidth dflags)) | otherwise -> Right genericIntAddCOp @@ -940,6 +944,19 @@ genericWordAdd2Op [res_h, res_l] [arg_x, arg_y] (bottomHalf (CmmReg (CmmLocal r1))))] genericWordAdd2Op _ _ = panic "genericWordAdd2Op" +genericWordSubCOp :: GenericOp +genericWordSubCOp [res_r, res_c] [aa, bb] = do + dflags <- getDynFlags + emit $ catAGraphs + [ -- Put the result into 'res_r'. + mkAssign (CmmLocal res_r) $ + CmmMachOp (mo_wordSub dflags) [aa, bb] + -- Set 'res_c' to 1 if 'bb > aa' and to 0 otherwise. + , mkAssign (CmmLocal res_c) $ + CmmMachOp (mo_wordUGt dflags) [bb, aa] + ] +genericWordSubCOp _ _ = panic "genericWordSubCOp" + genericIntAddCOp :: GenericOp genericIntAddCOp [res_r, res_c] [aa, bb] {- |