summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2015-10-02 15:48:30 +0200
committerBen Gamari <ben@smart-cactus.org>2015-10-02 15:51:09 +0200
commitb29f20edb1ca7f1763ceb001e2bb2d5f2f11bec3 (patch)
tree88b2fb3943c7608f3f5c1fe9df6a441e9810c6a2 /includes
parent57e3742c20fcc55f21634b6a43fbee47bc053775 (diff)
downloadhaskell-b29f20edb1ca7f1763ceb001e2bb2d5f2f11bec3.tar.gz
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
Diffstat (limited to 'includes')
-rw-r--r--includes/CodeGen.Platform.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/includes/CodeGen.Platform.hs b/includes/CodeGen.Platform.hs
index b93f0074fd..b41ad54349 100644
--- a/includes/CodeGen.Platform.hs
+++ b/includes/CodeGen.Platform.hs
@@ -874,17 +874,25 @@ freeRegBase _ = True
#elif MACHREGS_powerpc
-freeReg 0 = False -- Hack: r0 can't be used in all insns,
- -- but it's actually free
+freeReg 0 = False -- Used by code setting the back chain pointer
+ -- in stack reallocations on Linux
+ -- r0 is not usable in all insns so also reserved
+ -- on Darwin.
freeReg 1 = False -- The Stack Pointer
# if !MACHREGS_darwin
-- most non-darwin powerpc OSes use r2 as a TOC pointer or something like that
freeReg 2 = False
--- TODO: make this conditonal for ppc64 ELF
-freeReg 13 = False -- reserved for system thread ID
--- TODO: do not reserve r30 in ppc64 ELF
+freeReg 13 = False -- reserved for system thread ID on 64 bit
-- at least linux in -fPIC relies on r30 in PLT stubs
freeReg 30 = False
+{- TODO: reserve r13 on 64 bit systems only and r30 on 32 bit respectively.
+ For now we use r30 on 64 bit and r13 on 32 bit as a temporary register
+ in stack handling code. See compiler/nativeGen/PPC/Ppr.hs.
+
+ Later we might want to reserve r13 and r30 only where it is required.
+ Then use r12 as temporary register, which is also what the C ABI does.
+-}
+
# endif
# ifdef REG_Base
freeReg REG_Base = False