- Add a minimalist C API for mlir::Dialect. - Allow one to query the context about registered and loaded dialects. - Add API for loading dialects. - Provide functions to register the Standard dialect. When used naively, this will require to separately register each dialect. When we have more than one exposed, we can add variadic macros that expand to individual calls. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D88162
26 lines
937 B
C++
26 lines
937 B
C++
//===- StandardDialect.cpp - C Interface for Standard dialect -------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir-c/StandardDialect.h"
|
|
#include "mlir-c/IR.h"
|
|
#include "mlir/CAPI/IR.h"
|
|
#include "mlir/CAPI/Support.h"
|
|
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
|
|
|
void mlirContextRegisterStandardDialect(MlirContext context) {
|
|
unwrap(context)->getDialectRegistry().insert<mlir::StandardOpsDialect>();
|
|
}
|
|
|
|
MlirDialect mlirContextLoadStandardDialect(MlirContext context) {
|
|
return wrap(unwrap(context)->getOrLoadDialect<mlir::StandardOpsDialect>());
|
|
}
|
|
|
|
MlirStringRef mlirStandardDialectGetNamespace() {
|
|
return wrap(mlir::StandardOpsDialect::getDialectNamespace());
|
|
}
|