[commit: ghc] wip/ppc-update-sp: PPC NCG: Refactor stack allocation code (3c097c6)
git at git.haskell.org
git at git.haskell.org
Sun Mar 31 15:08:09 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ppc-update-sp
Link : http://ghc.haskell.org/trac/ghc/changeset/3c097c682c3e26a778ae267eab3f13494bfb5442/ghc
>---------------------------------------------------------------
commit 3c097c682c3e26a778ae267eab3f13494bfb5442
Author: Peter Trommler <ptrommler at acm.org>
Date: Mon Dec 17 13:27:49 2018 +0100
PPC NCG: Refactor stack allocation code
There is only one place where UPDATE_SP was used. Instead of the
UPDATE_SP pseudo instruction build the list of instructions directly.
>---------------------------------------------------------------
3c097c682c3e26a778ae267eab3f13494bfb5442
compiler/nativeGen/PPC/Instr.hs | 23 +++++++++++++++--------
compiler/nativeGen/PPC/Ppr.hs | 18 ------------------
2 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/compiler/nativeGen/PPC/Instr.hs b/compiler/nativeGen/PPC/Instr.hs
index 8f3153c..f8dba25 100644
--- a/compiler/nativeGen/PPC/Instr.hs
+++ b/compiler/nativeGen/PPC/Instr.hs
@@ -87,11 +87,21 @@ ppc_mkStackDeallocInstr platform amount
ppc_mkStackAllocInstr' :: Platform -> Int -> [Instr]
ppc_mkStackAllocInstr' platform amount
- = case platformArch platform of
- ArchPPC -> [UPDATE_SP II32 (ImmInt amount)]
- ArchPPC_64 _ -> [UPDATE_SP II64 (ImmInt amount)]
- _ -> panic $ "ppc_mkStackAllocInstr' "
- ++ show (platformArch platform)
+ | fits16Bits amount
+ = [ LD fmt r0 (AddrRegImm sp zero)
+ , STU fmt r0 (AddrRegImm sp immAmount)
+ ]
+ | otherwise
+ = [ LD fmt r0 (AddrRegImm sp zero)
+ , ADDIS tmp sp (HA immAmount)
+ , ADD tmp tmp (RIImm (LO immAmount))
+ , STU fmt r0 (AddrRegReg sp tmp)
+ ]
+ where
+ fmt = intFormat $ widthFromBytes ((platformWordSize platform) `quot` 8)
+ zero = ImmInt 0
+ tmp = tmpReg platform
+ immAmount = ImmInt amount
--
-- See note [extra spill slots] in X86/Instr.hs
@@ -289,8 +299,6 @@ data Instr
| NOP -- no operation, PowerPC 64 bit
-- needs this as place holder to
-- reload TOC pointer
- | UPDATE_SP Format Imm -- expand/shrink spill area on C stack
- -- pseudo-instruction
-- | Get the registers that are being used by this instruction.
-- regUsage doesn't need to do any trickery for jumps and such.
@@ -370,7 +378,6 @@ ppc_regUsageOfInstr platform instr
MFCR reg -> usage ([], [reg])
MFLR reg -> usage ([], [reg])
FETCHPC reg -> usage ([], [reg])
- UPDATE_SP _ _ -> usage ([], [sp])
_ -> noUsage
where
usage (src, dst) = RU (filter (interesting platform) src)
diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs
index d7175b8..6bb8048 100644
--- a/compiler/nativeGen/PPC/Ppr.hs
+++ b/compiler/nativeGen/PPC/Ppr.hs
@@ -904,24 +904,6 @@ pprInstr LWSYNC = text "\tlwsync"
pprInstr NOP = text "\tnop"
-pprInstr (UPDATE_SP fmt amount@(ImmInt offset))
- | fits16Bits offset = vcat [
- pprInstr (LD fmt r0 (AddrRegImm sp (ImmInt 0))),
- pprInstr (STU fmt r0 (AddrRegImm sp amount))
- ]
-
-pprInstr (UPDATE_SP fmt amount)
- = sdocWithPlatform $ \platform ->
- let tmp = tmpReg platform in
- vcat [
- pprInstr (LD fmt r0 (AddrRegImm sp (ImmInt 0))),
- pprInstr (ADDIS tmp sp (HA amount)),
- pprInstr (ADD tmp tmp (RIImm (LO amount))),
- pprInstr (STU fmt r0 (AddrRegReg sp tmp))
- ]
-
--- pprInstr _ = panic "pprInstr (ppc)"
-
pprLogic :: PtrString -> Reg -> Reg -> RI -> SDoc
pprLogic op reg1 reg2 ri = hcat [
More information about the ghc-commits
mailing list