diff options
| author | Hideto Ueno <uenoku.tokotoko@gmail.com> | 2024-07-18 19:45:36 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 19:45:36 +0900 |
| commit | c0084c36ed55ce78331aca7d0d10781a9f00b256 (patch) | |
| tree | 7c5c64f91afaeb3e7b30f959903b44ef074b7c4e /mlir/lib/Bytecode/Reader/BytecodeReader.cpp | |
| parent | 6838c7afb2d2fa5eb642a4b5922ae55d97f7b344 (diff) | |
| download | llvm-c0084c36ed55ce78331aca7d0d10781a9f00b256.zip llvm-c0084c36ed55ce78331aca7d0d10781a9f00b256.tar.gz llvm-c0084c36ed55ce78331aca7d0d10781a9f00b256.tar.bz2 | |
[mlir][BytecodeReader] Const qualify *SectionReader, NFC (#99376)
`StringSectionReader`, `ResourceSectionReader` and
`PropertiesSectionReader` are immutable after `initialize` so this PR
adds const to their parsing functions and references in `AttrTypeReader`
and `DialectReader`.
Diffstat (limited to 'mlir/lib/Bytecode/Reader/BytecodeReader.cpp')
| -rw-r--r-- | mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp index 1064896..a57b217 100644 --- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp +++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp @@ -375,7 +375,7 @@ public: /// Parse a shared string from the string section. The shared string is /// encoded using an index to a corresponding string in the string section. - LogicalResult parseString(EncodingReader &reader, StringRef &result) { + LogicalResult parseString(EncodingReader &reader, StringRef &result) const { return parseEntry(reader, strings, result, "string"); } @@ -383,7 +383,7 @@ public: /// encoded using an index to a corresponding string in the string section. /// This variant parses a flag compressed with the index. LogicalResult parseStringWithFlag(EncodingReader &reader, StringRef &result, - bool &flag) { + bool &flag) const { uint64_t entryIdx; if (failed(reader.parseVarIntWithFlag(entryIdx, flag))) return failure(); @@ -393,7 +393,7 @@ public: /// Parse a shared string from the string section. The shared string is /// encoded using an index to a corresponding string in the string section. LogicalResult parseStringAtIndex(EncodingReader &reader, uint64_t index, - StringRef &result) { + StringRef &result) const { return resolveEntry(reader, strings, index, result, "string"); } @@ -544,7 +544,7 @@ public: /// Parse a dialect resource handle from the resource section. LogicalResult parseResourceHandle(EncodingReader &reader, - AsmDialectResourceHandle &result) { + AsmDialectResourceHandle &result) const { return parseEntry(reader, dialectResources, result, "resource handle"); } @@ -800,8 +800,8 @@ class AttrTypeReader { using TypeEntry = Entry<Type>; public: - AttrTypeReader(StringSectionReader &stringReader, - ResourceSectionReader &resourceReader, + AttrTypeReader(const StringSectionReader &stringReader, + const ResourceSectionReader &resourceReader, const llvm::StringMap<BytecodeDialect *> &dialectsMap, uint64_t &bytecodeVersion, Location fileLoc, const ParserConfig &config) @@ -881,11 +881,11 @@ private: /// The string section reader used to resolve string references when parsing /// custom encoded attribute/type entries. - StringSectionReader &stringReader; + const StringSectionReader &stringReader; /// The resource section reader used to resolve resource references when /// parsing custom encoded attribute/type entries. - ResourceSectionReader &resourceReader; + const ResourceSectionReader &resourceReader; /// The map of the loaded dialects used to retrieve dialect information, such /// as the dialect version. @@ -908,8 +908,8 @@ private: class DialectReader : public DialectBytecodeReader { public: DialectReader(AttrTypeReader &attrTypeReader, - StringSectionReader &stringReader, - ResourceSectionReader &resourceReader, + const StringSectionReader &stringReader, + const ResourceSectionReader &resourceReader, const llvm::StringMap<BytecodeDialect *> &dialectsMap, EncodingReader &reader, uint64_t &bytecodeVersion) : attrTypeReader(attrTypeReader), stringReader(stringReader), @@ -1042,8 +1042,8 @@ public: private: AttrTypeReader &attrTypeReader; - StringSectionReader &stringReader; - ResourceSectionReader &resourceReader; + const StringSectionReader &stringReader; + const ResourceSectionReader &resourceReader; const llvm::StringMap<BytecodeDialect *> &dialectsMap; EncodingReader &reader; uint64_t &bytecodeVersion; @@ -1082,7 +1082,7 @@ public: } LogicalResult read(Location fileLoc, DialectReader &dialectReader, - OperationName *opName, OperationState &opState) { + OperationName *opName, OperationState &opState) const { uint64_t propertiesIdx; if (failed(dialectReader.readVarInt(propertiesIdx))) return failure(); |
