diff options
author | Peter Trommler <ptrommler@acm.org> | 2018-12-17 13:27:49 +0100 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2018-12-27 02:00:36 -0500 |
commit | 93385cd882241d150bdc593e4c9d92e28747480f (patch) | |
tree | 553b15947f8e34bb03550b82876f84f8f0f5758b /compiler/nativeGen/PPC/Instr.hs | |
parent | 942b501972139ed95b49b75cb8c0523b460f6d10 (diff) | |
download | haskell-ppc-update-sp.tar.gz |
PPC NCG: Refactor stack allocation codeppc-update-sp
There is only one place where UPDATE_SP was used. Instead of the
UPDATE_SP pseudo instruction build the list of instructions directly.
Diffstat (limited to 'compiler/nativeGen/PPC/Instr.hs')
-rw-r--r-- | compiler/nativeGen/PPC/Instr.hs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/compiler/nativeGen/PPC/Instr.hs b/compiler/nativeGen/PPC/Instr.hs index ade39430c0..89709a2bc4 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) |