yuzu-emu
/
yuzu
Archived
1
0
Fork 0

glasm: Remove unnecessary value types

This commit is contained in:
ReinUsesLisp 2021-05-25 02:46:51 -03:00 committed by ameerj
parent 379b305b4b
commit 75fd0079db
3 changed files with 6 additions and 47 deletions

View File

@ -49,8 +49,7 @@ public:
inst = ir_value.InstRecursive();
reg = Register{value};
} else {
const bool is_long{value.type == Type::F64 || value.type == Type::U64};
reg = is_long ? reg_alloc.AllocLongReg() : reg_alloc.AllocReg();
reg = value.type == Type::U64 ? reg_alloc.AllocLongReg() : reg_alloc.AllocReg();
}
switch (value.type) {
case Type::Register:
@ -59,18 +58,9 @@ public:
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;
case Type::U64:
ctx.Add("MOV.U64 {}.x,{};", reg, value.imm_u64);
break;
case Type::F64:
ctx.Add("MOV.F64 {}.x,{};", reg, value.imm_f64);
break;
}
}

View File

@ -78,16 +78,16 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
ret.imm_u32 = value.U32();
break;
case IR::Type::F32:
ret.type = Type::F32;
ret.imm_f32 = value.F32();
ret.type = Type::U32;
ret.imm_u32 = Common::BitCast<u32>(value.F32());
break;
case IR::Type::U64:
ret.type = Type::U64;
ret.imm_u64 = value.U64();
break;
case IR::Type::F64:
ret.type = Type::F64;
ret.imm_f64 = value.F64();
ret.type = Type::U64;
ret.imm_u64 = Common::BitCast<u64>(value.F64());
break;
default:
throw NotImplementedException("Immediate type {}", value.Type());

View File

@ -26,10 +26,7 @@ enum class Type : u32 {
Void,
Register,
U32,
S32,
F32,
U64,
F64,
};
struct Id {
@ -57,10 +54,7 @@ struct Value {
union {
Id id;
u32 imm_u32;
s32 imm_s32;
f32 imm_f32;
u64 imm_u64;
f64 imm_f64;
};
bool operator==(const Value& rhs) const noexcept {
@ -74,14 +68,8 @@ struct Value {
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);
case Type::U64:
return imm_u64 == rhs.imm_u64;
case Type::F64:
return Common::BitCast<u64>(imm_f64) == Common::BitCast<u64>(rhs.imm_f64);
}
return false;
}
@ -245,12 +233,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarU32> {
return Shader::Backend::GLASM::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));
case Shader::Backend::GLASM::Type::U64:
case Shader::Backend::GLASM::Type::F64:
break;
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
@ -271,12 +254,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarS32> {
return Shader::Backend::GLASM::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));
case Shader::Backend::GLASM::Type::U64:
case Shader::Backend::GLASM::Type::F64:
break;
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
@ -296,13 +274,8 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF32> {
case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::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);
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f32>(value.imm_u32));
case Shader::Backend::GLASM::Type::U64:
case Shader::Backend::GLASM::Type::F64:
break;
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
@ -322,13 +295,9 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF64> {
case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32:
case Shader::Backend::GLASM::Type::S32:
case Shader::Backend::GLASM::Type::F32:
break;
case Shader::Backend::GLASM::Type::U64:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f64>(value.imm_u64));
case Shader::Backend::GLASM::Type::F64:
return fmt::format_to(ctx.out(), "{}", value.imm_f64);
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
}