import StgCmmClosure
import StgCmmProf
-import Cmm
+import CmmExpr
import CLabel
-import MkZipCfgCmm (CmmAGraph, mkNop)
+import MkGraph
import SMRep
import CostCentre
import Module
import PrelInfo
import Outputable
import Util ( lengthIs )
+
import Data.Char
+#if defined(mingw32_TARGET_OS)
+import StaticFlags ( opt_PIC )
+#endif
+
---------------------------------------------------------------
-- Top-level constructors
to be a literal. Reason: @Char@ like closures have an argument type
which is guaranteed in range.
-Because of this, we use can safely return an addressing mode. -}
+Because of this, we use can safely return an addressing mode.
+
+We don't support this optimisation when compiling into Windows DLLs yet
+because they don't support cross package data references well.
+-}
buildDynCon binder _cc con [arg]
| maybeIntLikeCon con
+#if defined(mingw32_TARGET_OS)
+ , not opt_PIC
+#endif
, StgLitArg (MachInt val) <- arg
, val <= fromIntegral mAX_INTLIKE -- Comparisons at type Integer!
, val >= fromIntegral mIN_INTLIKE -- ...ditto...
; return (litIdInfo binder (mkConLFInfo con) intlike_amode, mkNop) }
buildDynCon binder _cc con [arg]
- | maybeCharLikeCon con
+ | maybeCharLikeCon con
+#if defined(mingw32_TARGET_OS)
+ , not opt_PIC
+#endif
, StgLitArg (MachChar val) <- arg
, let val_int = ord val :: Int
, val_int <= mAX_CHARLIKE
= do { let (cl_info, args_w_offsets) = layOutDynConstr con (addArgReps args)
-- No void args in args_w_offsets
; (tmp, init) <- allocDynClosure cl_info use_cc blame_cc args_w_offsets
- ; return (regIdInfo binder lf_info tmp, init) }
+ ; regIdInfo binder lf_info tmp init }
where
lf_info = mkConLFInfo con