summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-20 21:45:57 +0000
committerDan Gohman <gohman@apple.com>2008-08-20 21:45:57 +0000
commit3e2225dfd67a345a52fe55b19c8e7686b67e1892 (patch)
tree0a4125cf8de9d7d482c66c79ef007c7cf11359f5 /llvm
parent814f291664deb14fd37f3fc90141f3e37c21f51f (diff)
downloadbcm5719-llvm-3e2225dfd67a345a52fe55b19c8e7686b67e1892.tar.gz
bcm5719-llvm-3e2225dfd67a345a52fe55b19c8e7686b67e1892.zip
Factor the code for determining the target-specific instruction
namespace out of the isel emitters and into common code. llvm-svn: 55079
Diffstat (limited to 'llvm')
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp15
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.h4
-rw-r--r--llvm/utils/TableGen/DAGISelEmitter.cpp13
-rw-r--r--llvm/utils/TableGen/FastISelEmitter.cpp8
4 files changed, 22 insertions, 18 deletions
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index d9f4c3e3413..4e7a10c1d81 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -135,6 +135,21 @@ const std::string &CodeGenTarget::getName() const {
return TargetRec->getName();
}
+std::string CodeGenTarget::getInstNamespace() const {
+ std::string InstNS;
+
+ for (inst_iterator i = inst_begin(), e = inst_end(); i != e; ++i) {
+ InstNS = i->second.Namespace;
+
+ // Make sure not to pick up "TargetInstrInfo" by accidentally getting
+ // the namespace off the PHI instruction or something.
+ if (InstNS != "TargetInstrInfo")
+ break;
+ }
+
+ return InstNS;
+}
+
Record *CodeGenTarget::getInstructionSet() const {
return TargetRec->getValueAsDef("InstructionSet");
}
diff --git a/llvm/utils/TableGen/CodeGenTarget.h b/llvm/utils/TableGen/CodeGenTarget.h
index f53b6a99c15..ef46b6c6185 100644
--- a/llvm/utils/TableGen/CodeGenTarget.h
+++ b/llvm/utils/TableGen/CodeGenTarget.h
@@ -78,6 +78,10 @@ public:
Record *getTargetRecord() const { return TargetRec; }
const std::string &getName() const;
+ /// getInstNamespace - Return the target-specific instruction namespace.
+ ///
+ std::string getInstNamespace() const;
+
/// getInstructionSet - Return the InstructionSet object.
///
Record *getInstructionSet() const;
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index 9f0f155a7fc..12667d5656f 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -1604,17 +1604,8 @@ static std::string getLegalCName(std::string OpName) {
void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
const CodeGenTarget &Target = CGP.getTargetInfo();
- // Get the namespace to insert instructions into. Make sure not to pick up
- // "TargetInstrInfo" by accidentally getting the namespace off the PHI
- // instruction or something.
- std::string InstNS;
- for (CodeGenTarget::inst_iterator i = Target.inst_begin(),
- e = Target.inst_end(); i != e; ++i) {
- InstNS = i->second.Namespace;
- if (InstNS != "TargetInstrInfo")
- break;
- }
-
+ // Get the namespace to insert instructions into.
+ std::string InstNS = Target.getInstNamespace();
if (!InstNS.empty()) InstNS += "::";
// Group the patterns by their top-level opcodes.
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index 9650ea8855b..7edd5fca420 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -157,13 +157,7 @@ void FastISelEmitter::run(std::ostream &OS) {
// Get the namespace to insert instructions into. Make sure not to pick up
// "TargetInstrInfo" by accidentally getting the namespace off the PHI
// instruction or something.
- std::string InstNS;
- for (CodeGenTarget::inst_iterator i = Target.inst_begin(),
- e = Target.inst_end(); i != e; ++i) {
- InstNS = i->second.Namespace;
- if (InstNS != "TargetInstrInfo")
- break;
- }
+ std::string InstNS = Target.getInstNamespace();
OS << "namespace llvm {\n";
OS << "namespace " << InstNS << " {\n";
OpenPOWER on IntegriCloud