shader: Initial instruction support

This commit is contained in:
ReinUsesLisp 2021-02-03 16:43:04 -03:00 committed by ameerj
parent 6c4cc0cd06
commit d24a16045f
28 changed files with 1452 additions and 336 deletions

View file

@ -5,7 +5,9 @@
#pragma once
#include <array>
#include <cstring>
#include <span>
#include <type_traits>
#include <vector>
#include <boost/intrusive/list.hpp>
@ -23,7 +25,7 @@ constexpr size_t MAX_ARG_COUNT = 4;
class Inst : public boost::intrusive::list_base_hook<> {
public:
explicit Inst(Opcode op_) noexcept : op(op_) {}
explicit Inst(Opcode op_, u64 flags_) noexcept : op{op_}, flags{flags_} {}
/// Get the number of uses this instruction has.
[[nodiscard]] int UseCount() const noexcept {
@ -73,6 +75,14 @@ public:
void ReplaceUsesWith(Value replacement);
template <typename FlagsType>
requires(sizeof(FlagsType) <= sizeof(u64) && std::is_trivially_copyable_v<FlagsType>)
[[nodiscard]] FlagsType Flags() const noexcept {
FlagsType ret;
std::memcpy(&ret, &flags, sizeof(ret));
return ret;
}
private:
void Use(const Value& value);
void UndoUse(const Value& value);