MLIR  19.0.0git
Classes | Macros | Typedefs | Functions
Support.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  MlirStringRef
 A pointer to a sized fragment of a string, not necessarily null-terminated. More...
 
struct  MlirLogicalResult
 A logical result value, essentially a boolean with named states. More...
 

Macros

#define MLIR_CAPI_EXPORTED   __attribute__((visibility("default")))
 
#define DEFINE_C_API_STRUCT(name, storage)
 

Typedefs

typedef struct MlirStringRef MlirStringRef
 
typedef void(* MlirStringCallback) (MlirStringRef, void *)
 A callback for returning string references. More...
 
typedef struct MlirLogicalResult MlirLogicalResult
 

Functions

 DEFINE_C_API_STRUCT (MlirLlvmThreadPool, void)
 Re-export llvm::ThreadPool so as to avoid including the LLVM C API directly. More...
 
 DEFINE_C_API_STRUCT (MlirTypeID, const void)
 
 DEFINE_C_API_STRUCT (MlirTypeIDAllocator, void)
 
static MlirStringRef mlirStringRefCreate (const char *str, size_t length)
 Constructs a string reference from the pointer and length. More...
 
MLIR_CAPI_EXPORTED MlirStringRef mlirStringRefCreateFromCString (const char *str)
 Constructs a string reference from a null-terminated C string. More...
 
MLIR_CAPI_EXPORTED bool mlirStringRefEqual (MlirStringRef string, MlirStringRef other)
 Returns true if two string references are equal, false otherwise. More...
 
static bool mlirLogicalResultIsSuccess (MlirLogicalResult res)
 Checks if the given logical result represents a success. More...
 
static bool mlirLogicalResultIsFailure (MlirLogicalResult res)
 Checks if the given logical result represents a failure. More...
 
static MlirLogicalResult mlirLogicalResultSuccess (void)
 Creates a logical result representing a success. More...
 
static MlirLogicalResult mlirLogicalResultFailure (void)
 Creates a logical result representing a failure. More...
 
MLIR_CAPI_EXPORTED MlirLlvmThreadPool mlirLlvmThreadPoolCreate (void)
 Create an LLVM thread pool. More...
 
MLIR_CAPI_EXPORTED void mlirLlvmThreadPoolDestroy (MlirLlvmThreadPool pool)
 Destroy an LLVM thread pool. More...
 
MLIR_CAPI_EXPORTED MlirTypeID mlirTypeIDCreate (const void *ptr)
 ptr must be 8 byte aligned and unique to a type valid for the duration of the returned type id's usage More...
 
static bool mlirTypeIDIsNull (MlirTypeID typeID)
 Checks whether a type id is null. More...
 
MLIR_CAPI_EXPORTED bool mlirTypeIDEqual (MlirTypeID typeID1, MlirTypeID typeID2)
 Checks if two type ids are equal. More...
 
MLIR_CAPI_EXPORTED size_t mlirTypeIDHashValue (MlirTypeID typeID)
 Returns the hash value of the type id. More...
 
MLIR_CAPI_EXPORTED MlirTypeIDAllocator mlirTypeIDAllocatorCreate (void)
 Creates a type id allocator for dynamic type id creation. More...
 
MLIR_CAPI_EXPORTED void mlirTypeIDAllocatorDestroy (MlirTypeIDAllocator allocator)
 Deallocates the allocator and all allocated type ids. More...
 
MLIR_CAPI_EXPORTED MlirTypeID mlirTypeIDAllocatorAllocateTypeID (MlirTypeIDAllocator allocator)
 Allocates a type id that is valid for the lifetime of the allocator. More...
 

Macro Definition Documentation

◆ DEFINE_C_API_STRUCT

#define DEFINE_C_API_STRUCT (   name,
  storage 
)
Value:
struct name { \
storage *ptr; \
}; \
typedef struct name name

Definition at line 53 of file Support.h.

◆ MLIR_CAPI_EXPORTED

#define MLIR_CAPI_EXPORTED   __attribute__((visibility("default")))

Definition at line 46 of file Support.h.

Typedef Documentation

◆ MlirLogicalResult

Definition at line 105 of file Support.h.

◆ MlirStringCallback

typedef void(* MlirStringCallback) (MlirStringRef, void *)

A callback for returning string references.

This function is called back by the functions that need to return a reference to the portion of the string with the following arguments:

  • an MlirStringRef representing the current portion of the string
  • a pointer to user data forwarded from the printing call.

Definition at line 105 of file Support.h.

◆ MlirStringRef

typedef struct MlirStringRef MlirStringRef

Definition at line 62 of file Support.h.

Function Documentation

◆ DEFINE_C_API_STRUCT() [1/3]

DEFINE_C_API_STRUCT ( MlirLlvmThreadPool  ,
void   
)

Re-export llvm::ThreadPool so as to avoid including the LLVM C API directly.

◆ DEFINE_C_API_STRUCT() [2/3]

DEFINE_C_API_STRUCT ( MlirTypeID  ,
const void   
)

◆ DEFINE_C_API_STRUCT() [3/3]

DEFINE_C_API_STRUCT ( MlirTypeIDAllocator  ,
void   
)

◆ mlirLlvmThreadPoolCreate()

MLIR_CAPI_EXPORTED MlirLlvmThreadPool mlirLlvmThreadPoolCreate ( void  )

Create an LLVM thread pool.

This is reexported here to avoid directly pulling in the LLVM headers directly.

Definition at line 27 of file Support.cpp.

References wrap().

◆ mlirLlvmThreadPoolDestroy()

MLIR_CAPI_EXPORTED void mlirLlvmThreadPoolDestroy ( MlirLlvmThreadPool  pool)

Destroy an LLVM thread pool.

Definition at line 31 of file Support.cpp.

◆ mlirLogicalResultFailure()

static MlirLogicalResult mlirLogicalResultFailure ( void  )
inlinestatic

◆ mlirLogicalResultIsFailure()

static bool mlirLogicalResultIsFailure ( MlirLogicalResult  res)
inlinestatic

◆ mlirLogicalResultIsSuccess()

static bool mlirLogicalResultIsSuccess ( MlirLogicalResult  res)
inlinestatic

Checks if the given logical result represents a success.

Definition at line 122 of file Support.h.

References MlirLogicalResult::value.

Referenced by populateDialectLLVMSubmodule(), populateTransformInterpreterSubmodule(), and unwrap().

◆ mlirLogicalResultSuccess()

static MlirLogicalResult mlirLogicalResultSuccess ( void  )
inlinestatic

◆ mlirStringRefCreate()

static MlirStringRef mlirStringRefCreate ( const char *  str,
size_t  length 
)
inlinestatic

◆ mlirStringRefCreateFromCString()

MLIR_CAPI_EXPORTED MlirStringRef mlirStringRefCreateFromCString ( const char *  str)

Constructs a string reference from a null-terminated C string.

Prefer mlirStringRefCreate if the length of the string is known.

Definition at line 15 of file Support.cpp.

References mlirStringRefCreate().

◆ mlirStringRefEqual()

MLIR_CAPI_EXPORTED bool mlirStringRefEqual ( MlirStringRef  string,
MlirStringRef  other 
)

Returns true if two string references are equal, false otherwise.

Definition at line 19 of file Support.cpp.

References MlirStringRef::data, and MlirStringRef::length.

◆ mlirTypeIDAllocatorAllocateTypeID()

MLIR_CAPI_EXPORTED MlirTypeID mlirTypeIDAllocatorAllocateTypeID ( MlirTypeIDAllocator  allocator)

Allocates a type id that is valid for the lifetime of the allocator.

Definition at line 67 of file Support.cpp.

References unwrap(), and wrap().

◆ mlirTypeIDAllocatorCreate()

MLIR_CAPI_EXPORTED MlirTypeIDAllocator mlirTypeIDAllocatorCreate ( void  )

Creates a type id allocator for dynamic type id creation.

Definition at line 59 of file Support.cpp.

References wrap().

◆ mlirTypeIDAllocatorDestroy()

MLIR_CAPI_EXPORTED void mlirTypeIDAllocatorDestroy ( MlirTypeIDAllocator  allocator)

Deallocates the allocator and all allocated type ids.

Definition at line 63 of file Support.cpp.

References unwrap().

◆ mlirTypeIDCreate()

MLIR_CAPI_EXPORTED MlirTypeID mlirTypeIDCreate ( const void *  ptr)

ptr must be 8 byte aligned and unique to a type valid for the duration of the returned type id's usage

Definition at line 38 of file Support.cpp.

References mlir::TypeID::getFromOpaquePointer(), and wrap().

Referenced by llvm::DenseMapInfo< MlirTypeID >::getEmptyKey(), and llvm::DenseMapInfo< MlirTypeID >::getTombstoneKey().

◆ mlirTypeIDEqual()

MLIR_CAPI_EXPORTED bool mlirTypeIDEqual ( MlirTypeID  typeID1,
MlirTypeID  typeID2 
)

Checks if two type ids are equal.

Definition at line 47 of file Support.cpp.

References unwrap().

Referenced by llvm::DenseMapInfo< MlirTypeID >::isEqual(), and mlir::python::PyTypeID::operator==().

◆ mlirTypeIDHashValue()

MLIR_CAPI_EXPORTED size_t mlirTypeIDHashValue ( MlirTypeID  typeID)

Returns the hash value of the type id.

Definition at line 51 of file Support.cpp.

References mlir::presburger::hash_value(), and unwrap().

Referenced by llvm::DenseMapInfo< MlirTypeID >::getHashValue().

◆ mlirTypeIDIsNull()

static bool mlirTypeIDIsNull ( MlirTypeID  typeID)
inlinestatic