[PATCH] D142217: [MC] Store target Insts table in reverse order. NFC.
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 07:15:47 PST 2023
foad created this revision.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This will allow an entry in the table to access data that is stored
immediately after the end of the table, by adding its opcode value
to its address.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142217
Files:
llvm/include/llvm/MC/MCInstrInfo.h
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/utils/TableGen/InstrInfoEmitter.cpp
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
===================================================================
--- llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -923,20 +923,19 @@
Records.startTimer("Emit operand info");
EmitOperandInfo(OS, OperandInfoIDs);
- // Emit all of the MCInstrDesc records in their ENUM ordering.
- //
+ // Emit all of the MCInstrDesc records in reverse ENUM ordering.
Records.startTimer("Emit InstrDesc records");
OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n";
ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
SequenceToOffsetTable<std::string> InstrNames;
- unsigned Num = 0;
- for (const CodeGenInstruction *Inst : NumberedInstructions) {
+ unsigned Num = NumberedInstructions.size();
+ for (const CodeGenInstruction *Inst : llvm::reverse(NumberedInstructions)) {
// Keep a list of the instruction names.
InstrNames.add(std::string(Inst->TheDef->getName()));
// Emit the record into the table.
- emitRecord(*Inst, Num++, InstrInfo, EmittedLists, OperandInfoIDs, OS);
+ emitRecord(*Inst, --Num, InstrInfo, EmittedLists, OperandInfoIDs, OS);
}
OS << "};\n\n";
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -2503,7 +2503,8 @@
RegNum = 0;
} else {
unsigned NextOpIndex = Inst.getNumOperands();
- const MCInstrDesc &MCID = ARMInsts[Inst.getOpcode()];
+ const MCInstrDesc &MCID =
+ ARMInsts[ARM::INSTRUCTION_LIST_END - 1 - Inst.getOpcode()];
int TiedOp = MCID.getOperandConstraint(NextOpIndex, MCOI::TIED_TO);
assert(TiedOp >= 0 &&
"Inactive register in vpred_r is not tied to an output!");
Index: llvm/include/llvm/MC/MCInstrInfo.h
===================================================================
--- llvm/include/llvm/MC/MCInstrInfo.h
+++ llvm/include/llvm/MC/MCInstrInfo.h
@@ -62,7 +62,7 @@
/// specified instruction opcode.
const MCInstrDesc &get(unsigned Opcode) const {
assert(Opcode < NumOpcodes && "Invalid opcode!");
- return Desc[Opcode];
+ return Desc[NumOpcodes - 1 - Opcode];
}
/// Returns the name for the instructions with the given opcode.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142217.490835.patch
Type: text/x-patch
Size: 2435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/723771f6/attachment.bin>
More information about the llvm-commits
mailing list