[llvm-commits] CVS: llvm/utils/TableGen/RegisterInfoEmitter.cpp InstrInfoEmitter.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Wed Oct 8 00:21:02 PDT 2003
Changes in directory llvm/utils/TableGen:
RegisterInfoEmitter.cpp updated: 1.12 -> 1.13
InstrInfoEmitter.cpp updated: 1.4 -> 1.5
---
Log message:
Change MRegisterDesc::AliasSet, TargetInstrDescriptor::ImplicitDefs
and TargetInstrDescriptor::ImplicitUses to always point to a null
terminated array and never be null. So there is no need to check for
pointer validity when iterating over those sets. Code that looked
like:
if (const unsigned* AS = TID.ImplicitDefs) {
for (int i = 0; AS[i]; ++i) {
// use AS[i]
}
}
was changed to:
for (const unsigned* AS = TID.ImplicitDefs; *AS; ++AS) {
// use *AS
}
---
Diffs of the changes: (+10 -4)
Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
diff -u llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.12 llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.13
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.12 Thu Aug 14 23:36:19 2003
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp Wed Oct 8 00:20:08 2003
@@ -138,7 +138,7 @@
std::vector<Record*> RegisterAliasesRecs =
Records.getAllDerivedDefinitions("RegisterAliases");
std::map<Record*, std::set<Record*> > RegisterAliases;
-
+
for (unsigned i = 0, e = RegisterAliasesRecs.size(); i != e; ++i) {
Record *AS = RegisterAliasesRecs[i];
Record *R = AS->getValueAsDef("Reg");
@@ -166,6 +166,8 @@
if (!RegisterAliases.empty())
OS << "\n\n // Register Alias Sets...\n";
+ // Emit the empty alias list
+ OS << " const unsigned Empty_AliasSet[] = { 0 };\n";
// Loop over all of the registers which have aliases, emitting the alias list
// to memory.
for (std::map<Record*, std::set<Record*> >::iterator
@@ -192,7 +194,7 @@
if (RegisterAliases.count(Reg))
OS << Reg->getName() << "_AliasSet,\t";
else
- OS << "0,\t\t";
+ OS << "Empty_AliasSet,\t";
OS << "0, 0 },\n";
}
OS << " };\n"; // End of register descriptors...
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.4 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.5
--- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.4 Thu Aug 7 00:39:09 2003
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp Wed Oct 8 00:20:08 2003
@@ -65,6 +65,10 @@
std::vector<Record*> Instructions =
Records.getAllDerivedDefinitions("Instruction");
+ // Emit empty implicit uses and defs lists
+ OS << "static const unsigned EmptyImpUses[] = { 0 };\n"
+ << "static const unsigned EmptyImpDefs[] = { 0 };\n";
+
// Emit all of the instruction's implicit uses and defs...
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
Record *Inst = Instructions[i];
@@ -113,13 +117,13 @@
// Emit the implicit uses and defs lists...
LI = R->getValueAsListInit("Uses");
if (!LI->getSize())
- OS << "0, ";
+ OS << "EmptyImpUses, ";
else
OS << R->getName() << "ImpUses, ";
LI = R->getValueAsListInit("Defs");
if (!LI->getSize())
- OS << "0 ";
+ OS << "EmptyImpDefs ";
else
OS << R->getName() << "ImpDefs ";
More information about the llvm-commits
mailing list