ghc/ghc.git-b29f20.patch
2016-01-06 08:18:51 +00:00

80 lines
3.1 KiB
Diff

From b29f20edb1ca7f1763ceb001e2bb2d5f2f11bec3 Mon Sep 17 00:00:00 2001
From: Peter Trommler <ptrommler@acm.org>
Date: Fri, 2 Oct 2015 15:48:30 +0200
Subject: [PATCH] nativeGen PPC: fix > 16 bit offsets in stack handling
Implement access to spill slots at offsets larger than 16 bits.
Also allocation and deallocation of spill slots was restricted to
16 bit offsets. Now 32 bit offsets are supported on all PowerPC
platforms.
The implementation of 32 bit offsets requires more than one instruction
but the native code generator wants one instruction. So we implement
pseudo-instructions that are pretty printed into multiple assembly
instructions.
With pseudo-instructions for spill slot allocation and deallocation
we can also implement handling of the back chain pointer according
to the ELF ABIs.
Test Plan: validate (especially on powerpc (32 bit))
Reviewers: bgamari, austin, erikd
Reviewed By: erikd
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1296
GHC Trac Issues: #7830
---
compiler/nativeGen/PPC/Instr.hs | 39 ++++++++++++++++++++++++++++-----------
compiler/nativeGen/PPC/Ppr.hs | 33 +++++++++++++++++++++++++++++++++
compiler/nativeGen/PPC/Regs.hs | 14 ++++++++++++--
includes/CodeGen.Platform.hs | 18 +++++++++++++-----
4 files changed, 86 insertions(+), 18 deletions(-)
Index: ghc-7.10.2.20151105/compiler/nativeGen/PPC/Instr.hs
===================================================================
--- ghc-7.10.2.20151105.orig/compiler/nativeGen/PPC/Instr.hs
+++ ghc-7.10.2.20151105/compiler/nativeGen/PPC/Instr.hs
@@ -75,17 +75,19 @@ instance Instruction Instr where
ppc_mkStackAllocInstr :: Platform -> Int -> Instr
ppc_mkStackAllocInstr platform amount
- = case platformArch platform of
- ArchPPC -> UPDATE_SP II32 (ImmInt (-amount))
- ArchPPC_64 _ -> STU II64 sp (AddrRegImm sp (ImmInt (-amount)))
- arch -> panic $ "ppc_mkStackAllocInstr " ++ show arch
+ = ppc_mkStackAllocInstr' platform (-amount)
ppc_mkStackDeallocInstr :: Platform -> Int -> Instr
ppc_mkStackDeallocInstr platform amount
- = case platformArch platform of
- ArchPPC -> UPDATE_SP II32 (ImmInt amount)
- ArchPPC_64 _ -> ADD sp sp (RIImm (ImmInt amount))
- arch -> panic $ "ppc_mkStackDeallocInstr " ++ show arch
+ = ppc_mkStackAllocInstr' 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)
--
-- See note [extra spill slots] in X86/Instr.hs
Index: ghc-7.10.2.20151105/compiler/nativeGen/PPC/Regs.hs
===================================================================
--- ghc-7.10.2.20151105.orig/compiler/nativeGen/PPC/Regs.hs
+++ ghc-7.10.2.20151105/compiler/nativeGen/PPC/Regs.hs
@@ -335,4 +335,5 @@ tmpReg :: Platform -> Reg
tmpReg platform =
case platformArch platform of
ArchPPC -> regSingle 13
+ ArchPPC_64 _ -> regSingle 30
_ -> panic "PPC.Regs.tmpReg: unknowm arch"