summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/PIC.hs
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2017-04-25 18:37:16 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-25 18:39:50 -0400
commit89a3241f708502e8fbcfaddbbe634790ad9cd02a (patch)
tree9264c8bb53a229ea2a6a55debd0088bb88354bd2 /compiler/nativeGen/PIC.hs
parent9373994acaf1b73fe0e7cf8e03594c63cec8d235 (diff)
downloadhaskell-89a3241f708502e8fbcfaddbbe634790ad9cd02a.tar.gz
PPC NCG: Implement callish prim ops
Provide PowerPC optimised implementations of callish prim ops. MO_?_QuotRem The generic implementation of quotient remainder prim ops uses a division and a remainder operation. There is no remainder on PowerPC and so we need to implement remainder "by hand" which results in a duplication of the divide operation when using the generic code. Avoid this duplication by implementing the prim op in the native code generator. MO_U_Mul2 Use PowerPC's instructions for long multiplication. Addition and subtraction Use PowerPC add/subtract with carry/overflow instructions MO_Clz and MO_Ctz Use PowerPC's CNTLZ instruction and implement count trailing zeros using count leading zeros MO_QuotRem2 Implement an algorithm given by Henry Warren in "Hacker's Delight" using PowerPC divide instruction. TODO: Use long division instructions when available (POWER7 and later). Test Plan: validate on AIX and 32-bit Linux Reviewers: simonmar, erikd, hvr, austin, bgamari Reviewed By: erikd, hvr, bgamari Subscribers: trofi, kgardas, thomie Differential Revision: https://phabricator.haskell.org/D2973
Diffstat (limited to 'compiler/nativeGen/PIC.hs')
-rw-r--r--compiler/nativeGen/PIC.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs
index babceac4f0..d6005745b3 100644
--- a/compiler/nativeGen/PIC.hs
+++ b/compiler/nativeGen/PIC.hs
@@ -521,7 +521,7 @@ pprGotDeclaration _ _ OSAIX
]
--- PPC 64 ELF v1needs a Table Of Contents (TOC) on Linux
+-- PPC 64 ELF v1 needs a Table Of Contents (TOC) on Linux
pprGotDeclaration _ (ArchPPC_64 ELF_V1) OSLinux
= text ".section \".toc\",\"aw\""
-- In ELF v2 we also need to tell the assembler that we want ABI
@@ -814,7 +814,8 @@ initializePicBase_ppc ArchPPC os picReg
fetchPC (BasicBlock bID insns) =
BasicBlock bID (PPC.FETCHPC picReg
: PPC.ADDIS picReg picReg (PPC.HA gotOffset)
- : PPC.ADDI picReg picReg (PPC.LO gotOffset)
+ : PPC.ADD picReg picReg
+ (PPC.RIImm (PPC.LO gotOffset))
: PPC.MR PPC.r30 picReg
: insns)