module Data.SpirV.Enum.LoopControl where import Data.Bits (Bits) import Data.String (IsString(..)) import Data.Word (Word32) import Foreign (Storable(..)) import GHC.Read (Read(..)) import Text.ParserCombinators.ReadPrec (pfail) import qualified GHC.Read as Read import qualified Text.Read.Lex as Lex newtype LoopControl = LoopControl Word32 deriving (Eq, Ord, Storable, Bits) pattern Unroll :: LoopControl pattern Unroll = LoopControl 0x1 pattern DontUnroll :: LoopControl pattern DontUnroll = LoopControl 0x2 pattern DependencyInfinite :: LoopControl pattern DependencyInfinite = LoopControl 0x4 pattern DependencyLength :: LoopControl pattern DependencyLength = LoopControl 0x8 pattern MinIterations :: LoopControl pattern MinIterations = LoopControl 0x10 pattern MaxIterations :: LoopControl pattern MaxIterations = LoopControl 0x20 pattern IterationMultiple :: LoopControl pattern IterationMultiple = LoopControl 0x40 pattern PeelCount :: LoopControl pattern PeelCount = LoopControl 0x80 pattern PartialCount :: LoopControl pattern PartialCount = LoopControl 0x100 pattern InitiationIntervalINTEL :: LoopControl pattern InitiationIntervalINTEL = LoopControl 0x10000 pattern MaxConcurrencyINTEL :: LoopControl pattern MaxConcurrencyINTEL = LoopControl 0x20000 pattern DependencyArrayINTEL :: LoopControl pattern DependencyArrayINTEL = LoopControl 0x40000 pattern PipelineEnableINTEL :: LoopControl pattern PipelineEnableINTEL = LoopControl 0x80000 pattern LoopCoalesceINTEL :: LoopControl pattern LoopCoalesceINTEL = LoopControl 0x100000 pattern MaxInterleavingINTEL :: LoopControl pattern MaxInterleavingINTEL = LoopControl 0x200000 pattern SpeculatedIterationsINTEL :: LoopControl pattern SpeculatedIterationsINTEL = LoopControl 0x400000 pattern NoFusionINTEL :: LoopControl pattern NoFusionINTEL = LoopControl 0x800000 pattern LoopCountINTEL :: LoopControl pattern LoopCountINTEL = LoopControl 0x1000000 pattern MaxReinvocationDelayINTEL :: LoopControl pattern MaxReinvocationDelayINTEL = LoopControl 0x2000000 toName :: IsString a => LoopControl -> a toName x = case x of Unroll -> "Unroll" DontUnroll -> "DontUnroll" DependencyInfinite -> "DependencyInfinite" DependencyLength -> "DependencyLength" MinIterations -> "MinIterations" MaxIterations -> "MaxIterations" IterationMultiple -> "IterationMultiple" PeelCount -> "PeelCount" PartialCount -> "PartialCount" InitiationIntervalINTEL -> "InitiationIntervalINTEL" MaxConcurrencyINTEL -> "MaxConcurrencyINTEL" DependencyArrayINTEL -> "DependencyArrayINTEL" PipelineEnableINTEL -> "PipelineEnableINTEL" LoopCoalesceINTEL -> "LoopCoalesceINTEL" MaxInterleavingINTEL -> "MaxInterleavingINTEL" SpeculatedIterationsINTEL -> "SpeculatedIterationsINTEL" NoFusionINTEL -> "NoFusionINTEL" LoopCountINTEL -> "LoopCountINTEL" MaxReinvocationDelayINTEL -> "MaxReinvocationDelayINTEL" unknown -> fromString $ "LoopControl " ++ show unknown instance Show LoopControl where show = toName fromName :: (IsString a, Eq a) => a -> Maybe LoopControl fromName x = case x of "Unroll" -> Just Unroll "DontUnroll" -> Just DontUnroll "DependencyInfinite" -> Just DependencyInfinite "DependencyLength" -> Just DependencyLength "MinIterations" -> Just MinIterations "MaxIterations" -> Just MaxIterations "IterationMultiple" -> Just IterationMultiple "PeelCount" -> Just PeelCount "PartialCount" -> Just PartialCount "InitiationIntervalINTEL" -> Just InitiationIntervalINTEL "MaxConcurrencyINTEL" -> Just MaxConcurrencyINTEL "DependencyArrayINTEL" -> Just DependencyArrayINTEL "PipelineEnableINTEL" -> Just PipelineEnableINTEL "LoopCoalesceINTEL" -> Just LoopCoalesceINTEL "MaxInterleavingINTEL" -> Just MaxInterleavingINTEL "SpeculatedIterationsINTEL" -> Just SpeculatedIterationsINTEL "NoFusionINTEL" -> Just NoFusionINTEL "LoopCountINTEL" -> Just LoopCountINTEL "MaxReinvocationDelayINTEL" -> Just MaxReinvocationDelayINTEL _unknown -> Nothing instance Read LoopControl where readPrec = Read.parens do Lex.Ident s <- Read.lexP maybe pfail pure $ fromName s