[Mlir-commits] [mlir] 36e018b - [mlir] Add derived attribute op interface

Jacques Pienaar llvmlistbot at llvm.org
Thu Mar 12 10:32:42 PDT 2020


Author: Jacques Pienaar
Date: 2020-03-12T10:32:24-07:00
New Revision: 36e018b94111b90797489050aa8edc004781a1b5

URL: https://github.com/llvm/llvm-project/commit/36e018b94111b90797489050aa8edc004781a1b5
DIFF: https://github.com/llvm/llvm-project/commit/36e018b94111b90797489050aa8edc004781a1b5.diff

LOG: [mlir] Add derived attribute op interface

Interface provides uniform access to the the derived attribute query method.

Added: 
    mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.h
    mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.td
    mlir/lib/Interfaces/DerivedAttributeOpInterface.cpp

Modified: 
    mlir/include/mlir/Interfaces/CMakeLists.txt
    mlir/lib/Interfaces/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt
index 340c531077ed..4fe1871ad40c 100644
--- a/mlir/include/mlir/Interfaces/CMakeLists.txt
+++ b/mlir/include/mlir/Interfaces/CMakeLists.txt
@@ -8,6 +8,11 @@ mlir_tablegen(ControlFlowInterfaces.h.inc -gen-op-interface-decls)
 mlir_tablegen(ControlFlowInterfaces.cpp.inc -gen-op-interface-defs)
 add_public_tablegen_target(MLIRControlFlowInterfacesIncGen)
 
+set(LLVM_TARGET_DEFINITIONS DerivedAttributeOpInterface.td)
+mlir_tablegen(DerivedAttributeOpInterface.h.inc -gen-op-interface-decls)
+mlir_tablegen(DerivedAttributeOpInterface.cpp.inc -gen-op-interface-defs)
+add_public_tablegen_target(MLIRDerivedAttributeOpInterfaceIncGen)
+
 set(LLVM_TARGET_DEFINITIONS InferTypeOpInterface.td)
 mlir_tablegen(InferTypeOpInterface.h.inc -gen-op-interface-decls)
 mlir_tablegen(InferTypeOpInterface.cpp.inc -gen-op-interface-defs)

diff  --git a/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.h b/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.h
new file mode 100644
index 000000000000..debafc2438d2
--- /dev/null
+++ b/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.h
@@ -0,0 +1,22 @@
+//===- DerivedAttributeOpInterface.h ----------------------------*- C++ -*-===//
+//
+// 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 a set of interfaces for derived attribute op interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INTERFACES_DERIVEDATTRIBUTEOPINTERFACE_H_
+#define MLIR_INTERFACES_DERIVEDATTRIBUTEOPINTERFACE_H_
+
+#include "mlir/IR/OpDefinition.h"
+
+namespace mlir {
+#include "mlir/Interfaces/DerivedAttributeOpInterface.h.inc"
+} // namespace mlir
+
+#endif // MLIR_INTERFACES_DERIVEDATTRIBUTEOPINTERFACE_H_

diff  --git a/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.td b/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.td
new file mode 100644
index 000000000000..68b9c6c39f43
--- /dev/null
+++ b/mlir/include/mlir/Interfaces/DerivedAttributeOpInterface.td
@@ -0,0 +1,37 @@
+//===- DerivedAttributeOpInterface.td ----------------------*- 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 a set of interfaces for derived attribute op interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DERIVEDATTRIBUTEOPINTERFACE
+#define MLIR_DERIVEDATTRIBUTEOPINTERFACE
+
+include "mlir/IR/OpBase.td"
+
+def DerivedAttributeOpInterface : OpInterface<"DerivedAttributeOpInterface"> {
+  let description = [{
+    Interface to query derived attribute characteristics.
+
+    Derived attributes are not stored in the operation but are instead derived
+    from information of the operation. ODS generates convenience accessors for
+    derived attributes and can be used to simplify translations.
+  }];
+
+  let methods = [
+    StaticInterfaceMethod<
+      /*desc=*/"Returns whether name corresponds to a derived attribute.",
+      /*retTy=*/"bool",
+      /*methodName=*/"isDerivedAttribute",
+      /*args=*/(ins "StringRef":$name)
+    >,
+  ];
+}
+
+#endif // MLIR_DERIVEDATTRIBUTEOPINTERFACE

diff  --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt
index dc5e534fbd54..ccbfcf83b429 100644
--- a/mlir/lib/Interfaces/CMakeLists.txt
+++ b/mlir/lib/Interfaces/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_OPTIONAL_SOURCES
   CallInterfaces.cpp
   ControlFlowInterfaces.cpp
+  DerivedAttributeOpInterface.cpp
   InferTypeOpInterface.cpp
   SideEffects.cpp
   )
@@ -33,6 +34,20 @@ target_link_libraries(MLIRControlFlowInterfaces
   MLIRIR
   )
 
+add_llvm_library(MLIRDerivedAttributeOpInterface
+  DerivedAttributeOpInterface.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces
+  )
+add_dependencies(MLIRDerivedAttributeOpInterface
+  MLIRDerivedAttributeOpInterfaceIncGen
+  )
+target_link_libraries(MLIRDerivedAttributeOpInterface
+  PUBLIC
+  MLIRIR
+  )
+
 add_llvm_library(MLIRInferTypeOpInterface
   InferTypeOpInterface.cpp
 

diff  --git a/mlir/lib/Interfaces/DerivedAttributeOpInterface.cpp b/mlir/lib/Interfaces/DerivedAttributeOpInterface.cpp
new file mode 100644
index 000000000000..df5a5526d07e
--- /dev/null
+++ b/mlir/lib/Interfaces/DerivedAttributeOpInterface.cpp
@@ -0,0 +1,19 @@
+//===- DerivedAttributeOpInterface.cpp -- Derived Attribute interfaces ----===//
+//
+// 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 a set of interfaces for derived attribute op interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Interfaces/DerivedAttributeOpInterface.h"
+
+using namespace mlir;
+
+namespace mlir {
+#include "mlir/Interfaces/DerivedAttributeOpInterface.cpp.inc"
+} // namespace mlir


        


More information about the Mlir-commits mailing list