summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/nativeGen/PPC/Ppr.hs12
-rw-r--r--compiler/nativeGen/SPARC/Ppr.hs7
-rw-r--r--compiler/nativeGen/X86/Ppr.hs9
3 files changed, 24 insertions, 4 deletions
diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs
index 8d89a193a4..08c02f01c6 100644
--- a/compiler/nativeGen/PPC/Ppr.hs
+++ b/compiler/nativeGen/PPC/Ppr.hs
@@ -112,7 +112,7 @@ pprBasicBlock info_env (BasicBlock blockid instrs)
maybe_infotable = case mapLookup blockid info_env of
Nothing -> empty
Just (Statics info_lbl info) ->
- pprSectionAlign (Section Text info_lbl) $$
+ pprAlignForSection Text $$
vcat (map pprData info) $$
pprLabel info_lbl
@@ -305,9 +305,16 @@ pprAddr (AddrRegImm r1 imm) = hcat [ pprImm imm, char '(', pprReg r1, char ')' ]
pprSectionAlign :: Section -> SDoc
pprSectionAlign sec@(Section seg _) =
sdocWithPlatform $ \platform ->
+ pprSectionHeader platform sec $$
+ pprAlignForSection seg
+
+-- | Print appropriate alignment for the given section type.
+pprAlignForSection :: SectionType -> SDoc
+pprAlignForSection seg =
+ sdocWithPlatform $ \platform ->
let osDarwin = platformOS platform == OSDarwin
ppc64 = not $ target32Bit platform
- align = ptext $ case seg of
+ in ptext $ case seg of
Text -> sLit ".align 2"
Data
| ppc64 -> sLit ".align 3"
@@ -328,7 +335,6 @@ pprSectionAlign sec@(Section seg _) =
| osDarwin -> sLit ".align 4"
| otherwise -> sLit ".align 4"
OtherSection _ -> panic "PprMach.pprSectionAlign: unknown section"
- in pprSectionHeader platform sec $$ align
pprDataItem :: CmmLit -> SDoc
pprDataItem lit
diff --git a/compiler/nativeGen/SPARC/Ppr.hs b/compiler/nativeGen/SPARC/Ppr.hs
index 8c7871e059..eb41f2390f 100644
--- a/compiler/nativeGen/SPARC/Ppr.hs
+++ b/compiler/nativeGen/SPARC/Ppr.hs
@@ -96,7 +96,7 @@ pprBasicBlock info_env (BasicBlock blockid instrs)
maybe_infotable = case mapLookup blockid info_env of
Nothing -> empty
Just (Statics info_lbl info) ->
- pprSectionAlign (Section Text info_lbl) $$
+ pprAlignForSection Text $$
vcat (map pprData info) $$
pprLabel info_lbl
@@ -326,6 +326,11 @@ pprSectionAlign :: Section -> SDoc
pprSectionAlign sec@(Section seg _) =
sdocWithPlatform $ \platform ->
pprSectionHeader platform sec $$
+ pprAlignForSection seg
+
+-- | Print appropriate alignment for the given section type.
+pprAlignForSection :: SectionType -> SDoc
+pprAlignForSection seg =
ptext (case seg of
Text -> sLit ".align 4"
Data -> sLit ".align 8"
diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index f2fc884d58..7809ae1df9 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -109,6 +109,7 @@ pprBasicBlock info_env (BasicBlock blockid instrs)
maybe_infotable = case mapLookup blockid info_env of
Nothing -> empty
Just (Statics info_lbl info) ->
+ pprAlignForSection Text $$
infoTableLoc $$
vcat (map pprData info) $$
pprLabel info_lbl
@@ -386,8 +387,15 @@ pprSectionAlign (Section (OtherSection _) _) =
pprSectionAlign sec@(Section seg _) =
sdocWithPlatform $ \platform ->
pprSectionHeader platform sec $$
+ pprAlignForSection seg
+
+-- | Print appropriate alignment for the given section type.
+pprAlignForSection :: SectionType -> SDoc
+pprAlignForSection seg =
+ sdocWithPlatform $ \platform ->
text ".align " <>
case platformOS platform of
+ -- Darwin: alignments are given as shifts.
OSDarwin
| target32Bit platform ->
case seg of
@@ -397,6 +405,7 @@ pprSectionAlign sec@(Section seg _) =
case seg of
ReadOnlyData16 -> int 4
_ -> int 3
+ -- Other: alignments are given as bytes.
_
| target32Bit platform ->
case seg of