diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | ir.c | 40 | ||||
| -rw-r--r-- | ir.h | 8 | ||||
| -rw-r--r-- | lib.c | 2 | ||||
| -rw-r--r-- | lib.h | 1 | ||||
| -rw-r--r-- | optimize.c | 3 |
6 files changed, 55 insertions, 0 deletions
@@ -42,6 +42,7 @@ LIB_OBJS += expand.o LIB_OBJS += expression.o LIB_OBJS += flow.o LIB_OBJS += inline.o +LIB_OBJS += ir.o LIB_OBJS += lib.o LIB_OBJS += linearize.o LIB_OBJS += liveness.o @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT + +#include "ir.h" +#include "linearize.h" +#include <stdlib.h> + + +static int validate_insn(struct instruction *insn) +{ + int err = 0; + + switch (insn->opcode) { + default: + break; + } + + return err; +} + +int ir_validate(struct entrypoint *ep) +{ + struct basic_block *bb; + int err = 0; + + if (!dbg_ir || has_error) + return 0; + + FOR_EACH_PTR(ep->bbs, bb) { + struct instruction *insn; + FOR_EACH_PTR(bb->insns, insn) { + if (!insn->bb) + continue; + err += validate_insn(insn); + } END_FOR_EACH_PTR(insn); + } END_FOR_EACH_PTR(bb); + + if (err) + abort(); + return err; +} @@ -0,0 +1,8 @@ +#ifndef _IR_H +#define _IR_H + +#include "linearize.h" + +int ir_validate(struct entrypoint *ep); + +#endif @@ -286,6 +286,7 @@ int dump_macro_defs = 0; int dbg_compound = 0; int dbg_dead = 0; int dbg_entry = 0; +int dbg_ir = 0; unsigned long fdump_ir; int fmem_report = 0; @@ -762,6 +763,7 @@ static struct flag debugs[] = { { "compound", &dbg_compound}, { "dead", &dbg_dead}, { "entry", &dbg_entry}, + { "ir", &dbg_ir}, }; @@ -175,6 +175,7 @@ extern int dump_macro_defs; extern int dbg_compound; extern int dbg_dead; extern int dbg_entry; +extern int dbg_ir; extern unsigned int fmax_warnings; extern int fmem_report; @@ -11,6 +11,7 @@ #include "liveness.h" #include "flow.h" #include "cse.h" +#include "ir.h" int repeat_phase; @@ -50,12 +51,14 @@ void optimize(struct entrypoint *ep) * branches, kill dead basicblocks etc */ kill_unreachable_bbs(ep); + ir_validate(ep); /* * Turn symbols into pseudos */ if (fpasses & PASS_MEM2REG) simplify_symbol_usage(ep); + ir_validate(ep); if (fdump_ir & PASS_MEM2REG) show_entry(ep); |
