Skip to content

Commit c4704f2

Browse files
uenokuyuxuanchen1997
authored andcommitted
[mlir][BytecodeReader] Const qualify *SectionReader, NFC (#99376)
Summary: `StringSectionReader`, `ResourceSectionReader` and `PropertiesSectionReader` are immutable after `initialize` so this PR adds const to their parsing functions and references in `AttrTypeReader` and `DialectReader`. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250798
1 parent 386af2f commit c4704f2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,15 @@ class StringSectionReader {
375375

376376
/// Parse a shared string from the string section. The shared string is
377377
/// encoded using an index to a corresponding string in the string section.
378-
LogicalResult parseString(EncodingReader &reader, StringRef &result) {
378+
LogicalResult parseString(EncodingReader &reader, StringRef &result) const {
379379
return parseEntry(reader, strings, result, "string");
380380
}
381381

382382
/// Parse a shared string from the string section. The shared string is
383383
/// encoded using an index to a corresponding string in the string section.
384384
/// This variant parses a flag compressed with the index.
385385
LogicalResult parseStringWithFlag(EncodingReader &reader, StringRef &result,
386-
bool &flag) {
386+
bool &flag) const {
387387
uint64_t entryIdx;
388388
if (failed(reader.parseVarIntWithFlag(entryIdx, flag)))
389389
return failure();
@@ -393,7 +393,7 @@ class StringSectionReader {
393393
/// Parse a shared string from the string section. The shared string is
394394
/// encoded using an index to a corresponding string in the string section.
395395
LogicalResult parseStringAtIndex(EncodingReader &reader, uint64_t index,
396-
StringRef &result) {
396+
StringRef &result) const {
397397
return resolveEntry(reader, strings, index, result, "string");
398398
}
399399

@@ -544,7 +544,7 @@ class ResourceSectionReader {
544544

545545
/// Parse a dialect resource handle from the resource section.
546546
LogicalResult parseResourceHandle(EncodingReader &reader,
547-
AsmDialectResourceHandle &result) {
547+
AsmDialectResourceHandle &result) const {
548548
return parseEntry(reader, dialectResources, result, "resource handle");
549549
}
550550

@@ -800,8 +800,8 @@ class AttrTypeReader {
800800
using TypeEntry = Entry<Type>;
801801

802802
public:
803-
AttrTypeReader(StringSectionReader &stringReader,
804-
ResourceSectionReader &resourceReader,
803+
AttrTypeReader(const StringSectionReader &stringReader,
804+
const ResourceSectionReader &resourceReader,
805805
const llvm::StringMap<BytecodeDialect *> &dialectsMap,
806806
uint64_t &bytecodeVersion, Location fileLoc,
807807
const ParserConfig &config)
@@ -881,11 +881,11 @@ class AttrTypeReader {
881881

882882
/// The string section reader used to resolve string references when parsing
883883
/// custom encoded attribute/type entries.
884-
StringSectionReader &stringReader;
884+
const StringSectionReader &stringReader;
885885

886886
/// The resource section reader used to resolve resource references when
887887
/// parsing custom encoded attribute/type entries.
888-
ResourceSectionReader &resourceReader;
888+
const ResourceSectionReader &resourceReader;
889889

890890
/// The map of the loaded dialects used to retrieve dialect information, such
891891
/// as the dialect version.
@@ -908,8 +908,8 @@ class AttrTypeReader {
908908
class DialectReader : public DialectBytecodeReader {
909909
public:
910910
DialectReader(AttrTypeReader &attrTypeReader,
911-
StringSectionReader &stringReader,
912-
ResourceSectionReader &resourceReader,
911+
const StringSectionReader &stringReader,
912+
const ResourceSectionReader &resourceReader,
913913
const llvm::StringMap<BytecodeDialect *> &dialectsMap,
914914
EncodingReader &reader, uint64_t &bytecodeVersion)
915915
: attrTypeReader(attrTypeReader), stringReader(stringReader),
@@ -1042,8 +1042,8 @@ class DialectReader : public DialectBytecodeReader {
10421042

10431043
private:
10441044
AttrTypeReader &attrTypeReader;
1045-
StringSectionReader &stringReader;
1046-
ResourceSectionReader &resourceReader;
1045+
const StringSectionReader &stringReader;
1046+
const ResourceSectionReader &resourceReader;
10471047
const llvm::StringMap<BytecodeDialect *> &dialectsMap;
10481048
EncodingReader &reader;
10491049
uint64_t &bytecodeVersion;
@@ -1082,7 +1082,7 @@ class PropertiesSectionReader {
10821082
}
10831083

10841084
LogicalResult read(Location fileLoc, DialectReader &dialectReader,
1085-
OperationName *opName, OperationState &opState) {
1085+
OperationName *opName, OperationState &opState) const {
10861086
uint64_t propertiesIdx;
10871087
if (failed(dialectReader.readVarInt(propertiesIdx)))
10881088
return failure();

0 commit comments

Comments
 (0)