MLIR 23.0.0git
Support.cpp File Reference
#include "mlir/CAPI/Support.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <string>

Go to the source code of this file.

Functions

MlirStringRef mlirStringRefCreateFromCString (const char *str)
 Constructs a string reference from a null-terminated C string.
bool mlirStringRefEqual (MlirStringRef string, MlirStringRef other)
 Returns true if two string references are equal, false otherwise.
MlirLlvmThreadPool mlirLlvmThreadPoolCreate ()
 Create an LLVM thread pool.
void mlirLlvmThreadPoolDestroy (MlirLlvmThreadPool threadPool)
 Destroy an LLVM thread pool.
int mlirLlvmThreadPoolGetMaxConcurrency (MlirLlvmThreadPool threadPool)
 Returns the maximum number of threads in the thread pool.
MlirLlvmRawFdOStream mlirLlvmRawFdOStreamCreate (const char *path, bool binary, MlirStringCallback errorCallback, void *userData)
 Create a raw_fd_ostream for the given path.
void mlirLlvmRawFdOStreamWrite (MlirLlvmRawFdOStream stream, MlirStringRef string)
 Write a string to a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.
bool mlirLlvmRawFdOStreamIsNull (MlirLlvmRawFdOStream stream)
 Checks if a raw_fd_ostream is null.
void mlirLlvmRawFdOStreamDestroy (MlirLlvmRawFdOStream stream)
 Destroy a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.
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
bool mlirTypeIDEqual (MlirTypeID typeID1, MlirTypeID typeID2)
 Checks if two type ids are equal.
size_t mlirTypeIDHashValue (MlirTypeID typeID)
 Returns the hash value of the type id.
MlirTypeIDAllocator mlirTypeIDAllocatorCreate ()
 Creates a type id allocator for dynamic type id creation.
void mlirTypeIDAllocatorDestroy (MlirTypeIDAllocator allocator)
 Deallocates the allocator and all allocated type ids.
MlirTypeID mlirTypeIDAllocatorAllocateTypeID (MlirTypeIDAllocator allocator)
 Allocates a type id that is valid for the lifetime of the allocator.

Function Documentation

◆ mlirLlvmRawFdOStreamCreate()

MlirLlvmRawFdOStream mlirLlvmRawFdOStreamCreate ( const char * path,
bool binary,
MlirStringCallback errorCallback,
void * userData )

Create a raw_fd_ostream for the given path.

This wrapper is needed because std::ostream does not provide the file sharing semantics required on Windows.

  • path: output file path.
  • binary: controls text vs binary mode.
  • errorCallback: called with an error message on failure (optional).
  • userData: forwarded to errorCallback so it can copy the error message into caller-owned storage (e.g., a std::string). On failure, returns a null stream and invokes the optional error callback with the error message.

Definition at line 47 of file Support.cpp.

References mlirStringRefCreate(), and wrap().

Referenced by mlir::PyFileAccumulator::PyFileAccumulator().

◆ mlirLlvmRawFdOStreamDestroy()

void mlirLlvmRawFdOStreamDestroy ( MlirLlvmRawFdOStream stream)

Destroy a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.

Definition at line 73 of file Support.cpp.

References unwrap().

Referenced by mlir::RAIIMlirLlvmRawFdOStream::~RAIIMlirLlvmRawFdOStream().

◆ mlirLlvmRawFdOStreamIsNull()

bool mlirLlvmRawFdOStreamIsNull ( MlirLlvmRawFdOStream stream)

Checks if a raw_fd_ostream is null.

Definition at line 69 of file Support.cpp.

Referenced by mlir::PyFileAccumulator::PyFileAccumulator().

◆ mlirLlvmRawFdOStreamWrite()

void mlirLlvmRawFdOStreamWrite ( MlirLlvmRawFdOStream stream,
MlirStringRef string )

Write a string to a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.

Definition at line 64 of file Support.cpp.

References unwrap().

◆ mlirLlvmThreadPoolCreate()

MlirLlvmThreadPool mlirLlvmThreadPoolCreate ( void )

Create an LLVM thread pool.

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

Definition at line 30 of file Support.cpp.

References wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyThreadPool::~PyThreadPool().

◆ mlirLlvmThreadPoolDestroy()

void mlirLlvmThreadPoolDestroy ( MlirLlvmThreadPool threadPool)

Destroy an LLVM thread pool.

Definition at line 34 of file Support.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyThreadPool::getMaxConcurrency().

◆ mlirLlvmThreadPoolGetMaxConcurrency()

int mlirLlvmThreadPoolGetMaxConcurrency ( MlirLlvmThreadPool threadPool)

Returns the maximum number of threads in the thread pool.

Definition at line 38 of file Support.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyThreadPool::_mlir_thread_pool_ptr().

◆ mlirStringRefCreateFromCString()

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 18 of file Support.cpp.

References mlirStringRefCreate().

◆ mlirStringRefEqual()

bool mlirStringRefEqual ( MlirStringRef string,
MlirStringRef other )

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

Definition at line 22 of file Support.cpp.

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

◆ mlirTypeIDAllocatorAllocateTypeID()

MlirTypeID mlirTypeIDAllocatorAllocateTypeID ( MlirTypeIDAllocator allocator)

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

Definition at line 109 of file Support.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::TypeIDAllocator::allocate().

◆ mlirTypeIDAllocatorCreate()

MlirTypeIDAllocator mlirTypeIDAllocatorCreate ( void )

Creates a type id allocator for dynamic type id creation.

Definition at line 101 of file Support.cpp.

References wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::TypeIDAllocator::TypeIDAllocator().

◆ mlirTypeIDAllocatorDestroy()

void mlirTypeIDAllocatorDestroy ( MlirTypeIDAllocator allocator)

Deallocates the allocator and all allocated type ids.

Definition at line 105 of file Support.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::TypeIDAllocator::~TypeIDAllocator().

◆ mlirTypeIDCreate()

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 80 of file Support.cpp.

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

◆ mlirTypeIDEqual()

bool mlirTypeIDEqual ( MlirTypeID typeID1,
MlirTypeID typeID2 )

Checks if two type ids are equal.

Definition at line 89 of file Support.cpp.

References unwrap().

Referenced by mlir::python::MlirTypeIDEqual::operator()().

◆ mlirTypeIDHashValue()

size_t mlirTypeIDHashValue ( MlirTypeID typeID)

Returns the hash value of the type id.

Definition at line 93 of file Support.cpp.

References unwrap().

Referenced by mlir::python::MlirTypeIDHash::operator()(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().