summaryrefslogtreecommitdiff
path: root/compiler/GHC/CmmToAsm/AArch64.hs
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-10-22 12:08:34 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-05 10:29:57 -0400
commit3b1aa7dba7c006b473855a6b199b15fa3a3d77a0 (patch)
tree631816f4aef8d28ee596b51b70a0a0ba2df12230 /compiler/GHC/CmmToAsm/AArch64.hs
parent8c90e6c758769b068aea2891b26cc17577b6d36a (diff)
downloadhaskell-3b1aa7dba7c006b473855a6b199b15fa3a3d77a0.tar.gz
Adds AArch64 Native Code Generator
In which we add a new code generator to the Glasgow Haskell Compiler. This codegen supports ELF and Mach-O targets, thus covering Linux, macOS, and BSDs in principle. It was tested only on macOS and Linux. The NCG follows a similar structure as the other native code generators we already have, and should therfore be realtively easy to follow. It supports most of the features required for a proper native code generator, but does not claim to be perfect or fully optimised. There are still opportunities for optimisations. Metric Decrease: ManyAlternatives ManyConstructors MultiLayerModules PmSeriesG PmSeriesS PmSeriesT PmSeriesV T10421 T10421a T10858 T11195 T11276 T11303b T11374 T11822 T12227 T12545 T12707 T13035 T13253 T13253-spj T13379 T13701 T13719 T14683 T14697 T15164 T15630 T16577 T17096 T17516 T17836 T17836b T17977 T17977b T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T3064 T5030 T5321FD T5321Fun T5631 T5642 T5837 T783 T9198 T9233 T9630 T9872d T9961 WWRec Metric Increase: T4801
Diffstat (limited to 'compiler/GHC/CmmToAsm/AArch64.hs')
-rw-r--r--compiler/GHC/CmmToAsm/AArch64.hs60
1 files changed, 60 insertions, 0 deletions
diff --git a/compiler/GHC/CmmToAsm/AArch64.hs b/compiler/GHC/CmmToAsm/AArch64.hs
new file mode 100644
index 0000000000..14f4b5d0bd
--- /dev/null
+++ b/compiler/GHC/CmmToAsm/AArch64.hs
@@ -0,0 +1,60 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-- | Native code generator for x86 and x86-64 architectures
+module GHC.CmmToAsm.AArch64
+ ( ncgAArch64 )
+where
+
+import GHC.Prelude
+
+import GHC.CmmToAsm.Instr
+import GHC.CmmToAsm.Monad
+import GHC.CmmToAsm.Config
+import GHC.CmmToAsm.Types
+
+import qualified GHC.CmmToAsm.AArch64.Instr as AArch64
+import qualified GHC.CmmToAsm.AArch64.Ppr as AArch64
+import qualified GHC.CmmToAsm.AArch64.CodeGen as AArch64
+import qualified GHC.CmmToAsm.AArch64.Regs as AArch64
+import qualified GHC.CmmToAsm.AArch64.RegInfo as AArch64
+
+ncgAArch64 :: NCGConfig -> NcgImpl RawCmmStatics AArch64.Instr AArch64.JumpDest
+ncgAArch64 config
+ = NcgImpl {
+ ncgConfig = config
+ ,cmmTopCodeGen = AArch64.cmmTopCodeGen
+ ,generateJumpTableForInstr = AArch64.generateJumpTableForInstr config
+ ,getJumpDestBlockId = AArch64.getJumpDestBlockId
+ ,canShortcut = AArch64.canShortcut
+ ,shortcutStatics = AArch64.shortcutStatics
+ ,shortcutJump = AArch64.shortcutJump
+ ,pprNatCmmDecl = AArch64.pprNatCmmDecl config
+ ,maxSpillSlots = AArch64.maxSpillSlots config
+ ,allocatableRegs = AArch64.allocatableRegs platform
+ ,ncgAllocMoreStack = AArch64.allocMoreStack platform
+ ,ncgExpandTop = id
+ ,ncgMakeFarBranches = const id
+ ,extractUnwindPoints = const []
+ ,invertCondBranches = \_ _ -> id
+ }
+ where
+ platform = ncgPlatform config
+
+-- | Instruction instance for aarch64
+instance Instruction AArch64.Instr where
+ regUsageOfInstr = AArch64.regUsageOfInstr
+ patchRegsOfInstr = AArch64.patchRegsOfInstr
+ isJumpishInstr = AArch64.isJumpishInstr
+ jumpDestsOfInstr = AArch64.jumpDestsOfInstr
+ patchJumpInstr = AArch64.patchJumpInstr
+ mkSpillInstr = AArch64.mkSpillInstr
+ mkLoadInstr = AArch64.mkLoadInstr
+ takeDeltaInstr = AArch64.takeDeltaInstr
+ isMetaInstr = AArch64.isMetaInstr
+ mkRegRegMoveInstr _ = AArch64.mkRegRegMoveInstr
+ takeRegRegMoveInstr = AArch64.takeRegRegMoveInstr
+ mkJumpInstr = AArch64.mkJumpInstr
+ mkStackAllocInstr = AArch64.mkStackAllocInstr
+ mkStackDeallocInstr = AArch64.mkStackDeallocInstr
+ mkComment = pure . AArch64.COMMENT
+ pprInstr = AArch64.pprInstr