Fixed bug and spread some always_inlines

This commit is contained in:
jaby 2022-09-11 12:06:40 +02:00
parent 14d9caef43
commit 683bd7ac99
3 changed files with 22 additions and 22 deletions

View File

@ -62,89 +62,89 @@ public:
private:
template<typename S>
constexpr ComplexBitMap<T>& set_va(const S& value) {
constexpr __always_inline ComplexBitMap<T>& set_va(const S& value) {
return this->set(value);
}
template<typename S, typename...ARGS>
constexpr ComplexBitMap<T>& set_va(const S& value, const ARGS&...args) {
constexpr __always_inline ComplexBitMap<T>& set_va(const S& value, const ARGS&...args) {
return this->set_va(value).set_va(args...);
}
public:
template<typename...ARGS>
static constexpr ComplexBitMap<T> with(ARGS...args) {
static constexpr __always_inline ComplexBitMap<T> with(ARGS...args) {
return ComplexBitMap().set_va(args...);
}
//Accesssing bits
template<typename S>
constexpr ComplexBitMap<T>& set_bit(S bit) {
constexpr __always_inline ComplexBitMap<T>& set_bit(S bit) {
this->raw = bit::set(this->raw, static_cast<size_t>(bit));
return *this;
}
template<typename S>
constexpr ComplexBitMap<T>& clear_bit(S bit) {
constexpr __always_inline ComplexBitMap<T>& clear_bit(S bit) {
this->raw = bit::clear(this->raw, static_cast<size_t>(bit));
return *this;
}
template<typename S>
constexpr bool is_bit_set(S bit) {
constexpr __always_inline bool is_bit_set(S bit) {
return bit::is_set(this->raw, static_cast<size_t>(bit));
}
//Accessing values
template<typename S>
constexpr ComplexBitMap<T>& set_value(S value, const BitRange<S>& range) {
constexpr __always_inline ComplexBitMap<T>& set_value(S value, const BitRange<S>& range) {
this->raw = bit::value::set_normalized(this->raw, static_cast<T>(value), range.begin, range.length);
return *this;
}
template<typename S>
constexpr ComplexBitMap<T>& clear_value(const BitRange<S>& range) {
constexpr __always_inline ComplexBitMap<T>& clear_value(const BitRange<S>& range) {
this->raw = bit::value::clear_normalized(this->raw, range.begin, range.length);
return *this;
}
template<typename S>
constexpr S get_value(const BitRange<S>& range) {
constexpr __always_inline S get_value(const BitRange<S>& range) {
return static_cast<S>(bit::value::get_normalized(this->raw, range.begin, range.length));
}
// For easier constructing
constexpr ComplexBitMap<T>& set(const BitRange<T>& range, T value) {
constexpr __always_inline ComplexBitMap<T>& set(const BitRange<T>& range, T value) {
this->set_value(value, range);
return *this;
}
constexpr ComplexBitMap<T>& set(const BitRangeValue<T>& value) {
constexpr __always_inline ComplexBitMap<T>& set(const BitRangeValue<T>& value) {
this->set_value(value.value, {value.begin, value.length});
return *this;
}
constexpr ComplexBitMap<T>& set(const Bit<T>& bit) {
constexpr __always_inline ComplexBitMap<T>& set(const Bit<T>& bit) {
this->set_bit(bit.value);
return *this;
}
constexpr ComplexBitMap<T>& set(const ClearBitValue& value) {
constexpr __always_inline ComplexBitMap<T>& set(const ClearBitValue& value) {
this->clear_bit(value.bit);
return *this;
}
constexpr ComplexBitMap<T>& operator|(const BitRangeValue<T>& value) {
constexpr __always_inline ComplexBitMap<T>& operator|(const BitRangeValue<T>& value) {
this->set_value(value.value, value.range);
return *this;
}
constexpr ComplexBitMap<T>& operator|(const Bit<T>& bit) {
constexpr __always_inline ComplexBitMap<T>& operator|(const Bit<T>& bit) {
this->set_bit(bit.value);
return *this;
}
constexpr ComplexBitMap<T>& operator|(const ClearBitValue& value) {
constexpr __always_inline ComplexBitMap<T>& operator|(const ClearBitValue& value) {
this->clear_bit(value.bit);
return *this;
}

View File

@ -51,11 +51,11 @@ namespace GPU {
}
static constexpr GP0 TopLeftPosition(uint16_t x, uint16_t y) {
return ComplexBitMap{static_cast<uint16_t>((y << 16) | x)};
return ComplexBitMap{static_cast<uint32_t>((y << 16u) | x)};
}
static constexpr GP0 WidthHeight(uint16_t w, uint16_t h) {
return ComplexBitMap{static_cast<uint16_t>((h << 16) | w)};
return ComplexBitMap{static_cast<uint32_t>((h << 16u) | w)};
}
};

View File

@ -58,15 +58,15 @@ static constexpr uintptr_t IO_Base_Adr = 0x10000000;
#define __declare_io_port_global_const(type, name, adr) __declare_io_port_global_raw(const, type, name, adr)
#define __declare_io_port_global_array(type, name, adr, size) static __always_inline auto& name = reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>((IO_Base_Adr + (adr & ~IO_Base_Mask))));
#define __io_port_inherit_complex_bit_map(name) \
constexpr name() = default; \
constexpr name(ComplexBitMap value) : ComplexBitMap(value) { \
constexpr __always_inline name() = default; \
constexpr __always_inline name(ComplexBitMap value) : ComplexBitMap(value) { \
} \
template<typename...ARGS> \
static constexpr name with(ARGS...args) { \
static constexpr __always_inline name with(ARGS...args) { \
return {ComplexBitMap::with(args...)}; \
}\
template<typename T> \
constexpr void operator=(ComplexBitMap<T> value) volatile { \
constexpr void __always_inline operator=(ComplexBitMap<T> value) volatile { \
this->raw = value.raw; \
}