{-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_HADDOCK hide #-} -- | -- Module : LLVM.AST.Type.Instruction -- Copyright : [2015..2017] Trevor L. McDonell -- License : BSD3 -- -- Maintainer : Trevor L. McDonell -- Stability : experimental -- Portability : non-portable (GHC extensions) -- module LLVM.AST.Type.Instruction where import LLVM.AST.Type.Global import LLVM.AST.Type.Name import LLVM.AST.Type.Operand import LLVM.AST.Type.Representation import LLVM.AST.Type.Instruction.Atomic import LLVM.AST.Type.Instruction.Compare import LLVM.AST.Type.Instruction.RMW import LLVM.AST.Type.Instruction.Volatile import Data.Array.Accelerate.Product ( ProdRepr, TupleIdx ) import Prelude hiding ( Ordering ) -- | Non-terminating instructions -- -- * -- -- * -- -- * -- -- * -- -- * -- -- * -- data Instruction a where -- Binary Operations -- ----------------- -- -- -- Add :: NumType a -> Operand a -> Operand a -> Instruction a -- -- -- Sub :: NumType a -> Operand a -> Operand a -> Instruction a -- -- -- Mul :: NumType a -> Operand a -> Operand a -> Instruction a -- -- -- Quot :: IntegralType a -> Operand a -> Operand a -> Instruction a -- -- -- Rem :: IntegralType a -> Operand a -> Operand a -> Instruction a -- -- Div :: FloatingType a -> Operand a -> Operand a -> Instruction a -- -- ShiftL :: IntegralType a -> Operand a -> Operand a -> Instruction a -- -- ShiftRL :: IntegralType a -> Operand a -> Operand a -> Instruction a -- -- ShiftRA :: IntegralType a -> Operand a -> Operand a -> Instruction a -- Bitwise Binary Operations -- ------------------------- -- -- BAnd :: IntegralType a -> Operand a -> Operand a -> Instruction a LAnd :: Operand Bool -> Operand Bool -> Instruction Bool -- -- BOr :: IntegralType a -> Operand a -> Operand a -> Instruction a LOr :: Operand Bool -> Operand Bool -> Instruction Bool -- -- BXor :: IntegralType a -> Operand a -> Operand a -> Instruction a LNot :: Operand Bool -> Instruction Bool -- Vector Operations -- ----------------- -- -- ExtractElement :: VectorType (v e) -> TupleIdx (ProdRepr (v e)) e -> Operand (v e) -> Instruction e -- -- InsertElement :: Int32 -- TupleIdx (ProdRepr (v a)) a -> Operand (v a) -> Operand a -> Instruction (v a) -- ShuffleVector -- Aggregate Operations -- -------------------- -- -- ExtractValue :: ScalarType t -> TupleIdx (ProdRepr tup) t -> Operand tup -> Instruction t -- -- InsertValue -- Memory Access and Addressing Operations -- --------------------------------------- -- -- Alloca -- -- Load :: ScalarType a -> Volatility -> Operand (Ptr a) -> Instruction a -- -- Store :: Volatility -> Operand (Ptr a) -> Operand a -> Instruction () -- -- GetElementPtr :: Operand (Ptr a) -> [Operand i] -> Instruction (Ptr a) -- -- Fence :: Atomicity -> Instruction () -- -- CmpXchg :: IntegralType a -> Volatility -> Operand (Ptr a) -> Operand a -- expected value -> Operand a -- replacement value -> Atomicity -- on success -> MemoryOrdering -- on failure (see docs for restrictions) -> Instruction (a, Bool) -- -- AtomicRMW :: IntegralType a -> Volatility -> RMWOperation -> Operand (Ptr a) -> Operand a -> Atomicity -> Instruction a -- -- Trunc :: BoundedType a -- precondition: BitSize a > BitSize b -> BoundedType b -> Operand a -> Instruction b -- -- FTrunc :: FloatingType a -- precondition: BitSize a > BitSize b -> FloatingType b -> Operand a -> Instruction b -- -- -- Ext :: BoundedType a -- precondition: BitSize a < BitSize b -> BoundedType b -> Operand a -> Instruction b -- -- FExt :: FloatingType a -- precondition: BitSize a < BitSize b -> FloatingType b -> Operand a -> Instruction b -- -- -- FPToInt :: FloatingType a -> IntegralType b -> Operand a -> Instruction b -- -- -- IntToFP :: Either (IntegralType a) (NonNumType a) -> FloatingType b -> Operand a -> Instruction b -- -- BitCast :: ScalarType b -- precondition: BitSize a == BitSize b -> Operand a -> Instruction b PtrCast :: PrimType (Ptr b) -- precondition: same address space -> Operand (Ptr a) -> Instruction (Ptr b) -- PtrToInt -- IntToPtr -- AddrSpaceCast -- Other Operations -- ---------------- -- -- -- -- We treat non-scalar types as signed/unsigned integer values. -- FCmp :: FloatingType a -> FOrdering -> Operand a -> Operand a -> Instruction Bool Cmp :: SingleType a -> Ordering -> Operand a -> Operand a -> Instruction Bool -- -- Phi :: PrimType a -> [(Operand a, Label)] -> Instruction a -- -- Call :: GlobalFunction args t -> [Either GroupID FunctionAttribute] -> Instruction t -- -- Select :: SingleType a -> Operand Bool -> Operand a -> Operand a -> Instruction a -- VAArg -- LandingPad -- | Instances of instructions may be given a name, allowing their results to be -- referenced as Operands. Instructions returning void (e.g. function calls) -- don't need names. -- data Named ins a where (:=) :: Name a -> ins a -> Named ins a Do :: ins () -> Named ins ()