summaryrefslogtreecommitdiff
path: root/compiler/utils/AsmUtils.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-07-11 15:41:55 -0400
committerBen Gamari <ben@smart-cactus.org>2017-07-11 16:32:43 -0400
commit9b9f978fdcd13ff7b2a9b7391e02dff06da622a0 (patch)
tree23221a07613b0866727026b201778eb5bc3d08b4 /compiler/utils/AsmUtils.hs
parent4befb415d7ee63d2b0ecdc2384310dc4b3ccc90a (diff)
downloadhaskell-9b9f978fdcd13ff7b2a9b7391e02dff06da622a0.tar.gz
Use correct section types syntax for architecture
Previously GHC would always assume that section types began with `@` while producing assembly, which is not true. For instance, in ARM assembly syntax section types begin with `%`. This abstracts out section type pretty-printing and adjusts it to correctly account for the target architectures assembly flavor. Reviewers: austin, hvr, Phyx Reviewed By: Phyx Subscribers: Phyx, rwbarton, thomie, erikd GHC Trac Issues: #13937 Differential Revision: https://phabricator.haskell.org/D3712
Diffstat (limited to 'compiler/utils/AsmUtils.hs')
-rw-r--r--compiler/utils/AsmUtils.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/utils/AsmUtils.hs b/compiler/utils/AsmUtils.hs
new file mode 100644
index 0000000000..55f9d6d551
--- /dev/null
+++ b/compiler/utils/AsmUtils.hs
@@ -0,0 +1,18 @@
+-- | Various utilities used in generating assembler.
+--
+-- These are used not only by the native code generator, but also by the
+-- "DriverPipeline".
+module AsmUtils
+ ( sectionType
+ ) where
+
+import Platform
+import Outputable
+
+-- | Generate a section type (e.g. @\@progbits@). See #13937.
+sectionType :: String -- ^ section type
+ -> SDoc -- ^ pretty assembler fragment
+sectionType ty = sdocWithPlatform $ \platform ->
+ case platformArch platform of
+ ArchARM{} -> char '%' <> text ty
+ _ -> char '@' <> text ty