summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/PIC.hs
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-05-13 19:36:49 +0100
committerIan Lynagh <ian@well-typed.com>2013-05-13 19:36:49 +0100
commit7e723a1c70bee46a42d2cafb9ebd7399c3c054f0 (patch)
tree5754037e378f9c1b0af4c78155ac5e4ea02263e6 /compiler/nativeGen/PIC.hs
parent1cc96d54144f34f620e31d2dee133d17a2367610 (diff)
downloadhaskell-7e723a1c70bee46a42d2cafb9ebd7399c3c054f0.tar.gz
Refactor cmmMakeDynamicReference
It now has its own class, and the addImport function is defined in that class, rather than needing to be passed as an argument.
Diffstat (limited to 'compiler/nativeGen/PIC.hs')
-rw-r--r--compiler/nativeGen/PIC.hs21
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs
index 0187c4c410..6bf843affe 100644
--- a/compiler/nativeGen/PIC.hs
+++ b/compiler/nativeGen/PIC.hs
@@ -35,6 +35,7 @@
module PIC (
cmmMakeDynamicReference,
+ CmmMakeDynamicReferenceM(..),
ReferenceKind(..),
needImportedSymbols,
pprImportedSymbol,
@@ -96,16 +97,20 @@ data ReferenceKind
| JumpReference
deriving(Eq)
+class Monad m => CmmMakeDynamicReferenceM m where
+ addImport :: CLabel -> m ()
+
+instance CmmMakeDynamicReferenceM NatM where
+ addImport = addImportNat
cmmMakeDynamicReference
- :: Monad m => DynFlags
- -> (CLabel -> m ()) -- a monad & a function
- -- used for recording imported symbols
- -> ReferenceKind -- whether this is the target of a jump
- -> CLabel -- the label
- -> m CmmExpr
-
-cmmMakeDynamicReference dflags addImport referenceKind lbl
+ :: CmmMakeDynamicReferenceM m
+ => DynFlags
+ -> ReferenceKind -- whether this is the target of a jump
+ -> CLabel -- the label
+ -> m CmmExpr
+
+cmmMakeDynamicReference dflags referenceKind lbl
| Just _ <- dynamicLinkerLabelInfo lbl
= return $ CmmLit $ CmmLabel lbl -- already processed it, pass through