mirror of
https://github.com/azahar-emu/dynarmic
synced 2025-11-16 03:50:03 +01:00
u128: Add u128::Bit
This commit is contained in:
parent
3e62fea003
commit
5566fab29a
@ -24,7 +24,7 @@ struct u128 {
|
|||||||
|
|
||||||
u128(u64 lower_, u64 upper_) : lower(lower_), upper(upper_) {}
|
u128(u64 lower_, u64 upper_) : lower(lower_), upper(upper_) {}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
/* implicit */ u128(T value) : lower(value), upper(0) {
|
/* implicit */ u128(T value) : lower(value), upper(0) {
|
||||||
static_assert(std::is_integral_v<T>);
|
static_assert(std::is_integral_v<T>);
|
||||||
static_assert(Common::BitSize<T>() <= Common::BitSize<u64>());
|
static_assert(Common::BitSize<T>() <= Common::BitSize<u64>());
|
||||||
@ -32,6 +32,16 @@ struct u128 {
|
|||||||
|
|
||||||
u64 lower = 0;
|
u64 lower = 0;
|
||||||
u64 upper = 0;
|
u64 upper = 0;
|
||||||
|
|
||||||
|
template<size_t bit_position>
|
||||||
|
bool Bit() {
|
||||||
|
static_assert(bit_position < 128);
|
||||||
|
if constexpr (bit_position < 64) {
|
||||||
|
return Common::Bit<bit_position>(lower);
|
||||||
|
} else {
|
||||||
|
return Common::Bit<bit_position - 64>(upper);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(Common::BitSize<u128>() == 128);
|
static_assert(Common::BitSize<u128>() == 128);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user