10#include "llvm/ADT/StringRef.h"
11#include "llvm/Support/FileSystem.h"
12#include "llvm/Support/ThreadPool.h"
13#include "llvm/Support/raw_ostream.h"
23 return llvm::StringRef(
string.data,
string.length) ==
31 return wrap(
new llvm::DefaultThreadPool());
39 return unwrap(threadPool)->getMaxConcurrency();
50 auto flags = binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text;
51 auto *stream =
new llvm::raw_fd_ostream(path, ec, flags);
55 std::string message = ec.message();
59 return wrap(
static_cast<llvm::raw_fd_ostream *
>(
nullptr));
66 unwrap(stream)->write(
string.data,
string.length);
81 assert(
reinterpret_cast<uintptr_t
>(ptr) % 8 == 0 &&
82 "ptr must be 8 byte aligned");
94 return hash_value(
unwrap(typeID));
void mlirLlvmRawFdOStreamDestroy(MlirLlvmRawFdOStream stream)
Destroy a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.
bool mlirTypeIDEqual(MlirTypeID typeID1, MlirTypeID typeID2)
Checks if two type ids are equal.
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 usag...
bool mlirLlvmRawFdOStreamIsNull(MlirLlvmRawFdOStream stream)
Checks if a raw_fd_ostream is null.
void mlirLlvmRawFdOStreamWrite(MlirLlvmRawFdOStream stream, MlirStringRef string)
Write a string to a raw_fd_ostream created with mlirLlvmRawFdOStreamCreate.
size_t mlirTypeIDHashValue(MlirTypeID typeID)
Returns the hash value of the type id.
void mlirTypeIDAllocatorDestroy(MlirTypeIDAllocator allocator)
Deallocates the allocator and all allocated type ids.
void mlirLlvmThreadPoolDestroy(MlirLlvmThreadPool threadPool)
Destroy an LLVM thread pool.
MlirStringRef mlirStringRefCreateFromCString(const char *str)
Constructs a string reference from a null-terminated C string.
int mlirLlvmThreadPoolGetMaxConcurrency(MlirLlvmThreadPool threadPool)
Returns the maximum number of threads in the thread pool.
bool mlirStringRefEqual(MlirStringRef string, MlirStringRef other)
Returns true if two string references are equal, false otherwise.
MlirTypeID mlirTypeIDAllocatorAllocateTypeID(MlirTypeIDAllocator allocator)
Allocates a type id that is valid for the lifetime of the allocator.
MlirLlvmThreadPool mlirLlvmThreadPoolCreate()
Create an LLVM thread pool.
MlirTypeIDAllocator mlirTypeIDAllocatorCreate()
Creates a type id allocator for dynamic type id creation.
MlirLlvmRawFdOStream mlirLlvmRawFdOStreamCreate(const char *path, bool binary, MlirStringCallback errorCallback, void *userData)
Create a raw_fd_ostream for the given path.
This class provides a way to define new TypeIDs at runtime.
static TypeID getFromOpaquePointer(const void *pointer)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
static MlirStringRef mlirStringRefCreate(const char *str, size_t length)
Constructs a string reference from the pointer and length.
void(* MlirStringCallback)(MlirStringRef, void *)
A callback for returning string references.
A pointer to a sized fragment of a string, not necessarily null-terminated.
const char * data
Pointer to the first symbol.
size_t length
Length of the fragment.