Skip to content

Commit

Permalink
[mlir] don't use magic numbers in IRNumbering.cpp
Browse files Browse the repository at this point in the history
Bytecode versions have named constants that should be used instead of
magic numbers.
  • Loading branch information
ftynse committed Jan 4, 2024
1 parent 985bb3a commit 5ed11e7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mlir/lib/Bytecode/Writer/IRNumbering.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5ed11e7

Please sign in to comment.