diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h new file mode 100644 --- /dev/null +++ b/mlir/include/mlir-c/Dialect/LLVM.h @@ -0,0 +1,30 @@ +//===-- mlir-c/Dialect/LLVM.h - C API for LLVM --------------------*- 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_LLVM_H +#define MLIR_C_DIALECT_LLVM_H + +#include "mlir-c/IR.h" +#include "mlir-c/Registration.h" + +#ifdef __cplusplus +extern "C" { +#endif + +MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(LLVM, llvm); + +// Creates an llvm.ptr type +MLIR_CAPI_EXPORTED MlirType mlirLLVMPointerTypeGet(MlirType pointee, + unsigned addressSpace); + +#ifdef __cplusplus +} +#endif + +#endif // MLIR_C_DIALECT_LLVM_H diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/CAPI/Dialect/LLVM.cpp @@ -0,0 +1,21 @@ +//===- Linalg.cpp - C Interface for LLVM 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/LLVM.h" +#include "mlir/CAPI/Registration.h" +#include "mlir/Dialect/LLVMIR/LLVMDialect.h" +#include "mlir/Dialect/LLVMIR/LLVMTypes.h" + +using namespace mlir; +using namespace mlir::LLVM; + +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(LLVM, llvm, LLVMDialect) + +MlirType mlirLLVMPointerTypeGet(MlirType pointee, unsigned addressSpace) { + return wrap(LLVMPointerType::get(unwrap(pointee), addressSpace)); +}