mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 06:20:06 +00:00
glasm: Remove unnecessary value types
This commit is contained in:
parent
379b305b4b
commit
75fd0079db
@ -49,8 +49,7 @@ public:
|
|||||||
inst = ir_value.InstRecursive();
|
inst = ir_value.InstRecursive();
|
||||||
reg = Register{value};
|
reg = Register{value};
|
||||||
} else {
|
} else {
|
||||||
const bool is_long{value.type == Type::F64 || value.type == Type::U64};
|
reg = value.type == Type::U64 ? reg_alloc.AllocLongReg() : reg_alloc.AllocReg();
|
||||||
reg = is_long ? reg_alloc.AllocLongReg() : reg_alloc.AllocReg();
|
|
||||||
}
|
}
|
||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
case Type::Register:
|
case Type::Register:
|
||||||
@ -59,18 +58,9 @@ public:
|
|||||||
case Type::U32:
|
case Type::U32:
|
||||||
ctx.Add("MOV.U {}.x,{};", reg, value.imm_u32);
|
ctx.Add("MOV.U {}.x,{};", reg, value.imm_u32);
|
||||||
break;
|
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:
|
case Type::U64:
|
||||||
ctx.Add("MOV.U64 {}.x,{};", reg, value.imm_u64);
|
ctx.Add("MOV.U64 {}.x,{};", reg, value.imm_u64);
|
||||||
break;
|
break;
|
||||||
case Type::F64:
|
|
||||||
ctx.Add("MOV.F64 {}.x,{};", reg, value.imm_f64);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +78,16 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
|
|||||||
ret.imm_u32 = value.U32();
|
ret.imm_u32 = value.U32();
|
||||||
break;
|
break;
|
||||||
case IR::Type::F32:
|
case IR::Type::F32:
|
||||||
ret.type = Type::F32;
|
ret.type = Type::U32;
|
||||||
ret.imm_f32 = value.F32();
|
ret.imm_u32 = Common::BitCast<u32>(value.F32());
|
||||||
break;
|
break;
|
||||||
case IR::Type::U64:
|
case IR::Type::U64:
|
||||||
ret.type = Type::U64;
|
ret.type = Type::U64;
|
||||||
ret.imm_u64 = value.U64();
|
ret.imm_u64 = value.U64();
|
||||||
break;
|
break;
|
||||||
case IR::Type::F64:
|
case IR::Type::F64:
|
||||||
ret.type = Type::F64;
|
ret.type = Type::U64;
|
||||||
ret.imm_f64 = value.F64();
|
ret.imm_u64 = Common::BitCast<u64>(value.F64());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Immediate type {}", value.Type());
|
throw NotImplementedException("Immediate type {}", value.Type());
|
||||||
|
@ -26,10 +26,7 @@ enum class Type : u32 {
|
|||||||
Void,
|
Void,
|
||||||
Register,
|
Register,
|
||||||
U32,
|
U32,
|
||||||
S32,
|
|
||||||
F32,
|
|
||||||
U64,
|
U64,
|
||||||
F64,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Id {
|
struct Id {
|
||||||
@ -57,10 +54,7 @@ struct Value {
|
|||||||
union {
|
union {
|
||||||
Id id;
|
Id id;
|
||||||
u32 imm_u32;
|
u32 imm_u32;
|
||||||
s32 imm_s32;
|
|
||||||
f32 imm_f32;
|
|
||||||
u64 imm_u64;
|
u64 imm_u64;
|
||||||
f64 imm_f64;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const Value& rhs) const noexcept {
|
bool operator==(const Value& rhs) const noexcept {
|
||||||
@ -74,14 +68,8 @@ struct Value {
|
|||||||
return id == rhs.id;
|
return id == rhs.id;
|
||||||
case Type::U32:
|
case Type::U32:
|
||||||
return imm_u32 == rhs.imm_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:
|
case Type::U64:
|
||||||
return imm_u64 == rhs.imm_u64;
|
return imm_u64 == rhs.imm_u64;
|
||||||
case Type::F64:
|
|
||||||
return Common::BitCast<u64>(imm_f64) == Common::BitCast<u64>(rhs.imm_f64);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -245,12 +233,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarU32> {
|
|||||||
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:
|
||||||
return fmt::format_to(ctx.out(), "{}", value.imm_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::U64:
|
||||||
case Shader::Backend::GLASM::Type::F64:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw Shader::InvalidArgument("Invalid value type {}", value.type);
|
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);
|
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
|
||||||
case Shader::Backend::GLASM::Type::U32:
|
case Shader::Backend::GLASM::Type::U32:
|
||||||
return fmt::format_to(ctx.out(), "{}", static_cast<s32>(value.imm_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::U64:
|
||||||
case Shader::Backend::GLASM::Type::F64:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw Shader::InvalidArgument("Invalid value type {}", value.type);
|
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:
|
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:
|
||||||
return fmt::format_to(ctx.out(), "{}", Common::BitCast<u32>(value.imm_u32));
|
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f32>(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);
|
|
||||||
case Shader::Backend::GLASM::Type::U64:
|
case Shader::Backend::GLASM::Type::U64:
|
||||||
case Shader::Backend::GLASM::Type::F64:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw Shader::InvalidArgument("Invalid value type {}", value.type);
|
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:
|
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:
|
||||||
case Shader::Backend::GLASM::Type::S32:
|
|
||||||
case Shader::Backend::GLASM::Type::F32:
|
|
||||||
break;
|
break;
|
||||||
case Shader::Backend::GLASM::Type::U64:
|
case Shader::Backend::GLASM::Type::U64:
|
||||||
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f64>(value.imm_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);
|
throw Shader::InvalidArgument("Invalid value type {}", value.type);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user