[PATCH] D121402: [X86][NFC] Move table from getRelaxedOpcodeArith into its own class
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 20:20:55 PST 2022
MaskRay added inline comments.
================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp:126
+ // Stores memory unfolding tables entries sorted by opcode.
+ std::vector<X86InstrRelaxTableEntry> Table;
+
----------------
`SmallVector<X, 0>` usually compiles to less code and is more efficient
================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp:132
+
+ // Sort the table.
+ array_pod_sort(Table.begin(), Table.end());
----------------
Drop the comment. The code is self-explanatory
================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp:133
+ // Sort the table.
+ array_pod_sort(Table.begin(), Table.end());
+
----------------
You may just use llvm::sort which calls array_pod_sort if applicable
================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp:136
+ // Now that it's sorted, ensure its unique.
+ assert(std::adjacent_find(Table.begin(), Table.end()) == Table.end() &&
+ "Short form table is not unique!");
----------------
is_sorted
================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp:168
+unsigned X86::getRelaxedOpcodeArith(unsigned ShortOp) {
+ const X86InstrRelaxTableEntry *I = lookupRelaxTable(ShortOp);
+ if (!I)
----------------
```
if (const X86InstrRelaxTableEntry *I = lookupRelaxTable(ShortOp))
return I->DstOp;
return ShortOp;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121402/new/
https://reviews.llvm.org/D121402
More information about the llvm-commits
mailing list