[commit: ghc] master: llvmGen: Consolidate MetaExpr pretty-printing (85e09b1)
git at git.haskell.org
git at git.haskell.org
Sat Jun 18 10:39:27 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/85e09b1b621840fd923971d48df62b99580be618/ghc
>---------------------------------------------------------------
commit 85e09b1b621840fd923971d48df62b99580be618
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri Jun 17 23:52:39 2016 +0200
llvmGen: Consolidate MetaExpr pretty-printing
Previously this logic was duplicated needlessly.
>---------------------------------------------------------------
85e09b1b621840fd923971d48df62b99580be618
compiler/llvmGen/Llvm/MetaData.hs | 5 +++--
compiler/llvmGen/Llvm/PpLlvm.hs | 13 ++-----------
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/compiler/llvmGen/Llvm/MetaData.hs b/compiler/llvmGen/Llvm/MetaData.hs
index a50553c..3bdcd60 100644
--- a/compiler/llvmGen/Llvm/MetaData.hs
+++ b/compiler/llvmGen/Llvm/MetaData.hs
@@ -72,10 +72,11 @@ data MetaExpr = MetaStr LMString
deriving (Eq)
instance Outputable MetaExpr where
- ppr (MetaStr s ) = text "!\"" <> ftext s <> char '"'
+ ppr (MetaVar (LMLitVar (LMNullLit _))) = text "null"
+ ppr (MetaStr s ) = char '!' <> doubleQuotes (ftext s)
ppr (MetaNode n ) = ppr n
ppr (MetaVar v ) = ppr v
- ppr (MetaStruct es) = text "!{ " <> ppCommaJoin es <> char '}'
+ ppr (MetaStruct es) = char '!' <> braces (ppCommaJoin es)
-- | Associates some metadata with a specific label for attaching to an
-- instruction.
diff --git a/compiler/llvmGen/Llvm/PpLlvm.hs b/compiler/llvmGen/Llvm/PpLlvm.hs
index d92e3c0..47e26ab 100644
--- a/compiler/llvmGen/Llvm/PpLlvm.hs
+++ b/compiler/llvmGen/Llvm/PpLlvm.hs
@@ -107,22 +107,13 @@ ppLlvmMetas metas = vcat $ map ppLlvmMeta metas
-- | Print out an LLVM metadata definition.
ppLlvmMeta :: MetaDecl -> SDoc
ppLlvmMeta (MetaUnnamed n m)
- = ppr n <> text " = " <> ppLlvmMetaExpr m
+ = ppr n <+> equals <+> ppr m
ppLlvmMeta (MetaNamed n m)
- = exclamation <> ftext n <> text " = !" <> braces nodes
+ = exclamation <> ftext n <+> equals <+> exclamation <> braces nodes
where
nodes = hcat $ intersperse comma $ map ppr m
--- | Print out an LLVM metadata value.
-ppLlvmMetaExpr :: MetaExpr -> SDoc
-ppLlvmMetaExpr (MetaVar (LMLitVar (LMNullLit _))) = text "null"
-ppLlvmMetaExpr (MetaStr s ) = text "!" <> doubleQuotes (ftext s)
-ppLlvmMetaExpr (MetaNode n ) = ppr n
-ppLlvmMetaExpr (MetaVar v ) = ppr v
-ppLlvmMetaExpr (MetaStruct es) =
- text "!{" <> hsep (punctuate comma (map ppLlvmMetaExpr es)) <> char '}'
-
-- | Print out a list of function definitions.
ppLlvmFunctions :: LlvmFunctions -> SDoc
More information about the ghc-commits
mailing list