-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[NFC][TableGen] Change CodeGenIntrinsics
to use const references
#111219
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
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
Change `CodeGenIntrinsics` classes to vend out const references to `CodeGenIntrinsic` or `TargetSet` objects.
@llvm/pr-subscribers-tablegen Author: Rahul Joshi (jurahul) ChangesChange Full diff: https://github.com/llvm/llvm-project/pull/111219.diff 3 Files Affected:
diff --git a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
index c3bd7efd8387a8..fe3c83ce92e99d 100644
--- a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
+++ b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
@@ -124,7 +124,7 @@ void CodeGenIntrinsicTable::CheckTargetIndependentIntrinsics() const {
}
}
-CodeGenIntrinsic &CodeGenIntrinsicMap::operator[](const Record *Record) {
+const CodeGenIntrinsic &CodeGenIntrinsicMap::operator[](const Record *Record) {
if (!Record->isSubClassOf("Intrinsic"))
PrintFatalError("Intrinsic defs should be subclass of 'Intrinsic' class");
diff --git a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.h b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.h
index 1cdeaacd52dcdb..c2701e1586ee34 100644
--- a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.h
+++ b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.h
@@ -169,15 +169,12 @@ struct CodeGenIntrinsic {
};
class CodeGenIntrinsicTable {
- std::vector<CodeGenIntrinsic> Intrinsics;
-
public:
struct TargetSet {
StringRef Name;
size_t Offset;
size_t Count;
};
- std::vector<TargetSet> Targets;
explicit CodeGenIntrinsicTable(const RecordKeeper &RC);
@@ -185,14 +182,17 @@ class CodeGenIntrinsicTable {
size_t size() const { return Intrinsics.size(); }
auto begin() const { return Intrinsics.begin(); }
auto end() const { return Intrinsics.end(); }
- CodeGenIntrinsic &operator[](size_t Pos) { return Intrinsics[Pos]; }
const CodeGenIntrinsic &operator[](size_t Pos) const {
return Intrinsics[Pos];
}
+ ArrayRef<TargetSet> getTargets() const { return Targets; }
private:
void CheckDuplicateIntrinsics() const;
void CheckTargetIndependentIntrinsics() const;
+
+ std::vector<CodeGenIntrinsic> Intrinsics;
+ std::vector<TargetSet> Targets;
};
// This class builds `CodeGenIntrinsic` on demand for a given Def.
@@ -202,7 +202,7 @@ class CodeGenIntrinsicMap {
public:
explicit CodeGenIntrinsicMap(const RecordKeeper &RC) : Ctx(RC) {}
- CodeGenIntrinsic &operator[](const Record *Def);
+ const CodeGenIntrinsic &operator[](const Record *Def);
};
} // namespace llvm
diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp
index c8b5ec146dc503..6d92c733ea3d6d 100644
--- a/llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -124,7 +124,7 @@ void IntrinsicEmitter::EmitEnumInfo(const CodeGenIntrinsicTable &Ints,
// intrinsics like dbg.value.
using TargetSet = CodeGenIntrinsicTable::TargetSet;
const TargetSet *Set = nullptr;
- for (const auto &Target : Ints.Targets) {
+ for (const auto &Target : Ints.getTargets()) {
if (Target.Name == IntrinsicPrefix) {
Set = &Target;
break;
@@ -132,7 +132,7 @@ void IntrinsicEmitter::EmitEnumInfo(const CodeGenIntrinsicTable &Ints,
}
if (!Set) {
// The first entry is for target independent intrinsics, so drop it.
- auto KnowTargets = ArrayRef<TargetSet>(Ints.Targets).drop_front();
+ auto KnowTargets = Ints.getTargets().drop_front();
PrintFatalError([KnowTargets](raw_ostream &OS) {
OS << "tried to generate intrinsics for unknown target "
<< IntrinsicPrefix << "\nKnown targets are: ";
@@ -230,7 +230,7 @@ struct IntrinsicTargetInfo {
};
static constexpr IntrinsicTargetInfo TargetInfos[] = {
)";
- for (const auto [Name, Offset, Count] : Ints.Targets)
+ for (const auto [Name, Offset, Count] : Ints.getTargets())
OS << formatv(" {{\"{}\", {}, {}},\n", Name, Offset, Count);
OS << R"(};
#endif
|
kazutakahirata
approved these changes
Oct 5, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Kyvangka1610
pushed a commit
to Kyvangka1610/llvm-project
that referenced
this pull request
Oct 5, 2024
…lvm#111219) Change `CodeGenIntrinsics` classes to vend out const references to `CodeGenIntrinsic` or `TargetSet` objects.
Kyvangka1610
added a commit
to Kyvangka1610/llvm-project
that referenced
this pull request
Oct 5, 2024
* commit 'FETCH_HEAD': [clang][bytecode] Handle UETT_OpenMPRequiredSimdAlign (llvm#111259) [mlir][polynomial] Add and verify constraints of coefficientModulus for ringAttr (llvm#111016) [clang][bytecode] Save a per-Block IsWeak bit (llvm#111248) [analyzer] Fix wrong `builtin_*_overflow` return type (llvm#111253) [SelectOpt] Don't convert constant selects to branches. (llvm#110858) [InstCombine] Update and-or-icmps.ll after 574266c. NFC [Instcombine] Test for more gep canonicalization [NFC][TableGen] Change `CodeGenIntrinsics` to use const references (llvm#111219) Add warning message to `session save` when transcript isn't saved. (llvm#109020) [RISCV][TTI] Recognize CONCAT_VECTORS if a shufflevector mask is multiple insert subvector. (llvm#110457) Revert "[InstCombine] Folding `(icmp eq/ne (and X, -P2), INT_MIN)`" (llvm#111236) [NFC][lsan] Add SuspendAllThreads traces [lsan] Add `thread_suspend_fail` flag Signed-off-by: kyvangka1610 <[email protected]>
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.
Change
CodeGenIntrinsics
classes to vend out const references toCodeGenIntrinsic
orTargetSet
objects.