{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}

module Data.Macaw.AbsDomain.CallParams
  ( CallParams(..)
  ) where

import qualified Data.Kind as Kind
import           Data.Macaw.Types

-- | Minimal information needed to update stack constraints after a call.
data CallParams (r :: Type -> Kind.Type)
   = CallParams { forall (r :: Type -> Type). CallParams r -> Integer
postCallStackDelta :: Integer
                  -- ^ Amount stack should shift after call returns.
                  --
                  -- On X86_64 this is 8 to reflect the pop of the
                  -- return value.
                , forall (r :: Type -> Type). CallParams r -> Bool
stackGrowsDown :: !Bool
                  -- ^ Returns true if stack grows down
                , forall (r :: Type -> Type).
CallParams r -> forall (tp :: Type). r tp -> Bool
preserveReg        :: forall tp . r tp -> Bool
                  -- ^ Return true if a register value is preserved by
                  -- a call.
                  --
                  -- We assume stack pointer and instruction pointer
                  -- are preserved, so the return value for these does not matter.
                }