remove obsolete files
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#include "dynarmic/common/assert.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
[[noreturn]] void Terminate(fmt::string_view msg, fmt::format_args args) {
|
||||
fmt::print(stderr, "dynarmic assertion failed: ");
|
||||
fmt::vprint(stderr, msg, args);
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
71
externals/dynarmic/src/dynarmic/common/assert.h
vendored
71
externals/dynarmic/src/dynarmic/common/assert.h
vendored
@@ -1,71 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "dynarmic/common/unlikely.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
[[noreturn]] void Terminate(fmt::string_view msg, fmt::format_args args);
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename... Ts>
|
||||
[[noreturn]] void TerminateHelper(fmt::string_view msg, Ts... args) {
|
||||
Terminate(msg, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
|
||||
#if defined(__clang) || defined(__GNUC__)
|
||||
# define ASSUME(expr) [&] { if (!(expr)) __builtin_unreachable(); }()
|
||||
#elif defined(_MSC_VER)
|
||||
# define ASSUME(expr) __assume(expr)
|
||||
#else
|
||||
# define ASSUME(expr)
|
||||
#endif
|
||||
|
||||
#ifdef DYNARMIC_IGNORE_ASSERTS
|
||||
# if defined(__clang) || defined(__GNUC__)
|
||||
# define UNREACHABLE() __builtin_unreachable()
|
||||
# elif defined(_MSC_VER)
|
||||
# define UNREACHABLE() __assume(0)
|
||||
# else
|
||||
# define UNREACHABLE()
|
||||
# endif
|
||||
|
||||
# define ASSERT(expr) ASSUME(expr)
|
||||
# define ASSERT_MSG(expr, ...) ASSUME(expr)
|
||||
# define ASSERT_FALSE(...) UNREACHABLE()
|
||||
#else
|
||||
# define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
|
||||
|
||||
# define ASSERT(expr) \
|
||||
[&] { \
|
||||
if (UNLIKELY(!(expr))) { \
|
||||
::Dynarmic::Common::detail::TerminateHelper(#expr); \
|
||||
} \
|
||||
}()
|
||||
# define ASSERT_MSG(expr, ...) \
|
||||
[&] { \
|
||||
if (UNLIKELY(!(expr))) { \
|
||||
::Dynarmic::Common::detail::TerminateHelper(#expr "\nMessage: " __VA_ARGS__); \
|
||||
} \
|
||||
}()
|
||||
# define ASSERT_FALSE(...) ::Dynarmic::Common::detail::TerminateHelper("false\nMessage: " __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(NDEBUG) || defined(DYNARMIC_IGNORE_ASSERTS)
|
||||
# define DEBUG_ASSERT(expr) ASSUME(expr)
|
||||
# define DEBUG_ASSERT_MSG(expr, ...) ASSUME(expr)
|
||||
#else
|
||||
# define DEBUG_ASSERT(expr) ASSERT(expr)
|
||||
# define DEBUG_ASSERT_MSG(expr, ...) ASSERT_MSG(expr, __VA_ARGS__)
|
||||
#endif
|
||||
248
externals/dynarmic/src/dynarmic/common/bit_util.h
vendored
248
externals/dynarmic/src/dynarmic/common/bit_util.h
vendored
@@ -1,248 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include "dynarmic/common/assert.h"
|
||||
#include "dynarmic/common/common_types.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
/// The size of a type in terms of bits
|
||||
template<typename T>
|
||||
constexpr size_t BitSize() {
|
||||
return sizeof(T) * CHAR_BIT;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Ones(size_t count) {
|
||||
ASSERT_MSG(count <= BitSize<T>(), "count larger than bitsize of T");
|
||||
if (count == BitSize<T>())
|
||||
return static_cast<T>(~static_cast<T>(0));
|
||||
return ~(static_cast<T>(~static_cast<T>(0)) << count);
|
||||
}
|
||||
|
||||
/// Extract bits [begin_bit, end_bit] inclusive from value of type T.
|
||||
template<typename T>
|
||||
constexpr T Bits(const size_t begin_bit, const size_t end_bit, const T value) {
|
||||
ASSERT_MSG(begin_bit <= end_bit, "invalid bit range (position of beginning bit cannot be greater than that of end bit)");
|
||||
ASSERT_MSG(begin_bit < BitSize<T>(), "begin_bit must be smaller than size of T");
|
||||
ASSERT_MSG(end_bit < BitSize<T>(), "end_bit must be smaller than size of T");
|
||||
|
||||
return (value >> begin_bit) & Ones<T>(end_bit - begin_bit + 1);
|
||||
}
|
||||
|
||||
/// Extract bits [begin_bit, end_bit] inclusive from value of type T.
|
||||
template<size_t begin_bit, size_t end_bit, typename T>
|
||||
constexpr T Bits(const T value) {
|
||||
static_assert(begin_bit <= end_bit, "invalid bit range (position of beginning bit cannot be greater than that of end bit)");
|
||||
static_assert(begin_bit < BitSize<T>(), "begin_bit must be smaller than size of T");
|
||||
static_assert(end_bit < BitSize<T>(), "end_bit must be smaller than size of T");
|
||||
|
||||
return (value >> begin_bit) & Ones<T>(end_bit - begin_bit + 1);
|
||||
}
|
||||
|
||||
/// Create a mask of type T for bits [begin_bit, end_bit] inclusive.
|
||||
template<size_t begin_bit, size_t end_bit, typename T>
|
||||
constexpr T Mask() {
|
||||
static_assert(begin_bit <= end_bit, "invalid bit range (position of beginning bit cannot be greater than that of end bit)");
|
||||
static_assert(begin_bit < BitSize<T>(), "begin_bit must be smaller than size of T");
|
||||
static_assert(end_bit < BitSize<T>(), "end_bit must be smaller than size of T");
|
||||
|
||||
return Ones<T>(end_bit - begin_bit + 1) << begin_bit;
|
||||
}
|
||||
|
||||
/// Clears bits [begin_bit, end_bit] inclusive of value of type T.
|
||||
template<size_t begin_bit, size_t end_bit, typename T>
|
||||
constexpr T ClearBits(const T value) {
|
||||
return value & ~Mask<begin_bit, end_bit, T>();
|
||||
}
|
||||
|
||||
/// Modifies bits [begin_bit, end_bit] inclusive of value of type T.
|
||||
template<size_t begin_bit, size_t end_bit, typename T>
|
||||
constexpr T ModifyBits(const T value, const T new_bits) {
|
||||
return ClearBits<begin_bit, end_bit, T>(value) | ((new_bits << begin_bit) & Mask<begin_bit, end_bit, T>());
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4554)
|
||||
#endif
|
||||
/// Extracts a single bit at bit_position from value of type T.
|
||||
template<typename T>
|
||||
inline bool Bit(size_t bit_position, const T value) {
|
||||
ASSERT_MSG(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return ((value >> bit_position) & 1) != 0;
|
||||
}
|
||||
|
||||
/// Extracts a single bit at bit_position from value of type T.
|
||||
template<size_t bit_position, typename T>
|
||||
constexpr bool Bit(const T value) {
|
||||
static_assert(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return Bit<T>(bit_position, value);
|
||||
}
|
||||
|
||||
/// Clears a single bit at bit_position from value of type T.
|
||||
template<typename T>
|
||||
inline T ClearBit(size_t bit_position, const T value) {
|
||||
ASSERT_MSG(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return value & ~(static_cast<T>(1) << bit_position);
|
||||
}
|
||||
|
||||
/// Clears a single bit at bit_position from value of type T.
|
||||
template<size_t bit_position, typename T>
|
||||
constexpr T ClearBit(const T value) {
|
||||
static_assert(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return ClearBit<T>(bit_position, value);
|
||||
}
|
||||
|
||||
/// Modifies a single bit at bit_position from value of type T.
|
||||
template<typename T>
|
||||
inline T ModifyBit(size_t bit_position, const T value, bool new_bit) {
|
||||
ASSERT_MSG(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return ClearBit<T>(bit_position, value) | (static_cast<T>(new_bit) << bit_position);
|
||||
}
|
||||
|
||||
/// Modifies a single bit at bit_position from value of type T.
|
||||
template<size_t bit_position, typename T>
|
||||
constexpr T ModifyBit(const T value, bool new_bit) {
|
||||
static_assert(bit_position < BitSize<T>(), "bit_position must be smaller than size of T");
|
||||
|
||||
return ModifyBit<T>(bit_position, value, new_bit);
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/// Sign-extends a value that has bit_count bits to the full bitwidth of type T.
|
||||
template<size_t bit_count, typename T>
|
||||
constexpr T SignExtend(const T value) {
|
||||
static_assert(bit_count <= BitSize<T>(), "bit_count larger than bitsize of T");
|
||||
|
||||
constexpr T mask = static_cast<T>(1ULL << bit_count) - 1;
|
||||
const bool signbit = Bit<bit_count - 1, T>(value);
|
||||
if (signbit) {
|
||||
return value | ~mask;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Sign-extends a value that has bit_count bits to the full bitwidth of type T.
|
||||
template<typename T>
|
||||
inline T SignExtend(const size_t bit_count, const T value) {
|
||||
ASSERT_MSG(bit_count <= BitSize<T>(), "bit_count larger than bitsize of T");
|
||||
|
||||
const T mask = static_cast<T>(1ULL << bit_count) - 1;
|
||||
const bool signbit = Bit<T>(bit_count - 1, value);
|
||||
if (signbit) {
|
||||
return value | ~mask;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename Integral>
|
||||
inline size_t BitCount(Integral value) {
|
||||
return std::bitset<BitSize<Integral>()>(value).count();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr size_t CountLeadingZeros(T value) {
|
||||
auto x = static_cast<std::make_unsigned_t<T>>(value);
|
||||
size_t result = BitSize<T>();
|
||||
while (x != 0) {
|
||||
x >>= 1;
|
||||
result--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr int HighestSetBit(T value) {
|
||||
auto x = static_cast<std::make_unsigned_t<T>>(value);
|
||||
int result = -1;
|
||||
while (x != 0) {
|
||||
x >>= 1;
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr size_t LowestSetBit(T value) {
|
||||
auto x = static_cast<std::make_unsigned_t<T>>(value);
|
||||
if (x == 0)
|
||||
return BitSize<T>();
|
||||
|
||||
size_t result = 0;
|
||||
while ((x & 1) == 0) {
|
||||
x >>= 1;
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool MostSignificantBit(T value) {
|
||||
return Bit<BitSize<T>() - 1, T>(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Replicate(T value, size_t element_size) {
|
||||
ASSERT_MSG(BitSize<T>() % element_size == 0, "bitsize of T not divisible by element_size");
|
||||
if (element_size == BitSize<T>())
|
||||
return value;
|
||||
return Replicate<T>(T(value | value << element_size), element_size * 2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T RotateRight(T value, size_t amount) {
|
||||
amount %= BitSize<T>();
|
||||
|
||||
if (amount == 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
auto x = static_cast<std::make_unsigned_t<T>>(value);
|
||||
return static_cast<T>((x >> amount) | (x << (BitSize<T>() - amount)));
|
||||
}
|
||||
|
||||
constexpr u32 SwapHalves32(u32 value) {
|
||||
return ((value & 0xFFFF0000U) >> 16)
|
||||
| ((value & 0x0000FFFFU) << 16);
|
||||
}
|
||||
|
||||
constexpr u16 SwapBytes16(u16 value) {
|
||||
return static_cast<u16>(u32{value} >> 8 | u32{value} << 8);
|
||||
}
|
||||
|
||||
constexpr u32 SwapBytes32(u32 value) {
|
||||
return ((value & 0xFF000000U) >> 24)
|
||||
| ((value & 0x00FF0000U) >> 8)
|
||||
| ((value & 0x0000FF00U) << 8)
|
||||
| ((value & 0x000000FFU) << 24);
|
||||
}
|
||||
|
||||
constexpr u64 SwapBytes64(u64 value) {
|
||||
return ((value & 0xFF00000000000000ULL) >> 56)
|
||||
| ((value & 0x00FF000000000000ULL) >> 40)
|
||||
| ((value & 0x0000FF0000000000ULL) >> 24)
|
||||
| ((value & 0x000000FF00000000ULL) >> 8)
|
||||
| ((value & 0x00000000FF000000ULL) << 8)
|
||||
| ((value & 0x0000000000FF0000ULL) << 24)
|
||||
| ((value & 0x000000000000FF00ULL) << 40)
|
||||
| ((value & 0x00000000000000FFULL) << 56);
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
@@ -1,28 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
using u8 = std::uint8_t;
|
||||
using u16 = std::uint16_t;
|
||||
using u32 = std::uint32_t;
|
||||
using u64 = std::uint64_t;
|
||||
using uptr = std::uintptr_t;
|
||||
|
||||
using s8 = std::int8_t;
|
||||
using s16 = std::int16_t;
|
||||
using s32 = std::int32_t;
|
||||
using s64 = std::int64_t;
|
||||
using sptr = std::intptr_t;
|
||||
|
||||
using size_t = std::size_t;
|
||||
|
||||
using f32 = float;
|
||||
using f64 = double;
|
||||
static_assert(sizeof(f32) == sizeof(u32), "f32 must be 32 bits wide");
|
||||
static_assert(sizeof(f64) == sizeof(u64), "f64 must be 64 bits wide");
|
||||
@@ -1,379 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "dynarmic/common/assert.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
template<typename T>
|
||||
class IntrusiveList;
|
||||
template<typename T>
|
||||
class IntrusiveListIterator;
|
||||
|
||||
template<typename T>
|
||||
class IntrusiveListNode {
|
||||
public:
|
||||
bool IsSentinel() const {
|
||||
return is_sentinel;
|
||||
}
|
||||
|
||||
protected:
|
||||
IntrusiveListNode* next = nullptr;
|
||||
IntrusiveListNode* prev = nullptr;
|
||||
bool is_sentinel = false;
|
||||
|
||||
friend class IntrusiveList<T>;
|
||||
friend class IntrusiveListIterator<T>;
|
||||
friend class IntrusiveListIterator<const T>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class IntrusiveListSentinel final : public IntrusiveListNode<T> {
|
||||
using IntrusiveListNode<T>::next;
|
||||
using IntrusiveListNode<T>::prev;
|
||||
using IntrusiveListNode<T>::is_sentinel;
|
||||
|
||||
public:
|
||||
IntrusiveListSentinel() {
|
||||
next = this;
|
||||
prev = this;
|
||||
is_sentinel = true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class IntrusiveListIterator {
|
||||
public:
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using value_type = T;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
|
||||
// If value_type is const, we want "const IntrusiveListNode<value_type>", not "const IntrusiveListNode<const value_type>"
|
||||
using node_type = std::conditional_t<std::is_const<value_type>::value,
|
||||
const IntrusiveListNode<std::remove_const_t<value_type>>,
|
||||
IntrusiveListNode<value_type>>;
|
||||
using node_pointer = node_type*;
|
||||
using node_reference = node_type&;
|
||||
|
||||
IntrusiveListIterator() = default;
|
||||
IntrusiveListIterator(const IntrusiveListIterator& other) = default;
|
||||
IntrusiveListIterator& operator=(const IntrusiveListIterator& other) = default;
|
||||
|
||||
explicit IntrusiveListIterator(node_pointer list_node)
|
||||
: node(list_node) {
|
||||
}
|
||||
explicit IntrusiveListIterator(pointer data)
|
||||
: node(data) {
|
||||
}
|
||||
explicit IntrusiveListIterator(reference data)
|
||||
: node(&data) {
|
||||
}
|
||||
|
||||
IntrusiveListIterator& operator++() {
|
||||
node = node->next;
|
||||
return *this;
|
||||
}
|
||||
IntrusiveListIterator& operator--() {
|
||||
node = node->prev;
|
||||
return *this;
|
||||
}
|
||||
IntrusiveListIterator operator++(int) {
|
||||
IntrusiveListIterator it(*this);
|
||||
++*this;
|
||||
return it;
|
||||
}
|
||||
IntrusiveListIterator operator--(int) {
|
||||
IntrusiveListIterator it(*this);
|
||||
--*this;
|
||||
return it;
|
||||
}
|
||||
|
||||
bool operator==(const IntrusiveListIterator& other) const {
|
||||
return node == other.node;
|
||||
}
|
||||
bool operator!=(const IntrusiveListIterator& other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
reference operator*() const {
|
||||
DEBUG_ASSERT(!node->IsSentinel());
|
||||
return static_cast<reference>(*node);
|
||||
}
|
||||
pointer operator->() const {
|
||||
return std::addressof(operator*());
|
||||
}
|
||||
|
||||
node_pointer AsNodePointer() const {
|
||||
return node;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class IntrusiveList<T>;
|
||||
node_pointer node = nullptr;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class IntrusiveList {
|
||||
public:
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using value_type = T;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using iterator = IntrusiveListIterator<value_type>;
|
||||
using const_iterator = IntrusiveListIterator<const value_type>;
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
/**
|
||||
* Inserts a node at the given location indicated by an iterator.
|
||||
*
|
||||
* @param location The location to insert the node.
|
||||
* @param new_node The node to add.
|
||||
*/
|
||||
iterator insert(iterator location, pointer new_node) {
|
||||
return insert_before(location, new_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a node at the given location, moving the previous
|
||||
* node occupant ahead of the one inserted.
|
||||
*
|
||||
* @param location The location to insert the new node.
|
||||
* @param new_node The node to insert into the list.
|
||||
*/
|
||||
iterator insert_before(iterator location, pointer new_node) {
|
||||
auto existing_node = location.AsNodePointer();
|
||||
|
||||
new_node->next = existing_node;
|
||||
new_node->prev = existing_node->prev;
|
||||
existing_node->prev->next = new_node;
|
||||
existing_node->prev = new_node;
|
||||
|
||||
return iterator(new_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new node into the list ahead of the position indicated.
|
||||
*
|
||||
* @param position Location to insert the node in front of.
|
||||
* @param new_node The node to be inserted into the list.
|
||||
*/
|
||||
iterator insert_after(iterator position, pointer new_node) {
|
||||
if (empty())
|
||||
return insert(begin(), new_node);
|
||||
|
||||
return insert(++position, new_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an entry to the start of the list.
|
||||
* @param node Node to add to the list.
|
||||
*/
|
||||
void push_front(pointer node) {
|
||||
insert(begin(), node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an entry to the end of the list
|
||||
* @param node Node to add to the list.
|
||||
*/
|
||||
void push_back(pointer node) {
|
||||
insert(end(), node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases the node at the front of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
void pop_front() {
|
||||
DEBUG_ASSERT(!empty());
|
||||
erase(begin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases the node at the back of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
void pop_back() {
|
||||
DEBUG_ASSERT(!empty());
|
||||
erase(--end());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a node from this list
|
||||
* @param it An iterator that points to the node to remove from list.
|
||||
*/
|
||||
pointer remove(iterator& it) {
|
||||
DEBUG_ASSERT(it != end());
|
||||
|
||||
pointer node = &*it++;
|
||||
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
#if !defined(NDEBUG)
|
||||
node->next = nullptr;
|
||||
node->prev = nullptr;
|
||||
#endif
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a node from this list
|
||||
* @param it A constant iterator that points to the node to remove from list.
|
||||
*/
|
||||
pointer remove(const iterator& it) {
|
||||
iterator copy = it;
|
||||
return remove(copy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a node from this list.
|
||||
* @param node A pointer to the node to remove.
|
||||
*/
|
||||
pointer remove(pointer node) {
|
||||
return remove(iterator(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a node from this list.
|
||||
* @param node A reference to the node to remove.
|
||||
*/
|
||||
pointer remove(reference node) {
|
||||
return remove(iterator(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this list empty?
|
||||
* @returns true if there are no nodes in this list.
|
||||
*/
|
||||
bool empty() const {
|
||||
return root->next == root.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total number of elements within this list.
|
||||
* @return the number of elements in this list.
|
||||
*/
|
||||
size_type size() const {
|
||||
return static_cast<size_type>(std::distance(begin(), end()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a reference to the node at the front of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
reference front() {
|
||||
DEBUG_ASSERT(!empty());
|
||||
return *begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a constant reference to the node at the front of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
const_reference front() const {
|
||||
DEBUG_ASSERT(!empty());
|
||||
return *begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a reference to the node at the back of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
reference back() {
|
||||
DEBUG_ASSERT(!empty());
|
||||
return *--end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a constant reference to the node at the back of the list.
|
||||
* @note Must not be called on an empty list.
|
||||
*/
|
||||
const_reference back() const {
|
||||
DEBUG_ASSERT(!empty());
|
||||
return *--end();
|
||||
}
|
||||
|
||||
// Iterator interface
|
||||
iterator begin() { return iterator(root->next); }
|
||||
const_iterator begin() const { return const_iterator(root->next); }
|
||||
const_iterator cbegin() const { return begin(); }
|
||||
|
||||
iterator end() { return iterator(root.get()); }
|
||||
const_iterator end() const { return const_iterator(root.get()); }
|
||||
const_iterator cend() const { return end(); }
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator crbegin() const { return rbegin(); }
|
||||
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
||||
const_reverse_iterator crend() const { return rend(); }
|
||||
|
||||
/**
|
||||
* Erases a node from the list, indicated by an iterator.
|
||||
* @param it The iterator that points to the node to erase.
|
||||
*/
|
||||
iterator erase(iterator it) {
|
||||
remove(it);
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases a node from this list.
|
||||
* @param node A pointer to the node to erase from this list.
|
||||
*/
|
||||
iterator erase(pointer node) {
|
||||
return erase(iterator(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases a node from this list.
|
||||
* @param node A reference to the node to erase from this list.
|
||||
*/
|
||||
iterator erase(reference node) {
|
||||
return erase(iterator(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchanges contents of this list with another list instance.
|
||||
* @param other The other list to swap with.
|
||||
*/
|
||||
void swap(IntrusiveList& other) noexcept {
|
||||
root.swap(other.root);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IntrusiveListNode<T>> root = std::make_shared<IntrusiveListSentinel<T>>();
|
||||
};
|
||||
|
||||
/**
|
||||
* Exchanges contents of an intrusive list with another intrusive list.
|
||||
* @tparam T The type of data being kept track of by the lists.
|
||||
* @param lhs The first list.
|
||||
* @param rhs The second list.
|
||||
*/
|
||||
template<typename T>
|
||||
void swap(IntrusiveList<T>& lhs, IntrusiveList<T>& rhs) noexcept {
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
@@ -1,35 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct ReverseAdapter {
|
||||
T& iterable;
|
||||
|
||||
constexpr auto begin() {
|
||||
using namespace std;
|
||||
return rbegin(iterable);
|
||||
}
|
||||
|
||||
constexpr auto end() {
|
||||
using namespace std;
|
||||
return rend(iterable);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
constexpr detail::ReverseAdapter<T> Reverse(T&& iterable) {
|
||||
return detail::ReverseAdapter<T>{iterable};
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
@@ -1,15 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CONCATENATE_TOKENS(x, y) CONCATENATE_TOKENS_IMPL(x, y)
|
||||
#define CONCATENATE_TOKENS_IMPL(x, y) x##y
|
||||
|
||||
#ifdef __COUNTER__
|
||||
# define ANONYMOUS_VARIABLE(str) CONCATENATE_TOKENS(str, __COUNTER__)
|
||||
#else
|
||||
# define ANONYMOUS_VARIABLE(str) CONCATENATE_TOKENS(str, __LINE__)
|
||||
#endif
|
||||
@@ -1,86 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "dynarmic/common/macro_util.h"
|
||||
|
||||
namespace Dynarmic::detail {
|
||||
|
||||
struct ScopeExitTag {};
|
||||
struct ScopeFailTag {};
|
||||
struct ScopeSuccessTag {};
|
||||
|
||||
template<typename Function>
|
||||
class ScopeExit final {
|
||||
public:
|
||||
explicit ScopeExit(Function&& fn)
|
||||
: function(std::move(fn)) {}
|
||||
~ScopeExit() noexcept {
|
||||
function();
|
||||
}
|
||||
|
||||
private:
|
||||
Function function;
|
||||
};
|
||||
|
||||
template<typename Function>
|
||||
class ScopeFail final {
|
||||
public:
|
||||
explicit ScopeFail(Function&& fn)
|
||||
: function(std::move(fn)), exception_count(std::uncaught_exceptions()) {}
|
||||
~ScopeFail() noexcept {
|
||||
if (std::uncaught_exceptions() > exception_count) {
|
||||
function();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Function function;
|
||||
int exception_count;
|
||||
};
|
||||
|
||||
template<typename Function>
|
||||
class ScopeSuccess final {
|
||||
public:
|
||||
explicit ScopeSuccess(Function&& fn)
|
||||
: function(std::move(fn)), exception_count(std::uncaught_exceptions()) {}
|
||||
~ScopeSuccess() {
|
||||
if (std::uncaught_exceptions() <= exception_count) {
|
||||
function();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Function function;
|
||||
int exception_count;
|
||||
};
|
||||
|
||||
// We use ->* here as it has the highest precedence of the operators we can use.
|
||||
|
||||
template<typename Function>
|
||||
auto operator->*(ScopeExitTag, Function&& function) {
|
||||
return ScopeExit<std::decay_t<Function>>{std::forward<Function>(function)};
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
auto operator->*(ScopeFailTag, Function&& function) {
|
||||
return ScopeFail<std::decay_t<Function>>{std::forward<Function>(function)};
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
auto operator->*(ScopeSuccessTag, Function&& function) {
|
||||
return ScopeSuccess<std::decay_t<Function>>{std::forward<Function>(function)};
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::detail
|
||||
|
||||
#define SCOPE_EXIT auto ANONYMOUS_VARIABLE(_SCOPE_EXIT_) = ::Dynarmic::detail::ScopeExitTag{}->*[&]() noexcept
|
||||
#define SCOPE_FAIL auto ANONYMOUS_VARIABLE(_SCOPE_FAIL_) = ::Dynarmic::detail::ScopeFailTag{}->*[&]() noexcept
|
||||
#define SCOPE_SUCCESS auto ANONYMOUS_VARIABLE(_SCOPE_FAIL_) = ::Dynarmic::detail::ScopeSuccessTag{}->*[&]()
|
||||
@@ -1,12 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
# define UNLIKELY(x) !!(x)
|
||||
#endif
|
||||
28
externals/dynarmic/src/dynarmic/ir/access_type.h
vendored
28
externals/dynarmic/src/dynarmic/ir/access_type.h
vendored
@@ -1,28 +0,0 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2022 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Dynarmic::IR {
|
||||
|
||||
enum class AccessType {
|
||||
NORMAL,
|
||||
VEC,
|
||||
STREAM,
|
||||
VECSTREAM,
|
||||
ATOMIC,
|
||||
ORDERED,
|
||||
ORDEREDRW,
|
||||
LIMITEDORDERED,
|
||||
UNPRIV,
|
||||
IFETCH,
|
||||
PTW,
|
||||
DC,
|
||||
IC,
|
||||
DCZVA,
|
||||
AT,
|
||||
};
|
||||
|
||||
} // namespace Dynarmic::IR
|
||||
Reference in New Issue
Block a user