-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][BytecodeReader] Const qualify *SectionReader, NFC #99376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Author: Hideto Ueno (uenoku) Changes
Full diff: https://github.com/llvm/llvm-project/pull/99376.diff 1 Files Affected:
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index dd1e4abaea166..7e82399d9e968 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -376,7 +376,7 @@ class StringSectionReader {
/// 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");
}
@@ -384,7 +384,7 @@ class StringSectionReader {
/// 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();
@@ -394,7 +394,7 @@ class StringSectionReader {
/// 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");
}
@@ -545,7 +545,7 @@ class ResourceSectionReader {
/// 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");
}
@@ -801,8 +801,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)
@@ -882,11 +882,11 @@ class AttrTypeReader {
/// 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.
@@ -909,8 +909,8 @@ class AttrTypeReader {
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),
@@ -1043,8 +1043,8 @@ class DialectReader : public DialectBytecodeReader {
private:
AttrTypeReader &attrTypeReader;
- StringSectionReader &stringReader;
- ResourceSectionReader &resourceReader;
+ const StringSectionReader &stringReader;
+ const ResourceSectionReader &resourceReader;
const llvm::StringMap<BytecodeDialect *> &dialectsMap;
EncodingReader &reader;
uint64_t &bytecodeVersion;
@@ -1083,7 +1083,7 @@ class PropertiesSectionReader {
}
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();
|
joker-eph
approved these changes
Jul 17, 2024
yuxuanchen1997
pushed a commit
that referenced
this pull request
Jul 25, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
StringSectionReader
,ResourceSectionReader
andPropertiesSectionReader
are immutable afterinitialize
so this PR adds const to their parsing functions and references inAttrTypeReader
andDialectReader
.