[llvm-branch-commits] [llvm] 0b3e393 - [TableGen] [CodeGenTarget] Cache the target's instruction namespace.
Paul C. Anagnostopoulos via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Dec 6 08:14:01 PST 2020
Author: Paul C. Anagnostopoulos
Date: 2020-12-06T11:08:30-05:00
New Revision: 0b3e393d6c8b0f6bb8a13b1a71aba796c87ed239
URL: https://github.com/llvm/llvm-project/commit/0b3e393d6c8b0f6bb8a13b1a71aba796c87ed239
DIFF: https://github.com/llvm/llvm-project/commit/0b3e393d6c8b0f6bb8a13b1a71aba796c87ed239.diff
LOG: [TableGen] [CodeGenTarget] Cache the target's instruction namespace.
Differential Revision: https://reviews.llvm.org/D92722
Added:
Modified:
llvm/utils/TableGen/CodeGenTarget.cpp
llvm/utils/TableGen/CodeGenTarget.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index 794bb622dc99..d8e1d7f8cf0d 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -264,15 +264,20 @@ const StringRef CodeGenTarget::getName() const {
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 {
diff --git a/llvm/utils/TableGen/CodeGenTarget.h b/llvm/utils/TableGen/CodeGenTarget.h
index 44bc46a0a421..cc5bbe7a8bfe 100644
--- a/llvm/utils/TableGen/CodeGenTarget.h
+++ b/llvm/utils/TableGen/CodeGenTarget.h
@@ -60,6 +60,7 @@ class CodeGenTarget {
mutable std::unique_ptr<CodeGenSchedModels> SchedModels;
+ mutable StringRef InstNamespace;
mutable std::vector<const CodeGenInstruction*> InstrsByEnum;
mutable unsigned NumPseudoInstructions = 0;
public:
More information about the llvm-branch-commits
mailing list