dynarmic/tests/A64/inst_gen.h

37 lines
1 KiB
C
Raw Normal View History

2018-01-13 18:04:19 +00:00
/* This file is part of the dynarmic project.
* Copyright (c) 2018 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
#include <algorithm>
2018-01-13 18:04:19 +00:00
#include <cstring>
#include <vector>
#include "common/common_types.h"
struct InstructionGenerator final {
public:
explicit InstructionGenerator(const char* format);
u32 Generate() const;
u32 Bits() const { return bits; }
u32 Mask() const { return mask; }
bool Match(u32 inst) const { return (inst & mask) == bits; }
static void AddInvalidInstruction(const char* format) {
invalid_instructions.emplace_back(InstructionGenerator{format});
}
static bool IsInvalidInstruction(u32 inst) {
return std::any_of(invalid_instructions.begin(), invalid_instructions.end(),
[inst](const auto& invalid) { return invalid.Match(inst); });
2018-01-13 18:04:19 +00:00
}
private:
static inline std::vector<InstructionGenerator> invalid_instructions;
2018-01-13 18:04:19 +00:00
u32 bits = 0;
u32 mask = 0;
};