[mlir][IR] Move MemRefElementTypeInterface to a new BuiltinTypeInterfaces file
authorRiver Riddle <riddleriver@gmail.com>
Fri, 11 Jun 2021 00:22:37 +0000 (17:22 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Fri, 11 Jun 2021 00:23:06 +0000 (17:23 -0700)
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).

mlir/include/mlir/IR/BuiltinTypeInterfaces.td [new file with mode: 0644]
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/CMakeLists.txt
mlir/lib/IR/CMakeLists.txt

diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
new file mode 100644 (file)
index 0000000..f8879e5
--- /dev/null
@@ -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_
index b142f6e..3ad6e15 100644 (file)
@@ -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 differentiate the types here with the ones in OpBase.td. We should
@@ -249,31 +250,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
 //===----------------------------------------------------------------------===//
 
index b8b49aa..8dafaa1 100644 (file)
@@ -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)
index 06f1985..a04bc35 100644 (file)
@@ -39,6 +39,7 @@ add_mlir_library(MLIRIR
   MLIRBuiltinLocationAttributesIncGen
   MLIRBuiltinOpsIncGen
   MLIRBuiltinTypesIncGen
+  MLIRBuiltinTypeInterfacesIncGen
   MLIRCallInterfacesIncGen
   MLIRCastInterfacesIncGen
   MLIRDataLayoutInterfacesIncGen