summaryrefslogtreecommitdiff
path: root/compiler/GHC/CmmToAsm
diff options
context:
space:
mode:
authordoyougnu <jeffrey.young@iohk.io>2021-12-14 13:04:17 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-22 00:12:27 -0500
commit1a596d069991255e196621d06a046f60359f3129 (patch)
tree899cf688c007b92e4d96b839f18d0579eb9793e2 /compiler/GHC/CmmToAsm
parentff657a81ae5ebd4ea4628ca8ebc88dce3ecbe0ef (diff)
downloadhaskell-1a596d069991255e196621d06a046f60359f3129.tar.gz
Cmm: DynFlags to CmmConfig refactor
add files GHC.Cmm.Config, GHC.Driver.Config.Cmm Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: reorder imports, add handshake Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: DynFlag references --> CmmConfig Cmm.LayoutStack: DynFlag references -> CmmConfig Cmm.Info.Build: DynFlag references -> CmmConfig Cmm.Config: use profile to retrieve platform Cmm.CLabel: unpack NCGConfig in labelDynamic Cmm.Config: reduce CmmConfig surface area Cmm.Config: add cmmDoCmmSwitchPlans field Cmm.Config: correct cmmDoCmmSwitchPlans flag The original implementation dispatches work in cmmImplementSwitchPlans in an `otherwise` branch, hence we must add a not to correctly dispatch Cmm.Config: add cmmSplitProcPoints simplify Config remove cmmBackend, and cmmPosInd Cmm.CmmToAsm: move ncgLabelDynamic to CmmToAsm Cmm.CLabel: remove cmmLabelDynamic function Cmm.Config: rename cmmOptDoLinting -> cmmDoLinting testsuite: update CountDepsAst CountDepsParser
Diffstat (limited to 'compiler/GHC/CmmToAsm')
-rw-r--r--compiler/GHC/CmmToAsm/PIC.hs26
1 files changed, 17 insertions, 9 deletions
diff --git a/compiler/GHC/CmmToAsm/PIC.hs b/compiler/GHC/CmmToAsm/PIC.hs
index 10ddaa1f5f..8a728102e5 100644
--- a/compiler/GHC/CmmToAsm/PIC.hs
+++ b/compiler/GHC/CmmToAsm/PIC.hs
@@ -209,6 +209,13 @@ absoluteLabel lbl
-- pointers, code stubs and GOT offsets look like is located in the
-- module CLabel.
+-- | Helper to check whether the data resides in a DLL or not, see @labelDynamic@
+ncgLabelDynamic :: NCGConfig -> CLabel -> Bool
+ncgLabelDynamic config = labelDynamic (ncgThisModule config)
+ (ncgPlatform config)
+ (ncgExternalDynamicRefs config)
+
+
-- We have to decide which labels need to be accessed
-- indirectly or via a piece of stub code.
data LabelAccessStyle
@@ -247,7 +254,7 @@ howToAccessLabel config _arch OSMinGW32 _kind lbl
-- If the target symbol is in another PE we need to access it via the
-- appropriate __imp_SYMBOL pointer.
- | labelDynamic config lbl
+ | ncgLabelDynamic config lbl
= AccessViaSymbolPtr
-- Target symbol is in the same PE as the caller, so just access it directly.
@@ -262,7 +269,7 @@ howToAccessLabel config ArchAArch64 _os _kind lbl
| not (ncgExternalDynamicRefs config)
= AccessDirectly
- | labelDynamic config lbl
+ | ncgLabelDynamic config lbl
= AccessViaSymbolPtr
| otherwise
@@ -279,7 +286,7 @@ howToAccessLabel config ArchAArch64 _os _kind lbl
--
howToAccessLabel config arch OSDarwin DataReference lbl
-- data access to a dynamic library goes via a symbol pointer
- | labelDynamic config lbl
+ | ncgLabelDynamic config lbl
= AccessViaSymbolPtr
-- when generating PIC code, all cross-module data references must
@@ -300,7 +307,7 @@ howToAccessLabel config arch OSDarwin JumpReference lbl
-- stack alignment is only right for regular calls.
-- Therefore, we have to go via a symbol pointer:
| arch == ArchX86 || arch == ArchX86_64 || arch == ArchAArch64
- , labelDynamic config lbl
+ , ncgLabelDynamic config lbl
= AccessViaSymbolPtr
@@ -310,7 +317,7 @@ howToAccessLabel config arch OSDarwin _kind lbl
-- them automatically, neither on Aarch64 (arm64).
| arch /= ArchX86_64
, arch /= ArchAArch64
- , labelDynamic config lbl
+ , ncgLabelDynamic config lbl
= AccessViaStub
| otherwise
@@ -362,7 +369,7 @@ howToAccessLabel config arch os DataReference lbl
| osElfTarget os
= case () of
-- A dynamic label needs to be accessed via a symbol pointer.
- _ | labelDynamic config lbl
+ _ | ncgLabelDynamic config lbl
-> AccessViaSymbolPtr
-- For PowerPC32 -fPIC, we have to access even static data
@@ -390,18 +397,19 @@ howToAccessLabel config arch os DataReference lbl
howToAccessLabel config arch os CallReference lbl
| osElfTarget os
- , labelDynamic config lbl && not (ncgPIC config)
+ , ncgLabelDynamic config lbl
+ , not (ncgPIC config)
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
- , labelDynamic config lbl
+ , ncgLabelDynamic config lbl
, ncgPIC config
= AccessViaStub
howToAccessLabel config _arch os _kind lbl
| osElfTarget os
- = if labelDynamic config lbl
+ = if ncgLabelDynamic config lbl
then AccessViaSymbolPtr
else AccessDirectly