|
| 1 | + |
| 2 | +//===- ToLLVMInterface.td - Conversion to LLVM interfaces -----*- tablegen -*-===// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// Defines interfaces for managing transformations, including populating |
| 10 | +// pattern rewrites. |
| 11 | +// |
| 12 | +//===----------------------------------------------------------------------===// |
| 13 | + |
| 14 | +#ifndef MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD |
| 15 | +#define MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD |
| 16 | + |
| 17 | +include "mlir/IR/OpBase.td" |
| 18 | + |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | +// Attribute interface |
| 21 | +//===----------------------------------------------------------------------===// |
| 22 | + |
| 23 | +def ConvertToLLVMAttrInterface : |
| 24 | + AttrInterface<"ConvertToLLVMAttrInterface"> { |
| 25 | + let description = [{ |
| 26 | + The `ConvertToLLVMAttrInterface` attribute interfaces allows using |
| 27 | + attributes to configure the convert to LLVM infrastructure, this includes: |
| 28 | + - The conversion target. |
| 29 | + - The LLVM type converter. |
| 30 | + - The pattern set. |
| 31 | + |
| 32 | + This interface permits fined grained configuration of the `convert-to-llvm` |
| 33 | + process. For example, attributes with target information like |
| 34 | + `#nvvm.target` or `#rodcl.target` can leverage this interface for populating |
| 35 | + patterns specific to a particular target. |
| 36 | + }]; |
| 37 | + let cppNamespace = "::mlir"; |
| 38 | + let methods = [ |
| 39 | + InterfaceMethod< |
| 40 | + /*desc=*/[{ |
| 41 | + Populate the dialect conversion target, type converter and pattern set. |
| 42 | + }], |
| 43 | + /*retTy=*/"void", |
| 44 | + /*methodName=*/"populateConvertToLLVMConversionPatterns", |
| 45 | + /*args=*/(ins "::mlir::ConversionTarget&":$target, |
| 46 | + "::mlir::LLVMTypeConverter&":$typeConverter, |
| 47 | + "::mlir::RewritePatternSet&":$patternSet)> |
| 48 | + ]; |
| 49 | +} |
| 50 | + |
| 51 | +//===----------------------------------------------------------------------===// |
| 52 | +// Op interface |
| 53 | +//===----------------------------------------------------------------------===// |
| 54 | + |
| 55 | +def ConvertToLLVMOpInterface : OpInterface<"ConvertToLLVMOpInterface"> { |
| 56 | + let description = [{ |
| 57 | + Interface for collecting all convert to LLVM attributes stored in an |
| 58 | + operation. See `ConvertToLLVMAttrInterface` for more information on these |
| 59 | + attributes. |
| 60 | + }]; |
| 61 | + let cppNamespace = "::mlir"; |
| 62 | + let methods = [ |
| 63 | + InterfaceMethod< |
| 64 | + /*desc=*/[{ |
| 65 | + Populate the provided vector with a list of convert to LLVM attributes |
| 66 | + to apply. |
| 67 | + }], |
| 68 | + /*retTy=*/"void", |
| 69 | + /*methodName=*/"getConvertToLLVMConversionAttrs", |
| 70 | + /*args=*/(ins |
| 71 | + "::llvm::SmallVectorImpl<::mlir::ConvertToLLVMAttrInterface>&":$attrs) |
| 72 | + > |
| 73 | + ]; |
| 74 | +} |
| 75 | + |
| 76 | +#endif // MLIR_CONVERSION_CONVERTTOLLVM_TOLLVMINTERFACE_TD |
0 commit comments