From 13bb4bf44e6e690133be334bbf0c63fcae5db34a Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Thu, 22 Nov 2018 11:31:16 -0500 Subject: Rename literal constructors In a previous patch we replaced some built-in literal constructors (MachInt, MachWord, etc.) with a single LitNumber constructor. In this patch we replace the `Mach` prefix of the remaining constructors with `Lit` for consistency (e.g., LitChar, LitLabel, etc.). Sadly the name `LitString` was already taken for a kind of FastString and it would become misleading to have both `LitStr` (literal constructor renamed after `MachStr`) and `LitString` (FastString variant). Hence this patch renames the FastString variant `PtrString` (which is more accurate) and the literal string constructor now uses the least surprising `LitString` name. Both `Literal` and `LitString/PtrString` have recently seen breaking changes so doing this kind of renaming now shouldn't harm much. Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27, tdammers Subscribers: tdammers, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4881 --- compiler/codeGen/StgCmmCon.hs | 2 +- compiler/codeGen/StgCmmUtils.hs | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'compiler/codeGen') diff --git a/compiler/codeGen/StgCmmCon.hs b/compiler/codeGen/StgCmmCon.hs index a8ec300157..2ddeceb825 100644 --- a/compiler/codeGen/StgCmmCon.hs +++ b/compiler/codeGen/StgCmmCon.hs @@ -214,7 +214,7 @@ buildDynCon' dflags platform binder _ _cc con [arg] buildDynCon' dflags platform binder _ _cc con [arg] | maybeCharLikeCon con , platformOS platform /= OSMinGW32 || not (positionIndependent dflags) - , NonVoid (StgLitArg (MachChar val)) <- arg + , NonVoid (StgLitArg (LitChar val)) <- arg , let val_int = ord val :: Int , val_int <= mAX_CHARLIKE dflags , val_int >= mIN_CHARLIKE dflags diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs index 94e19e47fd..4a6135607e 100644 --- a/compiler/codeGen/StgCmmUtils.hs +++ b/compiler/codeGen/StgCmmUtils.hs @@ -86,27 +86,27 @@ import Data.Word ------------------------------------------------------------------------- cgLit :: Literal -> FCode CmmLit -cgLit (MachStr s) = newByteStringCLit (BS.unpack s) +cgLit (LitString s) = newByteStringCLit (BS.unpack s) -- not unpackFS; we want the UTF-8 byte stream. -cgLit other_lit = do dflags <- getDynFlags - return (mkSimpleLit dflags other_lit) +cgLit other_lit = do dflags <- getDynFlags + return (mkSimpleLit dflags other_lit) mkSimpleLit :: DynFlags -> Literal -> CmmLit -mkSimpleLit dflags (MachChar c) = CmmInt (fromIntegral (ord c)) (wordWidth dflags) -mkSimpleLit dflags MachNullAddr = zeroCLit dflags +mkSimpleLit dflags (LitChar c) = CmmInt (fromIntegral (ord c)) + (wordWidth dflags) +mkSimpleLit dflags LitNullAddr = zeroCLit dflags mkSimpleLit dflags (LitNumber LitNumInt i _) = CmmInt i (wordWidth dflags) mkSimpleLit _ (LitNumber LitNumInt64 i _) = CmmInt i W64 mkSimpleLit dflags (LitNumber LitNumWord i _) = CmmInt i (wordWidth dflags) mkSimpleLit _ (LitNumber LitNumWord64 i _) = CmmInt i W64 -mkSimpleLit _ (MachFloat r) = CmmFloat r W32 -mkSimpleLit _ (MachDouble r) = CmmFloat r W64 -mkSimpleLit _ (MachLabel fs ms fod) - = CmmLabel (mkForeignLabel fs ms labelSrc fod) - where - -- TODO: Literal labels might not actually be in the current package... - labelSrc = ForeignLabelInThisPackage --- NB: RubbishLit should have been lowered in "CoreToStg" -mkSimpleLit _ other = pprPanic "mkSimpleLit" (ppr other) +mkSimpleLit _ (LitFloat r) = CmmFloat r W32 +mkSimpleLit _ (LitDouble r) = CmmFloat r W64 +mkSimpleLit _ (LitLabel fs ms fod) + = let -- TODO: Literal labels might not actually be in the current package... + labelSrc = ForeignLabelInThisPackage + in CmmLabel (mkForeignLabel fs ms labelSrc fod) +-- NB: LitRubbish should have been lowered in "CoreToStg" +mkSimpleLit _ other = pprPanic "mkSimpleLit" (ppr other) -------------------------------------------------------------------------- -- -- cgit v1.2.1