Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvanbalen committed Apr 29, 2024
1 parent 53c3937 commit f6e6209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import qualified Debug.Trace
import Formatting.ShortFormatters (o)
import Data.Array.Accelerate (SLVOperation)
import Data.Array.Accelerate.Backend (SLVOperation(..))
import Data.Array.Accelerate.LLVM.CodeGen.IR



Expand Down Expand Up @@ -218,6 +219,9 @@ instance EvalOp NativeOp where
type Embed' NativeOp = Compose Maybe Operands
type EnvF NativeOp = GroundOperand

embed (GroundOperandParam x) = Compose $ Just $ ir' x
embed (GroundOperandBuffer x) = error "does this ever happen?"

unit = Compose $ Just OP_Unit

-- don't need to be in the monad!
Expand Down
15 changes: 14 additions & 1 deletion accelerate-llvm/src/Data/Array/Accelerate/LLVM/CodeGen/IR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Data.Array.Accelerate.LLVM.CodeGen.IR (

Operands(..),
IROP(..),

ir'
) where

import LLVM.AST.Type.Name
Expand All @@ -31,6 +31,7 @@ import Data.Primitive.Vec
import Formatting

import qualified Data.ByteString.Short as B
import LLVM.AST.Type.Constant (Constant(..))


-- We use a data family to represent sequences of LLVM (scalar) operands
Expand Down Expand Up @@ -180,3 +181,15 @@ instance IROP FloatingType where
ir TypeFloat = OP_Float
ir TypeDouble = OP_Double


ir' :: Operand a -> Operands a
ir' x = case x of
LocalReference t _ -> ir t x
ConstantOperand c -> case c of
ScalarConstant t _ -> ir t x
BooleanConstant _ -> ir BoolPrimType x
UndefConstant t -> ir t x
NullPtrConstant t -> ir t x
GlobalReference t _ -> ir t x
ConstantGetElementPtr t _ _ -> ir (PrimType $ PtrPrimType (ScalarPrimType t) undefined) x

0 comments on commit f6e6209

Please sign in to comment.