From 0537e2dfbfab2a7b943aafa280144308964bc619 Mon Sep 17 00:00:00 2001 From: "alexander.nutz" Date: Wed, 5 Jun 2024 08:06:30 +0200 Subject: [PATCH] important --- ir/ir.h | 7 +++++-- ir/transform/single_assign_conditional.c | 2 -- main.c | 14 +++++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ir/ir.h b/ir/ir.h index de6dc64..c426553 100644 --- a/ir/ir.h +++ b/ir/ir.h @@ -426,8 +426,11 @@ struct vx_IrOp_s { #define FOR_PARAMS(op,want,paramn,fn) { \ vx_IrName __names[] = want; \ for (size_t __it = 0; __it < sizeof(__names) / sizeof(vx_IrName); __it ++) { \ - vx_IrValue paramn = *vx_IrOp_param(op, __names[__it]); \ - fn; \ + vx_IrValue *__param = vx_IrOp_param(op, __names[__it]); \ + if (__param) {\ + vx_IrValue paramn = *__param; \ + fn; \ + }\ } \ } diff --git a/ir/transform/single_assign_conditional.c b/ir/transform/single_assign_conditional.c index d9380cc..815ed18 100644 --- a/ir/transform/single_assign_conditional.c +++ b/ir/transform/single_assign_conditional.c @@ -139,8 +139,6 @@ vx_OptIrVar vx_CIrBlock_mksa_states(vx_IrBlock *block) continue; // inside out: - assert(ifOp->params_len >= 2); - assert(ifOp->params_len <= 3); FOR_PARAMS(ifOp, MKARR(VX_IR_NAME_COND_THEN, VX_IR_NAME_COND_ELSE), param, { vx_IrBlock *conditional = param.block; diff --git a/main.c b/main.c index a61cf30..f12498a 100644 --- a/main.c +++ b/main.c @@ -158,9 +158,7 @@ void eq(int a, int b, int c, int d) { return block; } -static int cir_test(void) { - vx_IrBlock *block = build_test_bool(); - +static int cir_test(vx_IrBlock *block) { if (vx_cir_verify(block) != 0) return 1; @@ -223,13 +221,11 @@ int main(void) { ty_bool->base.align = 2; // depends on arch ty_bool->base.size = 1; - printf("C-IR test:\n"); - if (cir_test() != 0) - return 1; + printf("==== BOOL TEST ====\n"); + cir_test(build_test_bool()); - //printf("\nSSA-IR test:\n"); - //if (ir_test() != 0) - // return 1; + printf("==== CMOV TEST ====\n"); + cir_test(build_test_cmov()); return 0; }