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