@@ -657,7 +657,7 @@ LogicalResult BytecodeWriter::write(Operation *rootOp, raw_ostream &os) {
657
657
writeStringSection (emitter);
658
658
659
659
// Emit the properties section.
660
- if (config.bytecodeVersion >= 5 )
660
+ if (config.bytecodeVersion >= bytecode:: kNativePropertiesEncoding )
661
661
writePropertiesSection (emitter);
662
662
else if (!propertiesSection.empty ())
663
663
return rootOp->emitError (
@@ -708,7 +708,7 @@ void BytecodeWriter::writeDialectSection(EncodingEmitter &emitter) {
708
708
// Write the string section and get the ID.
709
709
size_t nameID = stringSection.insert (dialect.name );
710
710
711
- if (config.bytecodeVersion == 0 ) {
711
+ if (config.bytecodeVersion < bytecode:: kDialectVersioning ) {
712
712
dialectEmitter.emitVarInt (nameID);
713
713
continue ;
714
714
}
@@ -732,13 +732,13 @@ void BytecodeWriter::writeDialectSection(EncodingEmitter &emitter) {
732
732
std::move (versionEmitter));
733
733
}
734
734
735
- if (config.bytecodeVersion > 3 )
735
+ if (config.bytecodeVersion >= bytecode:: kElideUnknownBlockArgLocation )
736
736
dialectEmitter.emitVarInt (size (numberingState.getOpNames ()));
737
737
738
738
// Emit the referenced operation names grouped by dialect.
739
739
auto emitOpName = [&](OpNameNumbering &name) {
740
740
size_t stringId = stringSection.insert (name.name .stripDialect ());
741
- if (config.bytecodeVersion < 5 )
741
+ if (config.bytecodeVersion < bytecode:: kNativePropertiesEncoding )
742
742
dialectEmitter.emitVarInt (stringId);
743
743
else
744
744
dialectEmitter.emitVarIntWithFlag (stringId, name.name .isRegistered ());
@@ -826,7 +826,7 @@ LogicalResult BytecodeWriter::writeBlock(EncodingEmitter &emitter,
826
826
emitter.emitVarInt (args.size ());
827
827
for (BlockArgument arg : args) {
828
828
Location argLoc = arg.getLoc ();
829
- if (config.bytecodeVersion > 3 ) {
829
+ if (config.bytecodeVersion >= bytecode:: kElideUnknownBlockArgLocation ) {
830
830
emitter.emitVarIntWithFlag (numberingState.getNumber (arg.getType ()),
831
831
!isa<UnknownLoc>(argLoc));
832
832
if (!isa<UnknownLoc>(argLoc))
@@ -836,7 +836,7 @@ LogicalResult BytecodeWriter::writeBlock(EncodingEmitter &emitter,
836
836
emitter.emitVarInt (numberingState.getNumber (argLoc));
837
837
}
838
838
}
839
- if (config.bytecodeVersion > 2 ) {
839
+ if (config.bytecodeVersion >= bytecode:: kUseListOrdering ) {
840
840
uint64_t maskOffset = emitter.size ();
841
841
uint8_t encodingMask = 0 ;
842
842
emitter.emitByte (0 );
@@ -868,18 +868,19 @@ LogicalResult BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) {
868
868
869
869
// Emit the attributes of this operation.
870
870
DictionaryAttr attrs = op->getDiscardableAttrDictionary ();
871
- // Allow deployment to version <5 by merging inherent attribute with the
872
- // discardable ones. We should fail if there are any conflicts.
873
- if (config.bytecodeVersion < 5 )
871
+ // Allow deployment to version <kNativePropertiesEncoding by merging inherent
872
+ // attribute with the discardable ones. We should fail if there are any
873
+ // conflicts.
874
+ if (config.bytecodeVersion < bytecode::kNativePropertiesEncoding )
874
875
attrs = op->getAttrDictionary ();
875
876
if (!attrs.empty ()) {
876
877
opEncodingMask |= bytecode::OpEncodingMask::kHasAttrs ;
877
878
emitter.emitVarInt (numberingState.getNumber (attrs));
878
879
}
879
880
880
881
// Emit the properties of this operation, for now we still support deployment
881
- // to version <5 .
882
- if (config.bytecodeVersion >= 5 ) {
882
+ // to version <kNativePropertiesEncoding .
883
+ if (config.bytecodeVersion >= bytecode:: kNativePropertiesEncoding ) {
883
884
std::optional<ssize_t > propertiesId = propertiesSection.emit (op);
884
885
if (propertiesId.has_value ()) {
885
886
opEncodingMask |= bytecode::OpEncodingMask::kHasProperties ;
@@ -913,7 +914,7 @@ LogicalResult BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) {
913
914
914
915
// Emit the use-list orders to bytecode, so we can reconstruct the same order
915
916
// at parsing.
916
- if (config.bytecodeVersion > 2 )
917
+ if (config.bytecodeVersion >= bytecode:: kUseListOrdering )
917
918
writeUseListOrders (emitter, opEncodingMask, ValueRange (op->getResults ()));
918
919
919
920
// Check for regions.
@@ -934,8 +935,9 @@ LogicalResult BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) {
934
935
935
936
for (Region ®ion : op->getRegions ()) {
936
937
// If the region is not isolated from above, or we are emitting bytecode
937
- // targeting version <2, we don't use a section.
938
- if (!isIsolatedFromAbove || config.bytecodeVersion < 2 ) {
938
+ // targeting version <kLazyLoading, we don't use a section.
939
+ if (!isIsolatedFromAbove ||
940
+ config.bytecodeVersion < bytecode::kLazyLoading ) {
939
941
if (failed (writeRegion (emitter, ®ion)))
940
942
return failure ();
941
943
continue ;
0 commit comments