// This struct is used for both the folding and unfold tables. They KeyOp
// is used to determine the sorting order.
struct X86MemoryFoldTableEntry {
- uint16_t KeyOp;
- uint16_t DstOp;
+ unsigned KeyOp;
+ unsigned DstOp;
uint16_t Flags;
bool operator<(const X86MemoryFoldTableEntry &RHS) const {
};
- struct CodeGenInstructionComparator {
- // Comparator function
+ // NOTE: We check the fold tables are sorted in X86InstrFoldTables.cpp by the enum of the
+ // instruction, which is computed in CodeGenTarget::ComputeInstrsByEnum. So we should
+ // use the same comparator here.
+ // FIXME: Could we share the code with CodeGenTarget::ComputeInstrsByEnum?
+ struct CompareInstrsByEnum {
bool operator()(const CodeGenInstruction *LHS,
const CodeGenInstruction *RHS) const {
assert(LHS && RHS && "LHS and RHS shouldn't be nullptr");
- bool LHSpseudo = LHS->TheDef->getValueAsBit("isPseudo");
- bool RHSpseudo = RHS->TheDef->getValueAsBit("isPseudo");
- if (LHSpseudo != RHSpseudo)
- return LHSpseudo;
-
- return LHS->TheDef->getName() < RHS->TheDef->getName();
+ const auto &D1 = *LHS->TheDef;
+ const auto &D2 = *RHS->TheDef;
+ return std::make_tuple(!D1.getValueAsBit("isPseudo"), D1.getName()) <
+ std::make_tuple(!D2.getValueAsBit("isPseudo"), D2.getName());
}
};
typedef std::map<const CodeGenInstruction *, X86FoldTableEntry,
- CodeGenInstructionComparator>
+ CompareInstrsByEnum>
FoldTable;
// std::vector for each folding table.
// Table2Addr - Holds instructions which their memory form performs load+store