{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
module Language.C.Analysis.MachineDescs
  where

import Language.C.Analysis.ConstEval
import Language.C.Analysis.SemRep

x86_64 :: MachineDesc
x86_64 :: MachineDesc
x86_64 =
  let iSize :: IntType -> Integer
iSize = \case
        TyBool    -> 1
        TyChar    -> 1
        TySChar   -> 1
        TyUChar   -> 1
        TyShort   -> 2
        TyUShort  -> 2
        TyInt     -> 4
        TyUInt    -> 4
        TyLong    -> 8
        TyULong   -> 8
        TyLLong   -> 8
        TyULLong  -> 8
        TyInt128  -> 16
        TyUInt128 -> 16
      fSize :: FloatType -> Integer
fSize = \case
        TyFloat    -> 4
        TyDouble   -> 8
        TyLDouble  -> 16
        TyFloatN{} -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyFloatN"
      builtinSize :: BuiltinType -> Integer
builtinSize = \case
        TyVaList -> 24
        TyAny    -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyAny"
      ptrSize :: Integer
ptrSize  = 8
      voidSize :: Integer
voidSize = 1
      iAlign :: IntType -> Integer
iAlign   = \case
        TyBool    -> 1
        TyChar    -> 1
        TySChar   -> 1
        TyUChar   -> 1
        TyShort   -> 2
        TyUShort  -> 2
        TyInt     -> 4
        TyUInt    -> 4
        TyLong    -> 8
        TyULong   -> 8
        TyLLong   -> 8
        TyULLong  -> 8
        TyInt128  -> 16
        TyUInt128 -> 16
      fAlign :: FloatType -> Integer
fAlign = \case
        TyFloat    -> 4
        TyDouble   -> 8
        TyLDouble  -> 16
        TyFloatN{} -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyFloatN"
      builtinAlign :: BuiltinType -> Integer
builtinAlign = \case
        TyVaList -> 8
        TyAny    -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyAny"
      ptrAlign :: Integer
ptrAlign  = 8
      voidAlign :: Integer
voidAlign = 1
  in  MachineDesc :: (IntType -> Integer)
-> (FloatType -> Integer)
-> (BuiltinType -> Integer)
-> Integer
-> Integer
-> (IntType -> Integer)
-> (FloatType -> Integer)
-> (BuiltinType -> Integer)
-> Integer
-> Integer
-> MachineDesc
MachineDesc { .. }

armv7l :: MachineDesc
armv7l :: MachineDesc
armv7l =
  let iSize :: IntType -> Integer
iSize = \case
        TyBool    -> 1
        TyChar    -> 1
        TySChar   -> 1
        TyUChar   -> 1
        TyShort   -> 2
        TyUShort  -> 2
        TyInt     -> 4
        TyUInt    -> 4
        TyLong    -> 4
        TyULong   -> 4
        TyLLong   -> 8
        TyULLong  -> 8
        TyInt128  -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyInt128 on armv7l"
        TyUInt128 -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyUInt128 on armv7l"
      fSize :: FloatType -> Integer
fSize = \case
        TyFloat    -> 4
        TyDouble   -> 8
        TyLDouble  -> 8
        TyFloatN{} -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyFloatN"
      builtinSize :: BuiltinType -> Integer
builtinSize = \case
        TyVaList -> 4
        TyAny    -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyAny"
      ptrSize :: Integer
ptrSize  = 4
      voidSize :: Integer
voidSize = 1
      iAlign :: IntType -> Integer
iAlign   = \case
        TyBool    -> 1
        TyChar    -> 1
        TySChar   -> 1
        TyUChar   -> 1
        TyShort   -> 2
        TyUShort  -> 2
        TyInt     -> 4
        TyUInt    -> 4
        TyLong    -> 4
        TyULong   -> 4
        TyLLong   -> 8
        TyULLong  -> 8
        TyInt128  -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyInt128 on armv7l"
        TyUInt128 -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyUInt128 on armv7l"
      fAlign :: FloatType -> Integer
fAlign = \case
        TyFloat    -> 4
        TyDouble   -> 8
        TyLDouble  -> 8
        TyFloatN{} -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyFloatN"
      builtinAlign :: BuiltinType -> Integer
builtinAlign = \case
        TyVaList -> 4
        TyAny    -> [Char] -> Integer
forall a. HasCallStack => [Char] -> a
error "TyAny"
      ptrAlign :: Integer
ptrAlign  = 4
      voidAlign :: Integer
voidAlign = 1
  in  MachineDesc :: (IntType -> Integer)
-> (FloatType -> Integer)
-> (BuiltinType -> Integer)
-> Integer
-> Integer
-> (IntType -> Integer)
-> (FloatType -> Integer)
-> (BuiltinType -> Integer)
-> Integer
-> Integer
-> MachineDesc
MachineDesc { .. }