[Mlir-commits] [mlir] 5ed11e7 - [mlir] don't use magic numbers in IRNumbering.cpp

Alex Zinenko llvmlistbot at llvm.org
Thu Jan 4 01:49:42 PST 2024


Author: Alex Zinenko
Date: 2024-01-04T09:49:34Z
New Revision: 5ed11e767c0c39a3bc8e035588e7a383849d46a8

URL: https://github.com/llvm/llvm-project/commit/5ed11e767c0c39a3bc8e035588e7a383849d46a8
DIFF: https://github.com/llvm/llvm-project/commit/5ed11e767c0c39a3bc8e035588e7a383849d46a8.diff

LOG: [mlir] don't use magic numbers in IRNumbering.cpp

Bytecode versions have named constants that should be used instead of
magic numbers.

Added: 
    

Modified: 
    mlir/lib/Bytecode/Writer/IRNumbering.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index a306010698f200..f36c9ef060b6d7 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.


        


More information about the Mlir-commits mailing list