{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
module GHC.Toolchain.Target where
import GHC.Platform.ArchOS
import GHC.Toolchain.Prelude
import GHC.Toolchain.Program
import GHC.Toolchain.Tools.Cc
import GHC.Toolchain.Tools.Cxx
import GHC.Toolchain.Tools.Cpp
import GHC.Toolchain.Tools.Ar
import GHC.Toolchain.Tools.Ranlib
import GHC.Toolchain.Tools.Link
import GHC.Toolchain.Tools.Nm
import GHC.Toolchain.Tools.MergeObjs
data WordSize = WS4 | WS8
deriving (Int -> WordSize -> ShowS
[WordSize] -> ShowS
WordSize -> [Char]
(Int -> WordSize -> ShowS)
-> (WordSize -> [Char]) -> ([WordSize] -> ShowS) -> Show WordSize
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WordSize -> ShowS
showsPrec :: Int -> WordSize -> ShowS
$cshow :: WordSize -> [Char]
show :: WordSize -> [Char]
$cshowList :: [WordSize] -> ShowS
showList :: [WordSize] -> ShowS
Show, ReadPrec [WordSize]
ReadPrec WordSize
Int -> ReadS WordSize
ReadS [WordSize]
(Int -> ReadS WordSize)
-> ReadS [WordSize]
-> ReadPrec WordSize
-> ReadPrec [WordSize]
-> Read WordSize
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS WordSize
readsPrec :: Int -> ReadS WordSize
$creadList :: ReadS [WordSize]
readList :: ReadS [WordSize]
$creadPrec :: ReadPrec WordSize
readPrec :: ReadPrec WordSize
$creadListPrec :: ReadPrec [WordSize]
readListPrec :: ReadPrec [WordSize]
Read, WordSize -> WordSize -> Bool
(WordSize -> WordSize -> Bool)
-> (WordSize -> WordSize -> Bool) -> Eq WordSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WordSize -> WordSize -> Bool
== :: WordSize -> WordSize -> Bool
$c/= :: WordSize -> WordSize -> Bool
/= :: WordSize -> WordSize -> Bool
Eq, Eq WordSize
Eq WordSize =>
(WordSize -> WordSize -> Ordering)
-> (WordSize -> WordSize -> Bool)
-> (WordSize -> WordSize -> Bool)
-> (WordSize -> WordSize -> Bool)
-> (WordSize -> WordSize -> Bool)
-> (WordSize -> WordSize -> WordSize)
-> (WordSize -> WordSize -> WordSize)
-> Ord WordSize
WordSize -> WordSize -> Bool
WordSize -> WordSize -> Ordering
WordSize -> WordSize -> WordSize
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: WordSize -> WordSize -> Ordering
compare :: WordSize -> WordSize -> Ordering
$c< :: WordSize -> WordSize -> Bool
< :: WordSize -> WordSize -> Bool
$c<= :: WordSize -> WordSize -> Bool
<= :: WordSize -> WordSize -> Bool
$c> :: WordSize -> WordSize -> Bool
> :: WordSize -> WordSize -> Bool
$c>= :: WordSize -> WordSize -> Bool
>= :: WordSize -> WordSize -> Bool
$cmax :: WordSize -> WordSize -> WordSize
max :: WordSize -> WordSize -> WordSize
$cmin :: WordSize -> WordSize -> WordSize
min :: WordSize -> WordSize -> WordSize
Ord)
data Endianness = LittleEndian | BigEndian
deriving (Int -> Endianness -> ShowS
[Endianness] -> ShowS
Endianness -> [Char]
(Int -> Endianness -> ShowS)
-> (Endianness -> [Char])
-> ([Endianness] -> ShowS)
-> Show Endianness
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Endianness -> ShowS
showsPrec :: Int -> Endianness -> ShowS
$cshow :: Endianness -> [Char]
show :: Endianness -> [Char]
$cshowList :: [Endianness] -> ShowS
showList :: [Endianness] -> ShowS
Show, ReadPrec [Endianness]
ReadPrec Endianness
Int -> ReadS Endianness
ReadS [Endianness]
(Int -> ReadS Endianness)
-> ReadS [Endianness]
-> ReadPrec Endianness
-> ReadPrec [Endianness]
-> Read Endianness
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Endianness
readsPrec :: Int -> ReadS Endianness
$creadList :: ReadS [Endianness]
readList :: ReadS [Endianness]
$creadPrec :: ReadPrec Endianness
readPrec :: ReadPrec Endianness
$creadListPrec :: ReadPrec [Endianness]
readListPrec :: ReadPrec [Endianness]
Read, Endianness -> Endianness -> Bool
(Endianness -> Endianness -> Bool)
-> (Endianness -> Endianness -> Bool) -> Eq Endianness
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Endianness -> Endianness -> Bool
== :: Endianness -> Endianness -> Bool
$c/= :: Endianness -> Endianness -> Bool
/= :: Endianness -> Endianness -> Bool
Eq, Eq Endianness
Eq Endianness =>
(Endianness -> Endianness -> Ordering)
-> (Endianness -> Endianness -> Bool)
-> (Endianness -> Endianness -> Bool)
-> (Endianness -> Endianness -> Bool)
-> (Endianness -> Endianness -> Bool)
-> (Endianness -> Endianness -> Endianness)
-> (Endianness -> Endianness -> Endianness)
-> Ord Endianness
Endianness -> Endianness -> Bool
Endianness -> Endianness -> Ordering
Endianness -> Endianness -> Endianness
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Endianness -> Endianness -> Ordering
compare :: Endianness -> Endianness -> Ordering
$c< :: Endianness -> Endianness -> Bool
< :: Endianness -> Endianness -> Bool
$c<= :: Endianness -> Endianness -> Bool
<= :: Endianness -> Endianness -> Bool
$c> :: Endianness -> Endianness -> Bool
> :: Endianness -> Endianness -> Bool
$c>= :: Endianness -> Endianness -> Bool
>= :: Endianness -> Endianness -> Bool
$cmax :: Endianness -> Endianness -> Endianness
max :: Endianness -> Endianness -> Endianness
$cmin :: Endianness -> Endianness -> Endianness
min :: Endianness -> Endianness -> Endianness
Ord)
data Target = Target
{
Target -> ArchOS
tgtArchOs :: ArchOS
, Target -> Maybe [Char]
tgtVendor :: Maybe String
, Target -> Bool
tgtLocallyExecutable :: Bool
, Target -> Bool
tgtSupportsGnuNonexecStack :: Bool
, Target -> Bool
tgtSupportsSubsectionsViaSymbols :: Bool
, Target -> Bool
tgtSupportsIdentDirective :: Bool
, Target -> WordSize
tgtWordSize :: WordSize
, Target -> Endianness
tgtEndianness :: Endianness
, Target -> Bool
tgtSymbolsHaveLeadingUnderscore :: Bool
, Target -> [Char]
tgtLlvmTarget :: String
, Target -> Bool
tgtUnregisterised :: Bool
, Target -> Bool
tgtTablesNextToCode :: Bool
, Target -> Bool
tgtUseLibffiForAdjustors :: Bool
, Target -> Cc
tgtCCompiler :: Cc
, Target -> Cxx
tgtCxxCompiler :: Cxx
, Target -> Cpp
tgtCPreprocessor :: Cpp
, Target -> HsCpp
tgtHsCPreprocessor :: HsCpp
, Target -> Maybe JsCpp
tgtJsCPreprocessor :: Maybe JsCpp
, Target -> CmmCpp
tgtCmmCPreprocessor :: CmmCpp
, Target -> CcLink
tgtCCompilerLink :: CcLink
, Target -> Ar
tgtAr :: Ar
, Target -> Maybe Ranlib
tgtRanlib :: Maybe Ranlib
, Target -> Nm
tgtNm :: Nm
, Target -> Maybe MergeObjs
tgtMergeObjs :: Maybe MergeObjs
, Target -> Maybe Program
tgtLlc :: Maybe Program
, Target -> Maybe Program
tgtOpt :: Maybe Program
, Target -> Maybe Program
tgtLlvmAs :: Maybe Program
, Target -> Maybe Program
tgtWindres :: Maybe Program
, Target -> Maybe Program
tgtOtool :: Maybe Program
, Target -> Maybe Program
tgtInstallNameTool :: Maybe Program
}
deriving (ReadPrec [Target]
ReadPrec Target
Int -> ReadS Target
ReadS [Target]
(Int -> ReadS Target)
-> ReadS [Target]
-> ReadPrec Target
-> ReadPrec [Target]
-> Read Target
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Target
readsPrec :: Int -> ReadS Target
$creadList :: ReadS [Target]
readList :: ReadS [Target]
$creadPrec :: ReadPrec Target
readPrec :: ReadPrec Target
$creadListPrec :: ReadPrec [Target]
readListPrec :: ReadPrec [Target]
Read, Target -> Target -> Bool
(Target -> Target -> Bool)
-> (Target -> Target -> Bool) -> Eq Target
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Target -> Target -> Bool
== :: Target -> Target -> Bool
$c/= :: Target -> Target -> Bool
/= :: Target -> Target -> Bool
Eq, Eq Target
Eq Target =>
(Target -> Target -> Ordering)
-> (Target -> Target -> Bool)
-> (Target -> Target -> Bool)
-> (Target -> Target -> Bool)
-> (Target -> Target -> Bool)
-> (Target -> Target -> Target)
-> (Target -> Target -> Target)
-> Ord Target
Target -> Target -> Bool
Target -> Target -> Ordering
Target -> Target -> Target
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Target -> Target -> Ordering
compare :: Target -> Target -> Ordering
$c< :: Target -> Target -> Bool
< :: Target -> Target -> Bool
$c<= :: Target -> Target -> Bool
<= :: Target -> Target -> Bool
$c> :: Target -> Target -> Bool
> :: Target -> Target -> Bool
$c>= :: Target -> Target -> Bool
>= :: Target -> Target -> Bool
$cmax :: Target -> Target -> Target
max :: Target -> Target -> Target
$cmin :: Target -> Target -> Target
min :: Target -> Target -> Target
Ord)
wordSize2Bytes :: WordSize -> Int
wordSize2Bytes :: WordSize -> Int
wordSize2Bytes WordSize
WS4 = Int
4
wordSize2Bytes WordSize
WS8 = Int
8
targetPlatformTriple :: Target -> String
targetPlatformTriple :: Target -> [Char]
targetPlatformTriple Target{ArchOS
tgtArchOs :: Target -> ArchOS
tgtArchOs :: ArchOS
tgtArchOs, Maybe [Char]
tgtVendor :: Target -> Maybe [Char]
tgtVendor :: Maybe [Char]
tgtVendor} =
let archStr :: [Char]
archStr = Arch -> [Char]
stringEncodeArch (Arch -> [Char]) -> Arch -> [Char]
forall a b. (a -> b) -> a -> b
$ ArchOS -> Arch
archOS_arch ArchOS
tgtArchOs
osStr :: [Char]
osStr = OS -> [Char]
stringEncodeOS (OS -> [Char]) -> OS -> [Char]
forall a b. (a -> b) -> a -> b
$ ArchOS -> OS
archOS_OS ArchOS
tgtArchOs
in case Maybe [Char]
tgtVendor of
Maybe [Char]
Nothing -> [Char]
archStr [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
"-" [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
osStr
Just [Char]
vendor -> [Char]
archStr [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
"-" [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
vendor [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
"-" [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char]
osStr
instance Show Target where
show :: Target -> [Char]
show Target{Bool
[Char]
Maybe [Char]
Maybe Program
Maybe Ranlib
Maybe MergeObjs
Maybe JsCpp
ArchOS
Nm
Cxx
Cc
CcLink
CmmCpp
HsCpp
Cpp
Ar
Endianness
WordSize
tgtArchOs :: Target -> ArchOS
tgtVendor :: Target -> Maybe [Char]
tgtLocallyExecutable :: Target -> Bool
tgtSupportsGnuNonexecStack :: Target -> Bool
tgtSupportsSubsectionsViaSymbols :: Target -> Bool
tgtSupportsIdentDirective :: Target -> Bool
tgtWordSize :: Target -> WordSize
tgtEndianness :: Target -> Endianness
tgtSymbolsHaveLeadingUnderscore :: Target -> Bool
tgtLlvmTarget :: Target -> [Char]
tgtUnregisterised :: Target -> Bool
tgtTablesNextToCode :: Target -> Bool
tgtUseLibffiForAdjustors :: Target -> Bool
tgtCCompiler :: Target -> Cc
tgtCxxCompiler :: Target -> Cxx
tgtCPreprocessor :: Target -> Cpp
tgtHsCPreprocessor :: Target -> HsCpp
tgtJsCPreprocessor :: Target -> Maybe JsCpp
tgtCmmCPreprocessor :: Target -> CmmCpp
tgtCCompilerLink :: Target -> CcLink
tgtAr :: Target -> Ar
tgtRanlib :: Target -> Maybe Ranlib
tgtNm :: Target -> Nm
tgtMergeObjs :: Target -> Maybe MergeObjs
tgtLlc :: Target -> Maybe Program
tgtOpt :: Target -> Maybe Program
tgtLlvmAs :: Target -> Maybe Program
tgtWindres :: Target -> Maybe Program
tgtOtool :: Target -> Maybe Program
tgtInstallNameTool :: Target -> Maybe Program
tgtArchOs :: ArchOS
tgtVendor :: Maybe [Char]
tgtLocallyExecutable :: Bool
tgtSupportsGnuNonexecStack :: Bool
tgtSupportsSubsectionsViaSymbols :: Bool
tgtSupportsIdentDirective :: Bool
tgtWordSize :: WordSize
tgtEndianness :: Endianness
tgtSymbolsHaveLeadingUnderscore :: Bool
tgtLlvmTarget :: [Char]
tgtUnregisterised :: Bool
tgtTablesNextToCode :: Bool
tgtUseLibffiForAdjustors :: Bool
tgtCCompiler :: Cc
tgtCxxCompiler :: Cxx
tgtCPreprocessor :: Cpp
tgtHsCPreprocessor :: HsCpp
tgtJsCPreprocessor :: Maybe JsCpp
tgtCmmCPreprocessor :: CmmCpp
tgtCCompilerLink :: CcLink
tgtAr :: Ar
tgtRanlib :: Maybe Ranlib
tgtNm :: Nm
tgtMergeObjs :: Maybe MergeObjs
tgtLlc :: Maybe Program
tgtOpt :: Maybe Program
tgtLlvmAs :: Maybe Program
tgtWindres :: Maybe Program
tgtOtool :: Maybe Program
tgtInstallNameTool :: Maybe Program
..} = [[Char]] -> [Char]
unlines
[ [Char]
"Target"
, [Char]
"{ tgtArchOs = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ ArchOS -> [Char]
forall a. Show a => a -> [Char]
show ArchOS
tgtArchOs
, [Char]
", tgtVendor = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe [Char] -> [Char]
forall a. Show a => a -> [Char]
show Maybe [Char]
tgtVendor
, [Char]
", tgtLocallyExecutable = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtLocallyExecutable
, [Char]
", tgtSupportsGnuNonexecStack = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtSupportsGnuNonexecStack
, [Char]
", tgtSupportsSubsectionsViaSymbols = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtSupportsSubsectionsViaSymbols
, [Char]
", tgtSupportsIdentDirective = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtSupportsIdentDirective
, [Char]
", tgtWordSize = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ WordSize -> [Char]
forall a. Show a => a -> [Char]
show WordSize
tgtWordSize
, [Char]
", tgtEndianness = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Endianness -> [Char]
forall a. Show a => a -> [Char]
show Endianness
tgtEndianness
, [Char]
", tgtSymbolsHaveLeadingUnderscore = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtSymbolsHaveLeadingUnderscore
, [Char]
", tgtLlvmTarget = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> [Char]
show [Char]
tgtLlvmTarget
, [Char]
", tgtUnregisterised = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtUnregisterised
, [Char]
", tgtTablesNextToCode = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtTablesNextToCode
, [Char]
", tgtUseLibffiForAdjustors = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
tgtUseLibffiForAdjustors
, [Char]
", tgtCCompiler = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Cc -> [Char]
forall a. Show a => a -> [Char]
show Cc
tgtCCompiler
, [Char]
", tgtCxxCompiler = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Cxx -> [Char]
forall a. Show a => a -> [Char]
show Cxx
tgtCxxCompiler
, [Char]
", tgtCPreprocessor = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Cpp -> [Char]
forall a. Show a => a -> [Char]
show Cpp
tgtCPreprocessor
, [Char]
", tgtHsCPreprocessor = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ HsCpp -> [Char]
forall a. Show a => a -> [Char]
show HsCpp
tgtHsCPreprocessor
, [Char]
", tgtJsCPreprocessor = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe JsCpp -> [Char]
forall a. Show a => a -> [Char]
show Maybe JsCpp
tgtJsCPreprocessor
, [Char]
", tgtCmmCPreprocessor = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ CmmCpp -> [Char]
forall a. Show a => a -> [Char]
show CmmCpp
tgtCmmCPreprocessor
, [Char]
", tgtCCompilerLink = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ CcLink -> [Char]
forall a. Show a => a -> [Char]
show CcLink
tgtCCompilerLink
, [Char]
", tgtAr = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Ar -> [Char]
forall a. Show a => a -> [Char]
show Ar
tgtAr
, [Char]
", tgtRanlib = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Ranlib -> [Char]
forall a. Show a => a -> [Char]
show Maybe Ranlib
tgtRanlib
, [Char]
", tgtNm = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Nm -> [Char]
forall a. Show a => a -> [Char]
show Nm
tgtNm
, [Char]
", tgtMergeObjs = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe MergeObjs -> [Char]
forall a. Show a => a -> [Char]
show Maybe MergeObjs
tgtMergeObjs
, [Char]
", tgtLlc = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtLlc
, [Char]
", tgtOpt = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtOpt
, [Char]
", tgtLlvmAs = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtLlvmAs
, [Char]
", tgtWindres = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtWindres
, [Char]
", tgtOtool = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtOtool
, [Char]
", tgtInstallNameTool = " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Program -> [Char]
forall a. Show a => a -> [Char]
show Maybe Program
tgtInstallNameTool
, [Char]
"}"
]