diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-27 01:44:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-27 01:44:09 +0000 |
commit | f52e2618f3992aa673c738aa1d2e6c046a0b6f5a (patch) | |
tree | ad29157955933678963253288ca5ce276bcd14f3 | |
parent | 387e4bdf002c78a1b43a10e10cf5147baf32f513 (diff) |
If we want to emit things in enum order, use getInstructionsByEnumValue to
get the order, don't compute it ourselves.
Don't emit stuff like (14<<0), emit 14 instead.
Don't attempt to get target properties for builtin instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25672 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 463eb25213..22ac58df59 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -93,7 +93,6 @@ void InstrInfoEmitter::run(std::ostream &OS) { CodeGenTarget Target; const std::string &TargetName = Target.getName(); Record *InstrInfo = Target.getInstructionSet(); - Record *PHI = InstrInfo->getValueAsDef("PHIInst"); // Emit empty implicit uses and defs lists OS << "static const unsigned EmptyImpList[] = { 0 };\n"; @@ -144,19 +143,16 @@ void InstrInfoEmitter::run(std::ostream &OS) { } } - // Emit all of the TargetInstrDescriptor records. + // Emit all of the TargetInstrDescriptor records in their ENUM ordering. // OS << "\nstatic const TargetInstrDescriptor " << TargetName << "Insts[] = {\n"; - emitRecord(Target.getPHIInstruction(), 0, InstrInfo, EmittedLists, - OperandInfosEmitted, OS); + std::vector<const CodeGenInstruction*> NumberedInstructions; + Target.getInstructionsByEnumValue(NumberedInstructions); - unsigned i = 0; - for (CodeGenTarget::inst_iterator II = Target.inst_begin(), - E = Target.inst_end(); II != E; ++II) - if (II->second.TheDef != PHI) - emitRecord(II->second, ++i, InstrInfo, EmittedLists, - OperandInfosEmitted, OS); + for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) + emitRecord(*NumberedInstructions[i], i, InstrInfo, EmittedLists, + OperandInfosEmitted, OS); OS << "};\n"; OS << "} // End llvm namespace \n"; } @@ -272,8 +268,13 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val, RecordVal *RV = R->getValue(Val->getValue()); int Shift = ShiftInt->getValue(); - if (RV == 0 || RV->getValue() == 0) - throw R->getName() + " doesn't have a field named '" + Val->getValue()+"'!"; + if (RV == 0 || RV->getValue() == 0) { + // This isn't an error if this is a builtin instruction. + if (R->getName() != "PHI" && R->getName() != "INLINEASM") + throw R->getName() + " doesn't have a field named '" + + Val->getValue() + "'!"; + return; + } Init *Value = RV->getValue(); if (BitInit *BI = dynamic_cast<BitInit*>(Value)) { @@ -284,13 +285,22 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val, Init *I = BI->convertInitializerTo(new IntRecTy()); if (I) if (IntInit *II = dynamic_cast<IntInit*>(I)) { - if (II->getValue()) - OS << "|(" << II->getValue() << "<<" << Shift << ")"; + if (II->getValue()) { + if (Shift) + OS << "|(" << II->getValue() << "<<" << Shift << ")"; + else + OS << "|" << II->getValue(); + } return; } } else if (IntInit *II = dynamic_cast<IntInit*>(Value)) { - if (II->getValue()) OS << "|(" << II->getValue() << "<<" << Shift << ")"; + if (II->getValue()) { + if (Shift) + OS << "|(" << II->getValue() << "<<" << Shift << ")"; + else + OS << II->getValue(); + } return; } |