This allows for using other type interfaces in the builtin dialect, which currently results in a compile time failure (as it generates duplicate interface declarations).
--- /dev/null
+//===- BuiltinTypeInterfaces.td - Builtin type 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains definitions for type interfaces that closely interact with
+// attributes, types, and operations in the builtin dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_IR_BUILTINTYPEINTERFACES_TD_
+#define MLIR_IR_BUILTINTYPEINTERFACES_TD_
+
+include "mlir/IR/OpBase.td"
+
+//===----------------------------------------------------------------------===//
+// MemRefElementTypeInterface
+//===----------------------------------------------------------------------===//
+
+def MemRefElementTypeInterface : TypeInterface<"MemRefElementTypeInterface"> {
+ let cppNamespace = "::mlir";
+ let description = [{
+ Indication that this type can be used as element in memref types.
+
+ Implementing this interface establishes a contract between this type and the
+ memref type indicating that this type can be used as element of ranked or
+ unranked memrefs. The type is expected to:
+
+ - model an entity stored in memory;
+ - have non-zero size.
+
+ For example, scalar values such as integers can implement this interface,
+ but indicator types such as `void` or `unit` should not.
+
+ The interface currently has no methods and is used by types to opt into
+ being memref elements. This may change in the future, in particular to
+ require types to provide their size or alignment given a data layout.
+ }];
+}
+
+#endif // MLIR_IR_BUILTINTYPEINTERFACES_TD_
#define BUILTIN_TYPES
include "mlir/IR/BuiltinDialect.td"
+include "mlir/IR/BuiltinTypeInterfaces.td"
// TODO: Currently the types defined in this file are prefixed with `Builtin_`.
// This is to differentiate the types here with the ones in OpBase.td. We should
}
//===----------------------------------------------------------------------===//
-// MemRefElementTypeInterface
-//===----------------------------------------------------------------------===//
-
-def MemRefElementTypeInterface : TypeInterface<"MemRefElementTypeInterface"> {
- let cppNamespace = "::mlir";
- let description = [{
- Indication that this type can be used as element in memref types.
-
- Implementing this interface establishes a contract between this type and the
- memref type indicating that this type can be used as element of ranked or
- unranked memrefs. The type is expected to:
-
- - model an entity stored in memory;
- - have non-zero size.
-
- For example, scalar values such as integers can implement this interface,
- but indicator types such as `void` or `unit` should not.
-
- The interface currently has no methods and is used by types to opt into
- being memref elements. This may change in the future, in particular to
- require types to provide their size or alignment given a data layout.
- }];
-}
-
-//===----------------------------------------------------------------------===//
// MemRefType
//===----------------------------------------------------------------------===//
set(LLVM_TARGET_DEFINITIONS BuiltinTypes.td)
mlir_tablegen(BuiltinTypes.h.inc -gen-typedef-decls)
mlir_tablegen(BuiltinTypes.cpp.inc -gen-typedef-defs)
+add_public_tablegen_target(MLIRBuiltinTypesIncGen)
+
+set(LLVM_TARGET_DEFINITIONS BuiltinTypeInterfaces.td)
mlir_tablegen(BuiltinTypeInterfaces.h.inc -gen-type-interface-decls)
mlir_tablegen(BuiltinTypeInterfaces.cpp.inc -gen-type-interface-defs)
-add_public_tablegen_target(MLIRBuiltinTypesIncGen)
+add_public_tablegen_target(MLIRBuiltinTypeInterfacesIncGen)
set(LLVM_TARGET_DEFINITIONS TensorEncoding.td)
mlir_tablegen(TensorEncInterfaces.h.inc -gen-attr-interface-decls)
MLIRBuiltinLocationAttributesIncGen
MLIRBuiltinOpsIncGen
MLIRBuiltinTypesIncGen
+ MLIRBuiltinTypeInterfacesIncGen
MLIRCallInterfacesIncGen
MLIRCastInterfacesIncGen
MLIRDataLayoutInterfacesIncGen