[llvm-commits] [llvm] r55079 - in /llvm/trunk/utils/TableGen: CodeGenTarget.cpp CodeGenTarget.h DAGISelEmitter.cpp FastISelEmitter.cpp
Dan Gohman
gohman at apple.com
Wed Aug 20 14:45:57 PDT 2008
Author: djg
Date: Wed Aug 20 16:45:57 2008
New Revision: 55079
URL: http://llvm.org/viewvc/llvm-project?rev=55079&view=rev
Log:
Factor the code for determining the target-specific instruction
namespace out of the isel emitters and into common code.
Modified:
llvm/trunk/utils/TableGen/CodeGenTarget.cpp
llvm/trunk/utils/TableGen/CodeGenTarget.h
llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
llvm/trunk/utils/TableGen/FastISelEmitter.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=55079&r1=55078&r2=55079&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Wed Aug 20 16:45:57 2008
@@ -135,6 +135,21 @@
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");
}
Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=55079&r1=55078&r2=55079&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenTarget.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.h Wed Aug 20 16:45:57 2008
@@ -78,6 +78,10 @@
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;
Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=55079&r1=55078&r2=55079&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Aug 20 16:45:57 2008
@@ -1604,17 +1604,8 @@
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.
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=55079&r1=55078&r2=55079&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Aug 20 16:45:57 2008
@@ -157,13 +157,7 @@
// 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";
More information about the llvm-commits
mailing list