-- | Various utilities used in generating assembler.
--
-- These are used not only by the native code generator, but also by the
-- "GHC.Driver.Pipeline"
module GHC.Utils.Asm
    ( sectionType
    ) where

import GHC.Prelude

import GHC.Platform
import GHC.Utils.Outputable

-- | Generate a section type (e.g. @\@progbits@). See #13937.
sectionType :: Platform -- ^ Target platform
            -> String   -- ^ section type
            -> SDoc     -- ^ pretty assembler fragment
sectionType :: Platform -> String -> SDoc
sectionType Platform
platform String
ty =
    case Platform -> Arch
platformArch Platform
platform of
      ArchARM{} -> Char -> SDoc
char Char
'%' SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
ty
      Arch
_         -> Char -> SDoc
char Char
'@' SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
ty