[llvm-branch-commits] [mlir] c3529a5 - [mlir] Mark methods from mlir::OpState that just forward to mlir::Operation as deprecated.
Christian Sigg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 7 00:12:59 PST 2021
Author: Christian Sigg
Date: 2021-01-07T09:08:47+01:00
New Revision: c3529a5b0806843e75f0b6d9a83bb36de70b5ae6
URL: https://github.com/llvm/llvm-project/commit/c3529a5b0806843e75f0b6d9a83bb36de70b5ae6
DIFF: https://github.com/llvm/llvm-project/commit/c3529a5b0806843e75f0b6d9a83bb36de70b5ae6.diff
LOG: [mlir] Mark methods from mlir::OpState that just forward to mlir::Operation as deprecated.
The functions will be removed by January 20th.
All call sites within MLIR have been converted in previous changes.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D94191
Added:
Modified:
mlir/include/mlir/IR/OpDefinition.h
mlir/lib/IR/Operation.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 11dc4b77b677..e698ced314a1 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -105,26 +105,32 @@ class OpState {
Operation *getOperation() { return state; }
/// Return the dialect that this refers to.
- Dialect *getDialect() { return getOperation()->getDialect(); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ Dialect *getDialect(),
+ "Use Operation::getDialect() instead (replace '.' with '->').");
/// Return the parent Region of this operation.
- Region *getParentRegion() { return getOperation()->getParentRegion(); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ Region *getParentRegion(),
+ "Use Operation::getParentRegion() instead (replace '.' with '->').");
/// Returns the closest surrounding operation that contains this operation
/// or nullptr if this is a top-level operation.
- Operation *getParentOp() { return getOperation()->getParentOp(); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ Operation *getParentOp(),
+ "Use Operation::getParentOp() instead (replace '.' with '->').");
/// Return the closest surrounding parent operation that is of type 'OpTy'.
template <typename OpTy>
- OpTy getParentOfType() {
- return getOperation()->getParentOfType<OpTy>();
- }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ OpTy getParentOfType(),
+ "Use Operation::getParentOfType() instead (replace '.' with '->').");
/// Returns the closest surrounding parent operation with trait `Trait`.
template <template <typename T> class Trait>
- Operation *getParentWithTrait() {
- return getOperation()->getParentWithTrait<Trait>();
- }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ Operation *getParentWithTrait(),
+ "Use Operation::getParentWithTrait() instead (replace '.' with '->').");
/// Return the context this operation belongs to.
MLIRContext *getContext() { return getOperation()->getContext(); }
@@ -153,35 +159,43 @@ class OpState {
using dialect_attr_range = Operation::dialect_attr_range;
/// Return a range corresponding to the dialect attributes for this operation.
- dialect_attr_range getDialectAttrs() { return state->getDialectAttrs(); }
- dialect_attr_iterator dialect_attr_begin() {
- return state->dialect_attr_begin();
- }
- dialect_attr_iterator dialect_attr_end() { return state->dialect_attr_end(); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ dialect_attr_range getDialectAttrs(),
+ "Use Operation::getDialectAttrs() instead (replace '.' with '->').");
+ LLVM_ATTRIBUTE_DEPRECATED(
+ dialect_attr_iterator dialect_attr_begin(),
+ "Use Operation::dialect_attr_begin() instead (replace '.' with '->').");
+ LLVM_ATTRIBUTE_DEPRECATED(
+ dialect_attr_iterator dialect_attr_end(),
+ "Use Operation::dialect_attr_end() instead (replace '.' with '->').");
/// Return an attribute with the specified name.
- Attribute getAttr(StringRef name) { return state->getAttr(name); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ Attribute getAttr(StringRef name),
+ "Use Operation::getAttr() instead (replace '.' with '->').");
/// If the operation has an attribute of the specified type, return it.
template <typename AttrClass>
- AttrClass getAttrOfType(StringRef name) {
- return getAttr(name).dyn_cast_or_null<AttrClass>();
- }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ AttrClass getAttrOfType(StringRef name),
+ "Use Operation::getAttrOfType() instead (replace '.' with '->').");
/// If the an attribute exists with the specified name, change it to the new
/// value. Otherwise, add a new attribute with the specified name/value.
- void setAttr(Identifier name, Attribute value) {
- state->setAttr(name, value);
- }
- void setAttr(StringRef name, Attribute value) {
- setAttr(Identifier::get(name, getContext()), value);
- }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ void setAttr(Identifier name, Attribute value),
+ "Use Operation::setAttr() instead (replace '.' with '->').");
+ LLVM_ATTRIBUTE_DEPRECATED(
+ void setAttr(StringRef name, Attribute value),
+ "Use Operation::setAttr() instead (replace '.' with '->').");
/// Set the attributes held by this operation.
- void setAttrs(ArrayRef<NamedAttribute> attributes) {
- state->setAttrs(DictionaryAttr::get(attributes, getContext()));
- }
- void setAttrs(DictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
+ LLVM_ATTRIBUTE_DEPRECATED(
+ void setAttrs(ArrayRef<NamedAttribute> attributes),
+ "Use Operation::setAttrs() instead (replace '.' with '->').");
+ LLVM_ATTRIBUTE_DEPRECATED(
+ void setAttrs(DictionaryAttr newAttrs),
+ "Use Operation::setAttrs() instead (replace '.' with '->').");
/// Set the dialect attributes for this operation, and preserve all dependent.
template <typename DialectAttrs>
@@ -258,6 +272,19 @@ class OpState {
friend AbstractOperation;
};
+template <typename OpTy>
+OpTy OpState::getParentOfType() {
+ return getOperation()->getParentOfType<OpTy>();
+}
+template <template <typename T> class Trait>
+Operation *OpState::getParentWithTrait() {
+ return getOperation()->getParentWithTrait<Trait>();
+}
+template <typename AttrClass>
+AttrClass OpState::getAttrOfType(StringRef name) {
+ return getAttr(name).dyn_cast_or_null<AttrClass>();
+}
+
// Allow comparing operators.
inline bool operator==(OpState lhs, OpState rhs) {
return lhs.getOperation() == rhs.getOperation();
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 285d31a8f52e..4152121dd548 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -692,6 +692,30 @@ InFlightDiagnostic OpState::emitRemark(const Twine &message) {
return getOperation()->emitRemark(message);
}
+Dialect *OpState::getDialect() { return getOperation()->getDialect(); }
+Region *OpState::getParentRegion() { return getOperation()->getParentRegion(); }
+Operation *OpState::getParentOp() { return getOperation()->getParentOp(); }
+OpState::dialect_attr_range OpState::getDialectAttrs() {
+ return state->getDialectAttrs();
+}
+OpState::dialect_attr_iterator OpState::dialect_attr_begin() {
+ return state->dialect_attr_begin();
+}
+OpState::dialect_attr_iterator OpState::dialect_attr_end() {
+ return state->dialect_attr_end();
+}
+Attribute OpState::getAttr(StringRef name) { return state->getAttr(name); }
+void OpState::setAttr(Identifier name, Attribute value) {
+ state->setAttr(name, value);
+}
+void OpState::setAttr(StringRef name, Attribute value) {
+ setAttr(Identifier::get(name, getContext()), value);
+}
+void OpState::setAttrs(ArrayRef<NamedAttribute> attributes) {
+ state->setAttrs(DictionaryAttr::get(attributes, getContext()));
+}
+void OpState::setAttrs(DictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
+
//===----------------------------------------------------------------------===//
// Op Trait implementations
//===----------------------------------------------------------------------===//
More information about the llvm-branch-commits
mailing list