mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-06 05:33:28 +00:00
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
This commit is contained in:
parent
387e4bdf00
commit
f52e2618f3
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user