summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-13 16:20:21 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-13 16:20:21 +0800
commitc02f1578fa90028f3c581e261cf64ce5062fe2f4 (patch)
tree61550471982ea985847099eac0aa4b439b4e99f7
parent51973a64fe30d9481eabe9456982ab50542116f0 (diff)
downloadmrust-c02f1578fa90028f3c581e261cf64ce5062fe2f4.tar.gz
MIR Gen Match - Handle signed integers in _Simple
-rw-r--r--src/mir/from_hir_match.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index 35fee5d3..775bc3a3 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -253,6 +253,28 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
)
)
break;
+ case ::HIR::CoreType::I8:
+ case ::HIR::CoreType::I16:
+ case ::HIR::CoreType::I32:
+ case ::HIR::CoreType::I64:
+ case ::HIR::CoreType::Isize:
+ TU_MATCH_DEF( PatternRule, (rule), (re),
+ (
+ BUG(sp, "PatternRule for integer is not Value or ValueRange");
+ ),
+ (Value,
+ auto succ_bb = builder.new_bb_unlinked();
+
+ auto test_lval = builder.lvalue_or_temp(te, ::MIR::Constant(re.as_Int()));
+ auto cmp_lval = builder.lvalue_or_temp(::HIR::CoreType::Bool, ::MIR::RValue::make_BinOp({ match_val.clone(), ::MIR::eBinOp::EQ, mv$(test_lval) }));
+ builder.end_block( ::MIR::Terminator::make_If({ mv$(cmp_lval), succ_bb, fail_bb }) );
+ builder.set_cur_block(succ_bb);
+ ),
+ (ValueRange,
+ TODO(sp, "Simple match over primitive - " << ty << " - ValueRange");
+ )
+ )
+ break;
default:
TODO(sp, "Primitive - " << ty);
break;