diff options
author | Peter Trommler <ptrommler@acm.org> | 2018-12-26 13:15:38 +0100 |
---|---|---|
committer | Peter Trommler <ptrommler@acm.org> | 2018-12-28 11:14:29 +0100 |
commit | e29adf0577f59bcd265ac6ff7a73f26d900d66f7 (patch) | |
tree | 5500874e83d25572e7c3a57c4422bd072b8a0de6 | |
parent | 3748284196d5c68632b6b177c68080a269a9b423 (diff) | |
download | haskell-e29adf0577f59bcd265ac6ff7a73f26d900d66f7.tar.gz |
PPC NCG: Simple 64-bit condition code on 32-bit
Fixes #16094.
-rw-r--r-- | compiler/nativeGen/PPC/CodeGen.hs | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs index a716765eab..6c5d7d2915 100644 --- a/compiler/nativeGen/PPC/CodeGen.hs +++ b/compiler/nativeGen/PPC/CodeGen.hs @@ -904,10 +904,33 @@ getCondCode _ = panic "getCondCode(2)(powerpc)" -- passed back up the tree. condIntCode :: Cond -> Width -> CmmExpr -> CmmExpr -> NatM CondCode - +condIntCode cond width x y = do + dflags <- getDynFlags + condIntCode' (target32Bit (targetPlatform dflags)) cond width x y + +condIntCode' :: Bool -> Cond -> Width -> CmmExpr -> CmmExpr -> NatM CondCode + +-- simple code for 64-bit on 32-bit platforms +condIntCode' True cond W64 x y = do + ChildCode64 code_x x_lo <- iselExpr64 x + ChildCode64 code_y y_lo <- iselExpr64 y + let x_hi = getHiVRegFromLo x_lo + y_hi = getHiVRegFromLo y_lo + cmp = if condUnsigned cond then CMPL else CMP + end_lbl <- getBlockIdNat + let code = code_x `appOL` code_y `appOL` toOL + [ cmp II32 x_hi (RIReg y_hi) + , BCC NE end_lbl Nothing + , cmp II32 x_lo (RIReg y_lo) + , BCC ALWAYS end_lbl Nothing + + , NEWBLOCK end_lbl + ] + return (CondCode False cond code) + -- optimize pointer tag checks. Operation andi. sets condition register -- so cmpi ..., 0 is redundant. -condIntCode cond _ (CmmMachOp (MO_And _) [x, CmmLit (CmmInt imm rep)]) +condIntCode' _ cond _ (CmmMachOp (MO_And _) [x, CmmLit (CmmInt imm rep)]) (CmmLit (CmmInt 0 _)) | not $ condUnsigned cond, Just src2 <- makeImmediate rep False imm @@ -916,7 +939,7 @@ condIntCode cond _ (CmmMachOp (MO_And _) [x, CmmLit (CmmInt imm rep)]) let code' = code `snocOL` AND r0 src1 (RIImm src2) return (CondCode False cond code') -condIntCode cond width x (CmmLit (CmmInt y rep)) +condIntCode' _ cond width x (CmmLit (CmmInt y rep)) | Just src2 <- makeImmediate rep (not $ condUnsigned cond) y = do let op_len = max W32 width @@ -927,7 +950,7 @@ condIntCode cond width x (CmmLit (CmmInt y rep)) (if condUnsigned cond then CMPL else CMP) format src1 (RIImm src2) return (CondCode False cond code') -condIntCode cond width x y = do +condIntCode' _ cond width x y = do let op_len = max W32 width let extend = if condUnsigned cond then extendUExpr width op_len else extendSExpr width op_len |