From 45003cbd28240308e92e7fc6e92ef02d633b6af3 Mon Sep 17 00:00:00 2001 From: sewardj Date: Wed, 20 Dec 2000 16:42:28 +0000 Subject: [PATCH] [project @ 2000-12-20 16:42:28 by sewardj] Put string literals in read-only data segments on platforms which understand that. --- ghc/compiler/nativeGen/MachCode.lhs | 2 +- ghc/compiler/nativeGen/PprMach.lhs | 7 +++++++ ghc/compiler/nativeGen/Stix.lhs | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ghc/compiler/nativeGen/MachCode.lhs b/ghc/compiler/nativeGen/MachCode.lhs index a586a4a..a480840 100644 --- a/ghc/compiler/nativeGen/MachCode.lhs +++ b/ghc/compiler/nativeGen/MachCode.lhs @@ -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, diff --git a/ghc/compiler/nativeGen/PprMach.lhs b/ghc/compiler/nativeGen/PprMach.lhs index 7fb618d..613b413 100644 --- a/ghc/compiler/nativeGen/PprMach.lhs +++ b/ghc/compiler/nativeGen/PprMach.lhs @@ -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 diff --git a/ghc/compiler/nativeGen/Stix.lhs b/ghc/compiler/nativeGen/Stix.lhs index bb69123..06854db 100644 --- a/ghc/compiler/nativeGen/Stix.lhs +++ b/ghc/compiler/nativeGen/Stix.lhs @@ -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] -- 1.7.10.4