diff options
author | Ben Gamari <ben@smart-cactus.org> | 2017-11-13 12:34:54 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-11-28 15:49:46 -0500 |
commit | 048a91380cbbc18d1704bb7c328247a1660b5596 (patch) | |
tree | 4030bc33eff0bc45e14c59696146af7bda9c9e6a /compiler/nativeGen | |
parent | 17e71c14fee6bc068cf081abfc1abd0470e84c66 (diff) | |
download | haskell-048a91380cbbc18d1704bb7c328247a1660b5596.tar.gz |
cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks
blockLbl was originally changed in 8b007abbeb3045900a11529d907a835080129176 to
use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this
breaks the C code generator, which doesn't support AsmTempLabels (#14454).
Instead let's try going the other direction: use a new CLabel variety,
LocalBlockLabel. Then we can teach the C code generator to deal with
these as well.
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r-- | compiler/nativeGen/NCGMonad.hs | 5 | ||||
-rw-r--r-- | compiler/nativeGen/PPC/Ppr.hs | 4 | ||||
-rw-r--r-- | compiler/nativeGen/PPC/RegInfo.hs | 6 | ||||
-rw-r--r-- | compiler/nativeGen/SPARC/ShortcutJump.hs | 4 | ||||
-rw-r--r-- | compiler/nativeGen/X86/Instr.hs | 8 |
5 files changed, 13 insertions, 14 deletions
diff --git a/compiler/nativeGen/NCGMonad.hs b/compiler/nativeGen/NCGMonad.hs index f4d02dae3c..b9532e17b5 100644 --- a/compiler/nativeGen/NCGMonad.hs +++ b/compiler/nativeGen/NCGMonad.hs @@ -46,7 +46,7 @@ import TargetReg import BlockId import Hoopl.Collections import Hoopl.Label -import CLabel ( CLabel, mkAsmTempLabel ) +import CLabel ( CLabel ) import Debug import FastString ( FastString ) import UniqFM @@ -160,8 +160,7 @@ getBlockIdNat getNewLabelNat :: NatM CLabel getNewLabelNat - = do u <- getUniqueNat - return (mkAsmTempLabel u) + = blockLbl <$> getBlockIdNat getNewRegNat :: Format -> NatM Reg diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 101628e3a3..2f64d82ee5 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -603,7 +603,7 @@ pprInstr (BCC cond blockid prediction) = hcat [ char '\t', ppr lbl ] - where lbl = mkAsmTempLabel (getUnique blockid) + where lbl = mkLocalBlockLabel (getUnique blockid) pprPrediction p = case p of Nothing -> empty Just True -> char '+' @@ -621,7 +621,7 @@ pprInstr (BCCFAR cond blockid prediction) = vcat [ ppr lbl ] ] - where lbl = mkAsmTempLabel (getUnique blockid) + where lbl = mkLocalBlockLabel (getUnique blockid) neg_prediction = case prediction of Nothing -> empty Just True -> char '-' diff --git a/compiler/nativeGen/PPC/RegInfo.hs b/compiler/nativeGen/PPC/RegInfo.hs index bf894fd42f..1015ed661d 100644 --- a/compiler/nativeGen/PPC/RegInfo.hs +++ b/compiler/nativeGen/PPC/RegInfo.hs @@ -51,8 +51,8 @@ shortcutStatics fn (Statics lbl statics) shortcutLabel :: (BlockId -> Maybe JumpDest) -> CLabel -> CLabel shortcutLabel fn lab - | Just uq <- maybeAsmTemp lab = shortBlockId fn (mkBlockId uq) - | otherwise = lab + | Just blkId <- maybeLocalBlockLabel lab = shortBlockId fn blkId + | otherwise = lab shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic shortcutStatic fn (CmmStaticLit (CmmLabel lab)) @@ -71,6 +71,6 @@ shortBlockId shortBlockId fn blockid = case fn blockid of - Nothing -> mkAsmTempLabel uq + Nothing -> mkLocalBlockLabel uq Just (DestBlockId blockid') -> shortBlockId fn blockid' where uq = getUnique blockid diff --git a/compiler/nativeGen/SPARC/ShortcutJump.hs b/compiler/nativeGen/SPARC/ShortcutJump.hs index 0df280095b..86c28138f1 100644 --- a/compiler/nativeGen/SPARC/ShortcutJump.hs +++ b/compiler/nativeGen/SPARC/ShortcutJump.hs @@ -46,8 +46,8 @@ shortcutStatics fn (Statics lbl statics) shortcutLabel :: (BlockId -> Maybe JumpDest) -> CLabel -> CLabel shortcutLabel fn lab - | Just uq <- maybeAsmTemp lab = shortBlockId fn (mkBlockId uq) - | otherwise = lab + | Just blkId <- maybeLocalBlockLabel lab = shortBlockId fn blkId + | otherwise = lab shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic shortcutStatic fn (CmmStaticLit (CmmLabel lab)) diff --git a/compiler/nativeGen/X86/Instr.hs b/compiler/nativeGen/X86/Instr.hs index 1bb682ad87..c937d4dba0 100644 --- a/compiler/nativeGen/X86/Instr.hs +++ b/compiler/nativeGen/X86/Instr.hs @@ -1035,8 +1035,8 @@ shortcutStatics fn (align, Statics lbl statics) shortcutLabel :: (BlockId -> Maybe JumpDest) -> CLabel -> CLabel shortcutLabel fn lab - | Just uq <- maybeAsmTemp lab = shortBlockId fn emptyUniqSet (mkBlockId uq) - | otherwise = lab + | Just blkId <- maybeLocalBlockLabel lab = shortBlockId fn emptyUniqSet blkId + | otherwise = lab shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic shortcutStatic fn (CmmStaticLit (CmmLabel lab)) @@ -1056,8 +1056,8 @@ shortBlockId shortBlockId fn seen blockid = case (elementOfUniqSet uq seen, fn blockid) of - (True, _) -> mkAsmTempLabel uq - (_, Nothing) -> mkAsmTempLabel uq + (True, _) -> blockLbl blockid + (_, Nothing) -> blockLbl blockid (_, Just (DestBlockId blockid')) -> shortBlockId fn (addOneToUniqSet seen uq) blockid' (_, Just (DestImm (ImmCLbl lbl))) -> lbl (_, _other) -> panic "shortBlockId" |