glasm: Make GLASM aware of types

This commit is contained in:
ReinUsesLisp 2021-05-09 03:11:34 -03:00 committed by ameerj
parent 934d300246
commit 1c9307969c
12 changed files with 1396 additions and 1260 deletions

View File

@ -23,15 +23,15 @@ public:
explicit EmitContext(IR::Program& program); explicit EmitContext(IR::Program& program);
template <typename... Args> template <typename... Args>
void Add(const char* fmt, IR::Inst& inst, Args&&... args) { void Add(const char* format_str, IR::Inst& inst, Args&&... args) {
code += fmt::format(fmt, reg_alloc.Define(inst), std::forward<Args>(args)...); code += fmt::format(format_str, reg_alloc.Define(inst), std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }
template <typename... Args> template <typename... Args>
void Add(const char* fmt, Args&&... args) { void Add(const char* format_str, Args&&... args) {
code += fmt::format(fmt, std::forward<Args>(args)...); code += fmt::format(format_str, std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }

View File

@ -27,22 +27,80 @@ struct FuncTraits<ReturnType_ (*)(Args...)> {
using ArgType = std::tuple_element_t<I, std::tuple<Args...>>; using ArgType = std::tuple_element_t<I, std::tuple<Args...>>;
}; };
template <typename T>
struct Identity {
Identity(const T& data_) : data{data_} {}
const T& Extract() {
return data;
}
T data;
};
template <bool scalar>
struct RegWrapper {
RegWrapper(EmitContext& ctx, Value value)
: reg_alloc{ctx.reg_alloc}, allocated{value.type != Type::Register} {
reg = allocated ? reg_alloc.AllocReg() : Register{value};
switch (value.type) {
case Type::Register:
break;
case Type::U32:
ctx.Add("MOV.U {}.x,{};", reg, value.imm_u32);
break;
case Type::S32:
ctx.Add("MOV.S {}.x,{};", reg, value.imm_s32);
break;
case Type::F32:
ctx.Add("MOV.F {}.x,{};", reg, value.imm_f32);
break;
}
}
~RegWrapper() {
if (allocated) {
reg_alloc.FreeReg(reg);
}
}
auto Extract() {
return std::conditional_t<scalar, ScalarRegister, Register>{Value{reg}};
}
RegAlloc& reg_alloc;
Register reg{};
bool allocated{};
};
template <typename ArgType> template <typename ArgType>
auto Arg(EmitContext& ctx, const IR::Value& arg) { auto Arg(EmitContext& ctx, const IR::Value& arg) {
if constexpr (std::is_same_v<ArgType, std::string_view>) { if constexpr (std::is_same_v<ArgType, Register>) {
return ctx.reg_alloc.Consume(arg); return RegWrapper<false>{ctx, ctx.reg_alloc.Consume(arg)};
} else if constexpr (std::is_same_v<ArgType, ScalarRegister>) {
return RegWrapper<true>{ctx, ctx.reg_alloc.Consume(arg)};
} else if constexpr (std::is_base_of_v<Value, ArgType>) {
return Identity{ArgType{ctx.reg_alloc.Consume(arg)}};
} else if constexpr (std::is_same_v<ArgType, const IR::Value&>) { } else if constexpr (std::is_same_v<ArgType, const IR::Value&>) {
return arg; return Identity{arg};
} else if constexpr (std::is_same_v<ArgType, u32>) { } else if constexpr (std::is_same_v<ArgType, u32>) {
return arg.U32(); return Identity{arg.U32()};
} else if constexpr (std::is_same_v<ArgType, IR::Block*>) { } else if constexpr (std::is_same_v<ArgType, IR::Block*>) {
return arg.Label(); return Identity{arg.Label()};
} else if constexpr (std::is_same_v<ArgType, IR::Attribute>) { } else if constexpr (std::is_same_v<ArgType, IR::Attribute>) {
return arg.Attribute(); return Identity{arg.Attribute()};
} else if constexpr (std::is_same_v<ArgType, IR::Patch>) { } else if constexpr (std::is_same_v<ArgType, IR::Patch>) {
return arg.Patch(); return Identity{arg.Patch()};
} else if constexpr (std::is_same_v<ArgType, IR::Reg>) { } else if constexpr (std::is_same_v<ArgType, IR::Reg>) {
return arg.Reg(); return Identity{arg.Reg()};
}
}
template <auto func, bool is_first_arg_inst, typename... Args>
void InvokeCall(EmitContext& ctx, IR::Inst* inst, Args&&... args) {
if constexpr (is_first_arg_inst) {
func(ctx, *inst, std::forward<Args>(args.Extract())...);
} else {
func(ctx, std::forward<Args>(args.Extract())...);
} }
} }
@ -50,9 +108,10 @@ template <auto func, bool is_first_arg_inst, size_t... I>
void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) { void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) {
using Traits = FuncTraits<decltype(func)>; using Traits = FuncTraits<decltype(func)>;
if constexpr (is_first_arg_inst) { if constexpr (is_first_arg_inst) {
func(ctx, *inst, Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...); func(ctx, *inst,
Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I)).Extract()...);
} else { } else {
func(ctx, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...); func(ctx, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I)).Extract()...);
} }
} }
@ -81,7 +140,7 @@ void EmitInst(EmitContext& ctx, IR::Inst* inst) {
throw LogicError("Invalid opcode {}", inst->GetOpcode()); throw LogicError("Invalid opcode {}", inst->GetOpcode());
} }
void Identity(IR::Inst& inst, const IR::Value& value) { void Alias(IR::Inst& inst, const IR::Value& value) {
if (value.IsImmediate()) { if (value.IsImmediate()) {
return; return;
} }
@ -125,31 +184,31 @@ std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
} }
void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) { void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
Identity(inst, value); Alias(inst, value);
} }
} // namespace Shader::Backend::GLASM } // namespace Shader::Backend::GLASM

View File

@ -0,0 +1,225 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "shader_recompiler/backend/glasm/emit_context.h"
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
#include "shader_recompiler/frontend/ir/value.h"
namespace Shader::Backend::GLASM {
namespace {
template <typename... Values>
void CompositeConstructU32(EmitContext& ctx, IR::Inst& inst, Values&&... elements) {
const Register ret{ctx.reg_alloc.Define(inst)};
if (std::ranges::any_of(std::array{elements...},
[](const IR::Value& value) { return value.IsImmediate(); })) {
const std::array<u32, 4> values{(elements.IsImmediate() ? elements.U32() : 0)...};
ctx.Add("MOV.U {},{{{},{},{},{}}};", ret, fmt::to_string(values[0]),
fmt::to_string(values[1]), fmt::to_string(values[2]), fmt::to_string(values[3]));
}
size_t index{};
for (const IR::Value& element : {elements...}) {
if (!element.IsImmediate()) {
const ScalarU32 value{ctx.reg_alloc.Consume(element)};
ctx.Add("MOV.U {}.{},{};", ret, "xyzw"[index], value);
}
++index;
}
}
void CompositeExtractU32(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index) {
const Register ret{ctx.reg_alloc.Define(inst)};
if (ret == composite && index == 0) {
// No need to do anything here, the source and destination are the same register
return;
}
ctx.Add("MOV.U {}.x,{}.{};", ret, composite, "xyzw"[index]);
}
} // Anonymous namespace
void EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
const IR::Value& e2) {
CompositeConstructU32(ctx, inst, e1, e2);
}
void EmitCompositeConstructU32x3(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
const IR::Value& e2, const IR::Value& e3) {
CompositeConstructU32(ctx, inst, e1, e2, e3);
}
void EmitCompositeConstructU32x4(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
const IR::Value& e2, const IR::Value& e3, const IR::Value& e4) {
CompositeConstructU32(ctx, inst, e1, e2, e3, e4);
}
void EmitCompositeExtractU32x2(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index) {
CompositeExtractU32(ctx, inst, composite, index);
}
void EmitCompositeExtractU32x3(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index) {
CompositeExtractU32(ctx, inst, composite, index);
}
void EmitCompositeExtractU32x4(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index) {
CompositeExtractU32(ctx, inst, composite, index);
}
void EmitCompositeInsertU32x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarU32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertU32x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarU32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertU32x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarU32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF16x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register e1,
[[maybe_unused]] Register e2) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF16x3([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register e1,
[[maybe_unused]] Register e2, [[maybe_unused]] Register e3) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF16x4([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register e1,
[[maybe_unused]] Register e2, [[maybe_unused]] Register e3,
[[maybe_unused]] Register e4) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF16x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF16x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF16x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF16x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF16x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF16x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 e1,
[[maybe_unused]] ScalarF32 e2) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF32x3([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 e1,
[[maybe_unused]] ScalarF32 e2, [[maybe_unused]] ScalarF32 e3) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF32x4([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 e1,
[[maybe_unused]] ScalarF32 e2, [[maybe_unused]] ScalarF32 e3,
[[maybe_unused]] ScalarF32 e4) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF32x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF32x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF32x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF32x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarF32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF32x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarF32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF32x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite,
[[maybe_unused]] ScalarF32 object, [[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF64x2([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF64x3([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeConstructF64x4([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF64x2([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF64x3([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeExtractF64x4([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF64x2([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF64x3([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
void EmitCompositeInsertF64x4([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] Register composite, [[maybe_unused]] Register object,
[[maybe_unused]] u32 index) {
throw NotImplementedException("GLASM instruction");
}
} // namespace Shader::Backend::GLASM

View File

@ -10,64 +10,58 @@
namespace Shader::Backend::GLASM { namespace Shader::Backend::GLASM {
namespace { namespace {
void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const IR::Value& offset, void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset,
std::string_view size) { std::string_view size) {
if (!binding.IsImmediate()) { if (!binding.IsImmediate()) {
throw NotImplementedException("Indirect constant buffer loading"); throw NotImplementedException("Indirect constant buffer loading");
} }
const std::string ret{ctx.reg_alloc.Define(inst)}; const Register ret{ctx.reg_alloc.Define(inst)};
ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), ctx.reg_alloc.Consume(offset)); ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset);
} }
} // Anonymous namespace } // Anonymous namespace
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "U8"); GetCbuf(ctx, inst, binding, offset, "U8");
} }
void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "S8"); GetCbuf(ctx, inst, binding, offset, "S8");
} }
void EmitGetCbufU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "U16"); GetCbuf(ctx, inst, binding, offset, "U16");
} }
void EmitGetCbufS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "S16"); GetCbuf(ctx, inst, binding, offset, "S16");
} }
void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "U32"); GetCbuf(ctx, inst, binding, offset, "U32");
} }
void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
const IR::Value& offset) {
GetCbuf(ctx, inst, binding, offset, "F32"); GetCbuf(ctx, inst, binding, offset, "F32");
} }
void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
const IR::Value& offset) { ScalarU32 offset) {
GetCbuf(ctx, inst, binding, offset, "U32X2"); GetCbuf(ctx, inst, binding, offset, "U32X2");
} }
void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
[[maybe_unused]] std::string_view vertex) { [[maybe_unused]] ScalarU32 vertex) {
if (IR::IsGeneric(attr)) { if (IR::IsGeneric(attr)) {
const u32 index{IR::GenericAttributeIndex(attr)}; const u32 index{IR::GenericAttributeIndex(attr)};
const u32 element{IR::GenericAttributeElement(attr)}; const u32 element{IR::GenericAttributeElement(attr)};
ctx.Add("MOV.F {},in_attr{}.{};", inst, index, "xyzw"[element]); ctx.Add("MOV.F {}.x,in_attr{}.{};", inst, index, "xyzw"[element]);
return; return;
} }
throw NotImplementedException("Get attribute {}", attr); throw NotImplementedException("Get attribute {}", attr);
} }
void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value,
[[maybe_unused]] std::string_view vertex) { [[maybe_unused]] ScalarU32 vertex) {
const u32 element{static_cast<u32>(attr) % 4}; const u32 element{static_cast<u32>(attr) % 4};
const char swizzle{"xyzw"[element]}; const char swizzle{"xyzw"[element]};
if (IR::IsGeneric(attr)) { if (IR::IsGeneric(attr)) {
@ -87,16 +81,13 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val
} }
} }
void EmitGetAttributeIndexed([[maybe_unused]] EmitContext& ctx, void EmitGetAttributeIndexed([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 offset,
[[maybe_unused]] std::string_view offset, [[maybe_unused]] ScalarU32 vertex) {
[[maybe_unused]] std::string_view vertex) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSetAttributeIndexed([[maybe_unused]] EmitContext& ctx, void EmitSetAttributeIndexed([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 offset,
[[maybe_unused]] std::string_view offset, [[maybe_unused]] ScalarF32 value, [[maybe_unused]] ScalarU32 vertex) {
[[maybe_unused]] std::string_view value,
[[maybe_unused]] std::string_view vertex) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
@ -105,20 +96,20 @@ void EmitGetPatch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Patch
} }
void EmitSetPatch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Patch patch, void EmitSetPatch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Patch patch,
[[maybe_unused]] std::string_view value) { [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSetFragColor([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] u32 index, void EmitSetFragColor([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] u32 index,
[[maybe_unused]] u32 component, [[maybe_unused]] std::string_view value) { [[maybe_unused]] u32 component, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSetSampleMask([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitSetSampleMask([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSetFragDepth([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitSetFragDepth([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }

View File

@ -10,411 +10,382 @@
namespace Shader::Backend::GLASM { namespace Shader::Backend::GLASM {
void EmitFPAbs16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPAbs16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { void EmitFPAbs32(EmitContext& ctx, IR::Inst& inst, ScalarF32 value) {
ctx.Add("MOV.F {},|{}|;", inst, value); ctx.Add("MOV.F {}.x,|{}|;", inst, value);
} }
void EmitFPAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPAdd16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPAdd16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register a, [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { void EmitFPAdd32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b) {
ctx.Add("ADD.F {},{},{};", inst, a, b); ctx.Add("ADD.F {}.x,{},{};", inst, a, b);
} }
void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register a, [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b, [[maybe_unused]] Register a, [[maybe_unused]] Register b,
[[maybe_unused]] std::string_view c) { [[maybe_unused]] Register c) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPFma32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b, void EmitFPFma32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b, ScalarF32 c) {
std::string_view c) { ctx.Add("MAD.F {}.x,{},{},{};", inst, a, b, c);
ctx.Add("MAD.F {},{},{},{};", inst, a, b, c);
} }
void EmitFPFma64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPFma64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b, [[maybe_unused]] Register a, [[maybe_unused]] Register b,
[[maybe_unused]] std::string_view c) { [[maybe_unused]] Register c) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, void EmitFPMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 a,
[[maybe_unused]] std::string_view b) { [[maybe_unused]] ScalarF32 b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMax64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, void EmitFPMax64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
[[maybe_unused]] std::string_view b) { [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, void EmitFPMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 a,
[[maybe_unused]] std::string_view b) { [[maybe_unused]] ScalarF32 b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMin64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, void EmitFPMin64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
[[maybe_unused]] std::string_view b) { [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMul16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPMul16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register a, [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { void EmitFPMul32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b) {
ctx.Add("MUL.F {},{},{};", inst, a, b); ctx.Add("MUL.F {}.x,{},{};", inst, a, b);
} }
void EmitFPMul64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFPMul64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register a, [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPNeg16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPNeg16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPNeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { void EmitFPNeg32(EmitContext& ctx, IR::Inst& inst, ScalarRegister value) {
if (value[0] == '-') { ctx.Add("MOV.F {}.x,-{};", inst, value);
// Guard against negating a negative immediate
ctx.Add("MOV.F {},{};", inst, value.substr(1));
} else {
ctx.Add("MOV.F {},-{};", inst, value);
}
} }
void EmitFPNeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPNeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPSin([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPSin([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPCos([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPCos([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPExp2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPExp2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPLog2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPLog2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRecip32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRecip32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRecip64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRecip64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRecipSqrt32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRecipSqrt32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRecipSqrt64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRecipSqrt64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPSqrt([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPSqrt([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPSaturate16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPSaturate16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPSaturate32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { void EmitFPSaturate32(EmitContext& ctx, IR::Inst& inst, ScalarF32 value) {
ctx.Add("MOV.F.SAT {},{};", inst, value); ctx.Add("MOV.F.SAT {}.x,{};", inst, value);
} }
void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value, void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value,
[[maybe_unused]] std::string_view min_value, [[maybe_unused]] Register min_value, [[maybe_unused]] Register max_value) {
[[maybe_unused]] std::string_view max_value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value, void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value,
[[maybe_unused]] std::string_view min_value, [[maybe_unused]] ScalarF32 min_value, [[maybe_unused]] ScalarF32 max_value) {
[[maybe_unused]] std::string_view max_value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value, void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value,
[[maybe_unused]] std::string_view min_value, [[maybe_unused]] Register min_value, [[maybe_unused]] Register max_value) {
[[maybe_unused]] std::string_view max_value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRoundEven32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRoundEven32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPRoundEven64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPRoundEven64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPFloor16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPFloor16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPFloor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPFloor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPFloor64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPFloor64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPCeil16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPCeil16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPCeil32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPCeil32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPCeil64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPCeil64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPTrunc16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPTrunc16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPTrunc32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPTrunc32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPTrunc64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { void EmitFPTrunc64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs) {
std::string_view rhs) { const Register ret{ctx.reg_alloc.Define(inst)};
const std::string ret{ctx.reg_alloc.Define(inst)}; ctx.Add("SEQ.F {}.x,{},{};SNE.S {}.x,{},0;", ret, lhs, rhs, ret, ret);
ctx.Add("SEQ.F {},{},{};SNE.S {},{},0;", ret, lhs, rhs, ret, ret);
} }
void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarF32 rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdNotEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdNotEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarF32 rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdNotEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdNotEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordNotEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordNotEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarF32 rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordNotEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordNotEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs) {
std::string_view rhs) { const Register ret{ctx.reg_alloc.Define(inst)};
const std::string ret{ctx.reg_alloc.Define(inst)}; ctx.Add("SLT.F {}.x,{},{};SNE.S {}.x,{}.x,0;", ret, lhs, rhs, ret, ret);
ctx.Add("SLT.F {},{},{};SNE.S {},{},0;", ret, lhs, rhs, ret, ret);
} }
void EmitFPOrdLessThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPOrdLessThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThan32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordLessThan32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarF32 rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, void EmitFPUnordLessThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view rhs) { [[maybe_unused]] Register rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThan16([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThan32([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThan32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarF32 rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThan64([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThan16([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThan32([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThan32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarF32 rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThan64([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThan64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdLessThanEqual16([[maybe_unused]] EmitContext& ctx, void EmitFPOrdLessThanEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs) {
std::string_view rhs) { const Register ret{ctx.reg_alloc.Define(inst)};
const std::string ret{ctx.reg_alloc.Define(inst)}; ctx.Add("SLE.F {}.x,{},{};SNE.S {}.x,{}.x,0;", ret, lhs, rhs, ret, ret);
ctx.Add("SLE.F {},{},{};SNE.S {},{},0;", ret, lhs, rhs, ret, ret);
} }
void EmitFPOrdLessThanEqual64([[maybe_unused]] EmitContext& ctx, void EmitFPOrdLessThanEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThanEqual16([[maybe_unused]] EmitContext& ctx, void EmitFPUnordLessThanEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThanEqual32([[maybe_unused]] EmitContext& ctx, void EmitFPUnordLessThanEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarF32 rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordLessThanEqual64([[maybe_unused]] EmitContext& ctx, void EmitFPUnordLessThanEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThanEqual32([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThanEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarF32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarF32 rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPOrdGreaterThanEqual64([[maybe_unused]] EmitContext& ctx, void EmitFPOrdGreaterThanEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThanEqual32([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThanEqual32([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarF32 lhs, [[maybe_unused]] ScalarF32 rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFPUnordGreaterThanEqual64([[maybe_unused]] EmitContext& ctx, void EmitFPUnordGreaterThanEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] Register rhs) {
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }

View File

@ -4,9 +4,8 @@
#pragma once #pragma once
#include <string_view>
#include "common/common_types.h" #include "common/common_types.h"
#include "shader_recompiler/backend/glasm/reg_alloc.h"
namespace Shader::IR { namespace Shader::IR {
enum class Attribute : u64; enum class Attribute : u64;
@ -23,15 +22,14 @@ class EmitContext;
void EmitPhi(EmitContext& ctx, IR::Inst& inst); void EmitPhi(EmitContext& ctx, IR::Inst& inst);
void EmitVoid(EmitContext& ctx); void EmitVoid(EmitContext& ctx);
void EmitIdentity(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitIdentity(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBranch(EmitContext& ctx, std::string_view label); void EmitBranch(EmitContext& ctx);
void EmitBranchConditional(EmitContext& ctx, std::string_view condition, void EmitBranchConditional(EmitContext& ctx);
std::string_view true_label, std::string_view false_label); void EmitLoopMerge(EmitContext& ctx);
void EmitLoopMerge(EmitContext& ctx, std::string_view merge_label, std::string_view continue_label); void EmitSelectionMerge(EmitContext& ctx);
void EmitSelectionMerge(EmitContext& ctx, std::string_view merge_label);
void EmitReturn(EmitContext& ctx); void EmitReturn(EmitContext& ctx);
void EmitJoin(EmitContext& ctx); void EmitJoin(EmitContext& ctx);
void EmitUnreachable(EmitContext& ctx); void EmitUnreachable(EmitContext& ctx);
void EmitDemoteToHelperInvocation(EmitContext& ctx, std::string_view continue_label); void EmitDemoteToHelperInvocation(EmitContext& ctx);
void EmitBarrier(EmitContext& ctx); void EmitBarrier(EmitContext& ctx);
void EmitWorkgroupMemoryBarrier(EmitContext& ctx); void EmitWorkgroupMemoryBarrier(EmitContext& ctx);
void EmitDeviceMemoryBarrier(EmitContext& ctx); void EmitDeviceMemoryBarrier(EmitContext& ctx);
@ -47,32 +45,22 @@ void EmitSetGotoVariable(EmitContext& ctx);
void EmitGetGotoVariable(EmitContext& ctx); void EmitGetGotoVariable(EmitContext& ctx);
void EmitSetIndirectBranchVariable(EmitContext& ctx); void EmitSetIndirectBranchVariable(EmitContext& ctx);
void EmitGetIndirectBranchVariable(EmitContext& ctx); void EmitGetIndirectBranchVariable(EmitContext& ctx);
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
const IR::Value& offset); void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
const IR::Value& offset); void EmitGetCbufS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
void EmitGetCbufU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
const IR::Value& offset); void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
void EmitGetCbufS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset);
const IR::Value& offset); void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, ScalarU32 vertex);
void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, ScalarU32 vertex);
const IR::Value& offset); void EmitGetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarU32 vertex);
void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitSetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarF32 value, ScalarU32 vertex);
const IR::Value& offset);
void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
const IR::Value& offset);
void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
std::string_view vertex);
void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value,
std::string_view vertex);
void EmitGetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view vertex);
void EmitSetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view value,
std::string_view vertex);
void EmitGetPatch(EmitContext& ctx, IR::Patch patch); void EmitGetPatch(EmitContext& ctx, IR::Patch patch);
void EmitSetPatch(EmitContext& ctx, IR::Patch patch, std::string_view value); void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value);
void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_view value); void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, ScalarF32 value);
void EmitSetSampleMask(EmitContext& ctx, std::string_view value); void EmitSetSampleMask(EmitContext& ctx, ScalarF32 value);
void EmitSetFragDepth(EmitContext& ctx, std::string_view value); void EmitSetFragDepth(EmitContext& ctx, ScalarF32 value);
void EmitGetZFlag(EmitContext& ctx); void EmitGetZFlag(EmitContext& ctx);
void EmitGetSFlag(EmitContext& ctx); void EmitGetSFlag(EmitContext& ctx);
void EmitGetCFlag(EmitContext& ctx); void EmitGetCFlag(EmitContext& ctx);
@ -82,13 +70,13 @@ void EmitSetSFlag(EmitContext& ctx);
void EmitSetCFlag(EmitContext& ctx); void EmitSetCFlag(EmitContext& ctx);
void EmitSetOFlag(EmitContext& ctx); void EmitSetOFlag(EmitContext& ctx);
void EmitWorkgroupId(EmitContext& ctx); void EmitWorkgroupId(EmitContext& ctx);
void EmitLocalInvocationId(EmitContext& ctx); void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst);
void EmitInvocationId(EmitContext& ctx); void EmitInvocationId(EmitContext& ctx);
void EmitSampleId(EmitContext& ctx); void EmitSampleId(EmitContext& ctx);
void EmitIsHelperInvocation(EmitContext& ctx); void EmitIsHelperInvocation(EmitContext& ctx);
void EmitYDirection(EmitContext& ctx); void EmitYDirection(EmitContext& ctx);
void EmitLoadLocal(EmitContext& ctx, std::string_view word_offset); void EmitLoadLocal(EmitContext& ctx, ScalarU32 word_offset);
void EmitWriteLocal(EmitContext& ctx, std::string_view word_offset, std::string_view value); void EmitWriteLocal(EmitContext& ctx, ScalarU32 word_offset, ScalarU32 value);
void EmitUndefU1(EmitContext& ctx); void EmitUndefU1(EmitContext& ctx);
void EmitUndefU8(EmitContext& ctx); void EmitUndefU8(EmitContext& ctx);
void EmitUndefU16(EmitContext& ctx); void EmitUndefU16(EmitContext& ctx);
@ -98,368 +86,321 @@ void EmitLoadGlobalU8(EmitContext& ctx);
void EmitLoadGlobalS8(EmitContext& ctx); void EmitLoadGlobalS8(EmitContext& ctx);
void EmitLoadGlobalU16(EmitContext& ctx); void EmitLoadGlobalU16(EmitContext& ctx);
void EmitLoadGlobalS16(EmitContext& ctx); void EmitLoadGlobalS16(EmitContext& ctx);
void EmitLoadGlobal32(EmitContext& ctx, std::string_view address); void EmitLoadGlobal32(EmitContext& ctx, Register address);
void EmitLoadGlobal64(EmitContext& ctx, std::string_view address); void EmitLoadGlobal64(EmitContext& ctx, Register address);
void EmitLoadGlobal128(EmitContext& ctx, std::string_view address); void EmitLoadGlobal128(EmitContext& ctx, Register address);
void EmitWriteGlobalU8(EmitContext& ctx); void EmitWriteGlobalU8(EmitContext& ctx);
void EmitWriteGlobalS8(EmitContext& ctx); void EmitWriteGlobalS8(EmitContext& ctx);
void EmitWriteGlobalU16(EmitContext& ctx); void EmitWriteGlobalU16(EmitContext& ctx);
void EmitWriteGlobalS16(EmitContext& ctx); void EmitWriteGlobalS16(EmitContext& ctx);
void EmitWriteGlobal32(EmitContext& ctx, std::string_view address, std::string_view value); void EmitWriteGlobal32(EmitContext& ctx, Register address, ScalarU32 value);
void EmitWriteGlobal64(EmitContext& ctx, std::string_view address, std::string_view value); void EmitWriteGlobal64(EmitContext& ctx, Register address, Register value);
void EmitWriteGlobal128(EmitContext& ctx, std::string_view address, std::string_view value); void EmitWriteGlobal128(EmitContext& ctx, Register address, Register value);
void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorageU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset); ScalarU32 offset);
void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); ScalarU32 value);
void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); ScalarS32 value);
void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); ScalarU32 value);
void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); ScalarS32 value);
void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); ScalarU32 value);
void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); Register value);
void EmitWriteStorage128(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage128(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value); Register value);
void EmitLoadSharedU8(EmitContext& ctx, std::string_view offset); void EmitLoadSharedU8(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedS8(EmitContext& ctx, std::string_view offset); void EmitLoadSharedS8(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedU16(EmitContext& ctx, std::string_view offset); void EmitLoadSharedU16(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedS16(EmitContext& ctx, std::string_view offset); void EmitLoadSharedS16(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedU32(EmitContext& ctx, std::string_view offset); void EmitLoadSharedU32(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedU64(EmitContext& ctx, std::string_view offset); void EmitLoadSharedU64(EmitContext& ctx, ScalarU32 offset);
void EmitLoadSharedU128(EmitContext& ctx, std::string_view offset); void EmitLoadSharedU128(EmitContext& ctx, ScalarU32 offset);
void EmitWriteSharedU8(EmitContext& ctx, std::string_view offset, std::string_view value); void EmitWriteSharedU8(EmitContext& ctx, ScalarU32 offset, ScalarU32 value);
void EmitWriteSharedU16(EmitContext& ctx, std::string_view offset, std::string_view value); void EmitWriteSharedU16(EmitContext& ctx, ScalarU32 offset, ScalarU32 value);
void EmitWriteSharedU32(EmitContext& ctx, std::string_view offset, std::string_view value); void EmitWriteSharedU32(EmitContext& ctx, ScalarU32 offset, ScalarU32 value);
void EmitWriteSharedU64(EmitContext& ctx, std::string_view offset, std::string_view value); void EmitWriteSharedU64(EmitContext& ctx, ScalarU32 offset, Register value);
void EmitWriteSharedU128(EmitContext& ctx, std::string_view offset, std::string_view value); void EmitWriteSharedU128(EmitContext& ctx, ScalarU32 offset, Register value);
void EmitCompositeConstructU32x2(EmitContext& ctx, std::string_view e1, std::string_view e2); void EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
void EmitCompositeConstructU32x3(EmitContext& ctx, std::string_view e1, std::string_view e2, const IR::Value& e2);
std::string_view e3); void EmitCompositeConstructU32x3(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
void EmitCompositeConstructU32x4(EmitContext& ctx, std::string_view e1, std::string_view e2, const IR::Value& e2, const IR::Value& e3);
std::string_view e3, std::string_view e4); void EmitCompositeConstructU32x4(EmitContext& ctx, IR::Inst& inst, const IR::Value& e1,
void EmitCompositeExtractU32x2(EmitContext& ctx, std::string_view composite, u32 index); const IR::Value& e2, const IR::Value& e3, const IR::Value& e4);
void EmitCompositeExtractU32x3(EmitContext& ctx, std::string_view composite, u32 index); void EmitCompositeExtractU32x2(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index);
void EmitCompositeExtractU32x4(EmitContext& ctx, std::string_view composite, u32 index); void EmitCompositeExtractU32x3(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index);
void EmitCompositeInsertU32x2(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeExtractU32x4(EmitContext& ctx, IR::Inst& inst, Register composite, u32 index);
u32 index); void EmitCompositeInsertU32x2(EmitContext& ctx, Register composite, ScalarU32 object, u32 index);
void EmitCompositeInsertU32x3(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeInsertU32x3(EmitContext& ctx, Register composite, ScalarU32 object, u32 index);
u32 index); void EmitCompositeInsertU32x4(EmitContext& ctx, Register composite, ScalarU32 object, u32 index);
void EmitCompositeInsertU32x4(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeConstructF16x2(EmitContext& ctx, Register e1, Register e2);
u32 index); void EmitCompositeConstructF16x3(EmitContext& ctx, Register e1, Register e2, Register e3);
void EmitCompositeConstructF16x2(EmitContext& ctx, std::string_view e1, std::string_view e2); void EmitCompositeConstructF16x4(EmitContext& ctx, Register e1, Register e2, Register e3,
void EmitCompositeConstructF16x3(EmitContext& ctx, std::string_view e1, std::string_view e2, Register e4);
std::string_view e3); void EmitCompositeExtractF16x2(EmitContext& ctx, Register composite, u32 index);
void EmitCompositeConstructF16x4(EmitContext& ctx, std::string_view e1, std::string_view e2, void EmitCompositeExtractF16x3(EmitContext& ctx, Register composite, u32 index);
std::string_view e3, std::string_view e4); void EmitCompositeExtractF16x4(EmitContext& ctx, Register composite, u32 index);
void EmitCompositeExtractF16x2(EmitContext& ctx, std::string_view composite, u32 index); void EmitCompositeInsertF16x2(EmitContext& ctx, Register composite, Register object, u32 index);
void EmitCompositeExtractF16x3(EmitContext& ctx, std::string_view composite, u32 index); void EmitCompositeInsertF16x3(EmitContext& ctx, Register composite, Register object, u32 index);
void EmitCompositeExtractF16x4(EmitContext& ctx, std::string_view composite, u32 index); void EmitCompositeInsertF16x4(EmitContext& ctx, Register composite, Register object, u32 index);
void EmitCompositeInsertF16x2(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeConstructF32x2(EmitContext& ctx, ScalarF32 e1, ScalarF32 e2);
u32 index); void EmitCompositeConstructF32x3(EmitContext& ctx, ScalarF32 e1, ScalarF32 e2, ScalarF32 e3);
void EmitCompositeInsertF16x3(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeConstructF32x4(EmitContext& ctx, ScalarF32 e1, ScalarF32 e2, ScalarF32 e3,
u32 index); ScalarF32 e4);
void EmitCompositeInsertF16x4(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeExtractF32x2(EmitContext& ctx, Register composite, u32 index);
u32 index); void EmitCompositeExtractF32x3(EmitContext& ctx, Register composite, u32 index);
void EmitCompositeConstructF32x2(EmitContext& ctx, std::string_view e1, std::string_view e2); void EmitCompositeExtractF32x4(EmitContext& ctx, Register composite, u32 index);
void EmitCompositeConstructF32x3(EmitContext& ctx, std::string_view e1, std::string_view e2, void EmitCompositeInsertF32x2(EmitContext& ctx, Register composite, ScalarF32 object, u32 index);
std::string_view e3); void EmitCompositeInsertF32x3(EmitContext& ctx, Register composite, ScalarF32 object, u32 index);
void EmitCompositeConstructF32x4(EmitContext& ctx, std::string_view e1, std::string_view e2, void EmitCompositeInsertF32x4(EmitContext& ctx, Register composite, ScalarF32 object, u32 index);
std::string_view e3, std::string_view e4);
void EmitCompositeExtractF32x2(EmitContext& ctx, std::string_view composite, u32 index);
void EmitCompositeExtractF32x3(EmitContext& ctx, std::string_view composite, u32 index);
void EmitCompositeExtractF32x4(EmitContext& ctx, std::string_view composite, u32 index);
void EmitCompositeInsertF32x2(EmitContext& ctx, std::string_view composite, std::string_view object,
u32 index);
void EmitCompositeInsertF32x3(EmitContext& ctx, std::string_view composite, std::string_view object,
u32 index);
void EmitCompositeInsertF32x4(EmitContext& ctx, std::string_view composite, std::string_view object,
u32 index);
void EmitCompositeConstructF64x2(EmitContext& ctx); void EmitCompositeConstructF64x2(EmitContext& ctx);
void EmitCompositeConstructF64x3(EmitContext& ctx); void EmitCompositeConstructF64x3(EmitContext& ctx);
void EmitCompositeConstructF64x4(EmitContext& ctx); void EmitCompositeConstructF64x4(EmitContext& ctx);
void EmitCompositeExtractF64x2(EmitContext& ctx); void EmitCompositeExtractF64x2(EmitContext& ctx);
void EmitCompositeExtractF64x3(EmitContext& ctx); void EmitCompositeExtractF64x3(EmitContext& ctx);
void EmitCompositeExtractF64x4(EmitContext& ctx); void EmitCompositeExtractF64x4(EmitContext& ctx);
void EmitCompositeInsertF64x2(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeInsertF64x2(EmitContext& ctx, Register composite, Register object, u32 index);
u32 index); void EmitCompositeInsertF64x3(EmitContext& ctx, Register composite, Register object, u32 index);
void EmitCompositeInsertF64x3(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitCompositeInsertF64x4(EmitContext& ctx, Register composite, Register object, u32 index);
u32 index); void EmitSelectU1(EmitContext& ctx, ScalarS32 cond, ScalarS32 true_value, ScalarS32 false_value);
void EmitCompositeInsertF64x4(EmitContext& ctx, std::string_view composite, std::string_view object, void EmitSelectU8(EmitContext& ctx, ScalarS32 cond, ScalarS32 true_value, ScalarS32 false_value);
u32 index); void EmitSelectU16(EmitContext& ctx, ScalarS32 cond, ScalarS32 true_value, ScalarS32 false_value);
void EmitSelectU1(EmitContext& ctx, std::string_view cond, std::string_view true_value, void EmitSelectU32(EmitContext& ctx, ScalarS32 cond, ScalarS32 true_value, ScalarS32 false_value);
std::string_view false_value); void EmitSelectU64(EmitContext& ctx, ScalarS32 cond, Register true_value, Register false_value);
void EmitSelectU8(EmitContext& ctx, std::string_view cond, std::string_view true_value, void EmitSelectF16(EmitContext& ctx, ScalarS32 cond, Register true_value, Register false_value);
std::string_view false_value); void EmitSelectF32(EmitContext& ctx, ScalarS32 cond, ScalarS32 true_value, ScalarS32 false_value);
void EmitSelectU16(EmitContext& ctx, std::string_view cond, std::string_view true_value, void EmitSelectF64(EmitContext& ctx, ScalarS32 cond, Register true_value, Register false_value);
std::string_view false_value);
void EmitSelectU32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
std::string_view true_value, std::string_view false_value);
void EmitSelectU64(EmitContext& ctx, std::string_view cond, std::string_view true_value,
std::string_view false_value);
void EmitSelectF16(EmitContext& ctx, std::string_view cond, std::string_view true_value,
std::string_view false_value);
void EmitSelectF32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
std::string_view true_value, std::string_view false_value);
void EmitSelectF64(EmitContext& ctx, std::string_view cond, std::string_view true_value,
std::string_view false_value);
void EmitBitCastU16F16(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastU16F16(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBitCastU32F32(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastU32F32(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBitCastU64F64(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastU64F64(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBitCastF16U16(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastF16U16(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBitCastF32U32(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastF32U32(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitBitCastF64U64(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); void EmitBitCastF64U64(EmitContext& ctx, IR::Inst& inst, const IR::Value& value);
void EmitPackUint2x32(EmitContext& ctx, std::string_view value); void EmitPackUint2x32(EmitContext& ctx, Register value);
void EmitUnpackUint2x32(EmitContext& ctx, std::string_view value); void EmitUnpackUint2x32(EmitContext& ctx, Register value);
void EmitPackFloat2x16(EmitContext& ctx, std::string_view value); void EmitPackFloat2x16(EmitContext& ctx, Register value);
void EmitUnpackFloat2x16(EmitContext& ctx, std::string_view value); void EmitUnpackFloat2x16(EmitContext& ctx, Register value);
void EmitPackHalf2x16(EmitContext& ctx, std::string_view value); void EmitPackHalf2x16(EmitContext& ctx, Register value);
void EmitUnpackHalf2x16(EmitContext& ctx, std::string_view value); void EmitUnpackHalf2x16(EmitContext& ctx, Register value);
void EmitPackDouble2x32(EmitContext& ctx, std::string_view value); void EmitPackDouble2x32(EmitContext& ctx, Register value);
void EmitUnpackDouble2x32(EmitContext& ctx, std::string_view value); void EmitUnpackDouble2x32(EmitContext& ctx, Register value);
void EmitGetZeroFromOp(EmitContext& ctx); void EmitGetZeroFromOp(EmitContext& ctx);
void EmitGetSignFromOp(EmitContext& ctx); void EmitGetSignFromOp(EmitContext& ctx);
void EmitGetCarryFromOp(EmitContext& ctx); void EmitGetCarryFromOp(EmitContext& ctx);
void EmitGetOverflowFromOp(EmitContext& ctx); void EmitGetOverflowFromOp(EmitContext& ctx);
void EmitGetSparseFromOp(EmitContext& ctx); void EmitGetSparseFromOp(EmitContext& ctx);
void EmitGetInBoundsFromOp(EmitContext& ctx); void EmitGetInBoundsFromOp(EmitContext& ctx);
void EmitFPAbs16(EmitContext& ctx, std::string_view value); void EmitFPAbs16(EmitContext& ctx, Register value);
void EmitFPAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitFPAbs32(EmitContext& ctx, IR::Inst& inst, ScalarF32 value);
void EmitFPAbs64(EmitContext& ctx, std::string_view value); void EmitFPAbs64(EmitContext& ctx, Register value);
void EmitFPAdd16(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPAdd16(EmitContext& ctx, IR::Inst& inst, Register a, Register b);
void EmitFPAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPAdd32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b);
void EmitFPAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPAdd64(EmitContext& ctx, IR::Inst& inst, Register a, Register b);
void EmitFPFma16(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b, void EmitFPFma16(EmitContext& ctx, IR::Inst& inst, Register a, Register b, Register c);
std::string_view c); void EmitFPFma32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b, ScalarF32 c);
void EmitFPFma32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b, void EmitFPFma64(EmitContext& ctx, IR::Inst& inst, Register a, Register b, Register c);
std::string_view c); void EmitFPMax32(EmitContext& ctx, ScalarF32 a, ScalarF32 b);
void EmitFPFma64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b, void EmitFPMax64(EmitContext& ctx, Register a, Register b);
std::string_view c); void EmitFPMin32(EmitContext& ctx, ScalarF32 a, ScalarF32 b);
void EmitFPMax32(EmitContext& ctx, std::string_view a, std::string_view b); void EmitFPMin64(EmitContext& ctx, Register a, Register b);
void EmitFPMax64(EmitContext& ctx, std::string_view a, std::string_view b); void EmitFPMul16(EmitContext& ctx, IR::Inst& inst, Register a, Register b);
void EmitFPMin32(EmitContext& ctx, std::string_view a, std::string_view b); void EmitFPMul32(EmitContext& ctx, IR::Inst& inst, ScalarF32 a, ScalarF32 b);
void EmitFPMin64(EmitContext& ctx, std::string_view a, std::string_view b); void EmitFPMul64(EmitContext& ctx, IR::Inst& inst, Register a, Register b);
void EmitFPMul16(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPNeg16(EmitContext& ctx, Register value);
void EmitFPMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPNeg32(EmitContext& ctx, IR::Inst& inst, ScalarRegister value);
void EmitFPMul64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitFPNeg64(EmitContext& ctx, Register value);
void EmitFPNeg16(EmitContext& ctx, std::string_view value); void EmitFPSin(EmitContext& ctx, ScalarF32 value);
void EmitFPNeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitFPCos(EmitContext& ctx, ScalarF32 value);
void EmitFPNeg64(EmitContext& ctx, std::string_view value); void EmitFPExp2(EmitContext& ctx, ScalarF32 value);
void EmitFPSin(EmitContext& ctx, std::string_view value); void EmitFPLog2(EmitContext& ctx, ScalarF32 value);
void EmitFPCos(EmitContext& ctx, std::string_view value); void EmitFPRecip32(EmitContext& ctx, ScalarF32 value);
void EmitFPExp2(EmitContext& ctx, std::string_view value); void EmitFPRecip64(EmitContext& ctx, Register value);
void EmitFPLog2(EmitContext& ctx, std::string_view value); void EmitFPRecipSqrt32(EmitContext& ctx, ScalarF32 value);
void EmitFPRecip32(EmitContext& ctx, std::string_view value); void EmitFPRecipSqrt64(EmitContext& ctx, Register value);
void EmitFPRecip64(EmitContext& ctx, std::string_view value); void EmitFPSqrt(EmitContext& ctx, ScalarF32 value);
void EmitFPRecipSqrt32(EmitContext& ctx, std::string_view value); void EmitFPSaturate16(EmitContext& ctx, Register value);
void EmitFPRecipSqrt64(EmitContext& ctx, std::string_view value); void EmitFPSaturate32(EmitContext& ctx, IR::Inst& inst, ScalarF32 value);
void EmitFPSqrt(EmitContext& ctx, std::string_view value); void EmitFPSaturate64(EmitContext& ctx, Register value);
void EmitFPSaturate16(EmitContext& ctx, std::string_view value); void EmitFPClamp16(EmitContext& ctx, Register value, Register min_value, Register max_value);
void EmitFPSaturate32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitFPClamp32(EmitContext& ctx, ScalarF32 value, ScalarF32 min_value, ScalarF32 max_value);
void EmitFPSaturate64(EmitContext& ctx, std::string_view value); void EmitFPClamp64(EmitContext& ctx, Register value, Register min_value, Register max_value);
void EmitFPClamp16(EmitContext& ctx, std::string_view value, std::string_view min_value, void EmitFPRoundEven16(EmitContext& ctx, Register value);
std::string_view max_value); void EmitFPRoundEven32(EmitContext& ctx, ScalarF32 value);
void EmitFPClamp32(EmitContext& ctx, std::string_view value, std::string_view min_value, void EmitFPRoundEven64(EmitContext& ctx, Register value);
std::string_view max_value); void EmitFPFloor16(EmitContext& ctx, Register value);
void EmitFPClamp64(EmitContext& ctx, std::string_view value, std::string_view min_value, void EmitFPFloor32(EmitContext& ctx, ScalarF32 value);
std::string_view max_value); void EmitFPFloor64(EmitContext& ctx, Register value);
void EmitFPRoundEven16(EmitContext& ctx, std::string_view value); void EmitFPCeil16(EmitContext& ctx, Register value);
void EmitFPRoundEven32(EmitContext& ctx, std::string_view value); void EmitFPCeil32(EmitContext& ctx, ScalarF32 value);
void EmitFPRoundEven64(EmitContext& ctx, std::string_view value); void EmitFPCeil64(EmitContext& ctx, Register value);
void EmitFPFloor16(EmitContext& ctx, std::string_view value); void EmitFPTrunc16(EmitContext& ctx, Register value);
void EmitFPFloor32(EmitContext& ctx, std::string_view value); void EmitFPTrunc32(EmitContext& ctx, ScalarF32 value);
void EmitFPFloor64(EmitContext& ctx, std::string_view value); void EmitFPTrunc64(EmitContext& ctx, Register value);
void EmitFPCeil16(EmitContext& ctx, std::string_view value); void EmitFPOrdEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPCeil32(EmitContext& ctx, std::string_view value); void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPCeil64(EmitContext& ctx, std::string_view value); void EmitFPOrdEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPTrunc16(EmitContext& ctx, std::string_view value); void EmitFPUnordEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPTrunc32(EmitContext& ctx, std::string_view value); void EmitFPUnordEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPTrunc64(EmitContext& ctx, std::string_view value); void EmitFPUnordEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdNotEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitFPOrdNotEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPOrdEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdNotEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordNotEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordNotEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPUnordEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordNotEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdNotEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThan16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdNotEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPOrdNotEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThan64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordNotEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThan16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordNotEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThan32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPUnordNotEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThan64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdLessThan16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdGreaterThan16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitFPOrdGreaterThan32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
std::string_view rhs); void EmitFPOrdGreaterThan64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdLessThan64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordGreaterThan16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordLessThan16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordGreaterThan32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPUnordLessThan32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordGreaterThan64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordLessThan64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThanEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdGreaterThan16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPOrdGreaterThan32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdLessThanEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdGreaterThan64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThanEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordGreaterThan16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThanEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPUnordGreaterThan32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordLessThanEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordGreaterThan64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdGreaterThanEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdLessThanEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPOrdGreaterThanEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitFPOrdGreaterThanEqual64(EmitContext& ctx, Register lhs, Register rhs);
std::string_view rhs); void EmitFPUnordGreaterThanEqual16(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPOrdLessThanEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordGreaterThanEqual32(EmitContext& ctx, ScalarF32 lhs, ScalarF32 rhs);
void EmitFPUnordLessThanEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPUnordGreaterThanEqual64(EmitContext& ctx, Register lhs, Register rhs);
void EmitFPUnordLessThanEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPIsNan16(EmitContext& ctx, Register value);
void EmitFPUnordLessThanEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPIsNan32(EmitContext& ctx, ScalarF32 value);
void EmitFPOrdGreaterThanEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitFPIsNan64(EmitContext& ctx, Register value);
void EmitFPOrdGreaterThanEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitFPOrdGreaterThanEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitIAdd64(EmitContext& ctx, Register a, Register b);
void EmitFPUnordGreaterThanEqual16(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitFPUnordGreaterThanEqual32(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitISub64(EmitContext& ctx, Register a, Register b);
void EmitFPUnordGreaterThanEqual64(EmitContext& ctx, std::string_view lhs, std::string_view rhs); void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitFPIsNan16(EmitContext& ctx, std::string_view value); void EmitINeg32(EmitContext& ctx, ScalarS32 value);
void EmitFPIsNan32(EmitContext& ctx, std::string_view value); void EmitINeg64(EmitContext& ctx, Register value);
void EmitFPIsNan64(EmitContext& ctx, std::string_view value); void EmitIAbs32(EmitContext& ctx, ScalarS32 value);
void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitIAbs64(EmitContext& ctx, Register value);
void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift);
void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift);
void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitShiftRightLogical32(EmitContext& ctx, ScalarU32 base, ScalarU32 shift);
void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift);
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitShiftRightArithmetic32(EmitContext& ctx, ScalarS32 base, ScalarS32 shift);
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift);
void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitIAbs64(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitShiftLeftLogical32(EmitContext& ctx, std::string_view base, std::string_view shift); void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitShiftLeftLogical64(EmitContext& ctx, std::string_view base, std::string_view shift); void EmitBitFieldInsert(EmitContext& ctx, ScalarS32 base, ScalarS32 insert, ScalarS32 offset,
void EmitShiftRightLogical32(EmitContext& ctx, std::string_view base, std::string_view shift); ScalarS32 count);
void EmitShiftRightLogical64(EmitContext& ctx, std::string_view base, std::string_view shift); void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 offset,
void EmitShiftRightArithmetic32(EmitContext& ctx, std::string_view base, std::string_view shift); ScalarS32 count);
void EmitShiftRightArithmetic64(EmitContext& ctx, std::string_view base, std::string_view shift); void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset,
void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); ScalarU32 count);
void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitBitReverse32(EmitContext& ctx, ScalarS32 value);
void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitBitCount32(EmitContext& ctx, ScalarS32 value);
void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base, void EmitBitwiseNot32(EmitContext& ctx, ScalarS32 value);
std::string_view insert, std::string_view offset, std::string_view count); void EmitFindSMsb32(EmitContext& ctx, ScalarS32 value);
void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, void EmitFindUMsb32(EmitContext& ctx, ScalarU32 value);
std::string_view offset, std::string_view count); void EmitSMin32(EmitContext& ctx, ScalarS32 a, ScalarS32 b);
void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, void EmitUMin32(EmitContext& ctx, ScalarU32 a, ScalarU32 b);
std::string_view offset, std::string_view count); void EmitSMax32(EmitContext& ctx, ScalarS32 a, ScalarS32 b);
void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitUMax32(EmitContext& ctx, ScalarU32 a, ScalarU32 b);
void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max);
void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max);
void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitSLessThan(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, std::string_view value); void EmitULessThan(EmitContext& ctx, ScalarU32 lhs, ScalarU32 rhs);
void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitIEqual(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitSLessThanEqual(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitULessThanEqual(EmitContext& ctx, ScalarU32 lhs, ScalarU32 rhs);
void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); void EmitSGreaterThan(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, void EmitUGreaterThan(EmitContext& ctx, ScalarU32 lhs, ScalarU32 rhs);
std::string_view max); void EmitINotEqual(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, void EmitSGreaterThanEqual(EmitContext& ctx, ScalarS32 lhs, ScalarS32 rhs);
std::string_view max); void EmitUGreaterThanEqual(EmitContext& ctx, ScalarU32 lhs, ScalarU32 rhs);
void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicIAdd32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitULessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicSMin32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarS32 value);
void EmitIEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicUMin32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitSLessThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitSharedAtomicSMax32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarS32 value);
std::string_view rhs); void EmitSharedAtomicUMax32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitULessThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitSharedAtomicInc32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
std::string_view rhs); void EmitSharedAtomicDec32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitSGreaterThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicAnd32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitUGreaterThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicOr32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitINotEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs); void EmitSharedAtomicXor32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
void EmitSGreaterThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, void EmitSharedAtomicExchange32(EmitContext& ctx, ScalarU32 pointer_offset, ScalarU32 value);
std::string_view rhs); void EmitSharedAtomicExchange64(EmitContext& ctx, ScalarU32 pointer_offset, Register value);
void EmitUGreaterThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs,
std::string_view rhs);
void EmitSharedAtomicIAdd32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicSMin32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicUMin32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicSMax32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicUMax32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicInc32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicDec32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicAnd32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicOr32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicXor32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicExchange32(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitSharedAtomicExchange64(EmitContext& ctx, std::string_view pointer_offset,
std::string_view value);
void EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarS32 value);
void EmitStorageAtomicUMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicUMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicSMax32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicSMax32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarS32 value);
void EmitStorageAtomicUMax32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicUMax32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicInc32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicInc32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicDec32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicDec32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicAnd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicAnd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicOr32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicOr32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicXor32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicXor32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarU32 value);
void EmitStorageAtomicExchange32(EmitContext& ctx, const IR::Value& binding, void EmitStorageAtomicExchange32(EmitContext& ctx, const IR::Value& binding,
const IR::Value& offset, std::string_view value); const IR::Value& offset, ScalarU32 value);
void EmitStorageAtomicIAdd64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicIAdd64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicSMin64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicSMin64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicUMin64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicUMin64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicSMax64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicSMax64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicUMax64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicUMax64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicAnd64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicAnd64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicOr64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicOr64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicXor64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicXor64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, void EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding,
const IR::Value& offset, std::string_view value); const IR::Value& offset, Register value);
void EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); ScalarF32 value);
void EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicAddF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicAddF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicMinF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicMinF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicMinF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicMinF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicMaxF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicMaxF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitStorageAtomicMaxF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, void EmitStorageAtomicMaxF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
std::string_view value); Register value);
void EmitGlobalAtomicIAdd32(EmitContext& ctx); void EmitGlobalAtomicIAdd32(EmitContext& ctx);
void EmitGlobalAtomicSMin32(EmitContext& ctx); void EmitGlobalAtomicSMin32(EmitContext& ctx);
void EmitGlobalAtomicUMin32(EmitContext& ctx); void EmitGlobalAtomicUMin32(EmitContext& ctx);
@ -489,58 +430,58 @@ void EmitGlobalAtomicMinF16x2(EmitContext& ctx);
void EmitGlobalAtomicMinF32x2(EmitContext& ctx); void EmitGlobalAtomicMinF32x2(EmitContext& ctx);
void EmitGlobalAtomicMaxF16x2(EmitContext& ctx); void EmitGlobalAtomicMaxF16x2(EmitContext& ctx);
void EmitGlobalAtomicMaxF32x2(EmitContext& ctx); void EmitGlobalAtomicMaxF32x2(EmitContext& ctx);
void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b); void EmitLogicalOr(EmitContext& ctx, ScalarS32 a, ScalarS32 b);
void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b); void EmitLogicalAnd(EmitContext& ctx, ScalarS32 a, ScalarS32 b);
void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b); void EmitLogicalXor(EmitContext& ctx, ScalarS32 a, ScalarS32 b);
void EmitLogicalNot(EmitContext& ctx, std::string_view value); void EmitLogicalNot(EmitContext& ctx, ScalarS32 value);
void EmitConvertS16F16(EmitContext& ctx, std::string_view value); void EmitConvertS16F16(EmitContext& ctx, Register value);
void EmitConvertS16F32(EmitContext& ctx, std::string_view value); void EmitConvertS16F32(EmitContext& ctx, Register value);
void EmitConvertS16F64(EmitContext& ctx, std::string_view value); void EmitConvertS16F64(EmitContext& ctx, Register value);
void EmitConvertS32F16(EmitContext& ctx, std::string_view value); void EmitConvertS32F16(EmitContext& ctx, Register value);
void EmitConvertS32F32(EmitContext& ctx, std::string_view value); void EmitConvertS32F32(EmitContext& ctx, Register value);
void EmitConvertS32F64(EmitContext& ctx, std::string_view value); void EmitConvertS32F64(EmitContext& ctx, Register value);
void EmitConvertS64F16(EmitContext& ctx, std::string_view value); void EmitConvertS64F16(EmitContext& ctx, Register value);
void EmitConvertS64F32(EmitContext& ctx, std::string_view value); void EmitConvertS64F32(EmitContext& ctx, Register value);
void EmitConvertS64F64(EmitContext& ctx, std::string_view value); void EmitConvertS64F64(EmitContext& ctx, Register value);
void EmitConvertU16F16(EmitContext& ctx, std::string_view value); void EmitConvertU16F16(EmitContext& ctx, Register value);
void EmitConvertU16F32(EmitContext& ctx, std::string_view value); void EmitConvertU16F32(EmitContext& ctx, Register value);
void EmitConvertU16F64(EmitContext& ctx, std::string_view value); void EmitConvertU16F64(EmitContext& ctx, Register value);
void EmitConvertU32F16(EmitContext& ctx, std::string_view value); void EmitConvertU32F16(EmitContext& ctx, Register value);
void EmitConvertU32F32(EmitContext& ctx, std::string_view value); void EmitConvertU32F32(EmitContext& ctx, Register value);
void EmitConvertU32F64(EmitContext& ctx, std::string_view value); void EmitConvertU32F64(EmitContext& ctx, Register value);
void EmitConvertU64F16(EmitContext& ctx, std::string_view value); void EmitConvertU64F16(EmitContext& ctx, Register value);
void EmitConvertU64F32(EmitContext& ctx, std::string_view value); void EmitConvertU64F32(EmitContext& ctx, Register value);
void EmitConvertU64F64(EmitContext& ctx, std::string_view value); void EmitConvertU64F64(EmitContext& ctx, Register value);
void EmitConvertU64U32(EmitContext& ctx, std::string_view value); void EmitConvertU64U32(EmitContext& ctx, Register value);
void EmitConvertU32U64(EmitContext& ctx, std::string_view value); void EmitConvertU32U64(EmitContext& ctx, Register value);
void EmitConvertF16F32(EmitContext& ctx, std::string_view value); void EmitConvertF16F32(EmitContext& ctx, Register value);
void EmitConvertF32F16(EmitContext& ctx, std::string_view value); void EmitConvertF32F16(EmitContext& ctx, Register value);
void EmitConvertF32F64(EmitContext& ctx, std::string_view value); void EmitConvertF32F64(EmitContext& ctx, Register value);
void EmitConvertF64F32(EmitContext& ctx, std::string_view value); void EmitConvertF64F32(EmitContext& ctx, Register value);
void EmitConvertF16S8(EmitContext& ctx, std::string_view value); void EmitConvertF16S8(EmitContext& ctx, Register value);
void EmitConvertF16S16(EmitContext& ctx, std::string_view value); void EmitConvertF16S16(EmitContext& ctx, Register value);
void EmitConvertF16S32(EmitContext& ctx, std::string_view value); void EmitConvertF16S32(EmitContext& ctx, Register value);
void EmitConvertF16S64(EmitContext& ctx, std::string_view value); void EmitConvertF16S64(EmitContext& ctx, Register value);
void EmitConvertF16U8(EmitContext& ctx, std::string_view value); void EmitConvertF16U8(EmitContext& ctx, Register value);
void EmitConvertF16U16(EmitContext& ctx, std::string_view value); void EmitConvertF16U16(EmitContext& ctx, Register value);
void EmitConvertF16U32(EmitContext& ctx, std::string_view value); void EmitConvertF16U32(EmitContext& ctx, Register value);
void EmitConvertF16U64(EmitContext& ctx, std::string_view value); void EmitConvertF16U64(EmitContext& ctx, Register value);
void EmitConvertF32S8(EmitContext& ctx, std::string_view value); void EmitConvertF32S8(EmitContext& ctx, Register value);
void EmitConvertF32S16(EmitContext& ctx, std::string_view value); void EmitConvertF32S16(EmitContext& ctx, Register value);
void EmitConvertF32S32(EmitContext& ctx, std::string_view value); void EmitConvertF32S32(EmitContext& ctx, Register value);
void EmitConvertF32S64(EmitContext& ctx, std::string_view value); void EmitConvertF32S64(EmitContext& ctx, Register value);
void EmitConvertF32U8(EmitContext& ctx, std::string_view value); void EmitConvertF32U8(EmitContext& ctx, Register value);
void EmitConvertF32U16(EmitContext& ctx, std::string_view value); void EmitConvertF32U16(EmitContext& ctx, Register value);
void EmitConvertF32U32(EmitContext& ctx, std::string_view value); void EmitConvertF32U32(EmitContext& ctx, Register value);
void EmitConvertF32U64(EmitContext& ctx, std::string_view value); void EmitConvertF32U64(EmitContext& ctx, Register value);
void EmitConvertF64S8(EmitContext& ctx, std::string_view value); void EmitConvertF64S8(EmitContext& ctx, Register value);
void EmitConvertF64S16(EmitContext& ctx, std::string_view value); void EmitConvertF64S16(EmitContext& ctx, Register value);
void EmitConvertF64S32(EmitContext& ctx, std::string_view value); void EmitConvertF64S32(EmitContext& ctx, Register value);
void EmitConvertF64S64(EmitContext& ctx, std::string_view value); void EmitConvertF64S64(EmitContext& ctx, Register value);
void EmitConvertF64U8(EmitContext& ctx, std::string_view value); void EmitConvertF64U8(EmitContext& ctx, Register value);
void EmitConvertF64U16(EmitContext& ctx, std::string_view value); void EmitConvertF64U16(EmitContext& ctx, Register value);
void EmitConvertF64U32(EmitContext& ctx, std::string_view value); void EmitConvertF64U32(EmitContext& ctx, Register value);
void EmitConvertF64U64(EmitContext& ctx, std::string_view value); void EmitConvertF64U64(EmitContext& ctx, Register value);
void EmitBindlessImageSampleImplicitLod(EmitContext&); void EmitBindlessImageSampleImplicitLod(EmitContext&);
void EmitBindlessImageSampleExplicitLod(EmitContext&); void EmitBindlessImageSampleExplicitLod(EmitContext&);
void EmitBindlessImageSampleDrefImplicitLod(EmitContext&); void EmitBindlessImageSampleDrefImplicitLod(EmitContext&);
@ -566,36 +507,29 @@ void EmitBoundImageGradient(EmitContext&);
void EmitBoundImageRead(EmitContext&); void EmitBoundImageRead(EmitContext&);
void EmitBoundImageWrite(EmitContext&); void EmitBoundImageWrite(EmitContext&);
void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view bias_lc, Register coords, Register bias_lc, const IR::Value& offset);
const IR::Value& offset);
void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view lod_lc, Register coords, Register lod_lc, const IR::Value& offset);
const IR::Value& offset);
void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view dref, Register coords, Register dref, Register bias_lc,
std::string_view bias_lc, const IR::Value& offset); const IR::Value& offset);
void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view dref, Register coords, Register dref, Register lod_lc,
std::string_view lod_lc, const IR::Value& offset); const IR::Value& offset);
void EmitImageGather(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageGather(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, const IR::Value& offset, const IR::Value& offset2); const IR::Value& offset, const IR::Value& offset2);
void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, const IR::Value& offset, const IR::Value& offset2, const IR::Value& offset, const IR::Value& offset2, Register dref);
std::string_view dref); void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register offset, Register lod, Register ms);
std::string_view coords, std::string_view offset, std::string_view lod,
std::string_view ms);
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view lod); Register lod);
void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords);
std::string_view coords); void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register derivates, Register offset, Register lod_clamp);
std::string_view coords, std::string_view derivates, std::string_view offset, void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords);
std::string_view lod_clamp); void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register color);
std::string_view coords);
void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view color);
void EmitBindlessImageAtomicIAdd32(EmitContext&); void EmitBindlessImageAtomicIAdd32(EmitContext&);
void EmitBindlessImageAtomicSMin32(EmitContext&); void EmitBindlessImageAtomicSMin32(EmitContext&);
void EmitBindlessImageAtomicUMin32(EmitContext&); void EmitBindlessImageAtomicUMin32(EmitContext&);
@ -619,53 +553,49 @@ void EmitBoundImageAtomicOr32(EmitContext&);
void EmitBoundImageAtomicXor32(EmitContext&); void EmitBoundImageAtomicXor32(EmitContext&);
void EmitBoundImageAtomicExchange32(EmitContext&); void EmitBoundImageAtomicExchange32(EmitContext&);
void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarU32 value);
void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarS32 value);
void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarU32 value);
void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarS32 value);
void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarU32 value);
void EmitImageAtomicInc32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicInc32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, std::string_view value); ScalarU32 value);
void EmitImageAtomicDec32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicDec32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, std::string_view value); ScalarU32 value);
void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, std::string_view value); ScalarU32 value);
void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, std::string_view value); ScalarU32 value);
void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coords,
std::string_view coords, std::string_view value); ScalarU32 value);
void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view value); Register coords, ScalarU32 value);
void EmitLaneId(EmitContext& ctx); void EmitLaneId(EmitContext& ctx);
void EmitVoteAll(EmitContext& ctx, std::string_view pred); void EmitVoteAll(EmitContext& ctx, ScalarS32 pred);
void EmitVoteAny(EmitContext& ctx, std::string_view pred); void EmitVoteAny(EmitContext& ctx, ScalarS32 pred);
void EmitVoteEqual(EmitContext& ctx, std::string_view pred); void EmitVoteEqual(EmitContext& ctx, ScalarS32 pred);
void EmitSubgroupBallot(EmitContext& ctx, std::string_view pred); void EmitSubgroupBallot(EmitContext& ctx, ScalarS32 pred);
void EmitSubgroupEqMask(EmitContext& ctx); void EmitSubgroupEqMask(EmitContext& ctx);
void EmitSubgroupLtMask(EmitContext& ctx); void EmitSubgroupLtMask(EmitContext& ctx);
void EmitSubgroupLeMask(EmitContext& ctx); void EmitSubgroupLeMask(EmitContext& ctx);
void EmitSubgroupGtMask(EmitContext& ctx); void EmitSubgroupGtMask(EmitContext& ctx);
void EmitSubgroupGeMask(EmitContext& ctx); void EmitSubgroupGeMask(EmitContext& ctx);
void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value, void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index,
std::string_view index, std::string_view clamp, ScalarU32 clamp, ScalarU32 segmentation_mask);
std::string_view segmentation_mask); void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index,
void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index, ScalarU32 clamp, ScalarU32 segmentation_mask);
std::string_view clamp, std::string_view segmentation_mask); void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index,
void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value, ScalarU32 clamp, ScalarU32 segmentation_mask);
std::string_view index, std::string_view clamp, void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index,
std::string_view segmentation_mask); ScalarU32 clamp, ScalarU32 segmentation_mask);
void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value, void EmitFSwizzleAdd(EmitContext& ctx, ScalarF32 op_a, ScalarF32 op_b, ScalarU32 swizzle);
std::string_view index, std::string_view clamp, void EmitDPdxFine(EmitContext& ctx, ScalarF32 op_a);
std::string_view segmentation_mask); void EmitDPdyFine(EmitContext& ctx, ScalarF32 op_a);
void EmitFSwizzleAdd(EmitContext& ctx, std::string_view op_a, std::string_view op_b, void EmitDPdxCoarse(EmitContext& ctx, ScalarF32 op_a);
std::string_view swizzle); void EmitDPdyCoarse(EmitContext& ctx, ScalarF32 op_a);
void EmitDPdxFine(EmitContext& ctx, std::string_view op_a);
void EmitDPdyFine(EmitContext& ctx, std::string_view op_a);
void EmitDPdxCoarse(EmitContext& ctx, std::string_view op_a);
void EmitDPdyCoarse(EmitContext& ctx, std::string_view op_a);
} // namespace Shader::Backend::GLASM } // namespace Shader::Backend::GLASM

View File

@ -2,239 +2,209 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <string_view>
#include "shader_recompiler/backend/glasm/emit_context.h" #include "shader_recompiler/backend/glasm/emit_context.h"
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
#include "shader_recompiler/frontend/ir/value.h" #include "shader_recompiler/frontend/ir/value.h"
namespace Shader::Backend::GLASM { namespace Shader::Backend::GLASM {
void EmitIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { ctx.Add("ADD.S {}.x,{},{};", inst, a, b);
ctx.Add("ADD.U {},{},{};", inst, a, b);
} }
void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitISub32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { ctx.Add("SUB.S {}.x,{},{};", inst, a, b);
ctx.Add("SUB.U {},{},{};", inst, a, b);
} }
void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] Register b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitIMul32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { ctx.Add("MUL.S {}.x,{},{};", inst, a, b);
}
void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift) {
[[maybe_unused]] std::string_view value) { ctx.Add("SHL.U {}.x,{},{};", inst, base, shift);
}
void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
[[maybe_unused]] Register shift) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftLeftLogical32([[maybe_unused]] EmitContext& ctx, void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 base,
[[maybe_unused]] std::string_view base, [[maybe_unused]] ScalarU32 shift) {
[[maybe_unused]] std::string_view shift) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
[[maybe_unused]] std::string_view base, [[maybe_unused]] Register shift) {
[[maybe_unused]] std::string_view shift) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base,
[[maybe_unused]] std::string_view base, [[maybe_unused]] ScalarS32 shift) {
[[maybe_unused]] std::string_view shift) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
[[maybe_unused]] std::string_view base, [[maybe_unused]] Register shift) {
[[maybe_unused]] std::string_view shift) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] std::string_view base, ctx.Add("AND.S {}.x,{},{};", inst, a, b);
[[maybe_unused]] std::string_view shift) { }
void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
ctx.Add("OR.S {}.x,{},{};", inst, a, b);
}
void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
ctx.Add("XOR.S {}.x,{},{};", inst, a, b);
}
void EmitBitFieldInsert([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base,
[[maybe_unused]] ScalarS32 insert, [[maybe_unused]] ScalarS32 offset,
[[maybe_unused]] ScalarS32 count) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, void EmitBitFieldSExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view base, [[maybe_unused]] ScalarS32 base, [[maybe_unused]] ScalarS32 offset,
[[maybe_unused]] std::string_view shift) { [[maybe_unused]] ScalarS32 count) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitBitwiseAnd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitBitFieldUExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] ScalarU32 base, [[maybe_unused]] ScalarU32 offset,
ctx.Add("AND {},{},{};", inst, a, b); [[maybe_unused]] ScalarU32 count) {
}
void EmitBitwiseOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
ctx.Add("OR {},{},{};", inst, a, b);
}
void EmitBitwiseXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
ctx.Add("XOR {},{},{};", inst, a, b);
}
void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
std::string_view insert, std::string_view offset, std::string_view count) {
ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
ctx.Add("BFI.U {},RC,{},{};", inst, insert, base);
}
void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
std::string_view offset, std::string_view count) {
ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
ctx.Add("BFE.S {},RC,{};", inst, base);
}
void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
std::string_view offset, std::string_view count) {
ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
ctx.Add("BFE.U {},RC,{};", inst, base);
}
void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
ctx.Add("BFR {},{};", inst, value);
}
void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
[[maybe_unused]] std::string_view value) {
ctx.Add("NOT {},{};", inst, value);
}
void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 value) {
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { [[maybe_unused]] ScalarS32 b) {
throw NotImplementedException("GLASM instruction");
}
void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a,
[[maybe_unused]] ScalarU32 b) {
throw NotImplementedException("GLASM instruction");
}
void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a,
[[maybe_unused]] ScalarS32 b) {
throw NotImplementedException("GLASM instruction");
}
void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a,
[[maybe_unused]] ScalarU32 b) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value, [[maybe_unused]] std::string_view min, [[maybe_unused]] ScalarS32 value, [[maybe_unused]] ScalarS32 min,
[[maybe_unused]] std::string_view max) { [[maybe_unused]] ScalarS32 max) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value, [[maybe_unused]] std::string_view min, [[maybe_unused]] ScalarU32 value, [[maybe_unused]] ScalarU32 min,
[[maybe_unused]] std::string_view max) { [[maybe_unused]] ScalarU32 max) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarS32 rhs) {
ctx.Add("SLT.S {},{},{};", inst, lhs, rhs); throw NotImplementedException("GLASM instruction");
} }
void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarU32 rhs) {
ctx.Add("SLT.U {},{},{};", inst, lhs, rhs); throw NotImplementedException("GLASM instruction");
} }
void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarS32 rhs) {
ctx.Add("SEQ {},{},{};", inst, lhs, rhs); throw NotImplementedException("GLASM instruction");
} }
void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarS32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SLE.S {},{},{};", inst, lhs, rhs);
} }
void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarU32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SLE.U {},{},{};", inst, lhs, rhs);
} }
void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarS32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SGT.S {},{},{};", inst, lhs, rhs);
} }
void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarU32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SGT.U {},{},{};", inst, lhs, rhs);
} }
void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { [[maybe_unused]] ScalarS32 rhs) {
ctx.Add("SNE.U {},{},{};", inst, lhs, rhs); throw NotImplementedException("GLASM instruction");
} }
void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarS32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SGE.S {},{},{};", inst, lhs, rhs);
} }
void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
[[maybe_unused]] std::string_view lhs, [[maybe_unused]] ScalarU32 rhs) {
[[maybe_unused]] std::string_view rhs) { throw NotImplementedException("GLASM instruction");
ctx.Add("SGE.U {},{},{};", inst, lhs, rhs);
} }
} // namespace Shader::Backend::GLASM } // namespace Shader::Backend::GLASM

View File

@ -11,7 +11,7 @@
namespace Shader::Backend::GLASM { namespace Shader::Backend::GLASM {
namespace { namespace {
void StorageOp(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void StorageOp(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view then_expr, std::string_view else_expr = {}) { std::string_view then_expr, std::string_view else_expr = {}) {
// Operate on bindless SSBO, call the expression with bounds checking // Operate on bindless SSBO, call the expression with bounds checking
// address = c[binding].xy // address = c[binding].xy
@ -23,20 +23,21 @@ void StorageOp(EmitContext& ctx, const IR::Value& binding, std::string_view offs
"SLT.U.CC RC.x,{},c[{}].z;", // cc = offset < length "SLT.U.CC RC.x,{},c[{}].z;", // cc = offset < length
sb_binding, offset, offset, sb_binding); sb_binding, offset, offset, sb_binding);
if (else_expr.empty()) { if (else_expr.empty()) {
ctx.Add("{}", then_expr); ctx.Add("IF NE.x;{}ENDIF;", then_expr);
} else { } else {
ctx.Add("IF NE.x;{}ELSE;{}ENDIF;", then_expr, else_expr); ctx.Add("IF NE.x;{}ELSE;{}ENDIF;", then_expr, else_expr);
} }
} }
void Store(EmitContext& ctx, const IR::Value& binding, std::string_view offset, template <typename ValueType>
std::string_view value, std::string_view size) { void Store(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset, ValueType value,
std::string_view size) {
StorageOp(ctx, binding, offset, fmt::format("STORE.{} {},LC.x;", size, value)); StorageOp(ctx, binding, offset, fmt::format("STORE.{} {},LC.x;", size, value));
} }
void Load(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, std::string_view offset, void Load(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset,
std::string_view size) { std::string_view size) {
const std::string ret{ctx.reg_alloc.Define(inst)}; const Register ret{ctx.reg_alloc.Define(inst)};
StorageOp(ctx, binding, offset, fmt::format("STORE.{} {},LC.x;", size, ret), StorageOp(ctx, binding, offset, fmt::format("STORE.{} {},LC.x;", size, ret),
fmt::format("MOV.U {},{{0,0,0,0}};", ret)); fmt::format("MOV.U {},{{0,0,0,0}};", ret));
} }
@ -58,18 +59,15 @@ void EmitLoadGlobalS16([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitLoadGlobal32([[maybe_unused]] EmitContext& ctx, void EmitLoadGlobal32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address) {
[[maybe_unused]] std::string_view address) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitLoadGlobal64([[maybe_unused]] EmitContext& ctx, void EmitLoadGlobal64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address) {
[[maybe_unused]] std::string_view address) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitLoadGlobal128([[maybe_unused]] EmitContext& ctx, void EmitLoadGlobal128([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address) {
[[maybe_unused]] std::string_view address) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
@ -89,89 +87,88 @@ void EmitWriteGlobalS16([[maybe_unused]] EmitContext& ctx) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitWriteGlobal32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view address, void EmitWriteGlobal32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address,
[[maybe_unused]] std::string_view value) { [[maybe_unused]] ScalarU32 value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitWriteGlobal64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view address, void EmitWriteGlobal64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address,
[[maybe_unused]] std::string_view value) { [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitWriteGlobal128([[maybe_unused]] EmitContext& ctx, void EmitWriteGlobal128([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register address,
[[maybe_unused]] std::string_view address, [[maybe_unused]] Register value) {
[[maybe_unused]] std::string_view value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "U8"); Load(ctx, inst, binding, offset, "U8");
} }
void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "S8"); Load(ctx, inst, binding, offset, "S8");
} }
void EmitLoadStorageU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "U16"); Load(ctx, inst, binding, offset, "U16");
} }
void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "S16"); Load(ctx, inst, binding, offset, "S16");
} }
void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "U32"); Load(ctx, inst, binding, offset, "U32");
} }
void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "U32X2"); Load(ctx, inst, binding, offset, "U32X2");
} }
void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
std::string_view offset) { ScalarU32 offset) {
Load(ctx, inst, binding, offset, "U32X4"); Load(ctx, inst, binding, offset, "U32X4");
} }
void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { ScalarU32 value) {
Store(ctx, binding, offset, value, "U8"); Store(ctx, binding, offset, value, "U8");
} }
void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { ScalarS32 value) {
Store(ctx, binding, offset, value, "S8"); Store(ctx, binding, offset, value, "S8");
} }
void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { ScalarU32 value) {
Store(ctx, binding, offset, value, "U16"); Store(ctx, binding, offset, value, "U16");
} }
void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { ScalarS32 value) {
Store(ctx, binding, offset, value, "S16"); Store(ctx, binding, offset, value, "S16");
} }
void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { ScalarU32 value) {
Store(ctx, binding, offset, value, "U32"); Store(ctx, binding, offset, value, "U32");
} }
void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { Register value) {
Store(ctx, binding, offset, value, "U32X2"); Store(ctx, binding, offset, value, "U32X2");
} }
void EmitWriteStorage128(EmitContext& ctx, const IR::Value& binding, std::string_view offset, void EmitWriteStorage128(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset,
std::string_view value) { Register value) {
Store(ctx, binding, offset, value, "U32X4"); Store(ctx, binding, offset, value, "U32X4");
} }

View File

@ -1,46 +0,0 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <string_view>
#include "shader_recompiler/backend/glasm/emit_context.h"
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
#include "shader_recompiler/frontend/ir/value.h"
namespace Shader::Backend::GLASM {
void EmitSelectU1(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
void EmitSelectU8(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
void EmitSelectU16(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
void EmitSelectU32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
std::string_view true_value, std::string_view false_value) {
ctx.Add("CMP.S {},{},{},{};", inst, cond, true_value, false_value);
}
void EmitSelectU64(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
void EmitSelectF16(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
void EmitSelectF32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
std::string_view true_value, std::string_view false_value) {
ctx.Add("CMP.S {},{},{},{};", inst, cond, true_value, false_value);
}
void EmitSelectF64(EmitContext&, std::string_view, std::string_view, std::string_view) {
throw NotImplementedException("GLASM instruction");
}
} // namespace Shader::Backend::GLASM

View File

@ -12,53 +12,61 @@
#include "shader_recompiler/frontend/ir/value.h" #include "shader_recompiler/frontend/ir/value.h"
namespace Shader::Backend::GLASM { namespace Shader::Backend::GLASM {
namespace {
std::string Representation(Id id) { Register RegAlloc::Define(IR::Inst& inst) {
if (id.is_condition_code != 0) { const Id id{Alloc()};
throw NotImplementedException("Condition code"); inst.SetDefinition<Id>(id);
} Register ret;
if (id.is_spill != 0) { ret.type = Type::Register;
throw NotImplementedException("Spilling"); ret.id = id;
} return ret;
const u32 index{static_cast<u32>(id.index)};
return fmt::format("R{}.x", index);
} }
std::string ImmValue(const IR::Value& value) { Value RegAlloc::Consume(const IR::Value& value) {
if (!value.IsImmediate()) {
return Consume(*value.InstRecursive());
}
Value ret;
switch (value.Type()) { switch (value.Type()) {
case IR::Type::U1: case IR::Type::U1:
return value.U1() ? "-1" : "0"; ret.type = Type::U32;
ret.imm_u32 = value.U1() ? 0xffffffff : 0;
break;
case IR::Type::U32: case IR::Type::U32:
return fmt::format("{}", value.U32()); ret.type = Type::U32;
ret.imm_u32 = value.U32();
break;
case IR::Type::F32: case IR::Type::F32:
return fmt::format("{}", value.F32()); ret.type = Type::F32;
ret.imm_f32 = value.F32();
break;
default: default:
throw NotImplementedException("Immediate type {}", value.Type()); throw NotImplementedException("Immediate type {}", value.Type());
} }
} return ret;
} // Anonymous namespace
std::string RegAlloc::Define(IR::Inst& inst) {
const Id id{Alloc()};
inst.SetDefinition<Id>(id);
return Representation(id);
} }
std::string RegAlloc::Consume(const IR::Value& value) { Register RegAlloc::AllocReg() {
if (value.IsImmediate()) { Register ret;
return ImmValue(value); ret.type = Type::Register;
} else { ret.id = Alloc();
return Consume(*value.InstRecursive()); return ret;
}
} }
std::string RegAlloc::Consume(IR::Inst& inst) { void RegAlloc::FreeReg(Register reg) {
Free(reg.id);
}
Value RegAlloc::Consume(IR::Inst& inst) {
const Id id{inst.Definition<Id>()}; const Id id{inst.Definition<Id>()};
inst.DestructiveRemoveUsage(); inst.DestructiveRemoveUsage();
if (!inst.HasUses()) { if (!inst.HasUses()) {
Free(id); Free(id);
} }
return Representation(inst.Definition<Id>()); Value ret;
ret.type = Type::Register;
ret.id = id;
return ret;
} }
Id RegAlloc::Alloc() { Id RegAlloc::Alloc() {

View File

@ -6,8 +6,12 @@
#include <bitset> #include <bitset>
#include <fmt/format.h>
#include "common/bit_cast.h"
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "shader_recompiler/exception.h"
namespace Shader::IR { namespace Shader::IR {
class Inst; class Inst;
@ -18,6 +22,13 @@ namespace Shader::Backend::GLASM {
class EmitContext; class EmitContext;
enum class Type : u32 {
Register,
U32,
S32,
F32,
};
struct Id { struct Id {
union { union {
u32 raw; u32 raw;
@ -25,15 +36,62 @@ struct Id {
BitField<30, 1, u32> is_spill; BitField<30, 1, u32> is_spill;
BitField<31, 1, u32> is_condition_code; BitField<31, 1, u32> is_condition_code;
}; };
bool operator==(Id rhs) const noexcept {
return raw == rhs.raw;
}
bool operator!=(Id rhs) const noexcept {
return !operator==(rhs);
}
}; };
static_assert(sizeof(Id) == sizeof(u32));
struct Value {
Type type;
union {
Id id;
u32 imm_u32;
s32 imm_s32;
f32 imm_f32;
};
bool operator==(const Value& rhs) const noexcept {
if (type != rhs.type) {
return false;
}
switch (type) {
case Type::Register:
return id == rhs.id;
case Type::U32:
return imm_u32 == rhs.imm_u32;
case Type::S32:
return imm_s32 == rhs.imm_s32;
case Type::F32:
return Common::BitCast<u32>(imm_f32) == Common::BitCast<u32>(rhs.imm_f32);
}
return false;
}
bool operator!=(const Value& rhs) const noexcept {
return !operator==(rhs);
}
};
struct Register : Value {};
struct ScalarRegister : Value {};
struct ScalarU32 : Value {};
struct ScalarS32 : Value {};
struct ScalarF32 : Value {};
class RegAlloc { class RegAlloc {
public: public:
RegAlloc(EmitContext& ctx_) : ctx{ctx_} {} RegAlloc(EmitContext& ctx_) : ctx{ctx_} {}
std::string Define(IR::Inst& inst); Register Define(IR::Inst& inst);
std::string Consume(const IR::Value& value); Value Consume(const IR::Value& value);
Register AllocReg();
void FreeReg(Register reg);
[[nodiscard]] size_t NumUsedRegisters() const noexcept { [[nodiscard]] size_t NumUsedRegisters() const noexcept {
return num_used_registers; return num_used_registers;
@ -43,16 +101,132 @@ private:
static constexpr size_t NUM_REGS = 4096; static constexpr size_t NUM_REGS = 4096;
static constexpr size_t NUM_ELEMENTS = 4; static constexpr size_t NUM_ELEMENTS = 4;
EmitContext& ctx; Value Consume(IR::Inst& inst);
std::string Consume(IR::Inst& inst);
Id Alloc(); Id Alloc();
void Free(Id id); void Free(Id id);
EmitContext& ctx;
size_t num_used_registers{}; size_t num_used_registers{};
std::bitset<NUM_REGS> register_use{}; std::bitset<NUM_REGS> register_use{};
}; };
template <bool scalar, typename FormatContext>
auto FormatTo(FormatContext& ctx, Id id) {
if (id.is_condition_code != 0) {
throw NotImplementedException("Condition code emission");
}
if (id.is_spill != 0) {
throw NotImplementedException("Spill emission");
}
if constexpr (scalar) {
return fmt::format_to(ctx.out(), "R{}.x", id.index.Value());
} else {
return fmt::format_to(ctx.out(), "R{}", id.index.Value());
}
}
} // namespace Shader::Backend::GLASM } // namespace Shader::Backend::GLASM
template <>
struct fmt::formatter<Shader::Backend::GLASM::Id> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(Shader::Backend::GLASM::Id id, FormatContext& ctx) {
return FormatTo<true>(ctx, id);
}
};
template <>
struct fmt::formatter<Shader::Backend::GLASM::Register> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const Shader::Backend::GLASM::Register& value, FormatContext& ctx) {
if (value.type != Shader::Backend::GLASM::Type::Register) {
throw Shader::InvalidArgument("Register value type is not register");
}
return FormatTo<false>(ctx, value.id);
}
};
template <>
struct fmt::formatter<Shader::Backend::GLASM::ScalarRegister> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarRegister& value, FormatContext& ctx) {
if (value.type != Shader::Backend::GLASM::Type::Register) {
throw Shader::InvalidArgument("Register value type is not register");
}
return FormatTo<true>(ctx, value.id);
}
};
template <>
struct fmt::formatter<Shader::Backend::GLASM::ScalarU32> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarU32& value, FormatContext& ctx) {
switch (value.type) {
case Shader::Backend::GLASM::Type::Register:
return FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32:
return fmt::format_to(ctx.out(), "{}", value.imm_u32);
case Shader::Backend::GLASM::Type::S32:
return fmt::format_to(ctx.out(), "{}", static_cast<u32>(value.imm_s32));
case Shader::Backend::GLASM::Type::F32:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<u32>(value.imm_f32));
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
}
};
template <>
struct fmt::formatter<Shader::Backend::GLASM::ScalarS32> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarS32& value, FormatContext& ctx) {
switch (value.type) {
case Shader::Backend::GLASM::Type::Register:
return FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32:
return fmt::format_to(ctx.out(), "{}", static_cast<s32>(value.imm_u32));
case Shader::Backend::GLASM::Type::S32:
return fmt::format_to(ctx.out(), "{}", value.imm_s32);
case Shader::Backend::GLASM::Type::F32:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<s32>(value.imm_f32));
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
}
};
template <>
struct fmt::formatter<Shader::Backend::GLASM::ScalarF32> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarF32& value, FormatContext& ctx) {
switch (value.type) {
case Shader::Backend::GLASM::Type::Register:
return FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<u32>(value.imm_u32));
case Shader::Backend::GLASM::Type::S32:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<s32>(value.imm_s32));
case Shader::Backend::GLASM::Type::F32:
return fmt::format_to(ctx.out(), "{}", value.imm_f32);
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
}
};