diff options
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/Cmm.hs | 11 | ||||
-rw-r--r-- | compiler/cmm/CmmBuildInfoTables.hs | 6 | ||||
-rw-r--r-- | compiler/cmm/CmmInfo.hs | 2 | ||||
-rw-r--r-- | compiler/cmm/CmmParse.y | 4 | ||||
-rw-r--r-- | compiler/cmm/CmmUtils.hs | 7 | ||||
-rw-r--r-- | compiler/cmm/PprCmmDecl.hs | 26 |
6 files changed, 35 insertions, 21 deletions
diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs index 9e9bae93c6..d0564e6f68 100644 --- a/compiler/cmm/Cmm.hs +++ b/compiler/cmm/Cmm.hs @@ -8,7 +8,7 @@ module Cmm ( CmmGraph, GenCmmGraph(..), CmmBlock, RawCmmDecl, RawCmmGroup, - Section(..), CmmStatics(..), CmmStatic(..), + Section(..), SectionType(..), CmmStatics(..), CmmStatic(..), -- ** Blocks containing lists GenBasicBlock(..), blockId, @@ -48,8 +48,10 @@ import Data.Word ( Word8 ) -- A CmmProgram is a list of CmmGroups -- A CmmGroup is a list of top-level declarations --- When object-splitting is on,each group is compiled into a separate +-- When object-splitting is on, each group is compiled into a separate -- .o file. So typically we put closely related stuff in a CmmGroup. +-- Section-splitting follows suit and makes one .text subsection for each +-- CmmGroup. type CmmProgram = [CmmGroup] @@ -163,7 +165,7 @@ needsSRT (C_SRT _ _ _) = True -- Static Data ----------------------------------------------------------------------------- -data Section +data SectionType = Text | Data | ReadOnlyData @@ -171,6 +173,9 @@ data Section | UninitialisedData | ReadOnlyData16 -- .rodata.cst16 on x86_64, 16-byte aligned | OtherSection String + deriving (Show) + +data Section = Section SectionType CLabel data CmmStatic = CmmStaticLit CmmLit diff --git a/compiler/cmm/CmmBuildInfoTables.hs b/compiler/cmm/CmmBuildInfoTables.hs index 3bbd06f5c6..dafaea3156 100644 --- a/compiler/cmm/CmmBuildInfoTables.hs +++ b/compiler/cmm/CmmBuildInfoTables.hs @@ -148,8 +148,9 @@ addCAF caf srt = where last = next_elt srt srtToData :: TopSRT -> CmmGroup -srtToData srt = [CmmData RelocatableReadOnlyData (Statics (lbl srt) tbl)] +srtToData srt = [CmmData sec (Statics (lbl srt) tbl)] where tbl = map (CmmStaticLit . CmmLabel) (reverse (rev_elts srt)) + sec = Section RelocatableReadOnlyData (lbl srt) -- Once we have found the CAFs, we need to do two things: -- 1. Build a table of all the CAFs used in the procedure. @@ -223,7 +224,8 @@ to_SRT dflags top_srt off len bmp | len > maxBmpSize dflags || bmp == [toStgWord dflags (fromStgHalfWord (srtEscape dflags))] = do id <- getUniqueM let srt_desc_lbl = mkLargeSRTLabel id - tbl = CmmData RelocatableReadOnlyData $ + section = Section RelocatableReadOnlyData srt_desc_lbl + tbl = CmmData section $ Statics srt_desc_lbl $ map CmmStaticLit ( cmmLabelOffW dflags top_srt off : mkWordCLit dflags (fromIntegral len) diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs index ce8b9f8b6b..86133b662e 100644 --- a/compiler/cmm/CmmInfo.hs +++ b/compiler/cmm/CmmInfo.hs @@ -132,7 +132,7 @@ mkInfoTable dflags proc@(CmmProc infos entry_lbl live blocks) -- return (top_decls ++ [CmmProc mapEmpty entry_lbl live blocks, - mkDataLits Data info_lbl + mkDataLits (Section Data info_lbl) info_lbl (CmmLabel entry_lbl : rel_std_info ++ rel_extra_bits)]) -- diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y index ea0f4a5a66..c39c3ecae8 100644 --- a/compiler/cmm/CmmParse.y +++ b/compiler/cmm/CmmParse.y @@ -382,7 +382,7 @@ cmmdata :: { CmmParse () } : 'section' STRING '{' data_label statics '}' { do lbl <- $4; ss <- sequence $5; - code (emitDecl (CmmData (section $2) (Statics lbl $ concat ss))) } + code (emitDecl (CmmData (Section (section $2) lbl) (Statics lbl $ concat ss))) } data_label :: { CmmParse CLabel } : NAME ':' @@ -831,7 +831,7 @@ typenot8 :: { CmmType } | 'gcptr' {% do dflags <- getDynFlags; return $ gcWord dflags } { -section :: String -> Section +section :: String -> SectionType section "text" = Text section "data" = Data section "rodata" = ReadOnlyData diff --git a/compiler/cmm/CmmUtils.hs b/compiler/cmm/CmmUtils.hs index 904e19ad99..dca57dca01 100644 --- a/compiler/cmm/CmmUtils.hs +++ b/compiler/cmm/CmmUtils.hs @@ -162,9 +162,10 @@ mkByteStringCLit :: Unique -> [Word8] -> (CmmLit, GenCmmDecl CmmStatics info stm -- We have to make a top-level decl for the string, -- and return a literal pointing to it mkByteStringCLit uniq bytes - = (CmmLabel lbl, CmmData ReadOnlyData $ Statics lbl [CmmString bytes]) + = (CmmLabel lbl, CmmData sec $ Statics lbl [CmmString bytes]) where lbl = mkStringLitLabel uniq + sec = Section ReadOnlyData lbl mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt -- Build a data-segment data block mkDataLits section lbl lits @@ -175,8 +176,8 @@ mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt mkRODataLits lbl lits = mkDataLits section lbl lits where - section | any needsRelocation lits = RelocatableReadOnlyData - | otherwise = ReadOnlyData + section | any needsRelocation lits = Section RelocatableReadOnlyData lbl + | otherwise = Section ReadOnlyData lbl needsRelocation (CmmLabel _) = True needsRelocation (CmmLabelOff _ _) = True needsRelocation _ = False diff --git a/compiler/cmm/PprCmmDecl.hs b/compiler/cmm/PprCmmDecl.hs index 87cda6a9ad..bf6620f22c 100644 --- a/compiler/cmm/PprCmmDecl.hs +++ b/compiler/cmm/PprCmmDecl.hs @@ -154,14 +154,20 @@ pprStatic s = case s of -- data sections -- pprSection :: Section -> SDoc -pprSection s = case s of - Text -> section <+> doubleQuotes (text "text") - Data -> section <+> doubleQuotes (text "data") - ReadOnlyData -> section <+> doubleQuotes (text "readonly") - ReadOnlyData16 -> section <+> doubleQuotes (text "readonly16") - RelocatableReadOnlyData - -> section <+> doubleQuotes (text "relreadonly") - UninitialisedData -> section <+> doubleQuotes (text "uninitialised") - OtherSection s' -> section <+> doubleQuotes (text s') - where +pprSection (Section t suffix) = + section <+> doubleQuotes (pprSectionType t <+> text "." <+> ppr suffix) + where section = ptext (sLit "section") + +pprSectionType :: SectionType -> SDoc +pprSectionType s = doubleQuotes (text t) + where + t = case s of + Text -> "text" + Data -> "data" + ReadOnlyData -> "readonly" + ReadOnlyData16 -> "readonly16" + RelocatableReadOnlyData + -> "relreadonly" + UninitialisedData -> "uninitialised" + OtherSection s' -> s' |