summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorMax Bolingbroke <batterseapower@hotmail.com>2011-07-06 16:18:09 +0100
committerMax Bolingbroke <batterseapower@hotmail.com>2011-07-06 16:41:20 +0100
commit41ca0b8dcb91cf02f389b3d099c33fbdf009312c (patch)
tree29b35ed3623b47ce36f25ede3abd79eedeb84e6d /compiler/nativeGen
parent43293b8c3210003c9e5b5b4a662f0fdb874353b7 (diff)
downloadhaskell-41ca0b8dcb91cf02f389b3d099c33fbdf009312c.tar.gz
Refactoring: explicitly mark whether we have an info table in RawCmm
I introduced this to support explicitly recording the info table label in RawCmm for another patch I am working on, but it turned out to lead to significant simplification in those parts of the compiler that consume RawCmm. Now, instead of lots of tests for null [CmmStatic] we have a simple test of a Maybe, and have reduced the number of guys that need to know how to convert entry->info labels by a TON. There are only 3 callers of that function now!
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/AsmCodeGen.lhs2
-rw-r--r--compiler/nativeGen/Instruction.hs4
-rw-r--r--compiler/nativeGen/PPC/Ppr.hs30
-rw-r--r--compiler/nativeGen/RegAlloc/Liveness.hs6
-rw-r--r--compiler/nativeGen/SPARC/Ppr.hs30
-rw-r--r--compiler/nativeGen/X86/Ppr.hs33
6 files changed, 56 insertions, 49 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.lhs b/compiler/nativeGen/AsmCodeGen.lhs
index bfeaf9e8e3..83082eaab8 100644
--- a/compiler/nativeGen/AsmCodeGen.lhs
+++ b/compiler/nativeGen/AsmCodeGen.lhs
@@ -267,7 +267,7 @@ nativeCodeGen' dflags ncgImpl h us cmms
| dopt Opt_SplitObjs dflags = split_marker : tops
| otherwise = tops
- split_marker = CmmProc [] mkSplitMarkerLabel (ListGraph [])
+ split_marker = CmmProc Nothing mkSplitMarkerLabel (ListGraph [])
-- | Do native code generation on all these cmms.
diff --git a/compiler/nativeGen/Instruction.hs b/compiler/nativeGen/Instruction.hs
index 5c85101e8e..7bcaa2b2a9 100644
--- a/compiler/nativeGen/Instruction.hs
+++ b/compiler/nativeGen/Instruction.hs
@@ -38,13 +38,13 @@ noUsage = RU [] []
type NatCmm instr
= GenCmm
CmmStatics
- [CmmStatic]
+ (Maybe CmmStatics)
(ListGraph instr)
type NatCmmTop statics instr
= GenCmmTop
statics
- [CmmStatic]
+ (Maybe CmmStatics)
(ListGraph instr)
diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs
index 7d85b4c66b..3209e9981c 100644
--- a/compiler/nativeGen/PPC/Ppr.hs
+++ b/compiler/nativeGen/PPC/Ppr.hs
@@ -54,19 +54,23 @@ pprNatCmmTop (CmmData section dats) =
pprSectionHeader section $$ pprDatas dats
-- special case for split markers:
-pprNatCmmTop (CmmProc [] lbl (ListGraph [])) = pprLabel lbl
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph [])) = pprLabel lbl
-pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
+ -- special case for code without an info table:
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph blocks)) =
pprSectionHeader Text $$
- (if null info then -- blocks guaranteed not null, so label needed
- pprLabel lbl
- else
+ pprLabel lbl $$ -- blocks guaranteed not null, so label needed
+ vcat (map pprBasicBlock blocks)
+
+pprNatCmmTop (CmmProc (Just (Statics info_lbl info)) _entry_lbl (ListGraph blocks)) =
+ pprSectionHeader Text $$
+ (
#if HAVE_SUBSECTIONS_VIA_SYMBOLS
- pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- <> char ':' $$
+ pprCLabel_asm (mkDeadStripPreventer info_lbl)
+ <> char ':' $$
#endif
vcat (map pprData info) $$
- pprLabel (entryLblToInfoLbl lbl)
+ pprLabel info_lbl
) $$
vcat (map pprBasicBlock blocks)
-- above: Even the first block gets a label, because with branch-chain
@@ -78,12 +82,10 @@ pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
-- from the entry code to a label on the _top_ of of the info table,
-- so that the linker will not think it is unreferenced and dead-strip
-- it. That's why the label is called a DeadStripPreventer (_dsp).
- $$ if not (null info)
- then text "\t.long "
- <+> pprCLabel_asm (entryLblToInfoLbl lbl)
- <+> char '-'
- <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- else empty
+ $$ text "\t.long "
+ <+> pprCLabel_asm info_lbl
+ <+> char '-'
+ <+> pprCLabel_asm (mkDeadStripPreventer info_lbl)
#endif
diff --git a/compiler/nativeGen/RegAlloc/Liveness.hs b/compiler/nativeGen/RegAlloc/Liveness.hs
index a6a3724bfa..0f9220de8f 100644
--- a/compiler/nativeGen/RegAlloc/Liveness.hs
+++ b/compiler/nativeGen/RegAlloc/Liveness.hs
@@ -158,7 +158,7 @@ data Liveness
-- | Stash regs live on entry to each basic block in the info part of the cmm code.
data LiveInfo
= LiveInfo
- [CmmStatic] -- cmm static stuff
+ (Maybe CmmStatics) -- cmm info table static stuff
(Maybe BlockId) -- id of the first block
(Maybe (BlockMap RegSet)) -- argument locals live on entry to this block
(Map BlockId (Set Int)) -- stack slots live on entry to this block
@@ -212,8 +212,8 @@ instance Outputable instr
| otherwise = name <> (hcat $ punctuate space $ map ppr $ uniqSetToList regs)
instance Outputable LiveInfo where
- ppr (LiveInfo static firstId liveVRegsOnEntry liveSlotsOnEntry)
- = (vcat $ map ppr static)
+ ppr (LiveInfo mb_static firstId liveVRegsOnEntry liveSlotsOnEntry)
+ = (maybe empty ppr mb_static)
$$ text "# firstId = " <> ppr firstId
$$ text "# liveVRegsOnEntry = " <> ppr liveVRegsOnEntry
$$ text "# liveSlotsOnEntry = " <> text (show liveSlotsOnEntry)
diff --git a/compiler/nativeGen/SPARC/Ppr.hs b/compiler/nativeGen/SPARC/Ppr.hs
index 7f3583f26c..aab700acc3 100644
--- a/compiler/nativeGen/SPARC/Ppr.hs
+++ b/compiler/nativeGen/SPARC/Ppr.hs
@@ -52,19 +52,23 @@ pprNatCmmTop (CmmData section dats) =
pprSectionHeader section $$ pprDatas dats
-- special case for split markers:
-pprNatCmmTop (CmmProc [] lbl (ListGraph [])) = pprLabel lbl
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph [])) = pprLabel lbl
-pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
+ -- special case for code without info table:
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph blocks)) =
pprSectionHeader Text $$
- (if null info then -- blocks guaranteed not null, so label needed
- pprLabel lbl
- else
+ pprLabel lbl $$ -- blocks guaranteed not null, so label needed
+ vcat (map pprBasicBlock blocks)
+
+pprNatCmmTop (CmmProc (Just (Statics info_lbl info)) _entry_lbl (ListGraph blocks)) =
+ pprSectionHeader Text $$
+ (
#if HAVE_SUBSECTIONS_VIA_SYMBOLS
- pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- <> char ':' $$
+ pprCLabel_asm (mkDeadStripPreventer info_lbl)
+ <> char ':' $$
#endif
vcat (map pprData info) $$
- pprLabel (entryLblToInfoLbl lbl)
+ pprLabel info_lbl
) $$
vcat (map pprBasicBlock blocks)
-- above: Even the first block gets a label, because with branch-chain
@@ -76,12 +80,10 @@ pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
-- from the entry code to a label on the _top_ of of the info table,
-- so that the linker will not think it is unreferenced and dead-strip
-- it. That's why the label is called a DeadStripPreventer (_dsp).
- $$ if not (null info)
- then text "\t.long "
- <+> pprCLabel_asm (entryLblToInfoLbl lbl)
- <+> char '-'
- <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- else empty
+ $$ text "\t.long "
+ <+> pprCLabel_asm info_lbl
+ <+> char '-'
+ <+> pprCLabel_asm (mkDeadStripPreventer info_lbl)
#endif
diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index 10af5ef8c1..5762cd93d5 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -54,19 +54,24 @@ pprNatCmmTop (CmmData section dats) =
pprSectionHeader section $$ pprDatas dats
-- special case for split markers:
-pprNatCmmTop (CmmProc [] lbl (ListGraph [])) = pprLabel lbl
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph [])) = pprLabel lbl
-pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
+ -- special case for code without info table:
+pprNatCmmTop (CmmProc Nothing lbl (ListGraph blocks)) =
pprSectionHeader Text $$
- (if null info then -- blocks guaranteed not null, so label needed
- pprLabel lbl
- else
+ pprLabel lbl $$ -- blocks guaranteed not null, so label needed
+ vcat (map pprBasicBlock blocks) $$
+ pprSizeDecl lbl
+
+pprNatCmmTop (CmmProc (Just (Statics info_lbl info)) _entry_lbl (ListGraph blocks)) =
+ pprSectionHeader Text $$
+ (
#if HAVE_SUBSECTIONS_VIA_SYMBOLS
- pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- <> char ':' $$
+ pprCLabel_asm (mkDeadStripPreventer info_lbl)
+ <> char ':' $$
#endif
vcat (map pprData info) $$
- pprLabel (entryLblToInfoLbl lbl)
+ pprLabel info_lbl
) $$
vcat (map pprBasicBlock blocks)
-- above: Even the first block gets a label, because with branch-chain
@@ -78,14 +83,12 @@ pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) =
-- from the entry code to a label on the _top_ of of the info table,
-- so that the linker will not think it is unreferenced and dead-strip
-- it. That's why the label is called a DeadStripPreventer (_dsp).
- $$ if not (null info)
- then text "\t.long "
- <+> pprCLabel_asm (entryLblToInfoLbl lbl)
- <+> char '-'
- <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl)
- else empty
+ $$ text "\t.long "
+ <+> pprCLabel_asm info_lbl
+ <+> char '-'
+ <+> pprCLabel_asm (mkDeadStripPreventer info_lbl)
#endif
- $$ pprSizeDecl (if null info then lbl else entryLblToInfoLbl lbl)
+ $$ pprSizeDecl info_lbl
-- | Output the ELF .size directive.
pprSizeDecl :: CLabel -> Doc