Add PrimCall to the STG layer and update Core -> STG translation
[ghc-hetmet.git] / compiler / cmm / CLabel.hs
index f95a0fd..9ba55ac 100644 (file)
@@ -90,6 +90,8 @@ module CLabel (
 
        mkRtsApFastLabel,
 
+        mkPrimCallLabel,
+
        mkForeignLabel,
         addLabelSize,
         foreignLabelStdcallInfo,
@@ -133,6 +135,7 @@ import CostCentre
 import Outputable
 import FastString
 import DynFlags
+import UniqSet
 
 -- -----------------------------------------------------------------------------
 -- The CLabel type
@@ -374,6 +377,11 @@ mkSelectorEntryLabel upd off       = RtsLabel (RtsSelectorEntry   upd off)
 mkApInfoTableLabel  upd off    = RtsLabel (RtsApInfoTable upd off)
 mkApEntryLabel upd off         = RtsLabel (RtsApEntry   upd off)
 
+        -- Primitive / cmm call labels
+
+mkPrimCallLabel :: PrimCall -> CLabel
+mkPrimCallLabel (PrimCall str)  = ForeignLabel str Nothing False IsFunction
+
        -- Foreign labels
 
 mkForeignLabel :: FastString -> Maybe Int -> Bool -> FunctionOrData -> CLabel
@@ -522,9 +530,10 @@ maybeAsmTemp _                    = Nothing
 -- they are builtin to the C compiler.  For these labels we avoid
 -- generating our own C prototypes.
 isMathFun :: CLabel -> Bool
-isMathFun (ForeignLabel fs _ _ _) = fs `elem` math_funs
-  where
-  math_funs = [
+isMathFun (ForeignLabel fs _ _ _) = fs `elementOfUniqSet` math_funs
+isMathFun _ = False
+
+math_funs = mkUniqSet [
         -- _ISOC99_SOURCE
         (fsLit "acos"),         (fsLit "acosf"),        (fsLit "acosh"),
         (fsLit "acoshf"),       (fsLit "acoshl"),       (fsLit "acosl"),
@@ -603,7 +612,6 @@ isMathFun (ForeignLabel fs _ _ _) = fs `elem` math_funs
         (fsLit "y1"),           (fsLit "y1f"),          (fsLit "y1l"),
         (fsLit "yn"),           (fsLit "ynf"),          (fsLit "ynl")
     ]
-isMathFun _ = False
 
 -- -----------------------------------------------------------------------------
 -- Is a CLabel visible outside this object file or not?
@@ -961,6 +969,10 @@ asmTempLabelPrefix =
 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
 
 #if x86_64_TARGET_ARCH && darwin_TARGET_OS
+pprDynamicLinkerAsmLabel CodeStub lbl
+  = char 'L' <> pprCLabel lbl <> text "$stub"
+pprDynamicLinkerAsmLabel SymbolPtr lbl
+  = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
   = pprCLabel lbl <> text "@GOTPCREL"
 pprDynamicLinkerAsmLabel GotSymbolOffset lbl