mlir-hs-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

MLIR.Native

Description

This module defines a set of Haskell types wrapping references to native C++ MLIR objects along with some basic operations on them. See the submodules for more specialized components such as an ExecutionEngine or PassManager.

Synopsis

Contexts

data Context Source #

A native MLIR context.

Instances

Instances details
Storable Context Source # 
Instance details

Defined in MLIR.Native.FFI

createContext :: IO Context Source #

Creates a native MLIR context.

destroyContext :: Context -> IO () Source #

Destroys a native MLIR context.

withContext :: (Context -> IO a) -> IO a Source #

Wraps an IO action that gets access to a fresh MLIR context.

class HasContext a where Source #

A typeclass for retrieving MLIR contexts managing other native types.

Methods

getContext :: a -> IO Context Source #

Retrieve the MLIR context that manages the storage of the native value.

Instances

Instances details
HasContext Module Source # 
Instance details

Defined in MLIR.Native

Dialect registration

registerAllDialects :: Context -> IO () Source #

Register all builtin MLIR dialects in the specified Context.

getNumLoadedDialects :: Context -> IO Int Source #

Retrieve the count of dialects currently registered in the Context.

Type

data Type Source #

A native MLIR type object.

Instances

Instances details
Storable Type Source # 
Instance details

Defined in MLIR.Native.FFI

Methods

sizeOf :: Type -> Int #

alignment :: Type -> Int #

peekElemOff :: Ptr Type -> Int -> IO Type #

pokeElemOff :: Ptr Type -> Int -> Type -> IO () #

peekByteOff :: Ptr b -> Int -> IO Type #

pokeByteOff :: Ptr b -> Int -> Type -> IO () #

peek :: Ptr Type -> IO Type #

poke :: Ptr Type -> Type -> IO () #

FromAST Type Type Source # 
Instance details

Defined in MLIR.AST

FromAST Type Type Source # 
Instance details

Defined in MLIR.AST.Dialect.LLVM

Location

data Location Source #

A native MLIR location object.

Instances

Instances details
Storable Location Source # 
Instance details

Defined in MLIR.Native.FFI

FromAST Location Location Source # 
Instance details

Defined in MLIR.AST

getUnknownLocation :: Context -> IO Location Source #

Create an unknown source location.

Operation

data Operation Source #

A native MLIR operation instance.

Instances

Instances details
Storable Operation Source # 
Instance details

Defined in MLIR.Native.FFI

HasDump Operation Source # 
Instance details

Defined in MLIR.Native

Methods

dump :: Operation -> IO () Source #

FromAST Operation Operation Source # 
Instance details

Defined in MLIR.AST

getOperationName :: Operation -> IO Identifier Source #

Retrieve the name of the given operation.

showOperation :: Operation -> IO ByteString Source #

Show the operation using the MLIR printer.

showOperationWithLocation :: Operation -> IO ByteString Source #

Show the operation with location using the MLIR printer.

verifyOperation :: Operation -> IO Bool Source #

Check validity of the operation.

Region

data Region Source #

A native MLIR region.

Instances

Instances details
Storable Region Source # 
Instance details

Defined in MLIR.Native.FFI

FromAST Region Region Source # 
Instance details

Defined in MLIR.AST

getOperationRegions :: Operation -> IO [Region] Source #

Returns the regions of an Operation.

getRegionBlocks :: Region -> IO [Block] Source #

Returns the Blocks in a Region.

Block

data Block Source #

A native MLIR block object. Every block is a list of Operations.

Instances

Instances details
Storable Block Source # 
Instance details

Defined in MLIR.Native.FFI

Methods

sizeOf :: Block -> Int #

alignment :: Block -> Int #

peekElemOff :: Ptr Block -> Int -> IO Block #

pokeElemOff :: Ptr Block -> Int -> Block -> IO () #

peekByteOff :: Ptr b -> Int -> IO Block #

pokeByteOff :: Ptr b -> Int -> Block -> IO () #

peek :: Ptr Block -> IO Block #

poke :: Ptr Block -> Block -> IO () #

FromAST Block Block Source # 
Instance details

Defined in MLIR.AST

showBlock :: Block -> IO ByteString Source #

Show the block using the MLIR printer.

getBlockOperations :: Block -> IO [Operation] Source #

Returns the Operations in a Block.

Module

data Module Source #

A native MLIR module operation. Since every module is an operation, it can be converted to an Operation using moduleAsOperation.

Instances

Instances details
Storable Module Source # 
Instance details

Defined in MLIR.Native.FFI

HasDump Module Source # 
Instance details

Defined in MLIR.Native

Methods

dump :: Module -> IO () Source #

HasContext Module Source # 
Instance details

Defined in MLIR.Native

createEmptyModule :: Location -> IO Module Source #

Create an empty module.

parseModule :: Context -> StringRef -> IO (Maybe Module) Source #

Parse a module from a string. Returns Nothing in case of parse failure.

destroyModule :: Module -> IO () Source #

Destroy all resources associated with a Module.

getModuleBody :: Module -> IO Block Source #

Retrieve the block containg all module definitions.

moduleAsOperation :: Module -> IO Operation Source #

Convert a module to an Operation.

moduleFromOperation :: Operation -> IO (Maybe Module) Source #

Inverse of moduleAsOperation. Returns Nothing if the operation is not a builtin MLIR module operation.

showModule :: Module -> IO ByteString Source #

Show the module using the MLIR printer.

StringRef

data StringRef Source #

Constructors

StringRef (Ptr CChar) CSize 

withStringRef :: ByteString -> (StringRef -> IO a) -> IO a Source #

Use a ByteString as a StringRef. This is O(n) due to MLIR sometimes requiring the StringRefs to be null-terminated.

Identifier

data Identifier Source #

A native MLIR identifier. Identifiers are strings interned in the MLIR context.

createIdentifier :: Context -> StringRef -> IO Identifier Source #

Create an identifier from a StringRef.

identifierString :: Identifier -> IO StringRef Source #

View an identifier as a StringRef. The result is valid for as long as the Context managing the identifier.

LogicalResult

data LogicalResult Source #

A result code for many failable MLIR operations. The only valid cases are Success and Failure.

pattern Failure :: LogicalResult Source #

Indicates a filure of an MLIR operation. Inspect the diagnostics output to find the cause of the issue.

pattern Success :: LogicalResult Source #

Indicates a successful completion of an MLIR operation.

Debugging utilities

setDebugMode :: Bool -> IO () Source #

Enable or disable debug logging in MLIR.

class HasDump a where Source #

A class for native objects that can be dumped to standard error output.

Methods

dump :: a -> IO () Source #

Display the value in the standard error output.

Instances

Instances details
HasDump Module Source # 
Instance details

Defined in MLIR.Native

Methods

dump :: Module -> IO () Source #

HasDump Operation Source # 
Instance details

Defined in MLIR.Native

Methods

dump :: Operation -> IO () Source #