mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-12-16 15:55:30 +00:00
Merge pull request #3028 from lioncash/constexpr
shader_bytecode: Make Matcher constexpr capable
This commit is contained in:
commit
5062728669
|
@ -574,7 +574,7 @@ enum class ShuffleOperation : u64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
union Instruction {
|
union Instruction {
|
||||||
Instruction& operator=(const Instruction& instr) {
|
constexpr Instruction& operator=(const Instruction& instr) {
|
||||||
value = instr.value;
|
value = instr.value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -1760,22 +1760,22 @@ public:
|
||||||
|
|
||||||
class Matcher {
|
class Matcher {
|
||||||
public:
|
public:
|
||||||
Matcher(const char* const name, u16 mask, u16 expected, OpCode::Id id, OpCode::Type type)
|
constexpr Matcher(const char* const name, u16 mask, u16 expected, Id id, Type type)
|
||||||
: name{name}, mask{mask}, expected{expected}, id{id}, type{type} {}
|
: name{name}, mask{mask}, expected{expected}, id{id}, type{type} {}
|
||||||
|
|
||||||
const char* GetName() const {
|
constexpr const char* GetName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 GetMask() const {
|
constexpr u16 GetMask() const {
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id GetId() const {
|
constexpr Id GetId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type GetType() const {
|
constexpr Type GetType() const {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1784,7 +1784,7 @@ public:
|
||||||
* @param instruction The instruction to test
|
* @param instruction The instruction to test
|
||||||
* @returns true if the given instruction matches.
|
* @returns true if the given instruction matches.
|
||||||
*/
|
*/
|
||||||
bool Matches(u16 instruction) const {
|
constexpr bool Matches(u16 instruction) const {
|
||||||
return (instruction & mask) == expected;
|
return (instruction & mask) == expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1818,7 +1818,7 @@ private:
|
||||||
* A '0' in a bitstring indicates that a zero must be present at that bit position.
|
* A '0' in a bitstring indicates that a zero must be present at that bit position.
|
||||||
* A '1' in a bitstring indicates that a one must be present at that bit position.
|
* A '1' in a bitstring indicates that a one must be present at that bit position.
|
||||||
*/
|
*/
|
||||||
static auto GetMaskAndExpect(const char* const bitstring) {
|
static constexpr auto GetMaskAndExpect(const char* const bitstring) {
|
||||||
u16 mask = 0, expect = 0;
|
u16 mask = 0, expect = 0;
|
||||||
for (std::size_t i = 0; i < opcode_bitsize; i++) {
|
for (std::size_t i = 0; i < opcode_bitsize; i++) {
|
||||||
const std::size_t bit_position = opcode_bitsize - i - 1;
|
const std::size_t bit_position = opcode_bitsize - i - 1;
|
||||||
|
@ -1835,15 +1835,15 @@ private:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::make_tuple(mask, expect);
|
return std::make_pair(mask, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Creates a matcher that can match and parse instructions based on bitstring.
|
/// Creates a matcher that can match and parse instructions based on bitstring.
|
||||||
static auto GetMatcher(const char* const bitstring, OpCode::Id op, OpCode::Type type,
|
static constexpr auto GetMatcher(const char* const bitstring, Id op, Type type,
|
||||||
const char* const name) {
|
const char* const name) {
|
||||||
const auto mask_expect = GetMaskAndExpect(bitstring);
|
const auto [mask, expected] = GetMaskAndExpect(bitstring);
|
||||||
return Matcher(name, std::get<0>(mask_expect), std::get<1>(mask_expect), op, type);
|
return Matcher(name, mask, expected, op, type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue