summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-01-17 13:34:32 +0100
committerBen Gamari <ben@smart-cactus.org>2019-01-31 12:46:51 -0500
commit4fa32293c9d2658ce504b8fe6d909db2acf59983 (patch)
tree6c7519fd6a320cbaf2264c2cbfdfe1eef0d70acc /compiler/nativeGen
parentdeab6d64eac085b2e0ec68bfb3eeeda608dfb85a (diff)
downloadhaskell-4fa32293c9d2658ce504b8fe6d909db2acf59983.tar.gz
Use ByteString to represent Cmm string literals (#16198)
Also used ByteString in some other relevant places
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/Dwarf/Types.hs3
-rw-r--r--compiler/nativeGen/PprBase.hs6
-rw-r--r--compiler/nativeGen/SPARC/Ppr.hs3
3 files changed, 8 insertions, 4 deletions
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index 05b5b7faad..57ff0b2478 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -38,6 +38,7 @@ import Util
import Dwarf.Constants
+import qualified Data.ByteString as BS
import qualified Control.Monad.Trans.State.Strict as S
import Control.Monad (zipWithM, join)
import Data.Bits
@@ -583,7 +584,7 @@ pprString str
= pprString' $ hcat $ map escapeChar $
if str `lengthIs` utf8EncodedLength str
then str
- else map (chr . fromIntegral) $ bytesFS $ mkFastString str
+ else map (chr . fromIntegral) $ BS.unpack $ bytesFS $ mkFastString str
-- | Escape a single non-unicode character
escapeChar :: Char -> SDoc
diff --git a/compiler/nativeGen/PprBase.hs b/compiler/nativeGen/PprBase.hs
index 58566cf812..4cdcceec9e 100644
--- a/compiler/nativeGen/PprBase.hs
+++ b/compiler/nativeGen/PprBase.hs
@@ -34,6 +34,8 @@ import Control.Monad.ST
import Data.Word
import Data.Char
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
@@ -90,13 +92,13 @@ doubleToBytes d
-- Print as a string and escape non-printable characters.
-- This is similar to charToC in Utils.
-pprASCII :: [Word8] -> SDoc
+pprASCII :: ByteString -> SDoc
pprASCII str
-- Transform this given literal bytestring to escaped string and construct
-- the literal SDoc directly.
-- See Trac #14741
-- and Note [Pretty print ASCII when AsmCodeGen]
- = text $ foldr (\w s -> (do1 . fromIntegral) w ++ s) "" str
+ = text $ foldr (\w s -> (do1 . fromIntegral) w ++ s) "" (BS.unpack str)
where
do1 :: Int -> String
do1 w | '\t' <- chr w = "\\t"
diff --git a/compiler/nativeGen/SPARC/Ppr.hs b/compiler/nativeGen/SPARC/Ppr.hs
index 7fc3e2111f..705fc31153 100644
--- a/compiler/nativeGen/SPARC/Ppr.hs
+++ b/compiler/nativeGen/SPARC/Ppr.hs
@@ -50,6 +50,7 @@ import Outputable
import Platform
import FastString
import Data.Word
+import qualified Data.ByteString as BS
-- -----------------------------------------------------------------------------
-- Printing this stuff out
@@ -110,7 +111,7 @@ pprDatas (Statics lbl dats) = vcat (pprLabel lbl : map pprData dats)
pprData :: CmmStatic -> SDoc
pprData (CmmString str)
- = vcat (map do1 str) $$ do1 0
+ = vcat (map do1 (BS.unpack str)) $$ do1 0
where
do1 :: Word8 -> SDoc
do1 w = text "\t.byte\t" <> int (fromIntegral w)