Files
gps/tools/local/circt/include/mlir/Conversion/ConvertToLLVM/ToLLVMInterface.td
T
2026-07-12 11:01:51 +03:00

114 lines
4.3 KiB
TableGen

//===- ToLLVMInterface.td - Conversion to LLVM interfaces -----*- tablegen -*-===//
// 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
//
//===----------------------------------------------------------------------===//
//
// Defines interfaces for managing transformations, including populating
// pattern rewrites.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD
#define MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD
include "mlir/IR/OpBase.td"
//===----------------------------------------------------------------------===//
// Attribute interface
//===----------------------------------------------------------------------===//
def ConvertToLLVMAttrInterface :
AttrInterface<"ConvertToLLVMAttrInterface"> {
let description = [{
The `ConvertToLLVMAttrInterface` attribute interfaces allows using
attributes to configure the convert to LLVM infrastructure, this includes:
- The conversion target.
- The LLVM type converter.
- The pattern set.
This interface permits fined grained configuration of the `convert-to-llvm`
process. For example, attributes with target information like
`#nvvm.target` or `#rodcl.target` can leverage this interface for populating
patterns specific to a particular target.
}];
let cppNamespace = "::mlir";
let methods = [
InterfaceMethod<
/*desc=*/[{
Populate the dialect conversion target, type converter and pattern set.
}],
/*retTy=*/"void",
/*methodName=*/"populateConvertToLLVMConversionPatterns",
/*args=*/(ins "::mlir::ConversionTarget&":$target,
"::mlir::LLVMTypeConverter&":$typeConverter,
"::mlir::RewritePatternSet&":$patternSet)>
];
}
//===----------------------------------------------------------------------===//
// Op interface
//===----------------------------------------------------------------------===//
def ConvertToLLVMOpInterface : OpInterface<"ConvertToLLVMOpInterface"> {
let description = [{
Interface for collecting all convert to LLVM attributes stored in an
operation. See `ConvertToLLVMAttrInterface` for more information on these
attributes.
}];
let cppNamespace = "::mlir";
let methods = [
InterfaceMethod<
/*desc=*/[{
Populate the provided vector with a list of convert to LLVM attributes
to apply.
}],
/*retTy=*/"void",
/*methodName=*/"getConvertToLLVMConversionAttrs",
/*args=*/(ins
"::llvm::SmallVectorImpl<::mlir::ConvertToLLVMAttrInterface>&":$attrs)
>
];
}
//===----------------------------------------------------------------------===//
// Dialect interface
//===----------------------------------------------------------------------===//
def ConvertToLLVMPatternInterface : DialectInterface<"ConvertToLLVMPatternInterface"> {
let description = [{
Base class for dialect interfaces providing translation to LLVM IR.
Dialects that can be translated should provide an implementation of this
interface for the supported operations. The interface may be implemented in
a separate library to avoid the "main" dialect library depending on LLVM IR.
The interface can be attached using the delayed registration mechanism
available in DialectRegistry.
}];
let cppNamespace = "::mlir";
let methods = [
InterfaceMethod<[{
Hook for derived dialect interface to load the dialects they
target. The LLVMDialect is implicitly already loaded, but this
method allows to load other intermediate dialects used in the
conversion, or target dialects like NVVM for example.
}],
"void", "loadDependentDialects",
(ins "::mlir::MLIRContext *":$context), [{}]
>,
PureVirtualInterfaceMethod<[{
Hook for derived dialect interface to provide conversion patterns
and mark dialect legal for the conversion target.
}],
"void", "populateConvertToLLVMConversionPatterns",
(ins "::mlir::ConversionTarget &":$target,
"::mlir::LLVMTypeConverter &":$typeConverter,
"::mlir::RewritePatternSet &":$patterns)
>
];
}
#endif // MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD