@@ -105,26 +105,32 @@ class OpState {
105
105
Operation *getOperation () { return state; }
106
106
107
107
// / Return the dialect that this refers to.
108
- Dialect *getDialect () { return getOperation ()->getDialect (); }
108
+ LLVM_ATTRIBUTE_DEPRECATED (
109
+ Dialect *getDialect (),
110
+ "Use Operation::getDialect() instead (replace ' .' with ' ->' ).");
109
111
110
112
// / Return the parent Region of this operation.
111
- Region *getParentRegion () { return getOperation ()->getParentRegion (); }
113
+ LLVM_ATTRIBUTE_DEPRECATED (
114
+ Region *getParentRegion (),
115
+ "Use Operation::getParentRegion() instead (replace ' .' with ' ->' ).");
112
116
113
117
// / Returns the closest surrounding operation that contains this operation
114
118
// / or nullptr if this is a top-level operation.
115
- Operation *getParentOp () { return getOperation ()->getParentOp (); }
119
+ LLVM_ATTRIBUTE_DEPRECATED (
120
+ Operation *getParentOp (),
121
+ "Use Operation::getParentOp() instead (replace ' .' with ' ->' ).");
116
122
117
123
// / Return the closest surrounding parent operation that is of type 'OpTy'.
118
124
template <typename OpTy>
119
- OpTy getParentOfType () {
120
- return getOperation ()-> getParentOfType < OpTy>();
121
- }
125
+ LLVM_ATTRIBUTE_DEPRECATED (
126
+ OpTy getParentOfType (),
127
+ "Use Operation::getParentOfType() instead (replace ' . ' with ' -> ' ).");
122
128
123
129
// / Returns the closest surrounding parent operation with trait `Trait`.
124
130
template <template <typename T> class Trait >
125
- Operation * getParentWithTrait () {
126
- return getOperation ()-> getParentWithTrait <Trait>();
127
- }
131
+ LLVM_ATTRIBUTE_DEPRECATED (
132
+ Operation * getParentWithTrait (),
133
+ "Use Operation::getParentWithTrait() instead (replace ' . ' with ' -> ' ).");
128
134
129
135
// / Return the context this operation belongs to.
130
136
MLIRContext *getContext () { return getOperation ()->getContext (); }
@@ -153,35 +159,43 @@ class OpState {
153
159
using dialect_attr_range = Operation::dialect_attr_range;
154
160
155
161
// / Return a range corresponding to the dialect attributes for this operation.
156
- dialect_attr_range getDialectAttrs () { return state->getDialectAttrs (); }
157
- dialect_attr_iterator dialect_attr_begin () {
158
- return state->dialect_attr_begin ();
159
- }
160
- dialect_attr_iterator dialect_attr_end () { return state->dialect_attr_end (); }
162
+ LLVM_ATTRIBUTE_DEPRECATED (
163
+ dialect_attr_range getDialectAttrs (),
164
+ "Use Operation::getDialectAttrs() instead (replace ' .' with ' ->' ).");
165
+ LLVM_ATTRIBUTE_DEPRECATED (
166
+ dialect_attr_iterator dialect_attr_begin (),
167
+ "Use Operation::dialect_attr_begin() instead (replace ' .' with ' ->' ).");
168
+ LLVM_ATTRIBUTE_DEPRECATED (
169
+ dialect_attr_iterator dialect_attr_end (),
170
+ "Use Operation::dialect_attr_end() instead (replace ' .' with ' ->' ).");
161
171
162
172
// / Return an attribute with the specified name.
163
- Attribute getAttr (StringRef name) { return state->getAttr (name); }
173
+ LLVM_ATTRIBUTE_DEPRECATED (
174
+ Attribute getAttr (StringRef name),
175
+ "Use Operation::getAttr() instead (replace ' .' with ' ->' ).");
164
176
165
177
// / If the operation has an attribute of the specified type, return it.
166
178
template <typename AttrClass>
167
- AttrClass getAttrOfType (StringRef name) {
168
- return getAttr ( name). dyn_cast_or_null <AttrClass>();
169
- }
179
+ LLVM_ATTRIBUTE_DEPRECATED (
180
+ AttrClass getAttrOfType (StringRef name),
181
+ "Use Operation::getAttrOfType() instead (replace ' . ' with ' -> ' ).");
170
182
171
183
// / If the an attribute exists with the specified name, change it to the new
172
184
// / value. Otherwise, add a new attribute with the specified name/value.
173
- void setAttr (Identifier name, Attribute value) {
174
- state-> setAttr (name, value);
175
- }
176
- void setAttr (StringRef name, Attribute value) {
177
- setAttr (Identifier::get ( name, getContext ()), value);
178
- }
185
+ LLVM_ATTRIBUTE_DEPRECATED (
186
+ void setAttr (Identifier name, Attribute value),
187
+ "Use Operation::setAttr() instead (replace ' . ' with ' -> ' ).");
188
+ LLVM_ATTRIBUTE_DEPRECATED (
189
+ void setAttr (StringRef name, Attribute value),
190
+ "Use Operation::setAttr() instead (replace ' . ' with ' -> ' ).");
179
191
180
192
// / Set the attributes held by this operation.
181
- void setAttrs (ArrayRef<NamedAttribute> attributes) {
182
- state->setAttrs (DictionaryAttr::get (attributes, getContext ()));
183
- }
184
- void setAttrs (DictionaryAttr newAttrs) { state->setAttrs (newAttrs); }
193
+ LLVM_ATTRIBUTE_DEPRECATED (
194
+ void setAttrs (ArrayRef<NamedAttribute> attributes),
195
+ "Use Operation::setAttrs() instead (replace ' .' with ' ->' ).");
196
+ LLVM_ATTRIBUTE_DEPRECATED (
197
+ void setAttrs (DictionaryAttr newAttrs),
198
+ "Use Operation::setAttrs() instead (replace ' .' with ' ->' ).");
185
199
186
200
// / Set the dialect attributes for this operation, and preserve all dependent.
187
201
template <typename DialectAttrs>
@@ -258,6 +272,19 @@ class OpState {
258
272
friend AbstractOperation;
259
273
};
260
274
275
+ template <typename OpTy>
276
+ OpTy OpState::getParentOfType () {
277
+ return getOperation ()->getParentOfType <OpTy>();
278
+ }
279
+ template <template <typename T> class Trait >
280
+ Operation *OpState::getParentWithTrait () {
281
+ return getOperation ()->getParentWithTrait <Trait>();
282
+ }
283
+ template <typename AttrClass>
284
+ AttrClass OpState::getAttrOfType (StringRef name) {
285
+ return getAttr (name).dyn_cast_or_null <AttrClass>();
286
+ }
287
+
261
288
// Allow comparing operators.
262
289
inline bool operator ==(OpState lhs, OpState rhs) {
263
290
return lhs.getOperation () == rhs.getOperation ();
0 commit comments