summaryrefslogtreecommitdiff
path: root/compiler/GHC/CmmToAsm/SPARC.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-06-03 20:46:05 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-18 22:12:13 -0400
commit0c5ed5c7eb30bc5462b67ff097c3388597265a4b (patch)
treed55e420625a2118c7854d2b41bb4ee4ed5755b7f /compiler/GHC/CmmToAsm/SPARC.hs
parentaa4b744d51aa6bdb46064f981ea8e001627921d6 (diff)
downloadhaskell-0c5ed5c7eb30bc5462b67ff097c3388597265a4b.tar.gz
DynFlags: refactor GHC.CmmToAsm (#17957, #10143)
This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype.
Diffstat (limited to 'compiler/GHC/CmmToAsm/SPARC.hs')
-rw-r--r--compiler/GHC/CmmToAsm/SPARC.hs75
1 files changed, 75 insertions, 0 deletions
diff --git a/compiler/GHC/CmmToAsm/SPARC.hs b/compiler/GHC/CmmToAsm/SPARC.hs
new file mode 100644
index 0000000000..fe6c824a09
--- /dev/null
+++ b/compiler/GHC/CmmToAsm/SPARC.hs
@@ -0,0 +1,75 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-- | Native code generator for SPARC architectures
+module GHC.CmmToAsm.SPARC
+ ( ncgSPARC
+ )
+where
+
+import GHC.Prelude
+import GHC.Utils.Panic
+
+import GHC.CmmToAsm.Monad
+import GHC.CmmToAsm.Config
+import GHC.CmmToAsm.Types
+import GHC.CmmToAsm.Instr
+
+import qualified GHC.CmmToAsm.SPARC.Instr as SPARC
+import qualified GHC.CmmToAsm.SPARC.Ppr as SPARC
+import qualified GHC.CmmToAsm.SPARC.CodeGen as SPARC
+import qualified GHC.CmmToAsm.SPARC.CodeGen.Expand as SPARC
+import qualified GHC.CmmToAsm.SPARC.Regs as SPARC
+import qualified GHC.CmmToAsm.SPARC.ShortcutJump as SPARC
+
+
+ncgSPARC :: NCGConfig -> NcgImpl RawCmmStatics SPARC.Instr SPARC.JumpDest
+ncgSPARC config = NcgImpl
+ { ncgConfig = config
+ , cmmTopCodeGen = SPARC.cmmTopCodeGen
+ , generateJumpTableForInstr = SPARC.generateJumpTableForInstr platform
+ , getJumpDestBlockId = SPARC.getJumpDestBlockId
+ , canShortcut = SPARC.canShortcut
+ , shortcutStatics = SPARC.shortcutStatics
+ , shortcutJump = SPARC.shortcutJump
+ , pprNatCmmDecl = SPARC.pprNatCmmDecl config
+ , maxSpillSlots = SPARC.maxSpillSlots config
+ , allocatableRegs = SPARC.allocatableRegs
+ , ncgExpandTop = map SPARC.expandTop
+ , ncgMakeFarBranches = const id
+ , extractUnwindPoints = const []
+ , invertCondBranches = \_ _ -> id
+ -- Allocating more stack space for spilling isn't currently supported for the
+ -- linear register allocator on SPARC, hence the panic below.
+ , ncgAllocMoreStack = noAllocMoreStack
+ }
+ where
+ platform = ncgPlatform config
+
+ noAllocMoreStack amount _
+ = panic $ "Register allocator: out of stack slots (need " ++ show amount ++ ")\n"
+ ++ " If you are trying to compile SHA1.hs from the crypto library then this\n"
+ ++ " is a known limitation in the linear allocator.\n"
+ ++ "\n"
+ ++ " Try enabling the graph colouring allocator with -fregs-graph instead."
+ ++ " You can still file a bug report if you like.\n"
+
+
+-- | instance for sparc instruction set
+instance Instruction SPARC.Instr where
+ regUsageOfInstr = SPARC.regUsageOfInstr
+ patchRegsOfInstr = SPARC.patchRegsOfInstr
+ isJumpishInstr = SPARC.isJumpishInstr
+ jumpDestsOfInstr = SPARC.jumpDestsOfInstr
+ patchJumpInstr = SPARC.patchJumpInstr
+ mkSpillInstr = SPARC.mkSpillInstr
+ mkLoadInstr = SPARC.mkLoadInstr
+ takeDeltaInstr = SPARC.takeDeltaInstr
+ isMetaInstr = SPARC.isMetaInstr
+ mkRegRegMoveInstr = SPARC.mkRegRegMoveInstr
+ takeRegRegMoveInstr = SPARC.takeRegRegMoveInstr
+ mkJumpInstr = SPARC.mkJumpInstr
+ pprInstr = const SPARC.pprInstr
+ mkStackAllocInstr = panic "no sparc_mkStackAllocInstr"
+ mkStackDeallocInstr = panic "no sparc_mkStackDeallocInstr"
+
+