From 81c59c79125825989bd8d1f8a706681368b1c94d Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 5 Jan 2014 02:24:16 -0800 Subject: [PATCH] Sign extend constant handling. --- src/alloy/hir/value.cc | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/alloy/hir/value.cc b/src/alloy/hir/value.cc index cd8935842..156768903 100644 --- a/src/alloy/hir/value.cc +++ b/src/alloy/hir/value.cc @@ -78,7 +78,42 @@ void Value::ZeroExtend(TypeName target_type) { } void Value::SignExtend(TypeName target_type) { - // TODO(benvanik): big matrix. + switch (type) { + case INT8_TYPE: + type = target_type; + switch (target_type) { + case INT16_TYPE: + constant.i16 = constant.i8; + break; + case INT32_TYPE: + constant.i32 = constant.i8; + break; + case INT64_TYPE: + constant.i64 = constant.i8; + break; + } + return; + case INT16_TYPE: + type = target_type; + switch (target_type) { + case INT32_TYPE: + constant.i32 = constant.i16; + break; + case INT64_TYPE: + constant.i64 = constant.i16; + break; + } + return; + case INT32_TYPE: + type = target_type; + switch (target_type) { + case INT64_TYPE: + constant.i64 = constant.i32; + break; + } + return; + } + // Unsupported types. XEASSERTALWAYS(); }