diff options
Diffstat (limited to 'externals/dynarmic/src/dynarmic/frontend/A32/decoder/thumb16.h')
-rw-r--r-- | externals/dynarmic/src/dynarmic/frontend/A32/decoder/thumb16.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/externals/dynarmic/src/dynarmic/frontend/A32/decoder/thumb16.h b/externals/dynarmic/src/dynarmic/frontend/A32/decoder/thumb16.h new file mode 100644 index 0000000000..6a4275f726 --- /dev/null +++ b/externals/dynarmic/src/dynarmic/frontend/A32/decoder/thumb16.h @@ -0,0 +1,39 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2016 MerryMage + * SPDX-License-Identifier: 0BSD + */ + +#pragma once + +#include <algorithm> +#include <functional> +#include <optional> +#include <vector> + +#include <mcl/stdint.hpp> + +#include "dynarmic/frontend/decoder/decoder_detail.h" +#include "dynarmic/frontend/decoder/matcher.h" + +namespace Dynarmic::A32 { + +template<typename Visitor> +using Thumb16Matcher = Decoder::Matcher<Visitor, u16>; + +template<typename V> +std::optional<std::reference_wrapper<const Thumb16Matcher<V>>> DecodeThumb16(u16 instruction) { + static const std::vector<Thumb16Matcher<V>> table = { + +#define INST(fn, name, bitstring) DYNARMIC_DECODER_GET_MATCHER(Thumb16Matcher, fn, name, Decoder::detail::StringToArray<16>(bitstring)), +#include "./thumb16.inc" +#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); + return iter != table.end() ? std::optional<std::reference_wrapper<const Thumb16Matcher<V>>>(*iter) : std::nullopt; +} + +} // namespace Dynarmic::A32 |