summaryrefslogtreecommitdiff
path: root/mlir/lib/Bytecode
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2024-01-04 09:48:29 +0000
committerAlex Zinenko <zinenko@google.com>2024-01-04 09:49:34 +0000
commit5ed11e767c0c39a3bc8e035588e7a383849d46a8 (patch)
tree978e793280741fb6ce60a7a27e40002b6de0446b /mlir/lib/Bytecode
parent985bb3a20a788b3cda3256084fbdef20296ba8cb (diff)
[mlir] don't use magic numbers in IRNumbering.cpp
Bytecode versions have named constants that should be used instead of magic numbers.
Diffstat (limited to 'mlir/lib/Bytecode')
-rw-r--r--mlir/lib/Bytecode/Writer/IRNumbering.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index a306010698f2..f36c9ef060b6 100644
--- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp
+++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
@@ -9,6 +9,7 @@
#include "IRNumbering.h"
#include "mlir/Bytecode/BytecodeImplementation.h"
#include "mlir/Bytecode/BytecodeOpInterface.h"
+#include "mlir/Bytecode/Encoding.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
@@ -425,17 +426,20 @@ void IRNumberingState::number(Operation &op) {
// Only number the operation's dictionary if it isn't empty.
DictionaryAttr dictAttr = op.getDiscardableAttrDictionary();
- // Prior to version 5, or when properties are not used, we need to number also
- // the merged dictionary containing both the inherent and discardable
- // attribute.
- if (config.getDesiredBytecodeVersion() < 5 || !op.getPropertiesStorage())
+ // Prior to a version with native property encoding, or when properties are
+ // not used, we need to number also the merged dictionary containing both the
+ // inherent and discardable attribute.
+ if (config.getDesiredBytecodeVersion() <
+ bytecode::kNativePropertiesEncoding ||
+ !op.getPropertiesStorage()) {
dictAttr = op.getAttrDictionary();
+ }
if (!dictAttr.empty())
number(dictAttr);
// Visit the operation properties (if any) to make sure referenced attributes
// are numbered.
- if (config.getDesiredBytecodeVersion() >= 5 &&
+ if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding &&
op.getPropertiesStorageSize()) {
if (op.isRegistered()) {
// Operation that have properties *must* implement this interface.