ir_init: Accept flags as an additional arguments

Signed-off-by: Anatol Belski <ab@php.net>
This commit is contained in:
Anatol Belski 2023-03-27 01:09:35 +02:00
parent b701684704
commit d0b4f108ee
5 changed files with 12 additions and 15 deletions

4
ir.c
View File

@ -282,7 +282,7 @@ void ir_truncate(ir_ctx *ctx)
ctx->ir_base = buf + ctx->consts_limit;
}
void ir_init(ir_ctx *ctx, ir_ref consts_limit, ir_ref insns_limit)
void ir_init(ir_ctx *ctx, uint32_t flags, ir_ref consts_limit, ir_ref insns_limit)
{
ir_insn *buf;
@ -294,7 +294,7 @@ void ir_init(ir_ctx *ctx, ir_ref consts_limit, ir_ref insns_limit)
ctx->consts_count = -(IR_TRUE - 1);
ctx->consts_limit = consts_limit;
ctx->fold_cse_limit = IR_UNUSED + 1;
ctx->flags = 0;
ctx->flags = flags;
ctx->binding = NULL;

2
ir.h
View File

@ -557,7 +557,7 @@ struct _ir_ctx {
};
/* Basic IR Construction API (implementation in ir.c) */
void ir_init(ir_ctx *ctx, ir_ref consts_limit, ir_ref insns_limit);
void ir_init(ir_ctx *ctx, uint32_t flags, ir_ref consts_limit, ir_ref insns_limit);
void ir_free(ir_ctx *ctx);
void ir_truncate(ir_ctx *ctx);

View File

@ -658,9 +658,8 @@ restart:
ir_mem_free(_prev);
ir_init(&new_ctx, consts_count, insns_count);
ir_init(&new_ctx, ctx->flags, consts_count, insns_count);
new_ctx.insns_count = insns_count;
new_ctx.flags = ctx->flags;
new_ctx.spill_base = ctx->spill_base;
new_ctx.fixed_stack_red_zone = ctx->fixed_stack_red_zone;
new_ctx.fixed_stack_frame_size = ctx->fixed_stack_frame_size;

View File

@ -381,19 +381,18 @@ int main(int argc, char **argv)
ir_loader_init();
ir_init(&ctx, 256, 1024);
ctx.flags |= IR_FUNCTION;
ctx.flags |= mflags;
uint32_t flags = IR_FUNCTION | mflags;
if (opt_level > 0) {
ctx.flags |= IR_OPT_FOLDING | IR_OPT_CFG | IR_OPT_CODEGEN;
flags |= IR_OPT_FOLDING | IR_OPT_CFG | IR_OPT_CODEGEN;
}
if (emit_c) {
ctx.flags |= IR_GEN_C;
flags |= IR_GEN_C;
}
if (dump_asm || run) {
ctx.flags |= IR_GEN_NATIVE;
flags |= IR_GEN_NATIVE;
}
ir_init(&ctx, flags, 256, 1024);
ctx.fixed_regset = ~debug_regset;
if (!ir_load(&ctx, f)) {

View File

@ -134,12 +134,11 @@ int main(int argc, char **argv)
}
}
ir_init(&ctx, 256, 1024);
ctx.flags |= IR_FUNCTION;
ctx.flags |= mflags;
uint32_t flags = IR_FUNCTION | mflags;
if (opt_level > 0) {
ctx.flags |= IR_OPT_FOLDING | IR_OPT_CFG | IR_OPT_CODEGEN;
flags |= IR_OPT_FOLDING | IR_OPT_CFG | IR_OPT_CODEGEN;
}
ir_init(&ctx, flags, 256, 1024);
ctx.fixed_regset = ~debug_regset;
gen_mandelbrot(&ctx);
// ir_save(&ctx, stderr);