From 17d18f715493c44260e5fb42294547501dd48efb Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 1 Dec 2015 20:24:34 -0600 Subject: [PATCH] Implement a few cases for Value::Cast/Convert --- src/xenia/cpu/hir/value.cc | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/xenia/cpu/hir/value.cc b/src/xenia/cpu/hir/value.cc index d8f614a7e..e0be35b58 100644 --- a/src/xenia/cpu/hir/value.cc +++ b/src/xenia/cpu/hir/value.cc @@ -77,8 +77,8 @@ uint64_t Value::AsUint64() { } void Value::Cast(TypeName target_type) { - // TODO(benvanik): big matrix. - assert_always(); + // Only need a type change. + type = target_type; } void Value::ZeroExtend(TypeName target_type) { @@ -199,8 +199,25 @@ void Value::Truncate(TypeName target_type) { } void Value::Convert(TypeName target_type, RoundMode round_mode) { - // TODO(benvanik): big matrix. - assert_always(); + switch (type) { + case FLOAT32_TYPE: + switch (target_type) { + case FLOAT64_TYPE: + type = target_type; + constant.f64 = constant.f32; + return; + } + case FLOAT64_TYPE: + switch (target_type) { + case FLOAT32_TYPE: + type = target_type; + constant.f32 = (float)constant.f64; + return; + } + default: + assert_unhandled_case(target_type); + return; + } } void Value::Round(RoundMode round_mode) {