diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-10-08 05:20:08 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-10-08 05:20:08 +0000 |
commit | 73ff5120eb8b8c0ccbfed8a17f1024c67a75f319 (patch) | |
tree | ea737ea5c41b893d3584c3c2d2f0ba5e118d929d /utils | |
parent | 6b8b22585c8ee1ee9bed9c218c604dfb3d88a851 (diff) | |
download | llvm-73ff5120eb8b8c0ccbfed8a17f1024c67a75f319.tar.gz llvm-73ff5120eb8b8c0ccbfed8a17f1024c67a75f319.tar.bz2 llvm-73ff5120eb8b8c0ccbfed8a17f1024c67a75f319.tar.xz |
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
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 8 | ||||
-rw-r--r-- | utils/TableGen/RegisterInfoEmitter.cpp | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index c794cd0441..7b64f922f6 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -65,6 +65,10 @@ void InstrInfoEmitter::run(std::ostream &OS) { 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 @@ void InstrInfoEmitter::emitRecord(Record *R, unsigned Num, Record *InstrInfo, // 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 "; diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index af3efe3a9c..7652e67772 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -138,7 +138,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) { 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 @@ void RegisterInfoEmitter::run(std::ostream &OS) { 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 @@ void RegisterInfoEmitter::run(std::ostream &OS) { 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... |