summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgUtils.hs
diff options
context:
space:
mode:
authorBen.Lippmeier@anu.edu.au <unknown>2009-11-06 03:05:30 +0000
committerBen.Lippmeier@anu.edu.au <unknown>2009-11-06 03:05:30 +0000
commita02e7f40afc1aab7fe466f949f505c1d7250713d (patch)
treec2e281c50f9bcc84d9cc871012e875e3f36986cb /compiler/codeGen/CgUtils.hs
parentddb7062b0674e8a08bd90b4eca0b9379195d5e40 (diff)
downloadhaskell-a02e7f40afc1aab7fe466f949f505c1d7250713d.tar.gz
* Refactor CLabel.RtsLabel to CLabel.CmmLabel
The type of the CmmLabel ctor is now CmmLabel :: PackageId -> FastString -> CmmLabelInfo -> CLabel - When you construct a CmmLabel you have to explicitly say what package it is in. Many of these will just use rtsPackageId, but I've left it this way to remind people not to pretend labels are in the RTS package when they're not. - When parsing a Cmm file, labels that are not defined in the current file are assumed to be in the RTS package. Labels imported like import label are assumed to be in a generic "foreign" package, which is different from the current one. Labels imported like import "package-name" label are marked as coming from the named package. This last one is needed for the integer-gmp library as we want to refer to labels that are not in the same compilation unit, but are in the same non-rts package. This should help remove the nasty #ifdef __PIC__ stuff from integer-gmp/cbits/gmp-wrappers.cmm
Diffstat (limited to 'compiler/codeGen/CgUtils.hs')
-rw-r--r--compiler/codeGen/CgUtils.hs34
1 files changed, 23 insertions, 11 deletions
diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs
index 0a545432d6..75f6b19292 100644
--- a/compiler/codeGen/CgUtils.hs
+++ b/compiler/codeGen/CgUtils.hs
@@ -67,6 +67,7 @@ import CmmUtils
import ForeignCall
import ClosureInfo
import StgSyn (SRT(..))
+import Module
import Literal
import Digraph
import ListSetOps
@@ -331,28 +332,39 @@ emitIfThenElse cond then_part else_part
; labelC join_id
}
-emitRtsCall :: FastString -> [CmmHinted CmmExpr] -> Bool -> Code
-emitRtsCall fun args safe = emitRtsCall' [] fun args Nothing safe
+
+-- | Emit code to call a Cmm function.
+emitRtsCall
+ :: PackageId -- ^ package the function is in
+ -> FastString -- ^ name of function
+ -> [CmmHinted CmmExpr] -- ^ function args
+ -> Bool -- ^ whether this is a safe call
+ -> Code -- ^ cmm code
+
+emitRtsCall pkg fun args safe = emitRtsCall' [] pkg fun args Nothing safe
-- The 'Nothing' says "save all global registers"
-emitRtsCallWithVols :: FastString -> [CmmHinted CmmExpr] -> [GlobalReg] -> Bool -> Code
-emitRtsCallWithVols fun args vols safe
- = emitRtsCall' [] fun args (Just vols) safe
+emitRtsCallWithVols :: PackageId -> FastString -> [CmmHinted CmmExpr] -> [GlobalReg] -> Bool -> Code
+emitRtsCallWithVols pkg fun args vols safe
+ = emitRtsCall' [] pkg fun args (Just vols) safe
-emitRtsCallWithResult :: LocalReg -> ForeignHint -> FastString
- -> [CmmHinted CmmExpr] -> Bool -> Code
-emitRtsCallWithResult res hint fun args safe
- = emitRtsCall' [CmmHinted res hint] fun args Nothing safe
+emitRtsCallWithResult
+ :: LocalReg -> ForeignHint
+ -> PackageId -> FastString
+ -> [CmmHinted CmmExpr] -> Bool -> Code
+emitRtsCallWithResult res hint pkg fun args safe
+ = emitRtsCall' [CmmHinted res hint] pkg fun args Nothing safe
-- Make a call to an RTS C procedure
emitRtsCall'
:: [CmmHinted LocalReg]
+ -> PackageId
-> FastString
-> [CmmHinted CmmExpr]
-> Maybe [GlobalReg]
-> Bool -- True <=> CmmSafe call
-> Code
-emitRtsCall' res fun args vols safe = do
+emitRtsCall' res pkg fun args vols safe = do
safety <- if safe
then getSRTInfo >>= (return . CmmSafe)
else return CmmUnsafe
@@ -362,7 +374,7 @@ emitRtsCall' res fun args vols safe = do
where
(caller_save, caller_load) = callerSaveVolatileRegs vols
target = CmmCallee fun_expr CCallConv
- fun_expr = mkLblExpr (mkRtsCodeLabel fun)
+ fun_expr = mkLblExpr (mkCmmCodeLabel pkg fun)
-----------------------------------------------------------------------------
--