nac3core: fix broken tests
This commit is contained in:
parent
393f01c08c
commit
b7e694d09c
|
@ -1240,17 +1240,23 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
|
||||||
let cont_bb = ctx.ctx.append_basic_block(current, "cont");
|
let cont_bb = ctx.ctx.append_basic_block(current, "cont");
|
||||||
ctx.builder.build_conditional_branch(test, then_bb, else_bb);
|
ctx.builder.build_conditional_branch(test, then_bb, else_bb);
|
||||||
ctx.builder.position_at_end(then_bb);
|
ctx.builder.position_at_end(then_bb);
|
||||||
let a = generator.gen_expr(ctx, body)?.unwrap().to_basic_value_enum(ctx, generator)?;
|
let a = generator.gen_expr(ctx, body)?;
|
||||||
match result {
|
match result {
|
||||||
None => None,
|
None => None,
|
||||||
Some(v) => Some(ctx.builder.build_store(v, a))
|
Some(v) => {
|
||||||
|
let a = a.unwrap().to_basic_value_enum(ctx, generator)?;
|
||||||
|
Some(ctx.builder.build_store(v, a))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ctx.builder.build_unconditional_branch(cont_bb);
|
ctx.builder.build_unconditional_branch(cont_bb);
|
||||||
ctx.builder.position_at_end(else_bb);
|
ctx.builder.position_at_end(else_bb);
|
||||||
let b = generator.gen_expr(ctx, orelse)?.unwrap().to_basic_value_enum(ctx, generator)?;
|
let b = generator.gen_expr(ctx, orelse)?;
|
||||||
match result {
|
match result {
|
||||||
None => None,
|
None => None,
|
||||||
Some(v) => Some(ctx.builder.build_store(v, b))
|
Some(v) => {
|
||||||
|
let b = b.unwrap().to_basic_value_enum(ctx, generator)?;
|
||||||
|
Some(ctx.builder.build_store(v, b))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ctx.builder.build_unconditional_branch(cont_bb);
|
ctx.builder.build_unconditional_branch(cont_bb);
|
||||||
ctx.builder.position_at_end(cont_bb);
|
ctx.builder.position_at_end(cont_bb);
|
||||||
|
|
|
@ -180,13 +180,22 @@ fn test_primitives() {
|
||||||
let expected = indoc! {"
|
let expected = indoc! {"
|
||||||
; ModuleID = 'test'
|
; ModuleID = 'test'
|
||||||
source_filename = \"test\"
|
source_filename = \"test\"
|
||||||
|
|
||||||
define i32 @testing(i32 %0, i32 %1) {
|
define i32 @testing(i32 %0, i32 %1) {
|
||||||
init:
|
init:
|
||||||
%add = add i32 %0, %1
|
%add = add i32 %0, %1
|
||||||
%cmp = icmp eq i32 %add, 1
|
%cmp = icmp eq i32 %add, 1
|
||||||
%ifexpr = select i1 %cmp, i32 %0, i32 0
|
br i1 %cmp, label %then, label %else
|
||||||
ret i32 %ifexpr
|
|
||||||
|
then: ; preds = %init
|
||||||
|
br label %cont
|
||||||
|
|
||||||
|
else: ; preds = %init
|
||||||
|
br label %cont
|
||||||
|
|
||||||
|
cont: ; preds = %else, %then
|
||||||
|
%if_exp_result.0 = phi i32 [ %0, %then ], [ 0, %else ]
|
||||||
|
ret i32 %if_exp_result.0
|
||||||
}
|
}
|
||||||
"}
|
"}
|
||||||
.trim();
|
.trim();
|
||||||
|
|
Loading…
Reference in New Issue