[PATCH] D92722: [TableGen] [CodeGenTarget] Cache the target's instruction namespace
Paul C. Anagnostopoulos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 5 15:26:54 PST 2020
Paul-C-Anagnostopoulos updated this revision to Diff 309753.
Paul-C-Anagnostopoulos marked an inline comment as done.
Paul-C-Anagnostopoulos added a comment.
Eliminated explicit InstNamespace initializer.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92722/new/
https://reviews.llvm.org/D92722
Files:
llvm/utils/TableGen/CodeGenTarget.cpp
llvm/utils/TableGen/CodeGenTarget.h
Index: llvm/utils/TableGen/CodeGenTarget.h
===================================================================
--- llvm/utils/TableGen/CodeGenTarget.h
+++ llvm/utils/TableGen/CodeGenTarget.h
@@ -60,6 +60,7 @@
mutable std::unique_ptr<CodeGenSchedModels> SchedModels;
+ mutable StringRef InstNamespace;
mutable std::vector<const CodeGenInstruction*> InstrsByEnum;
mutable unsigned NumPseudoInstructions = 0;
public:
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -264,15 +264,20 @@
return TargetRec->getName();
}
+/// getInstNamespace - Find and return the target machine's instruction
+/// namespace. The namespace is cached because it is requested multiple times.
StringRef CodeGenTarget::getInstNamespace() const {
- for (const CodeGenInstruction *Inst : getInstructionsByEnumValue()) {
- // Make sure not to pick up "TargetOpcode" by accidentally getting
- // the namespace off the PHI instruction or something.
- if (Inst->Namespace != "TargetOpcode")
- return Inst->Namespace;
+ if (InstNamespace.empty()) {
+ for (const CodeGenInstruction *Inst : getInstructionsByEnumValue()) {
+ // We are not interested in the "TargetOpcode" namespace.
+ if (Inst->Namespace != "TargetOpcode") {
+ InstNamespace = Inst->Namespace;
+ break;
+ }
+ }
}
- return "";
+ return InstNamespace;
}
StringRef CodeGenTarget::getRegNamespace() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92722.309753.patch
Type: text/x-patch
Size: 1568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201205/4a0bd77d/attachment.bin>
More information about the llvm-commits
mailing list