[Mlir-commits] [mlir] f8a1d65 - [mlir][IR] Move MemRefElementTypeInterface to a new BuiltinTypeInterfaces file
River Riddle
llvmlistbot at llvm.org
Thu Jun 10 17:28:43 PDT 2021
Author: River Riddle
Date: 2021-06-10T17:23:06-07:00
New Revision: f8a1d652da00ecff448213c58522da5a61d9bc4b
URL: https://github.com/llvm/llvm-project/commit/f8a1d652da00ecff448213c58522da5a61d9bc4b
DIFF: https://github.com/llvm/llvm-project/commit/f8a1d652da00ecff448213c58522da5a61d9bc4b.diff
LOG: [mlir][IR] Move MemRefElementTypeInterface to a new BuiltinTypeInterfaces file
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).
Added:
mlir/include/mlir/IR/BuiltinTypeInterfaces.td
Modified:
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/CMakeLists.txt
mlir/lib/IR/CMakeLists.txt
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
new file mode 100644
index 0000000000000..f8879e55bfd48
--- /dev/null
+++ b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
@@ -0,0 +1,44 @@
+//===- 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_
diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td
index b142f6e4865d1..3ad6e1512bc7e 100644
--- a/mlir/include/mlir/IR/BuiltinTypes.td
+++ b/mlir/include/mlir/IR/BuiltinTypes.td
@@ -15,6 +15,7 @@
#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
diff erentiate the types here with the ones in OpBase.td. We should
@@ -248,31 +249,6 @@ def Builtin_Integer : Builtin_Type<"Integer"> {
}];
}
-//===----------------------------------------------------------------------===//
-// 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
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/IR/CMakeLists.txt b/mlir/include/mlir/IR/CMakeLists.txt
index b8b49aa425a9b..8dafaa1ebdac9 100644
--- a/mlir/include/mlir/IR/CMakeLists.txt
+++ b/mlir/include/mlir/IR/CMakeLists.txt
@@ -24,9 +24,12 @@ add_public_tablegen_target(MLIRBuiltinOpsIncGen)
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)
diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt
index 06f1985b53283..a04bc3522a722 100644
--- a/mlir/lib/IR/CMakeLists.txt
+++ b/mlir/lib/IR/CMakeLists.txt
@@ -39,6 +39,7 @@ add_mlir_library(MLIRIR
MLIRBuiltinLocationAttributesIncGen
MLIRBuiltinOpsIncGen
MLIRBuiltinTypesIncGen
+ MLIRBuiltinTypeInterfacesIncGen
MLIRCallInterfacesIncGen
MLIRCastInterfacesIncGen
MLIRDataLayoutInterfacesIncGen
More information about the Mlir-commits
mailing list