Factor the code for determining the target-specific instruction

namespace out of the isel emitters and into common code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2008-08-20 21:45:57 +00:00
parent 0bfa1bfbff
commit 1e0ee4bc38
4 changed files with 22 additions and 18 deletions

View File

@ -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");
}

View File

@ -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;

View File

@ -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.

View File

@ -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";