mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
glasm: Implement GLASM fp16 packing and move bitwise insns
This commit is contained in:
parent
4de65fbff4
commit
9f851e3832
4 changed files with 77 additions and 66 deletions
|
@ -139,18 +139,6 @@ void EmitInst(EmitContext& ctx, IR::Inst* inst) {
|
|||
}
|
||||
throw LogicError("Invalid opcode {}", inst->GetOpcode());
|
||||
}
|
||||
|
||||
void Alias(IR::Inst& inst, const IR::Value& value) {
|
||||
if (value.IsImmediate()) {
|
||||
return;
|
||||
}
|
||||
IR::Inst* const value_inst{value.InstRecursive()};
|
||||
if (inst.GetOpcode() == IR::Opcode::Identity) {
|
||||
value_inst->DestructiveAddUsage(inst.UseCount());
|
||||
value_inst->DestructiveRemoveUsage();
|
||||
}
|
||||
inst.SetDefinition(value_inst->Definition<Id>());
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
|
||||
|
@ -183,32 +171,4 @@ std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
|
|||
return ctx.code;
|
||||
}
|
||||
|
||||
void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
} // namespace Shader::Backend::GLASM
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
// 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 {
|
||||
|
||||
static void Alias(IR::Inst& inst, const IR::Value& value) {
|
||||
if (value.IsImmediate()) {
|
||||
return;
|
||||
}
|
||||
IR::Inst* const value_inst{value.InstRecursive()};
|
||||
if (inst.GetOpcode() == IR::Opcode::Identity) {
|
||||
value_inst->DestructiveAddUsage(inst.UseCount());
|
||||
value_inst->DestructiveRemoveUsage();
|
||||
}
|
||||
inst.SetDefinition(value_inst->Definition<Id>());
|
||||
}
|
||||
|
||||
void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
|
||||
Alias(inst, value);
|
||||
}
|
||||
|
||||
void EmitPackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
|
||||
throw NotImplementedException("GLASM instruction");
|
||||
}
|
||||
|
||||
void EmitUnpackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
|
||||
throw NotImplementedException("GLASM instruction");
|
||||
}
|
||||
|
||||
void EmitPackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
|
||||
throw NotImplementedException("GLASM instruction");
|
||||
}
|
||||
|
||||
void EmitUnpackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
|
||||
throw NotImplementedException("GLASM instruction");
|
||||
}
|
||||
|
||||
void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
|
||||
ctx.Add("PK2H {}.x,{};", inst, value);
|
||||
}
|
||||
|
||||
void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
|
||||
ctx.Add("UP2H {}.xy,{}.x;", inst, value);
|
||||
}
|
||||
|
||||
} // namespace Shader::Backend::GLASM
|
|
@ -200,8 +200,8 @@ void EmitPackUint2x32(EmitContext& ctx, Register value);
|
|||
void EmitUnpackUint2x32(EmitContext& ctx, Register value);
|
||||
void EmitPackFloat2x16(EmitContext& ctx, Register value);
|
||||
void EmitUnpackFloat2x16(EmitContext& ctx, Register value);
|
||||
void EmitPackHalf2x16(EmitContext& ctx, Register value);
|
||||
void EmitUnpackHalf2x16(EmitContext& ctx, Register value);
|
||||
void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value);
|
||||
void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value);
|
||||
void EmitPackDouble2x32(EmitContext& ctx, Register value);
|
||||
void EmitUnpackDouble2x32(EmitContext& ctx, Register value);
|
||||
void EmitGetZeroFromOp(EmitContext& ctx);
|
||||
|
|
|
@ -281,30 +281,6 @@ void EmitSelectF64(EmitContext& ctx, ScalarS32 cond, Register true_value, Regist
|
|||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitPackUint2x32(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitUnpackUint2x32(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitPackFloat2x16(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitUnpackFloat2x16(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitPackHalf2x16(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitUnpackHalf2x16(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
void EmitPackDouble2x32(EmitContext& ctx, Register value) {
|
||||
NotImplemented();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue