[PATCH] D75953: [mlir] Add derived attribute op interface

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 12:00:50 PDT 2020


jpienaar created this revision.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, rriddle, mehdi_amini, mgorny.
Herald added a project: LLVM.

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

Reviewers: rriddle


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75953

Files:
  mlir/include/mlir/Analysis/CMakeLists.txt
  mlir/include/mlir/Analysis/DerivedAttributeOpInterface.h
  mlir/include/mlir/Analysis/DerivedAttributeOpInterface.td


Index: mlir/include/mlir/Analysis/DerivedAttributeOpInterface.td
===================================================================
--- /dev/null
+++ mlir/include/mlir/Analysis/DerivedAttributeOpInterface.td
@@ -0,0 +1,33 @@
+//===- 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.
+  }];
+
+  let methods = [
+    StaticInterfaceMethod<
+      /*desc=*/"Returns whether string corresponds to derived attribute.",
+      /*retTy=*/"bool",
+      /*methodName=*/"isDerivedAttribute",
+      /*args=*/(ins "StringRef":$name)
+    >,
+  ];
+}
+
+#endif // MLIR_DERIVEDATTRIBUTEOPINTERFACE
Index: mlir/include/mlir/Analysis/DerivedAttributeOpInterface.h
===================================================================
--- /dev/null
+++ mlir/include/mlir/Analysis/DerivedAttributeOpInterface.h
@@ -0,0 +1,26 @@
+//===- 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_ANALYSIS_DERIVEDATTRIBUTEOPINTERFACE_H_
+#define MLIR_ANALYSIS_DERIVEDATTRIBUTEOPINTERFACE_H_
+
+#include "mlir/IR/OpDefinition.h"
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace mlir {
+
+#include "mlir/Analysis/DerivedAttributeOpInterface.h.inc"
+
+} // namespace mlir
+
+#endif // MLIR_ANALYSIS_DERIVEDATTRIBUTEOPINTERFACE_H_
Index: mlir/include/mlir/Analysis/CMakeLists.txt
===================================================================
--- mlir/include/mlir/Analysis/CMakeLists.txt
+++ mlir/include/mlir/Analysis/CMakeLists.txt
@@ -8,6 +8,11 @@
 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(MLIRTypeInferOpInterfaceIncGen)
+
 set(LLVM_TARGET_DEFINITIONS InferTypeOpInterface.td)
 mlir_tablegen(InferTypeOpInterface.h.inc -gen-op-interface-decls)
 mlir_tablegen(InferTypeOpInterface.cpp.inc -gen-op-interface-defs)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75953.249465.patch
Type: text/x-patch
Size: 3320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200310/e338b2e3/attachment.bin>


More information about the llvm-commits mailing list