{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_HADDOCK hide #-}
-- |
-- Module      : LLVM.AST.Type.Flags
-- Copyright   : [2015..2020] The Accelerate Team
-- License     : BSD3
--
-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--

module LLVM.AST.Type.Flags (

  NSW(..), NUW(..), FastMathFlags(..)

) where

import Data.Default.Class
import LLVM.AST.Instruction                               ( FastMathFlags(..) )


-- If the 'NoSignedWrap' or 'NoUnsignedWrap' keywords are present, the result
-- value of an operation is a poison value if signed and/or unsigned overflow,
-- respectively, occurs.
--
data NSW = NoSignedWrap   | SignedWrap
data NUW = NoUnsignedWrap | UnsignedWrap

instance Default NSW where
  def :: NSW
def = NSW
SignedWrap

instance Default NUW where
  def :: NUW
def = NUW
UnsignedWrap

instance Default FastMathFlags where
#if MIN_VERSION_llvm_hs_pure(6,0,0)
  def :: FastMathFlags
def = FastMathFlags :: Bool
-> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> FastMathFlags
FastMathFlags
          { allowReassoc :: Bool
allowReassoc    = Bool
True
          , noNaNs :: Bool
noNaNs          = Bool
True
          , noInfs :: Bool
noInfs          = Bool
True
          , noSignedZeros :: Bool
noSignedZeros   = Bool
True
          , allowReciprocal :: Bool
allowReciprocal = Bool
True
          , allowContract :: Bool
allowContract   = Bool
True
          , approxFunc :: Bool
approxFunc      = Bool
True
          }
#else
  def = UnsafeAlgebra -- allow everything
#endif