diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-01 23:46:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-01 23:46:16 +0000 |
commit | eff5c3623848152b60457318af8e23df25496449 (patch) | |
tree | d5bf713019a997595aab7ccd62bfee63381e9983 /utils | |
parent | 1c174c62b87ea2403b7b6cee2e0128a69db58c88 (diff) | |
download | external_llvm-eff5c3623848152b60457318af8e23df25496449.zip external_llvm-eff5c3623848152b60457318af8e23df25496449.tar.gz external_llvm-eff5c3623848152b60457318af8e23df25496449.tar.bz2 |
Put instruction names into the first non TargetInstrInfo namespace found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 35fbed3..d39a51f 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -28,23 +28,31 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { // We must emit the PHI opcode first... Record *InstrInfo = Target.getInstructionSet(); - std::string Namespace = Target.inst_begin()->second.Namespace; - - if (!Namespace.empty()) - OS << "namespace " << Namespace << " {\n"; - OS << " enum {\n"; + std::string Namespace; + for (CodeGenTarget::inst_iterator II = Target.inst_begin(), + E = Target.inst_end(); II != E; ++II) { + if (II->second.Namespace != "TargetInstrInfo") { + Namespace = II->second.Namespace; + break; + } + } + + if (Namespace.empty()) { + std::cerr << "No instructions defined!\n"; + exit(1); + } std::vector<const CodeGenInstruction*> NumberedInstructions; Target.getInstructionsByEnumValue(NumberedInstructions); + OS << "namespace " << Namespace << " {\n"; + OS << " enum {\n"; for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) { OS << " " << NumberedInstructions[i]->TheDef->getName() - << ", \t// " << i << "\n"; + << "\t= " << i << ",\n"; } - OS << " INSTRUCTION_LIST_END\n"; - OS << " };\n"; - if (!Namespace.empty()) - OS << "}\n"; + OS << " INSTRUCTION_LIST_END = " << NumberedInstructions.size() << "\n"; + OS << " };\n}\n"; OS << "} // End llvm namespace \n"; } |