[project @ 2000-12-20 16:42:28 by sewardj]
authorsewardj <unknown>
Wed, 20 Dec 2000 16:42:28 +0000 (16:42 +0000)
committersewardj <unknown>
Wed, 20 Dec 2000 16:42:28 +0000 (16:42 +0000)
Put string literals in read-only data segments on platforms which
understand that.

ghc/compiler/nativeGen/MachCode.lhs
ghc/compiler/nativeGen/PprMach.lhs
ghc/compiler/nativeGen/Stix.lhs

index a586a4a..a480840 100644 (file)
@@ -262,7 +262,7 @@ getRegister (StString s)
        imm_lbl = ImmCLbl lbl
 
        code dst = toOL [
-           SEGMENT DataSegment,
+           SEGMENT RoDataSegment,
            LABEL lbl,
            ASCII True (_UNPK_ s),
            SEGMENT TextSegment,
index 7fb618d..613b413 100644 (file)
@@ -386,6 +386,13 @@ pprInstr (SEGMENT DataSegment)
        ,IF_ARCH_i386(SLIT(".data\n\t.align 4")
        ,)))
 
+pprInstr (SEGMENT RoDataSegment)
+    = ptext
+        IF_ARCH_alpha(SLIT("\t.data\n\t.align 3")
+       ,IF_ARCH_sparc(SLIT(".data\n\t.align 8") {-<8 will break double constants -}
+       ,IF_ARCH_i386(SLIT(".section .rodata\n\t.align 4")
+       ,)))
+
 pprInstr (LABEL clab)
   = let
        pp_lab = pprCLabel_asm clab
index bb69123..06854db 100644 (file)
@@ -158,7 +158,7 @@ pprStixTree t
        StInt i          -> paren (integer i)
        StFloat rat      -> paren (text "Float" <+> rational rat)
        StDouble        rat     -> paren (text "Double" <+> rational rat)
-       StString str     -> paren (text "Str" <+> ptext str)
+       StString str     -> paren (text "Str `" <> ptext str <> char '\'')
        StComment str    -> paren (text "Comment" <+> ptext str)
        StCLbl lbl       -> pprCLabel lbl
        StReg reg        -> ppStixReg reg
@@ -224,7 +224,7 @@ segment (or that it has no segments at all, and we can lump these
 together).
 
 \begin{code}
-data CodeSegment = DataSegment | TextSegment deriving (Eq, Show)
+data CodeSegment = DataSegment | TextSegment | RoDataSegment deriving (Eq, Show)
 ppCodeSegment = text . show
 
 type StixTreeList = [StixTree] -> [StixTree]