glasm: Add Void type to GLASM values

This commit is contained in:
ReinUsesLisp 2021-05-15 18:15:13 -03:00 committed by ameerj
parent 3764750339
commit 31d402ee74
3 changed files with 15 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public:
} }
switch (value.type) { switch (value.type) {
case Type::Register: case Type::Register:
case Type::Void:
break; break;
case Type::U32: case Type::U32:
ctx.Add("MOV.U {}.x,{};", reg, value.imm_u32); ctx.Add("MOV.U {}.x,{};", reg, value.imm_u32);

View File

@ -57,6 +57,9 @@ void RegAlloc::FreeReg(Register reg) {
Value RegAlloc::MakeImm(const IR::Value& value) { Value RegAlloc::MakeImm(const IR::Value& value) {
Value ret; Value ret;
switch (value.Type()) { switch (value.Type()) {
case IR::Type::Void:
ret.type = Type::Void;
break;
case IR::Type::U1: case IR::Type::U1:
ret.type = Type::U32; ret.type = Type::U32;
ret.imm_u32 = value.U1() ? 0xffffffff : 0; ret.imm_u32 = value.U1() ? 0xffffffff : 0;

View File

@ -23,6 +23,7 @@ namespace Shader::Backend::GLASM {
class EmitContext; class EmitContext;
enum class Type : u32 { enum class Type : u32 {
Void,
Register, Register,
U32, U32,
S32, S32,
@ -65,6 +66,8 @@ struct Value {
return false; return false;
} }
switch (type) { switch (type) {
case Type::Void:
return true;
case Type::Register: case Type::Register:
return id == rhs.id; return id == rhs.id;
case Type::U32: case Type::U32:
@ -218,6 +221,8 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarU32> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarU32& value, FormatContext& ctx) { auto format(const Shader::Backend::GLASM::ScalarU32& value, FormatContext& ctx) {
switch (value.type) { switch (value.type) {
case Shader::Backend::GLASM::Type::Void:
break;
case Shader::Backend::GLASM::Type::Register: case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id); return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32: case Shader::Backend::GLASM::Type::U32:
@ -242,6 +247,8 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarS32> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarS32& value, FormatContext& ctx) { auto format(const Shader::Backend::GLASM::ScalarS32& value, FormatContext& ctx) {
switch (value.type) { switch (value.type) {
case Shader::Backend::GLASM::Type::Void:
break;
case Shader::Backend::GLASM::Type::Register: case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id); return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32: case Shader::Backend::GLASM::Type::U32:
@ -266,6 +273,8 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF32> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarF32& value, FormatContext& ctx) { auto format(const Shader::Backend::GLASM::ScalarF32& value, FormatContext& ctx) {
switch (value.type) { switch (value.type) {
case Shader::Backend::GLASM::Type::Void:
break;
case Shader::Backend::GLASM::Type::Register: case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id); return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32: case Shader::Backend::GLASM::Type::U32:
@ -290,6 +299,8 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF64> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Shader::Backend::GLASM::ScalarF64& value, FormatContext& ctx) { auto format(const Shader::Backend::GLASM::ScalarF64& value, FormatContext& ctx) {
switch (value.type) { switch (value.type) {
case Shader::Backend::GLASM::Type::Void:
break;
case Shader::Backend::GLASM::Type::Register: case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id); return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32: case Shader::Backend::GLASM::Type::U32: