diff --git a/mlir/include/mlir-c/Dialect/PDL.h b/mlir/include/mlir-c/Dialect/PDL.h new file mode 100644 --- /dev/null +++ b/mlir/include/mlir-c/Dialect/PDL.h @@ -0,0 +1,72 @@ +//===-- mlir-c/Dialect/PDL.h - C API for PDL Dialect --------------*- C -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_C_DIALECT_PDL_H +#define MLIR_C_DIALECT_PDL_H + +#include "mlir-c/IR.h" +#include "mlir-c/Registration.h" + +#ifdef __cplusplus +extern "C" { +#endif + +MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(PDL, pdl); + +//===---------------------------------------------------------------------===// +// PDLType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLType(MlirType type); + +//===---------------------------------------------------------------------===// +// AttributeType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLAttributeType(MlirType type); + +MLIR_CAPI_EXPORTED MlirType mlirPDLAttributeTypeGet(MlirContext ctx); + +//===---------------------------------------------------------------------===// +// OperationType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLOperationType(MlirType type); + +MLIR_CAPI_EXPORTED MlirType mlirPDLOperationTypeGet(MlirContext ctx); + +//===---------------------------------------------------------------------===// +// RangeType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLRangeType(MlirType type); + +MLIR_CAPI_EXPORTED MlirType mlirPDLRangeTypeGet(MlirType elementType); + +//===---------------------------------------------------------------------===// +// TypeType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLTypeType(MlirType type); + +MLIR_CAPI_EXPORTED MlirType mlirPDLTypeTypeGet(MlirContext ctx); + +//===---------------------------------------------------------------------===// +// ValueType +//===---------------------------------------------------------------------===// + +MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLValueType(MlirType type); + +MLIR_CAPI_EXPORTED MlirType mlirPDLValueTypeGet(MlirContext ctx); + +#ifdef __cplusplus +} +#endif + +#endif // MLIR_C_DIALECT_QUANT_H diff --git a/mlir/include/mlir-c/Dialect/Quant.h b/mlir/include/mlir-c/Dialect/Quant.h --- a/mlir/include/mlir-c/Dialect/Quant.h +++ b/mlir/include/mlir-c/Dialect/Quant.h @@ -1,4 +1,4 @@ -//===-- mlir-c/Dialect/LLVM.h - C API for LLVM --------------------*- C -*-===// +//===-- mlir-c/Dialect/Quant.h - C API for LLVM -------------------*- C -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM // Exceptions. diff --git a/mlir/lib/CAPI/Dialect/CMakeLists.txt b/mlir/lib/CAPI/Dialect/CMakeLists.txt --- a/mlir/lib/CAPI/Dialect/CMakeLists.txt +++ b/mlir/lib/CAPI/Dialect/CMakeLists.txt @@ -106,3 +106,12 @@ MLIRCAPIIR MLIRQuant ) + +add_mlir_upstream_c_api_library(MLIRCAPIPDL + PDL.cpp + + PARTIAL_SOURCES_INTENDED + LINK_LIBS PUBLIC + MLIRCAPIIR + MLIRPDL +) diff --git a/mlir/lib/CAPI/Dialect/PDL.cpp b/mlir/lib/CAPI/Dialect/PDL.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/CAPI/Dialect/PDL.cpp @@ -0,0 +1,85 @@ +//===- PDL.cpp - C Interface for PDL 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/Dialect/PDL.h" +#include "mlir/CAPI/Registration.h" +#include "mlir/Dialect/PDL/IR/PDL.h" +#include "mlir/Dialect/PDL/IR/PDLOps.h" +#include "mlir/Dialect/PDL/IR/PDLTypes.h" + +using namespace mlir; + +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PDL, pdl, pdl::PDLDialect) + +//===---------------------------------------------------------------------===// +// PDLType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLType(MlirType type) { + return unwrap(type).isa(); +} + +//===---------------------------------------------------------------------===// +// AttributeType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLAttributeType(MlirType type) { + return unwrap(type).isa(); +} + +MlirType mlirPDLAttributeTypeGet(MlirContext ctx) { + return wrap(pdl::AttributeType::get(unwrap(ctx))); +} + +//===---------------------------------------------------------------------===// +// OperationType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLOperationType(MlirType type) { + return unwrap(type).isa(); +} + +MlirType mlirPDLOperationTypeGet(MlirContext ctx) { + return wrap(pdl::OperationType::get(unwrap(ctx))); +} + +//===---------------------------------------------------------------------===// +// RangeType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLRangeType(MlirType type) { + return unwrap(type).isa(); +} + +MlirType mlirPDLRangeTypeGet(MlirType elementType) { + return wrap(pdl::RangeType::get(unwrap(elementType))); +} + +//===---------------------------------------------------------------------===// +// TypeType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLTypeType(MlirType type) { + return unwrap(type).isa(); +} + +MlirType mlirPDLTypeTypeGet(MlirContext ctx) { + return wrap(pdl::TypeType::get(unwrap(ctx))); +} + +//===---------------------------------------------------------------------===// +// ValueType +//===---------------------------------------------------------------------===// + +bool mlirTypeIsAPDLValueType(MlirType type) { + return unwrap(type).isa(); +} + +MlirType mlirPDLValueTypeGet(MlirContext ctx) { + return wrap(pdl::ValueType::get(unwrap(ctx))); +} diff --git a/mlir/lib/CAPI/Dialect/Quant.cpp b/mlir/lib/CAPI/Dialect/Quant.cpp --- a/mlir/lib/CAPI/Dialect/Quant.cpp +++ b/mlir/lib/CAPI/Dialect/Quant.cpp @@ -1,4 +1,4 @@ -//===- LLVM.cpp - C Interface for Quant dialect ---------------------------===// +//===- Quant.cpp - C Interface for Quant dialect --------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt --- a/mlir/test/CAPI/CMakeLists.txt +++ b/mlir/test/CAPI/CMakeLists.txt @@ -66,3 +66,11 @@ MLIRCAPIRegistration MLIRCAPIQuant ) + +_add_capi_test_executable(mlir-capi-pdl-test + pdl.c + LINK_LIBS PRIVATE + MLIRCAPIIR + MLIRCAPIRegistration + MLIRCAPIPDL +) diff --git a/mlir/test/CAPI/pdl.c b/mlir/test/CAPI/pdl.c new file mode 100644 --- /dev/null +++ b/mlir/test/CAPI/pdl.c @@ -0,0 +1,332 @@ +//===- pdl.c - Test of PDL dialect C API ----------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// RUN: mlir-capi-pdl-test 2>&1 | FileCheck %s + +#include "mlir-c/Dialect/PDL.h" +#include "mlir-c/BuiltinTypes.h" +#include "mlir-c/IR.h" + +#include +#include +#include +#include + +// CHECK-LABEL: testAttributeType +void testAttributeType(MlirContext ctx) { + fprintf(stderr, "testAttributeType\n"); + + MlirType parsedType = mlirTypeParseGet( + ctx, mlirStringRefCreateFromCString("!pdl.attribute")); + MlirType constructedType = mlirPDLAttributeTypeGet(ctx); + + assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType"); + assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType"); + + // CHECK: parsedType isa PDLType: 1 + fprintf(stderr, "parsedType isa PDLType: %d\n", + mlirTypeIsAPDLType(parsedType)); + // CHECK: parsedType isa PDLAttributeType: 1 + fprintf(stderr, "parsedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(parsedType)); + // CHECK: parsedType isa PDLOperationType: 0 + fprintf(stderr, "parsedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(parsedType)); + // CHECK: parsedType isa PDLRangeType: 0 + fprintf(stderr, "parsedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(parsedType)); + // CHECK: parsedType isa PDLTypeType: 0 + fprintf(stderr, "parsedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(parsedType)); + // CHECK: parsedType isa PDLValueType: 0 + fprintf(stderr, "parsedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(parsedType)); + + // CHECK: constructedType isa PDLType: 1 + fprintf(stderr, "constructedType isa PDLType: %d\n", + mlirTypeIsAPDLType(constructedType)); + // CHECK: constructedType isa PDLAttributeType: 1 + fprintf(stderr, "constructedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(constructedType)); + // CHECK: constructedType isa PDLOperationType: 0 + fprintf(stderr, "constructedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(constructedType)); + // CHECK: constructedType isa PDLRangeType: 0 + fprintf(stderr, "constructedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(constructedType)); + // CHECK: constructedType isa PDLTypeType: 0 + fprintf(stderr, "constructedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(constructedType)); + // CHECK: constructedType isa PDLValueType: 0 + fprintf(stderr, "constructedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(constructedType)); + + // CHECK: equal: 1 + fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType)); + + // CHECK: !pdl.attribute + mlirTypeDump(parsedType); + // CHECK: !pdl.attribute + mlirTypeDump(constructedType); + + fprintf(stderr, "\n\n"); +} + +// CHECK-LABEL: testOperationType +void testOperationType(MlirContext ctx) { + fprintf(stderr, "testOperationType\n"); + + MlirType parsedType = mlirTypeParseGet( + ctx, mlirStringRefCreateFromCString("!pdl.operation")); + MlirType constructedType = mlirPDLOperationTypeGet(ctx); + + assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType"); + assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType"); + + // CHECK: parsedType isa PDLType: 1 + fprintf(stderr, "parsedType isa PDLType: %d\n", + mlirTypeIsAPDLType(parsedType)); + // CHECK: parsedType isa PDLAttributeType: 0 + fprintf(stderr, "parsedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(parsedType)); + // CHECK: parsedType isa PDLOperationType: 1 + fprintf(stderr, "parsedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(parsedType)); + // CHECK: parsedType isa PDLRangeType: 0 + fprintf(stderr, "parsedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(parsedType)); + // CHECK: parsedType isa PDLTypeType: 0 + fprintf(stderr, "parsedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(parsedType)); + // CHECK: parsedType isa PDLValueType: 0 + fprintf(stderr, "parsedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(parsedType)); + + // CHECK: constructedType isa PDLType: 1 + fprintf(stderr, "constructedType isa PDLType: %d\n", + mlirTypeIsAPDLType(constructedType)); + // CHECK: constructedType isa PDLAttributeType: 0 + fprintf(stderr, "constructedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(constructedType)); + // CHECK: constructedType isa PDLOperationType: 1 + fprintf(stderr, "constructedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(constructedType)); + // CHECK: constructedType isa PDLRangeType: 0 + fprintf(stderr, "constructedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(constructedType)); + // CHECK: constructedType isa PDLTypeType: 0 + fprintf(stderr, "constructedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(constructedType)); + // CHECK: constructedType isa PDLValueType: 0 + fprintf(stderr, "constructedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(constructedType)); + + // CHECK: equal: 1 + fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType)); + + // CHECK: !pdl.operation + mlirTypeDump(parsedType); + // CHECK: !pdl.operation + mlirTypeDump(constructedType); + + fprintf(stderr, "\n\n"); +} + +// CHECK-LABEL: testRangeType +void testRangeType(MlirContext ctx) { + fprintf(stderr, "testRangeType\n"); + + MlirType typeType = mlirPDLTypeTypeGet(ctx); + MlirType parsedType = mlirTypeParseGet( + ctx, mlirStringRefCreateFromCString("!pdl.range")); + MlirType constructedType = mlirPDLRangeTypeGet(typeType); + + assert(!mlirTypeIsNull(typeType) && "couldn't get PDLTypeType"); + assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType"); + assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType"); + + // CHECK: parsedType isa PDLType: 1 + fprintf(stderr, "parsedType isa PDLType: %d\n", + mlirTypeIsAPDLType(parsedType)); + // CHECK: parsedType isa PDLAttributeType: 0 + fprintf(stderr, "parsedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(parsedType)); + // CHECK: parsedType isa PDLOperationType: 0 + fprintf(stderr, "parsedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(parsedType)); + // CHECK: parsedType isa PDLRangeType: 1 + fprintf(stderr, "parsedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(parsedType)); + // CHECK: parsedType isa PDLTypeType: 0 + fprintf(stderr, "parsedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(parsedType)); + // CHECK: parsedType isa PDLValueType: 0 + fprintf(stderr, "parsedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(parsedType)); + + // CHECK: constructedType isa PDLType: 1 + fprintf(stderr, "constructedType isa PDLType: %d\n", + mlirTypeIsAPDLType(constructedType)); + // CHECK: constructedType isa PDLAttributeType: 0 + fprintf(stderr, "constructedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(constructedType)); + // CHECK: constructedType isa PDLOperationType: 0 + fprintf(stderr, "constructedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(constructedType)); + // CHECK: constructedType isa PDLRangeType: 1 + fprintf(stderr, "constructedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(constructedType)); + // CHECK: constructedType isa PDLTypeType: 0 + fprintf(stderr, "constructedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(constructedType)); + // CHECK: constructedType isa PDLValueType: 0 + fprintf(stderr, "constructedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(constructedType)); + + // CHECK: equal: 1 + fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType)); + + // CHECK: !pdl.range + mlirTypeDump(parsedType); + // CHECK: !pdl.range + mlirTypeDump(constructedType); + + fprintf(stderr, "\n\n"); +} + +// CHECK-LABEL: testTypeType +void testTypeType(MlirContext ctx) { + fprintf(stderr, "testTypeType\n"); + + MlirType parsedType = mlirTypeParseGet( + ctx, mlirStringRefCreateFromCString("!pdl.type")); + MlirType constructedType = mlirPDLTypeTypeGet(ctx); + + assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType"); + assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType"); + + // CHECK: parsedType isa PDLType: 1 + fprintf(stderr, "parsedType isa PDLType: %d\n", + mlirTypeIsAPDLType(parsedType)); + // CHECK: parsedType isa PDLAttributeType: 0 + fprintf(stderr, "parsedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(parsedType)); + // CHECK: parsedType isa PDLOperationType: 0 + fprintf(stderr, "parsedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(parsedType)); + // CHECK: parsedType isa PDLRangeType: 0 + fprintf(stderr, "parsedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(parsedType)); + // CHECK: parsedType isa PDLTypeType: 1 + fprintf(stderr, "parsedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(parsedType)); + // CHECK: parsedType isa PDLValueType: 0 + fprintf(stderr, "parsedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(parsedType)); + + // CHECK: constructedType isa PDLType: 1 + fprintf(stderr, "constructedType isa PDLType: %d\n", + mlirTypeIsAPDLType(constructedType)); + // CHECK: constructedType isa PDLAttributeType: 0 + fprintf(stderr, "constructedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(constructedType)); + // CHECK: constructedType isa PDLOperationType: 0 + fprintf(stderr, "constructedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(constructedType)); + // CHECK: constructedType isa PDLRangeType: 0 + fprintf(stderr, "constructedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(constructedType)); + // CHECK: constructedType isa PDLTypeType: 1 + fprintf(stderr, "constructedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(constructedType)); + // CHECK: constructedType isa PDLValueType: 0 + fprintf(stderr, "constructedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(constructedType)); + + // CHECK: equal: 1 + fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType)); + + // CHECK: !pdl.type + mlirTypeDump(parsedType); + // CHECK: !pdl.type + mlirTypeDump(constructedType); + + fprintf(stderr, "\n\n"); +} + +// CHECK-LABEL: testValueType +void testValueType(MlirContext ctx) { + fprintf(stderr, "testValueType\n"); + + MlirType parsedType = mlirTypeParseGet( + ctx, mlirStringRefCreateFromCString("!pdl.value")); + MlirType constructedType = mlirPDLValueTypeGet(ctx); + + assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType"); + assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType"); + + // CHECK: parsedType isa PDLType: 1 + fprintf(stderr, "parsedType isa PDLType: %d\n", + mlirTypeIsAPDLType(parsedType)); + // CHECK: parsedType isa PDLAttributeType: 0 + fprintf(stderr, "parsedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(parsedType)); + // CHECK: parsedType isa PDLOperationType: 0 + fprintf(stderr, "parsedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(parsedType)); + // CHECK: parsedType isa PDLRangeType: 0 + fprintf(stderr, "parsedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(parsedType)); + // CHECK: parsedType isa PDLTypeType: 0 + fprintf(stderr, "parsedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(parsedType)); + // CHECK: parsedType isa PDLValueType: 1 + fprintf(stderr, "parsedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(parsedType)); + + // CHECK: constructedType isa PDLType: 1 + fprintf(stderr, "constructedType isa PDLType: %d\n", + mlirTypeIsAPDLType(constructedType)); + // CHECK: constructedType isa PDLAttributeType: 0 + fprintf(stderr, "constructedType isa PDLAttributeType: %d\n", + mlirTypeIsAPDLAttributeType(constructedType)); + // CHECK: constructedType isa PDLOperationType: 0 + fprintf(stderr, "constructedType isa PDLOperationType: %d\n", + mlirTypeIsAPDLOperationType(constructedType)); + // CHECK: constructedType isa PDLRangeType: 0 + fprintf(stderr, "constructedType isa PDLRangeType: %d\n", + mlirTypeIsAPDLRangeType(constructedType)); + // CHECK: constructedType isa PDLTypeType: 0 + fprintf(stderr, "constructedType isa PDLTypeType: %d\n", + mlirTypeIsAPDLTypeType(constructedType)); + // CHECK: constructedType isa PDLValueType: 1 + fprintf(stderr, "constructedType isa PDLValueType: %d\n", + mlirTypeIsAPDLValueType(constructedType)); + + // CHECK: equal: 1 + fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType)); + + // CHECK: !pdl.value + mlirTypeDump(parsedType); + // CHECK: !pdl.value + mlirTypeDump(constructedType); + + fprintf(stderr, "\n\n"); +} + +int main() { + MlirContext ctx = mlirContextCreate(); + mlirDialectHandleRegisterDialect(mlirGetDialectHandle__pdl__(), ctx); + testAttributeType(ctx); + testOperationType(ctx); + testRangeType(ctx); + testTypeType(ctx); + testValueType(ctx); + return EXIT_SUCCESS; +} diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -75,6 +75,7 @@ mlir-capi-pass-test mlir-capi-sparse-tensor-test mlir-capi-quant-test + mlir-capi-pdl-test mlir-cpu-runner mlir-linalg-ods-yaml-gen mlir-lsp-server diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py --- a/mlir/test/lit.cfg.py +++ b/mlir/test/lit.cfg.py @@ -68,6 +68,7 @@ 'mlir-capi-pass-test', 'mlir-capi-sparse-tensor-test', 'mlir-capi-quant-test', + 'mlir-capi-pdl-test', 'mlir-cpu-runner', 'mlir-linalg-ods-yaml-gen', 'mlir-reduce', diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -514,6 +514,26 @@ ], ) +mlir_c_api_cc_library( + name = "CAPIPDL", + srcs = [ + "lib/CAPI/Dialect/PDL.cpp", + ], + hdrs = [ + "include/mlir-c/Dialect/PDL.h", + ], + header_deps = [ + ":CAPIIRHeaders", + ], + includes = ["include"], + deps = [ + ":CAPIIR", + ":PDLDialect", + ":PDLOpsIncGen", + ":PDLTypesIncGen", + ], +) + mlir_c_api_cc_library( name = "CAPIConversion", srcs = ["lib/CAPI/Conversion/Passes.cpp"],