X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firprog.c;h=9aa961267e1c229a4f727374622f7d349ad62620;hb=1852308bd33b77378f0fca9e5347d4f9082464c4;hp=b0a118d0f0ffb69fbf6e265bdf4bb3ddbd38c6f8;hpb=af9b9a12e6cd2aaf7a0d71c262f068a516a8735f;p=libfirm diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index b0a118d0f..9aa961267 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -30,6 +30,7 @@ #include "irprog_t.h" #include "irgraph_t.h" +#include "irpass_t.h" #include "pseudo_irg.h" #include "array.h" #include "error.h" @@ -322,7 +323,7 @@ void add_irp_opcode(ir_op *opcode) { assert(irp); len = ARR_LEN(irp->opcodes); code = opcode->code; - if (code >= len) { + if ((int) code >= len) { ARR_RESIZE(ir_op*, irp->opcodes, code+1); memset(&irp->opcodes[len], 0, (code-len+1) * sizeof(irp->opcodes[0])); } @@ -333,7 +334,7 @@ void add_irp_opcode(ir_op *opcode) { /* Removes opcode from the list of opcodes and shrinks the list by one. */ void remove_irp_opcode(ir_op *opcode) { - assert(opcode->code < ARR_LEN(irp->opcodes)); + assert((int) opcode->code < ARR_LEN(irp->opcodes)); irp->opcodes[opcode->code] = NULL; } @@ -384,6 +385,45 @@ void set_irp_phase_state(irg_phase_state s) { irp->phase_state = s; } +struct pass_t { + ir_prog_pass_t pass; + irg_phase_state state; +}; + +/** + * Wrapper for setting the state of a whole ir_prog. + */ +static int set_irp_phase_state_wrapper(ir_prog *irp, void *context) { + struct pass_t *pass = context; + irg_phase_state state = pass->state; + int i; + + (void)irp; + + /* set the phase of all graphs */ + for (i = get_irp_n_irgs() - 1; i >= 0; --i) + set_irg_phase_state(get_irp_irg(i), state); + + /* set the irp phase */ + set_irp_phase_state(state); + + return 0; +} + +ir_prog_pass_t *set_irp_phase_state_pass(const char *name, irg_phase_state state) { + struct pass_t *pass = XMALLOCZ(struct pass_t); + + def_prog_pass_constructor( + &pass->pass, name ? name : "set_irp_phase", set_irp_phase_state_wrapper); + pass->state = state; + + /* no dump/verify */ + pass->pass.verify_irprog = ir_prog_no_verify; + pass->pass.dump_irprog = ir_prog_no_dump; + + return &pass->pass; +} + irg_outs_state get_irp_ip_outs_state(void) { return irp->outs_state; }