Commit 374e4470 authored by Peter Trommler's avatar Peter Trommler 🥁 Committed by Ben Gamari

PPC NCG: Remove Darwin support

Support for Mac OS X on PowerPC has been dropped by Apple years ago. We
follow suit and remove PowerPC support for Darwin.

Fixes #16106.
parent ae4f1033
Pipeline #761 passed with stages
in 253 minutes and 23 seconds
......@@ -167,7 +167,6 @@ cpsTop hsc_env proc =
usingInconsistentPicReg
= case (platformArch platform, platformOS platform, positionIndependent dflags)
of (ArchX86, OSDarwin, pic) -> pic
(ArchPPC, OSDarwin, pic) -> pic
_ -> False
-- Note [Sinking after stack layout]
......@@ -314,12 +313,6 @@ points, then at the join point we don't have a consistent value for
Hence, on x86/Darwin, we have to split proc points, and then each proc
point will get its own PIC initialisation sequence.
The situation is the same for ppc/Darwin. We use essentially the same
sequence to load the program counter onto reg:
bcl 20,31,1f
1: mflr reg
This isn't an issue on x86/ELF, where the sequence is
call 1f
......
......@@ -12,7 +12,6 @@ import Reg
import qualified CodeGen.Platform.ARM as ARM
import qualified CodeGen.Platform.ARM64 as ARM64
import qualified CodeGen.Platform.PPC as PPC
import qualified CodeGen.Platform.PPC_Darwin as PPC_Darwin
import qualified CodeGen.Platform.SPARC as SPARC
import qualified CodeGen.Platform.X86 as X86
import qualified CodeGen.Platform.X86_64 as X86_64
......@@ -33,9 +32,7 @@ callerSaves platform
ArchARM64 -> ARM64.callerSaves
arch
| arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] ->
case platformOS platform of
OSDarwin -> PPC_Darwin.callerSaves
_ -> PPC.callerSaves
PPC.callerSaves
| otherwise -> NoRegs.callerSaves
......@@ -56,9 +53,7 @@ activeStgRegs platform
ArchARM64 -> ARM64.activeStgRegs
arch
| arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] ->
case platformOS platform of
OSDarwin -> PPC_Darwin.activeStgRegs
_ -> PPC.activeStgRegs
PPC.activeStgRegs
| otherwise -> NoRegs.activeStgRegs
......@@ -74,9 +69,7 @@ haveRegBase platform
ArchARM64 -> ARM64.haveRegBase
arch
| arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] ->
case platformOS platform of
OSDarwin -> PPC_Darwin.haveRegBase
_ -> PPC.haveRegBase
PPC.haveRegBase
| otherwise -> NoRegs.haveRegBase
......@@ -92,9 +85,7 @@ globalRegMaybe platform
ArchARM64 -> ARM64.globalRegMaybe
arch
| arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] ->
case platformOS platform of
OSDarwin -> PPC_Darwin.globalRegMaybe
_ -> PPC.globalRegMaybe
PPC.globalRegMaybe
| otherwise -> NoRegs.globalRegMaybe
......@@ -110,9 +101,7 @@ freeReg platform
ArchARM64 -> ARM64.freeReg
arch
| arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] ->
case platformOS platform of
OSDarwin -> PPC_Darwin.freeReg
_ -> PPC.freeReg
PPC.freeReg
| otherwise -> NoRegs.freeReg
{-# LANGUAGE CPP #-}
module CodeGen.Platform.PPC_Darwin where
import GhcPrelude
#define MACHREGS_NO_REGS 0
#define MACHREGS_powerpc 1
#define MACHREGS_darwin 1
#include "../../../../includes/CodeGen.Platform.hs"
......@@ -272,7 +272,6 @@ Library
CodeGen.Platform.ARM64
CodeGen.Platform.NoRegs
CodeGen.Platform.PPC
CodeGen.Platform.PPC_Darwin
CodeGen.Platform.SPARC
CodeGen.Platform.X86
CodeGen.Platform.X86_64
......
......@@ -569,60 +569,6 @@ pprGotDeclaration _ _ _
-- the splitter in driver/split/ghc-split.pl recognizes the new output
pprImportedSymbol :: DynFlags -> Platform -> CLabel -> SDoc
pprImportedSymbol dflags platform@(Platform { platformArch = ArchPPC, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case positionIndependent dflags of
False ->
vcat [
text ".symbol_stub",
text "L" <> pprCLabel platform lbl <> ptext (sLit "$stub:"),
text "\t.indirect_symbol" <+> pprCLabel platform lbl,
text "\tlis r11,ha16(L" <> pprCLabel platform lbl
<> text "$lazy_ptr)",
text "\tlwz r12,lo16(L" <> pprCLabel platform lbl
<> text "$lazy_ptr)(r11)",
text "\tmtctr r12",
text "\taddi r11,r11,lo16(L" <> pprCLabel platform lbl
<> text "$lazy_ptr)",
text "\tbctr"
]
True ->
vcat [
text ".section __TEXT,__picsymbolstub1,"
<> text "symbol_stubs,pure_instructions,32",
text "\t.align 2",
text "L" <> pprCLabel platform lbl <> ptext (sLit "$stub:"),
text "\t.indirect_symbol" <+> pprCLabel platform lbl,
text "\tmflr r0",
text "\tbcl 20,31,L0$" <> pprCLabel platform lbl,
text "L0$" <> pprCLabel platform lbl <> char ':',
text "\tmflr r11",
text "\taddis r11,r11,ha16(L" <> pprCLabel platform lbl
<> text "$lazy_ptr-L0$" <> pprCLabel platform lbl <> char ')',
text "\tmtlr r0",
text "\tlwzu r12,lo16(L" <> pprCLabel platform lbl
<> text "$lazy_ptr-L0$" <> pprCLabel platform lbl
<> text ")(r11)",
text "\tmtctr r12",
text "\tbctr"
]
$+$ vcat [
text ".lazy_symbol_pointer",
text "L" <> pprCLabel platform lbl <> ptext (sLit "$lazy_ptr:"),
text "\t.indirect_symbol" <+> pprCLabel platform lbl,
text "\t.long dyld_stub_binding_helper"]
| Just (SymbolPtr, lbl) <- dynamicLinkerLabelInfo importedLbl
= vcat [
text ".non_lazy_symbol_pointer",
char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr:",
text "\t.indirect_symbol" <+> pprCLabel platform lbl,
text "\t.long\t0"]
| otherwise
= empty
pprImportedSymbol dflags platform@(Platform { platformArch = ArchX86, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case positionIndependent dflags of
......@@ -827,14 +773,6 @@ initializePicBase_ppc ArchPPC os picReg
return (CmmProc info lab live (ListGraph blocks') : statics)
initializePicBase_ppc ArchPPC OSDarwin picReg
(CmmProc info lab live (ListGraph (entry:blocks)) : statics) -- just one entry because of splitting
= return (CmmProc info lab live (ListGraph (b':blocks)) : statics)
where BasicBlock bID insns = entry
b' = BasicBlock bID (PPC.FETCHPC picReg : insns)
-------------------------------------------------------------------------
-- Load TOC into register 2
-- PowerPC 64-bit ELF ABI 2.0 requires the address of the callee
......
......@@ -1566,7 +1566,7 @@ genCCall target dest_regs argsAndHints
= panic "genCall: Wrong number of arguments/results for fabs"
-- TODO: replace 'Int' by an enum such as 'PPC_64ABI'
data GenCCallPlatform = GCPLinux | GCPDarwin | GCPLinux64ELF !Int | GCPAIX
data GenCCallPlatform = GCPLinux | GCPLinux64ELF !Int | GCPAIX
platformToGCP :: Platform -> GenCCallPlatform
platformToGCP platform = case platformOS platform of
......@@ -1576,7 +1576,6 @@ platformToGCP platform = case platformOS platform of
ArchPPC_64 ELF_V2 -> GCPLinux64ELF 2
_ -> panic "PPC.CodeGen.platformToGCP: Unknown Linux"
OSAIX -> GCPAIX
OSDarwin -> GCPDarwin
_ -> panic "PPC.CodeGen.platformToGCP: not defined for this OS"
......@@ -1588,51 +1587,49 @@ genCCall'
-> [CmmActual] -- arguments (of mixed type)
-> NatM InstrBlock
{-
The PowerPC calling convention for Darwin/Mac OS X
is described in Apple's document
"Inside Mac OS X - Mach-O Runtime Architecture".
{-
PowerPC Linux uses the System V Release 4 Calling Convention
for PowerPC. It is described in the
"System V Application Binary Interface PowerPC Processor Supplement".
Both conventions are similar:
PowerPC 64 Linux uses the System V Release 4 Calling Convention for
64-bit PowerPC. It is specified in
"64-bit PowerPC ELF Application Binary Interface Supplement 1.9"
(PPC64 ELF v1.9).
PowerPC 64 Linux in little endian mode uses the "Power Architecture 64-Bit
ELF V2 ABI Specification -- OpenPOWER ABI for Linux Supplement"
(PPC64 ELF v2).
AIX follows the "PowerOpen ABI: Application Binary Interface Big-Endian
32-Bit Hardware Implementation"
All four conventions are similar:
Parameters may be passed in general-purpose registers starting at r3, in
floating point registers starting at f1, or on the stack.
But there are substantial differences:
* The number of registers used for parameter passing and the exact set of
nonvolatile registers differs (see MachRegs.hs).
* On Darwin, stack space is always reserved for parameters, even if they are
passed in registers. The called routine may choose to save parameters from
registers to the corresponding space on the stack.
* On Darwin, a corresponding amount of GPRs is skipped when a floating point
parameter is passed in an FPR.
* On AIX and 64-bit ELF, stack space is always reserved for parameters,
even if they are passed in registers. The called routine may choose to
save parameters from registers to the corresponding space on the stack.
* On AIX and 64-bit ELF, a corresponding amount of GPRs is skipped when
a floating point parameter is passed in an FPR.
* SysV insists on either passing I64 arguments on the stack, or in two GPRs,
starting with an odd-numbered GPR. It may skip a GPR to achieve this.
Darwin just treats an I64 like two separate II32s (high word first).
AIX just treats an I64 likt two separate I32s (high word first).
* I64 and FF64 arguments are 8-byte aligned on the stack for SysV, but only
4-byte aligned like everything else on Darwin.
4-byte aligned like everything else on AIX.
* The SysV spec claims that FF32 is represented as FF64 on the stack. GCC on
PowerPC Linux does not agree, so neither do we.
PowerPC 64 Linux uses the System V Release 4 Calling Convention for
64-bit PowerPC. It is specified in
"64-bit PowerPC ELF Application Binary Interface Supplement 1.9"
(PPC64 ELF v1.9).
PowerPC 64 Linux in little endian mode uses the "Power Architecture 64-Bit
ELF V2 ABI Specification -- OpenPOWER ABI for Linux Supplement"
(PPC64 ELF v2).
AIX follows the "PowerOpen ABI: Application Binary Interface Big-Endian
32-Bit Hardware Implementation"
According to all conventions, the parameter area should be part of the
caller's stack frame, allocated in the caller's prologue code (large enough
to hold the parameter lists for all called routines). The NCG already
uses the stack for register spilling, leaving 64 bytes free at the top.
If we need a larger parameter area than that, we just allocate a new stack
frame just before ccalling.
If we need a larger parameter area than that, we increase the size
of the stack frame just before ccalling.
-}
......@@ -1715,7 +1712,6 @@ genCCall' dflags gcp target dest_regs args
initialStackOffset = case gcp of
GCPAIX -> 24
GCPDarwin -> 24
GCPLinux -> 8
GCPLinux64ELF 1 -> 48
GCPLinux64ELF 2 -> 32
......@@ -1725,9 +1721,6 @@ genCCall' dflags gcp target dest_regs args
GCPAIX ->
roundTo 16 $ (24 +) $ max 32 $ sum $
map (widthInBytes . typeWidth) argReps
GCPDarwin ->
roundTo 16 $ (24 +) $ max 32 $ sum $
map (widthInBytes . typeWidth) argReps
GCPLinux -> roundTo 16 finalStack
GCPLinux64ELF 1 ->
roundTo 16 $ (48 +) $ max 64 $ sum $
......@@ -1783,19 +1776,7 @@ genCCall' dflags gcp target dest_regs args
let vr_hi = getHiVRegFromLo vr_lo
case gcp of
GCPAIX -> -- same as for Darwin
do let storeWord vr (gpr:_) _ = MR gpr vr
storeWord vr [] offset
= ST II32 vr (AddrRegImm sp (ImmInt offset))
passArguments args
(drop 2 gprs)
fprs
(stackOffset+8)
(accumCode `appOL` code
`snocOL` storeWord vr_hi gprs stackOffset
`snocOL` storeWord vr_lo (drop 1 gprs) (stackOffset+4))
((take 2 gprs) ++ accumUsed)
GCPDarwin ->
GCPAIX ->
do let storeWord vr (gpr:_) _ = MR gpr vr
storeWord vr [] offset
= ST II32 vr (AddrRegImm sp (ImmInt offset))
......@@ -1836,10 +1817,9 @@ genCCall' dflags gcp target dest_regs args
Fixed _ freg fcode -> fcode `snocOL` MR reg freg
Any _ acode -> acode reg
stackOffsetRes = case gcp of
-- The Darwin ABI requires that we reserve
-- stack slots for register parameters
GCPDarwin -> stackOffset + stackBytes
-- ... so does the PowerOpen ABI.
-- The PowerOpen ABI requires that we
-- reserve stack slots for register
-- parameters
GCPAIX -> stackOffset + stackBytes
-- ... the SysV ABI 32-bit doesn't.
GCPLinux -> stackOffset
......@@ -1861,13 +1841,9 @@ genCCall' dflags gcp target dest_regs args
accumUsed
where
stackOffset' = case gcp of
GCPDarwin ->
-- stackOffset is at least 4-byte aligned
-- The Darwin ABI is happy with that.
stackOffset
GCPAIX ->
-- The 32bit PowerOPEN ABI is happy with
-- 32bit-alignment as well...
-- 32bit-alignment ...
stackOffset
GCPLinux
-- ... the SysV ABI requires 8-byte
......@@ -1914,18 +1890,6 @@ genCCall' dflags gcp target dest_regs args
FF64 -> (2, 1, 8, fprs)
II64 -> panic "genCCall' passArguments II64"
FF80 -> panic "genCCall' passArguments FF80"
GCPDarwin ->
case cmmTypeFormat rep of
II8 -> (1, 0, 4, gprs)
II16 -> (1, 0, 4, gprs)
II32 -> (1, 0, 4, gprs)
-- The Darwin ABI requires that we skip a
-- corresponding number of GPRs when we use
-- the FPRs.
FF32 -> (1, 1, 4, fprs)
FF64 -> (2, 1, 8, fprs)
II64 -> panic "genCCall' passArguments II64"
FF80 -> panic "genCCall' passArguments FF80"
GCPLinux ->
case cmmTypeFormat rep of
II8 -> (1, 0, 4, gprs)
......
......@@ -582,7 +582,6 @@ stackFrameHeaderSize dflags
ArchPPC_64 ELF_V2 -> 32 + 8 * 8
_ -> panic "PPC.stackFrameHeaderSize: Unknown Linux"
OSAIX -> 24 + 8 * 4
OSDarwin -> 64 -- TODO: check ABI spec
_ -> panic "PPC.stackFrameHeaderSize: not defined for this OS"
where platform = targetPlatform dflags
......@@ -602,8 +601,8 @@ maxSpillSlots dflags
-- = 0 -- useful for testing allocMoreStack
-- | The number of bytes that the stack pointer should be aligned
-- to. This is 16 both on PPC32 and PPC64 at least for Darwin, and
-- Linux (see ELF processor specific supplements).
-- to. This is 16 both on PPC32 and PPC64 ELF (see ELF processor
-- specific supplements).
stackAlign :: Int
stackAlign = 16
......
......@@ -129,7 +129,6 @@ pprData (CmmString str) = pprASCII str
pprData (CmmUninitialised bytes) = keyword <> int bytes
where keyword = sdocWithPlatform $ \platform ->
case platformOS platform of
OSDarwin -> text ".space "
OSAIX -> text ".space "
_ -> text ".skip "
pprData (CmmStaticLit lit) = pprDataItem lit
......@@ -181,50 +180,10 @@ pprReg r
RegVirtual (VirtualRegSSE u) -> text "%vSSE_" <> pprUniqueAlways u
where
ppr_reg_no :: Int -> SDoc
ppr_reg_no i =
sdocWithPlatform $ \platform ->
case platformOS platform of
OSDarwin ->
ptext
(case i of {
0 -> sLit "r0"; 1 -> sLit "r1";
2 -> sLit "r2"; 3 -> sLit "r3";
4 -> sLit "r4"; 5 -> sLit "r5";
6 -> sLit "r6"; 7 -> sLit "r7";
8 -> sLit "r8"; 9 -> sLit "r9";
10 -> sLit "r10"; 11 -> sLit "r11";
12 -> sLit "r12"; 13 -> sLit "r13";
14 -> sLit "r14"; 15 -> sLit "r15";
16 -> sLit "r16"; 17 -> sLit "r17";
18 -> sLit "r18"; 19 -> sLit "r19";
20 -> sLit "r20"; 21 -> sLit "r21";
22 -> sLit "r22"; 23 -> sLit "r23";
24 -> sLit "r24"; 25 -> sLit "r25";
26 -> sLit "r26"; 27 -> sLit "r27";
28 -> sLit "r28"; 29 -> sLit "r29";
30 -> sLit "r30"; 31 -> sLit "r31";
32 -> sLit "f0"; 33 -> sLit "f1";
34 -> sLit "f2"; 35 -> sLit "f3";
36 -> sLit "f4"; 37 -> sLit "f5";
38 -> sLit "f6"; 39 -> sLit "f7";
40 -> sLit "f8"; 41 -> sLit "f9";
42 -> sLit "f10"; 43 -> sLit "f11";
44 -> sLit "f12"; 45 -> sLit "f13";
46 -> sLit "f14"; 47 -> sLit "f15";
48 -> sLit "f16"; 49 -> sLit "f17";
50 -> sLit "f18"; 51 -> sLit "f19";
52 -> sLit "f20"; 53 -> sLit "f21";
54 -> sLit "f22"; 55 -> sLit "f23";
56 -> sLit "f24"; 57 -> sLit "f25";
58 -> sLit "f26"; 59 -> sLit "f27";
60 -> sLit "f28"; 61 -> sLit "f29";
62 -> sLit "f30"; 63 -> sLit "f31";
_ -> sLit "very naughty powerpc register"
})
_
| i <= 31 -> int i -- GPRs
| i <= 63 -> int (i-32) -- FPRs
| otherwise -> text "very naughty powerpc register"
ppr_reg_no i
| i <= 31 = int i -- GPRs
| i <= 63 = int (i-32) -- FPRs
| otherwise = text "very naughty powerpc register"
......@@ -272,16 +231,10 @@ pprImm (LO (ImmInteger i)) = pprImm (ImmInteger (toInteger lo16))
lo16 = fromInteger (i .&. 0xffff) :: Int16
pprImm (LO i)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin
then hcat [ text "lo16(", pprImm i, rparen ]
else pprImm i <> text "@l"
= pprImm i <> text "@l"
pprImm (HI i)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin
then hcat [ text "hi16(", pprImm i, rparen ]
else pprImm i <> text "@h"
= pprImm i <> text "@h"
pprImm (HA (ImmInt i)) = pprImm (HA (ImmInteger (toInteger i)))
pprImm (HA (ImmInteger i)) = pprImm (ImmInteger ha16)
......@@ -291,22 +244,13 @@ pprImm (HA (ImmInteger i)) = pprImm (ImmInteger ha16)
lo16 = i .&. 0xffff
pprImm (HA i)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin
then hcat [ text "ha16(", pprImm i, rparen ]
else pprImm i <> text "@ha"
= pprImm i <> text "@ha"
pprImm (HIGHERA i)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin
then panic "PPC.pprImm: highera not implemented on Darwin"
else pprImm i <> text "@highera"
= pprImm i <> text "@highera"
pprImm (HIGHESTA i)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin
then panic "PPC.pprImm: highesta not implemented on Darwin"
else pprImm i <> text "@highesta"
= pprImm i <> text "@highesta"
pprAddr :: AddrMode -> SDoc
......@@ -330,32 +274,25 @@ pprSectionAlign sec@(Section seg _) =
pprAlignForSection :: SectionType -> SDoc
pprAlignForSection seg =
sdocWithPlatform $ \platform ->
let osDarwin = platformOS platform == OSDarwin
ppc64 = not $ target32Bit platform
let ppc64 = not $ target32Bit platform
in ptext $ case seg of
Text -> sLit ".align 2"
Data
| ppc64 -> sLit ".align 3"
| otherwise -> sLit ".align 2"
ReadOnlyData
| osDarwin -> sLit ".align 2"
| ppc64 -> sLit ".align 3"
| otherwise -> sLit ".align 2"
RelocatableReadOnlyData
| osDarwin -> sLit ".align 2"
| ppc64 -> sLit ".align 3"
| otherwise -> sLit ".align 2"
UninitialisedData
| osDarwin -> sLit ".align 2"
| ppc64 -> sLit ".align 3"
| otherwise -> sLit ".align 2"
ReadOnlyData16
| osDarwin -> sLit ".align 4"
| otherwise -> sLit ".align 4"
ReadOnlyData16 -> sLit ".align 4"
-- TODO: This is copied from the ReadOnlyData case, but it can likely be
-- made more efficient.
CString
| osDarwin -> sLit ".align 2"
| ppc64 -> sLit ".align 3"
| otherwise -> sLit ".align 2"
OtherSection _ -> panic "PprMach.pprSectionAlign: unknown section"
......
......@@ -232,7 +232,6 @@ callClobberedRegs :: Platform -> [Reg]
callClobberedRegs platform
= case platformOS platform of
OSAIX -> map regSingle (0:[2..12] ++ map fReg [0..13])
OSDarwin -> map regSingle (0:[2..12] ++ map fReg [0..13])
OSLinux -> map regSingle (0:[2..13] ++ map fReg [0..13])
_ -> panic "PPC.Regs.callClobberedRegs: not defined for this architecture"
......@@ -264,7 +263,6 @@ allFPArgRegs :: Platform -> [Reg]
allFPArgRegs platform
= case platformOS platform of
OSAIX -> map (regSingle . fReg) [1..13]
OSDarwin -> map (regSingle . fReg) [1..13]
OSLinux -> case platformArch platform of
ArchPPC -> map (regSingle . fReg) [1..8]
ArchPPC_64 _ -> map (regSingle . fReg) [1..13]
......
......@@ -1221,16 +1221,7 @@ case ${TargetOS} in
RtsLinkerUseMmap=1
;;
darwin|ios|watchos|tvos)
# Don't use mmap on powerpc/darwin as the mmap there doesn't support
# reallocating. Reallocating is needed to allocate jump islands just
# after each object image. Jumps to these jump islands use relative
# branches which are limited to offsets that can be represented in
# 24-bits.
if test "$TargetArch" != "powerpc" ; then
RtsLinkerUseMmap=1
else
RtsLinkerUseMmap=0
fi
RtsLinkerUseMmap=1
;;
*)
# Windows (which doesn't have mmap) and everything else.
......
......@@ -885,12 +885,10 @@ freeRegBase _ = True
#elif defined(MACHREGS_powerpc)
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.
-- in stack reallocations on Linux.
-- Moreover r0 is not usable in all insns.
freeReg 1 = False -- The Stack Pointer
# if !defined(MACHREGS_darwin)
-- most non-darwin powerpc OSes use r2 as a TOC pointer or something like that
-- most ELF PowerPC OSes use r2 as a TOC pointer
freeReg 2 = False
freeReg 13 = False -- reserved for system thread ID on 64 bit
-- at least linux in -fPIC relies on r30 in PLT stubs
......@@ -903,7 +901,6 @@ freeReg 30 = False
Then use r12 as temporary register, which is also what the C ABI does.
-}
# endif
# if defined(REG_Base)
freeReg REG_Base = False
# endif
......
......@@ -279,8 +279,6 @@ the stack. See Note [Overlapping global registers] for implications.
1 SP (callee-save, non-volatile)
2 AIX, powerpc64-linux:
RTOC (a strange special case)
darwin:
(caller-save, volatile)
powerpc32-linux:
reserved for use by system
......@@ -315,18 +313,6 @@ the stack. See Note [Overlapping global registers] for implications.
#define REG_R7 r20
#define REG_R8 r21
#if defined(MACHREGS_darwin)
#define REG_F1 f14
#define REG_F2 f15
#define REG_F3 f16
#define REG_F4 f17
#define REG_D1 f18
#define REG_D2 f19
#else
#define REG_F1 fr14
#define REG_F2 fr15
#define REG_F3 fr16
......@@ -341,8 +327,6 @@ the stack. See Note [Overlapping global registers] for implications.
#define REG_D5 fr24
#define REG_D6 fr25
#endif
#define REG_Sp r22
#define REG_SpLim r24
......
......@@ -287,32 +287,12 @@ extern void obscure_ccall_ret_code(void);
*/
typedef struct AdjustorStub {
#if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS)
unsigned lis;
unsigned ori;
unsigned lwz;
unsigned mtctr;
unsigned bctr;
StgFunPtr code;
#elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS)
/* powerpc64-darwin: just guessing that it won't use fundescs. */
unsigned lis;
unsigned ori;
unsigned rldimi;
unsigned oris;
unsigned ori2;
unsigned lwz;
unsigned mtctr;
unsigned bctr;
StgFunPtr code;
#else
/* fundesc-based ABIs */
#define FUNDESCS
StgFunPtr code;
struct AdjustorStub
*toc;
void *env;
#endif
StgStablePtr hptr;
StgFunPtr wptr;
StgInt negative_framesize;
......@@ -1036,20 +1016,16 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
whose stack layout is based on the AIX ABI.
Besides (obviously) AIX, this includes
Mac OS 9 and BeOS/PPC (may they rest in peace),
Mac OS 9 and BeOS/PPC and Mac OS X PPC (may they rest in peace),
which use the 32-bit AIX ABI
powerpc64-linux,
which uses the 64-bit AIX ABI
and Darwin (Mac OS X),
which uses the same stack layout as AIX,
but no function descriptors.
which uses the 64-bit AIX ABI.
The actual stack-frame shuffling is implemented out-of-line
in the function adjustorCode, in AdjustorAsm.S.
Here, we set up an AdjustorStub structure, which
is a function descriptor (on platforms that have function
descriptors) or a short piece of stub code (on Darwin) to call
adjustorCode with a pointer to the AdjustorStub struct loaded
is a function descriptor with a pointer to the AdjustorStub
struct in the position of the TOC that is loaded
into register r2.
One nice thing about this is that there is _no_ code generated at
......
......@@ -30,39 +30,13 @@
/* The following defines mirror struct AdjustorStub
from Adjustor.c. Make sure to keep these in sync.
*/
#if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS)
#define HEADER_WORDS 6
#elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS)
#else
#define HEADER_WORDS 3
#endif
#define HPTR_OFF ((HEADER_WORDS )*WS)
#define WPTR_OFF ((HEADER_WORDS + 1)*WS)
#define FRAMESIZE_OFF ((HEADER_WORDS + 2)*WS)
#define EXTRA_WORDS_OFF ((HEADER_WORDS + 3)*WS)
/* Darwin insists on register names, everyone else prefers
to use numbers. */
#if !defined(darwin_HOST_OS)
#define r0 0
#define r1 1
#define r2 2
#define r3 3
#define r4 4
#define r5 5
#define r6 6
#define r7 7
#define r8 8
#define r9 9
#define r10 10
#define r11 11
#define r12 12
#define r30 30
#define r31 31
#endif
#if defined(aix_HOST_OS)
/* IBM's assembler needs a different pseudo-op to declare a .text section */
.csect .text[PR]
......@@ -83,69 +57,65 @@ adjustorCode:
/* On entry, r2 will point to the AdjustorStub data structure. */