diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2016-03-24 23:24:08 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2016-03-24 23:26:58 +0100 |
commit | 4dc883562b6adaba36e79a4fd3e46ec92ad78f4f (patch) | |
tree | 33447f452c38f793bd4b4efdb1d5f47da0394917 | |
parent | df26b95559fd467abc0a3a4151127c95cb5011b9 (diff) | |
download | haskell-4dc883562b6adaba36e79a4fd3e46ec92ad78f4f.tar.gz |
Remove code-duplication in the PPC NCG
Reviewed By: bgamari, trommler
Differential Revision: https://phabricator.haskell.org/D2020
-rw-r--r-- | compiler/nativeGen/PPC/CodeGen.hs | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs index d8e328633d..7b2f79b9db 100644 --- a/compiler/nativeGen/PPC/CodeGen.hs +++ b/compiler/nativeGen/PPC/CodeGen.hs @@ -1005,17 +1005,7 @@ genJump (CmmLit (CmmLabel lbl)) genJump tree = do dflags <- getDynFlags - let platform = targetPlatform dflags - case platformOS platform of - OSLinux -> case platformArch platform of - ArchPPC -> genJump' tree GCPLinux - ArchPPC_64 ELF_V1 -> genJump' tree (GCPLinux64ELF 1) - ArchPPC_64 ELF_V2 -> genJump' tree (GCPLinux64ELF 2) - _ -> panic "PPC.CodeGen.genJump: Unknown Linux" - OSAIX -> genJump' tree GCPAIX - OSDarwin -> genJump' tree GCPDarwin - _ -> panic "PPC.CodeGen.genJump: not defined for this os" - + genJump' tree (platformToGCP (targetPlatform dflags)) genJump' :: CmmExpr -> GenCCallPlatform -> NatM InstrBlock @@ -1085,21 +1075,24 @@ genCCall :: ForeignTarget -- function to call -> NatM InstrBlock genCCall target dest_regs argsAndHints = do dflags <- getDynFlags - let platform = targetPlatform dflags - case platformOS platform of - OSLinux -> case platformArch platform of - ArchPPC -> genCCall' dflags GCPLinux - target dest_regs argsAndHints - ArchPPC_64 ELF_V1 -> genCCall' dflags (GCPLinux64ELF 1) - target dest_regs argsAndHints - ArchPPC_64 ELF_V2 -> genCCall' dflags (GCPLinux64ELF 2) - target dest_regs argsAndHints - _ -> panic "PPC.CodeGen.genCCall: Unknown Linux" - OSAIX -> genCCall' dflags GCPAIX target dest_regs argsAndHints - OSDarwin -> genCCall' dflags GCPDarwin target dest_regs argsAndHints - _ -> panic "PPC.CodeGen.genCCall: not defined for this os" - -data GenCCallPlatform = GCPLinux | GCPDarwin | GCPLinux64ELF Int | GCPAIX + genCCall' dflags (platformToGCP (targetPlatform dflags)) + target dest_regs argsAndHints + +-- TODO: replace 'Int' by an enum such as 'PPC_64ABI' +data GenCCallPlatform = GCPLinux | GCPDarwin | GCPLinux64ELF !Int | GCPAIX + deriving Eq + +platformToGCP :: Platform -> GenCCallPlatform +platformToGCP platform = case platformOS platform of + OSLinux -> case platformArch platform of + ArchPPC -> GCPLinux + ArchPPC_64 ELF_V1 -> GCPLinux64ELF 1 + 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" + genCCall' :: DynFlags |