Skip to content

Commit 5ed11e7

Browse files
committed
[mlir] don't use magic numbers in IRNumbering.cpp
Bytecode versions have named constants that should be used instead of magic numbers.
1 parent 985bb3a commit 5ed11e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mlir/lib/Bytecode/Writer/IRNumbering.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "IRNumbering.h"
1010
#include "mlir/Bytecode/BytecodeImplementation.h"
1111
#include "mlir/Bytecode/BytecodeOpInterface.h"
12+
#include "mlir/Bytecode/Encoding.h"
1213
#include "mlir/IR/AsmState.h"
1314
#include "mlir/IR/BuiltinTypes.h"
1415
#include "mlir/IR/OpDefinition.h"
@@ -425,17 +426,20 @@ void IRNumberingState::number(Operation &op) {
425426

426427
// Only number the operation's dictionary if it isn't empty.
427428
DictionaryAttr dictAttr = op.getDiscardableAttrDictionary();
428-
// Prior to version 5, or when properties are not used, we need to number also
429-
// the merged dictionary containing both the inherent and discardable
430-
// attribute.
431-
if (config.getDesiredBytecodeVersion() < 5 || !op.getPropertiesStorage())
429+
// Prior to a version with native property encoding, or when properties are
430+
// not used, we need to number also the merged dictionary containing both the
431+
// inherent and discardable attribute.
432+
if (config.getDesiredBytecodeVersion() <
433+
bytecode::kNativePropertiesEncoding ||
434+
!op.getPropertiesStorage()) {
432435
dictAttr = op.getAttrDictionary();
436+
}
433437
if (!dictAttr.empty())
434438
number(dictAttr);
435439

436440
// Visit the operation properties (if any) to make sure referenced attributes
437441
// are numbered.
438-
if (config.getDesiredBytecodeVersion() >= 5 &&
442+
if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding &&
439443
op.getPropertiesStorageSize()) {
440444
if (op.isRegistered()) {
441445
// Operation that have properties *must* implement this interface.

0 commit comments

Comments
 (0)