decoder/arm: Sort decoders according to number of bits in mask

This commit is contained in:
MerryMage 2016-12-22 15:25:38 +00:00
parent cb38c94b58
commit c78f153ddb

View file

@ -14,6 +14,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include "common/bit_util.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "frontend/decoder/decoder_detail.h" #include "frontend/decoder/decoder_detail.h"
#include "frontend/decoder/matcher.h" #include "frontend/decoder/matcher.h"
@ -318,7 +319,10 @@ std::vector<ArmMatcher<V>> GetArmDecodeTable() {
}; };
std::stable_partition(table.begin(), table.end(), [](const auto& matcher) { return (matcher.GetMask() & 0xF0000000) != 0; }); // If a matcher has more bits in its mask it is more specific, so it should come first.
std::stable_sort(table.begin(), table.end(), [](const auto& matcher1, const auto& matcher2) {
return Common::BitCount(matcher1.GetMask()) > Common::BitCount(matcher2.GetMask());
});
return table; return table;
} }