{-# LANGUAGE LambdaCase, ScopedTypeVariables #-}

-- | Platform architecture and OS
--
-- We need it in ghc-boot because ghc-pkg needs it.
module GHC.Platform.ArchOS
   ( ArchOS(..)
   , Arch(..)
   , OS(..)
   , ArmISA(..)
   , ArmISAExt(..)
   , ArmABI(..)
   , PPC_64ABI(..)
   , stringEncodeArch
   , stringEncodeOS
   )
where

import Prelude -- See Note [Why do we import Prelude here?]

-- | Platform architecture and OS.
data ArchOS
   = ArchOS
      { ArchOS -> Arch
archOS_arch :: Arch
      , ArchOS -> OS
archOS_OS   :: OS
      }
   deriving (ReadPrec [ArchOS]
ReadPrec ArchOS
Int -> ReadS ArchOS
ReadS [ArchOS]
(Int -> ReadS ArchOS)
-> ReadS [ArchOS]
-> ReadPrec ArchOS
-> ReadPrec [ArchOS]
-> Read ArchOS
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ArchOS
readsPrec :: Int -> ReadS ArchOS
$creadList :: ReadS [ArchOS]
readList :: ReadS [ArchOS]
$creadPrec :: ReadPrec ArchOS
readPrec :: ReadPrec ArchOS
$creadListPrec :: ReadPrec [ArchOS]
readListPrec :: ReadPrec [ArchOS]
Read, Int -> ArchOS -> ShowS
[ArchOS] -> ShowS
ArchOS -> String
(Int -> ArchOS -> ShowS)
-> (ArchOS -> String) -> ([ArchOS] -> ShowS) -> Show ArchOS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArchOS -> ShowS
showsPrec :: Int -> ArchOS -> ShowS
$cshow :: ArchOS -> String
show :: ArchOS -> String
$cshowList :: [ArchOS] -> ShowS
showList :: [ArchOS] -> ShowS
Show, ArchOS -> ArchOS -> Bool
(ArchOS -> ArchOS -> Bool)
-> (ArchOS -> ArchOS -> Bool) -> Eq ArchOS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArchOS -> ArchOS -> Bool
== :: ArchOS -> ArchOS -> Bool
$c/= :: ArchOS -> ArchOS -> Bool
/= :: ArchOS -> ArchOS -> Bool
Eq, Eq ArchOS
Eq ArchOS =>
(ArchOS -> ArchOS -> Ordering)
-> (ArchOS -> ArchOS -> Bool)
-> (ArchOS -> ArchOS -> Bool)
-> (ArchOS -> ArchOS -> Bool)
-> (ArchOS -> ArchOS -> Bool)
-> (ArchOS -> ArchOS -> ArchOS)
-> (ArchOS -> ArchOS -> ArchOS)
-> Ord ArchOS
ArchOS -> ArchOS -> Bool
ArchOS -> ArchOS -> Ordering
ArchOS -> ArchOS -> ArchOS
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 :: ArchOS -> ArchOS -> Ordering
compare :: ArchOS -> ArchOS -> Ordering
$c< :: ArchOS -> ArchOS -> Bool
< :: ArchOS -> ArchOS -> Bool
$c<= :: ArchOS -> ArchOS -> Bool
<= :: ArchOS -> ArchOS -> Bool
$c> :: ArchOS -> ArchOS -> Bool
> :: ArchOS -> ArchOS -> Bool
$c>= :: ArchOS -> ArchOS -> Bool
>= :: ArchOS -> ArchOS -> Bool
$cmax :: ArchOS -> ArchOS -> ArchOS
max :: ArchOS -> ArchOS -> ArchOS
$cmin :: ArchOS -> ArchOS -> ArchOS
min :: ArchOS -> ArchOS -> ArchOS
Ord)

-- | Architectures
--
-- TODO: It might be nice to extend these constructors with information about
-- what instruction set extensions an architecture might support.
--
data Arch
   = ArchUnknown
   | ArchX86
   | ArchX86_64
   | ArchPPC
   | ArchPPC_64 PPC_64ABI
   | ArchS390X
   | ArchARM ArmISA [ArmISAExt] ArmABI
   | ArchAArch64
   | ArchAlpha
   | ArchMipseb
   | ArchMipsel
   | ArchRISCV64
   | ArchLoongArch64
   | ArchJavaScript
   | ArchWasm32
   deriving (ReadPrec [Arch]
ReadPrec Arch
Int -> ReadS Arch
ReadS [Arch]
(Int -> ReadS Arch)
-> ReadS [Arch] -> ReadPrec Arch -> ReadPrec [Arch] -> Read Arch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Arch
readsPrec :: Int -> ReadS Arch
$creadList :: ReadS [Arch]
readList :: ReadS [Arch]
$creadPrec :: ReadPrec Arch
readPrec :: ReadPrec Arch
$creadListPrec :: ReadPrec [Arch]
readListPrec :: ReadPrec [Arch]
Read, Int -> Arch -> ShowS
[Arch] -> ShowS
Arch -> String
(Int -> Arch -> ShowS)
-> (Arch -> String) -> ([Arch] -> ShowS) -> Show Arch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Arch -> ShowS
showsPrec :: Int -> Arch -> ShowS
$cshow :: Arch -> String
show :: Arch -> String
$cshowList :: [Arch] -> ShowS
showList :: [Arch] -> ShowS
Show, Arch -> Arch -> Bool
(Arch -> Arch -> Bool) -> (Arch -> Arch -> Bool) -> Eq Arch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Arch -> Arch -> Bool
== :: Arch -> Arch -> Bool
$c/= :: Arch -> Arch -> Bool
/= :: Arch -> Arch -> Bool
Eq, Eq Arch
Eq Arch =>
(Arch -> Arch -> Ordering)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Arch)
-> (Arch -> Arch -> Arch)
-> Ord Arch
Arch -> Arch -> Bool
Arch -> Arch -> Ordering
Arch -> Arch -> Arch
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 :: Arch -> Arch -> Ordering
compare :: Arch -> Arch -> Ordering
$c< :: Arch -> Arch -> Bool
< :: Arch -> Arch -> Bool
$c<= :: Arch -> Arch -> Bool
<= :: Arch -> Arch -> Bool
$c> :: Arch -> Arch -> Bool
> :: Arch -> Arch -> Bool
$c>= :: Arch -> Arch -> Bool
>= :: Arch -> Arch -> Bool
$cmax :: Arch -> Arch -> Arch
max :: Arch -> Arch -> Arch
$cmin :: Arch -> Arch -> Arch
min :: Arch -> Arch -> Arch
Ord)

-- | ARM Instruction Set Architecture
data ArmISA
   = ARMv5
   | ARMv6
   | ARMv7
   deriving (ReadPrec [ArmISA]
ReadPrec ArmISA
Int -> ReadS ArmISA
ReadS [ArmISA]
(Int -> ReadS ArmISA)
-> ReadS [ArmISA]
-> ReadPrec ArmISA
-> ReadPrec [ArmISA]
-> Read ArmISA
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ArmISA
readsPrec :: Int -> ReadS ArmISA
$creadList :: ReadS [ArmISA]
readList :: ReadS [ArmISA]
$creadPrec :: ReadPrec ArmISA
readPrec :: ReadPrec ArmISA
$creadListPrec :: ReadPrec [ArmISA]
readListPrec :: ReadPrec [ArmISA]
Read, Int -> ArmISA -> ShowS
[ArmISA] -> ShowS
ArmISA -> String
(Int -> ArmISA -> ShowS)
-> (ArmISA -> String) -> ([ArmISA] -> ShowS) -> Show ArmISA
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArmISA -> ShowS
showsPrec :: Int -> ArmISA -> ShowS
$cshow :: ArmISA -> String
show :: ArmISA -> String
$cshowList :: [ArmISA] -> ShowS
showList :: [ArmISA] -> ShowS
Show, ArmISA -> ArmISA -> Bool
(ArmISA -> ArmISA -> Bool)
-> (ArmISA -> ArmISA -> Bool) -> Eq ArmISA
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArmISA -> ArmISA -> Bool
== :: ArmISA -> ArmISA -> Bool
$c/= :: ArmISA -> ArmISA -> Bool
/= :: ArmISA -> ArmISA -> Bool
Eq, Eq ArmISA
Eq ArmISA =>
(ArmISA -> ArmISA -> Ordering)
-> (ArmISA -> ArmISA -> Bool)
-> (ArmISA -> ArmISA -> Bool)
-> (ArmISA -> ArmISA -> Bool)
-> (ArmISA -> ArmISA -> Bool)
-> (ArmISA -> ArmISA -> ArmISA)
-> (ArmISA -> ArmISA -> ArmISA)
-> Ord ArmISA
ArmISA -> ArmISA -> Bool
ArmISA -> ArmISA -> Ordering
ArmISA -> ArmISA -> ArmISA
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 :: ArmISA -> ArmISA -> Ordering
compare :: ArmISA -> ArmISA -> Ordering
$c< :: ArmISA -> ArmISA -> Bool
< :: ArmISA -> ArmISA -> Bool
$c<= :: ArmISA -> ArmISA -> Bool
<= :: ArmISA -> ArmISA -> Bool
$c> :: ArmISA -> ArmISA -> Bool
> :: ArmISA -> ArmISA -> Bool
$c>= :: ArmISA -> ArmISA -> Bool
>= :: ArmISA -> ArmISA -> Bool
$cmax :: ArmISA -> ArmISA -> ArmISA
max :: ArmISA -> ArmISA -> ArmISA
$cmin :: ArmISA -> ArmISA -> ArmISA
min :: ArmISA -> ArmISA -> ArmISA
Ord)

-- | ARM extensions
data ArmISAExt
   = VFPv2
   | VFPv3
   | VFPv3D16
   | NEON
   | IWMMX2
   deriving (ReadPrec [ArmISAExt]
ReadPrec ArmISAExt
Int -> ReadS ArmISAExt
ReadS [ArmISAExt]
(Int -> ReadS ArmISAExt)
-> ReadS [ArmISAExt]
-> ReadPrec ArmISAExt
-> ReadPrec [ArmISAExt]
-> Read ArmISAExt
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ArmISAExt
readsPrec :: Int -> ReadS ArmISAExt
$creadList :: ReadS [ArmISAExt]
readList :: ReadS [ArmISAExt]
$creadPrec :: ReadPrec ArmISAExt
readPrec :: ReadPrec ArmISAExt
$creadListPrec :: ReadPrec [ArmISAExt]
readListPrec :: ReadPrec [ArmISAExt]
Read, Int -> ArmISAExt -> ShowS
[ArmISAExt] -> ShowS
ArmISAExt -> String
(Int -> ArmISAExt -> ShowS)
-> (ArmISAExt -> String)
-> ([ArmISAExt] -> ShowS)
-> Show ArmISAExt
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArmISAExt -> ShowS
showsPrec :: Int -> ArmISAExt -> ShowS
$cshow :: ArmISAExt -> String
show :: ArmISAExt -> String
$cshowList :: [ArmISAExt] -> ShowS
showList :: [ArmISAExt] -> ShowS
Show, ArmISAExt -> ArmISAExt -> Bool
(ArmISAExt -> ArmISAExt -> Bool)
-> (ArmISAExt -> ArmISAExt -> Bool) -> Eq ArmISAExt
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArmISAExt -> ArmISAExt -> Bool
== :: ArmISAExt -> ArmISAExt -> Bool
$c/= :: ArmISAExt -> ArmISAExt -> Bool
/= :: ArmISAExt -> ArmISAExt -> Bool
Eq, Eq ArmISAExt
Eq ArmISAExt =>
(ArmISAExt -> ArmISAExt -> Ordering)
-> (ArmISAExt -> ArmISAExt -> Bool)
-> (ArmISAExt -> ArmISAExt -> Bool)
-> (ArmISAExt -> ArmISAExt -> Bool)
-> (ArmISAExt -> ArmISAExt -> Bool)
-> (ArmISAExt -> ArmISAExt -> ArmISAExt)
-> (ArmISAExt -> ArmISAExt -> ArmISAExt)
-> Ord ArmISAExt
ArmISAExt -> ArmISAExt -> Bool
ArmISAExt -> ArmISAExt -> Ordering
ArmISAExt -> ArmISAExt -> ArmISAExt
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 :: ArmISAExt -> ArmISAExt -> Ordering
compare :: ArmISAExt -> ArmISAExt -> Ordering
$c< :: ArmISAExt -> ArmISAExt -> Bool
< :: ArmISAExt -> ArmISAExt -> Bool
$c<= :: ArmISAExt -> ArmISAExt -> Bool
<= :: ArmISAExt -> ArmISAExt -> Bool
$c> :: ArmISAExt -> ArmISAExt -> Bool
> :: ArmISAExt -> ArmISAExt -> Bool
$c>= :: ArmISAExt -> ArmISAExt -> Bool
>= :: ArmISAExt -> ArmISAExt -> Bool
$cmax :: ArmISAExt -> ArmISAExt -> ArmISAExt
max :: ArmISAExt -> ArmISAExt -> ArmISAExt
$cmin :: ArmISAExt -> ArmISAExt -> ArmISAExt
min :: ArmISAExt -> ArmISAExt -> ArmISAExt
Ord)

-- | ARM ABI
data ArmABI
   = SOFT
   | SOFTFP
   | HARD
   deriving (ReadPrec [ArmABI]
ReadPrec ArmABI
Int -> ReadS ArmABI
ReadS [ArmABI]
(Int -> ReadS ArmABI)
-> ReadS [ArmABI]
-> ReadPrec ArmABI
-> ReadPrec [ArmABI]
-> Read ArmABI
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ArmABI
readsPrec :: Int -> ReadS ArmABI
$creadList :: ReadS [ArmABI]
readList :: ReadS [ArmABI]
$creadPrec :: ReadPrec ArmABI
readPrec :: ReadPrec ArmABI
$creadListPrec :: ReadPrec [ArmABI]
readListPrec :: ReadPrec [ArmABI]
Read, Int -> ArmABI -> ShowS
[ArmABI] -> ShowS
ArmABI -> String
(Int -> ArmABI -> ShowS)
-> (ArmABI -> String) -> ([ArmABI] -> ShowS) -> Show ArmABI
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArmABI -> ShowS
showsPrec :: Int -> ArmABI -> ShowS
$cshow :: ArmABI -> String
show :: ArmABI -> String
$cshowList :: [ArmABI] -> ShowS
showList :: [ArmABI] -> ShowS
Show, ArmABI -> ArmABI -> Bool
(ArmABI -> ArmABI -> Bool)
-> (ArmABI -> ArmABI -> Bool) -> Eq ArmABI
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArmABI -> ArmABI -> Bool
== :: ArmABI -> ArmABI -> Bool
$c/= :: ArmABI -> ArmABI -> Bool
/= :: ArmABI -> ArmABI -> Bool
Eq, Eq ArmABI
Eq ArmABI =>
(ArmABI -> ArmABI -> Ordering)
-> (ArmABI -> ArmABI -> Bool)
-> (ArmABI -> ArmABI -> Bool)
-> (ArmABI -> ArmABI -> Bool)
-> (ArmABI -> ArmABI -> Bool)
-> (ArmABI -> ArmABI -> ArmABI)
-> (ArmABI -> ArmABI -> ArmABI)
-> Ord ArmABI
ArmABI -> ArmABI -> Bool
ArmABI -> ArmABI -> Ordering
ArmABI -> ArmABI -> ArmABI
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 :: ArmABI -> ArmABI -> Ordering
compare :: ArmABI -> ArmABI -> Ordering
$c< :: ArmABI -> ArmABI -> Bool
< :: ArmABI -> ArmABI -> Bool
$c<= :: ArmABI -> ArmABI -> Bool
<= :: ArmABI -> ArmABI -> Bool
$c> :: ArmABI -> ArmABI -> Bool
> :: ArmABI -> ArmABI -> Bool
$c>= :: ArmABI -> ArmABI -> Bool
>= :: ArmABI -> ArmABI -> Bool
$cmax :: ArmABI -> ArmABI -> ArmABI
max :: ArmABI -> ArmABI -> ArmABI
$cmin :: ArmABI -> ArmABI -> ArmABI
min :: ArmABI -> ArmABI -> ArmABI
Ord)

-- | PowerPC 64-bit ABI
data PPC_64ABI
   = ELF_V1 -- ^ PowerPC64
   | ELF_V2 -- ^ PowerPC64 LE
   deriving (ReadPrec [PPC_64ABI]
ReadPrec PPC_64ABI
Int -> ReadS PPC_64ABI
ReadS [PPC_64ABI]
(Int -> ReadS PPC_64ABI)
-> ReadS [PPC_64ABI]
-> ReadPrec PPC_64ABI
-> ReadPrec [PPC_64ABI]
-> Read PPC_64ABI
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PPC_64ABI
readsPrec :: Int -> ReadS PPC_64ABI
$creadList :: ReadS [PPC_64ABI]
readList :: ReadS [PPC_64ABI]
$creadPrec :: ReadPrec PPC_64ABI
readPrec :: ReadPrec PPC_64ABI
$creadListPrec :: ReadPrec [PPC_64ABI]
readListPrec :: ReadPrec [PPC_64ABI]
Read, Int -> PPC_64ABI -> ShowS
[PPC_64ABI] -> ShowS
PPC_64ABI -> String
(Int -> PPC_64ABI -> ShowS)
-> (PPC_64ABI -> String)
-> ([PPC_64ABI] -> ShowS)
-> Show PPC_64ABI
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PPC_64ABI -> ShowS
showsPrec :: Int -> PPC_64ABI -> ShowS
$cshow :: PPC_64ABI -> String
show :: PPC_64ABI -> String
$cshowList :: [PPC_64ABI] -> ShowS
showList :: [PPC_64ABI] -> ShowS
Show, PPC_64ABI -> PPC_64ABI -> Bool
(PPC_64ABI -> PPC_64ABI -> Bool)
-> (PPC_64ABI -> PPC_64ABI -> Bool) -> Eq PPC_64ABI
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PPC_64ABI -> PPC_64ABI -> Bool
== :: PPC_64ABI -> PPC_64ABI -> Bool
$c/= :: PPC_64ABI -> PPC_64ABI -> Bool
/= :: PPC_64ABI -> PPC_64ABI -> Bool
Eq, Eq PPC_64ABI
Eq PPC_64ABI =>
(PPC_64ABI -> PPC_64ABI -> Ordering)
-> (PPC_64ABI -> PPC_64ABI -> Bool)
-> (PPC_64ABI -> PPC_64ABI -> Bool)
-> (PPC_64ABI -> PPC_64ABI -> Bool)
-> (PPC_64ABI -> PPC_64ABI -> Bool)
-> (PPC_64ABI -> PPC_64ABI -> PPC_64ABI)
-> (PPC_64ABI -> PPC_64ABI -> PPC_64ABI)
-> Ord PPC_64ABI
PPC_64ABI -> PPC_64ABI -> Bool
PPC_64ABI -> PPC_64ABI -> Ordering
PPC_64ABI -> PPC_64ABI -> PPC_64ABI
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 :: PPC_64ABI -> PPC_64ABI -> Ordering
compare :: PPC_64ABI -> PPC_64ABI -> Ordering
$c< :: PPC_64ABI -> PPC_64ABI -> Bool
< :: PPC_64ABI -> PPC_64ABI -> Bool
$c<= :: PPC_64ABI -> PPC_64ABI -> Bool
<= :: PPC_64ABI -> PPC_64ABI -> Bool
$c> :: PPC_64ABI -> PPC_64ABI -> Bool
> :: PPC_64ABI -> PPC_64ABI -> Bool
$c>= :: PPC_64ABI -> PPC_64ABI -> Bool
>= :: PPC_64ABI -> PPC_64ABI -> Bool
$cmax :: PPC_64ABI -> PPC_64ABI -> PPC_64ABI
max :: PPC_64ABI -> PPC_64ABI -> PPC_64ABI
$cmin :: PPC_64ABI -> PPC_64ABI -> PPC_64ABI
min :: PPC_64ABI -> PPC_64ABI -> PPC_64ABI
Ord)

-- | Operating systems.
--
-- Using OSUnknown to generate code should produce a sensible default, but no
-- promises.
data OS
   = OSUnknown
   | OSLinux
   | OSDarwin
   | OSSolaris2
   | OSMinGW32
   | OSFreeBSD
   | OSDragonFly
   | OSOpenBSD
   | OSNetBSD
   | OSKFreeBSD
   | OSHaiku
   | OSQNXNTO
   | OSAIX
   | OSHurd
   | OSWasi
   deriving (ReadPrec [OS]
ReadPrec OS
Int -> ReadS OS
ReadS [OS]
(Int -> ReadS OS)
-> ReadS [OS] -> ReadPrec OS -> ReadPrec [OS] -> Read OS
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS OS
readsPrec :: Int -> ReadS OS
$creadList :: ReadS [OS]
readList :: ReadS [OS]
$creadPrec :: ReadPrec OS
readPrec :: ReadPrec OS
$creadListPrec :: ReadPrec [OS]
readListPrec :: ReadPrec [OS]
Read, Int -> OS -> ShowS
[OS] -> ShowS
OS -> String
(Int -> OS -> ShowS)
-> (OS -> String) -> ([OS] -> ShowS) -> Show OS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OS -> ShowS
showsPrec :: Int -> OS -> ShowS
$cshow :: OS -> String
show :: OS -> String
$cshowList :: [OS] -> ShowS
showList :: [OS] -> ShowS
Show, OS -> OS -> Bool
(OS -> OS -> Bool) -> (OS -> OS -> Bool) -> Eq OS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OS -> OS -> Bool
== :: OS -> OS -> Bool
$c/= :: OS -> OS -> Bool
/= :: OS -> OS -> Bool
Eq, Eq OS
Eq OS =>
(OS -> OS -> Ordering)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> OS)
-> (OS -> OS -> OS)
-> Ord OS
OS -> OS -> Bool
OS -> OS -> Ordering
OS -> OS -> OS
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 :: OS -> OS -> Ordering
compare :: OS -> OS -> Ordering
$c< :: OS -> OS -> Bool
< :: OS -> OS -> Bool
$c<= :: OS -> OS -> Bool
<= :: OS -> OS -> Bool
$c> :: OS -> OS -> Bool
> :: OS -> OS -> Bool
$c>= :: OS -> OS -> Bool
>= :: OS -> OS -> Bool
$cmax :: OS -> OS -> OS
max :: OS -> OS -> OS
$cmin :: OS -> OS -> OS
min :: OS -> OS -> OS
Ord)


-- Note [Platform Syntax]
-- ~~~~~~~~~~~~~~~~~~~~~~
--
-- There is a very loose encoding of platforms shared by many tools we are
-- encoding to here. GNU Config (http://git.savannah.gnu.org/cgit/config.git),
-- and LLVM's http://llvm.org/doxygen/classllvm_1_1Triple.html are perhaps the
-- most definitional parsers. The basic syntax is a list of '-'-separated
-- components. The Unix 'uname' command syntax is related but briefer.
--
-- Those two parsers are quite forgiving, and even the 'config.sub'
-- normalization is forgiving too. The "best" way to encode a platform is
-- therefore somewhat a matter of taste.
--
-- The 'stringEncode*' functions here convert each part of GHC's structured
-- notion of a platform into one dash-separated component.

-- | See Note [Platform Syntax].
stringEncodeArch :: Arch -> String
stringEncodeArch :: Arch -> String
stringEncodeArch = \case
  Arch
ArchUnknown       -> String
"unknown"
  Arch
ArchX86           -> String
"i386"
  Arch
ArchX86_64        -> String
"x86_64"
  Arch
ArchPPC           -> String
"powerpc"
  ArchPPC_64 PPC_64ABI
ELF_V1 -> String
"powerpc64"
  ArchPPC_64 PPC_64ABI
ELF_V2 -> String
"powerpc64le"
  Arch
ArchS390X         -> String
"s390x"
  ArchARM ArmISA
ARMv5 [ArmISAExt]
_ ArmABI
_ -> String
"armv5"
  ArchARM ArmISA
ARMv6 [ArmISAExt]
_ ArmABI
_ -> String
"armv6"
  ArchARM ArmISA
ARMv7 [ArmISAExt]
_ ArmABI
_ -> String
"armv7"
  Arch
ArchAArch64       -> String
"aarch64"
  Arch
ArchAlpha         -> String
"alpha"
  Arch
ArchMipseb        -> String
"mipseb"
  Arch
ArchMipsel        -> String
"mipsel"
  Arch
ArchRISCV64       -> String
"riscv64"
  Arch
ArchLoongArch64   -> String
"loongarch64"
  Arch
ArchJavaScript    -> String
"javascript"
  Arch
ArchWasm32        -> String
"wasm32"

-- | See Note [Platform Syntax].
stringEncodeOS :: OS -> String
stringEncodeOS :: OS -> String
stringEncodeOS = \case
  OS
OSUnknown   -> String
"unknown"
  OS
OSLinux     -> String
"linux"
  OS
OSDarwin    -> String
"darwin"
  OS
OSSolaris2  -> String
"solaris2"
  OS
OSMinGW32   -> String
"mingw32"
  OS
OSFreeBSD   -> String
"freebsd"
  OS
OSDragonFly -> String
"dragonfly"
  OS
OSOpenBSD   -> String
"openbsd"
  OS
OSNetBSD    -> String
"netbsd"
  OS
OSKFreeBSD  -> String
"kfreebsdgnu"
  OS
OSHaiku     -> String
"haiku"
  OS
OSQNXNTO    -> String
"nto-qnx"
  OS
OSAIX       -> String
"aix"
  OS
OSHurd      -> String
"hurd"
  OS
OSWasi      -> String
"wasi"