2016-07-18 22:18:58 +01:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
|
|
* General Public License version 2 or any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "frontend/decoder/decoder_detail.h"
|
2016-09-17 09:48:18 +01:00
|
|
|
#include "frontend/decoder/matcher.h"
|
2016-07-18 22:18:58 +01:00
|
|
|
|
|
|
|
namespace Dynarmic {
|
2018-01-01 15:23:56 +00:00
|
|
|
namespace A32 {
|
2016-07-18 22:18:58 +01:00
|
|
|
|
|
|
|
template <typename Visitor>
|
2018-01-01 15:23:56 +00:00
|
|
|
using Thumb32Matcher = Decoder::Matcher<Visitor, u32>;
|
2016-07-18 22:18:58 +01:00
|
|
|
|
|
|
|
template<typename V>
|
|
|
|
boost::optional<const Thumb32Matcher<V>&> DecodeThumb32(u32 instruction) {
|
2017-09-29 01:23:45 +01:00
|
|
|
static const std::vector<Thumb32Matcher<V>> table = {
|
2016-07-18 22:18:58 +01:00
|
|
|
|
2018-01-01 15:23:56 +00:00
|
|
|
#define INST(fn, name, bitstring) Decoder::detail::detail<Thumb32Matcher<V>>::GetMatcher(fn, name, bitstring)
|
2016-07-18 22:18:58 +01:00
|
|
|
|
|
|
|
// Branch instructions
|
|
|
|
INST(&V::thumb32_BL_imm, "BL (imm)", "11110vvvvvvvvvvv11111vvvvvvvvvvv"), // v4T
|
|
|
|
INST(&V::thumb32_BLX_imm, "BLX (imm)", "11110vvvvvvvvvvv11101vvvvvvvvvvv"), // v5T
|
|
|
|
|
|
|
|
// Misc instructions
|
|
|
|
INST(&V::thumb32_UDF, "UDF", "111101111111----1010------------"), // v6T2
|
|
|
|
|
|
|
|
#undef INST
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto matches_instruction = [instruction](const auto& matcher){ return matcher.Matches(instruction); };
|
|
|
|
|
|
|
|
auto iter = std::find_if(table.begin(), table.end(), matches_instruction);
|
2017-11-28 20:56:49 +00:00
|
|
|
return iter != table.end() ? boost::optional<const Thumb32Matcher<V>&>(*iter) : boost::none;
|
2016-07-18 22:18:58 +01:00
|
|
|
}
|
|
|
|
|
2018-01-01 15:23:56 +00:00
|
|
|
} // namespace A32
|
2016-07-18 22:18:58 +01:00
|
|
|
} // namespace Dynarmic
|