[llvm-commits] CVS: llvm/utils/TableGen/CodeGenTarget.cpp CodeGenTarget.h InstrInfoEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 22 10:59:06 PST 2005
Changes in directory llvm/utils/TableGen:
CodeGenTarget.cpp updated: 1.26 -> 1.27
CodeGenTarget.h updated: 1.15 -> 1.16
InstrInfoEmitter.cpp updated: 1.16 -> 1.17
---
Log message:
Refactor code for numbering instructions into CodeGenTarget.
---
Diffs of the changes: (+29 -10)
CodeGenTarget.cpp | 16 ++++++++++++++++
CodeGenTarget.h | 6 ++++++
InstrInfoEmitter.cpp | 17 +++++++----------
3 files changed, 29 insertions(+), 10 deletions(-)
Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.26 llvm/utils/TableGen/CodeGenTarget.cpp:1.27
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.26 Sat Jan 1 20:29:04 2005
+++ llvm/utils/TableGen/CodeGenTarget.cpp Sat Jan 22 12:58:51 2005
@@ -198,6 +198,22 @@
return I->second;
}
+/// getInstructionsByEnumValue - Return all of the instructions defined by the
+/// target, ordered by their enum value.
+void CodeGenTarget::
+getInstructionsByEnumValue(std::vector<const CodeGenInstruction*>
+ &NumberedInstructions) {
+
+ // Print out the rest of the instructions now.
+ unsigned i = 0;
+ const CodeGenInstruction *PHI = &getPHIInstruction();
+ NumberedInstructions.push_back(PHI);
+ for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II)
+ if (&II->second != PHI)
+ NumberedInstructions.push_back(&II->second);
+}
+
+
/// isLittleEndianEncoding - Return whether this target encodes its instruction
/// in little-endian format, i.e. bits laid out in the order [0..n]
///
Index: llvm/utils/TableGen/CodeGenTarget.h
diff -u llvm/utils/TableGen/CodeGenTarget.h:1.15 llvm/utils/TableGen/CodeGenTarget.h:1.16
--- llvm/utils/TableGen/CodeGenTarget.h:1.15 Wed Oct 27 11:06:27 2004
+++ llvm/utils/TableGen/CodeGenTarget.h Sat Jan 22 12:58:51 2005
@@ -93,6 +93,12 @@
inst_iterator inst_begin() const { return getInstructions().begin(); }
inst_iterator inst_end() const { return Instructions.end(); }
+ /// getInstructionsByEnumValue - Return all of the instructions defined by the
+ /// target, ordered by their enum value.
+ void getInstructionsByEnumValue(std::vector<const CodeGenInstruction*>
+ &NumberedInstructions);
+
+
/// getPHIInstruction - Return the designated PHI instruction.
///
const CodeGenInstruction &getPHIInstruction() const;
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.16 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.17
--- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.16 Sat Jan 1 20:29:04 2005
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp Sat Jan 22 12:58:51 2005
@@ -26,7 +26,6 @@
// We must emit the PHI opcode first...
Record *InstrInfo = Target.getInstructionSet();
- Record *PHI = InstrInfo->getValueAsDef("PHIInst");
std::string Namespace = Target.inst_begin()->second.Namespace;
@@ -34,15 +33,13 @@
OS << "namespace " << Namespace << " {\n";
OS << " enum {\n";
- OS << " " << PHI->getName() << ", \t// 0 (fixed for all targets)\n";
-
- // Print out the rest of the instructions now.
- unsigned i = 0;
- for (CodeGenTarget::inst_iterator II = Target.inst_begin(),
- E = Target.inst_end(); II != E; ++II)
- if (II->second.TheDef != PHI)
- OS << " " << II->first << ", \t// " << ++i << "\n";
-
+ std::vector<const CodeGenInstruction*> NumberedInstructions;
+ Target.getInstructionsByEnumValue(NumberedInstructions);
+
+ for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
+ OS << " " << NumberedInstructions[i]->TheDef->getName()
+ << ", \t// " << i << "\n";
+ }
OS << " };\n";
if (!Namespace.empty())
OS << "}\n";
More information about the llvm-commits
mailing list