summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm/Utils.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-07-07 18:48:31 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-25 00:45:08 -0400
commit9dfeca6c2019fdb46613a68ccd6e650e40c7baac (patch)
tree29a2cda3faddedc7024be259011f4406b6473f45 /compiler/GHC/Cmm/Utils.hs
parent6333d7391068d8029eed3e8eff019b9e2c104c7b (diff)
downloadhaskell-9dfeca6c2019fdb46613a68ccd6e650e40c7baac.tar.gz
Remove platform constant wrappers
Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801
Diffstat (limited to 'compiler/GHC/Cmm/Utils.hs')
-rw-r--r--compiler/GHC/Cmm/Utils.hs26
1 files changed, 14 insertions, 12 deletions
diff --git a/compiler/GHC/Cmm/Utils.hs b/compiler/GHC/Cmm/Utils.hs
index 2581056fc6..d762f0d9b0 100644
--- a/compiler/GHC/Cmm/Utils.hs
+++ b/compiler/GHC/Cmm/Utils.hs
@@ -48,7 +48,7 @@ module GHC.Cmm.Utils(
-- Tagging
cmmTagMask, cmmPointerMask, cmmUntag, cmmIsTagged,
- cmmConstrTag1,
+ cmmConstrTag1, mAX_PTR_TAG, tAG_MASK,
-- Overlap and usage
regsOverlap, regUsedIn,
@@ -79,7 +79,6 @@ import GHC.Cmm
import GHC.Cmm.BlockId
import GHC.Cmm.CLabel
import GHC.Utils.Outputable
-import GHC.Driver.Session
import GHC.Types.Unique
import GHC.Platform.Regs
@@ -428,26 +427,29 @@ isComparisonExpr _ = False
--
---------------------------------------------------
+tAG_MASK :: Platform -> Int
+tAG_MASK platform = (1 `shiftL` pc_TAG_BITS (platformConstants platform)) - 1
+
+mAX_PTR_TAG :: Platform -> Int
+mAX_PTR_TAG = tAG_MASK
+
-- Tag bits mask
-cmmTagMask, cmmPointerMask :: DynFlags -> CmmExpr
-cmmTagMask dflags = mkIntExpr (targetPlatform dflags) (tAG_MASK dflags)
-cmmPointerMask dflags = mkIntExpr (targetPlatform dflags) (complement (tAG_MASK dflags))
+cmmTagMask, cmmPointerMask :: Platform -> CmmExpr
+cmmTagMask platform = mkIntExpr platform (tAG_MASK platform)
+cmmPointerMask platform = mkIntExpr platform (complement (tAG_MASK platform))
-- Used to untag a possibly tagged pointer
-- A static label need not be untagged
-cmmUntag, cmmIsTagged, cmmConstrTag1 :: DynFlags -> CmmExpr -> CmmExpr
+cmmUntag, cmmIsTagged, cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr
cmmUntag _ e@(CmmLit (CmmLabel _)) = e
-- Default case
-cmmUntag dflags e = cmmAndWord platform e (cmmPointerMask dflags)
- where platform = targetPlatform dflags
+cmmUntag platform e = cmmAndWord platform e (cmmPointerMask platform)
-- Test if a closure pointer is untagged
-cmmIsTagged dflags e = cmmNeWord platform (cmmAndWord platform e (cmmTagMask dflags)) (zeroExpr platform)
- where platform = targetPlatform dflags
+cmmIsTagged platform e = cmmNeWord platform (cmmAndWord platform e (cmmTagMask platform)) (zeroExpr platform)
-- Get constructor tag, but one based.
-cmmConstrTag1 dflags e = cmmAndWord platform e (cmmTagMask dflags)
- where platform = targetPlatform dflags
+cmmConstrTag1 platform e = cmmAndWord platform e (cmmTagMask platform)
-----------------------------------------------------------------------------