summaryrefslogtreecommitdiff
path: root/compiler/utils/AsmUtils.hs
blob: 591b53dc318f43e9f435a8ccfe9af85559aa2140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- | Various utilities used in generating assembler.
--
-- These are used not only by the native code generator, but also by the
-- GHC.Driver.Pipeline
module AsmUtils
    ( sectionType
    ) where

import GhcPrelude

import GHC.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