diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-08 02:49:34 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-28 11:46:40 +0100 |
commit | d50ca778c27ebf10c75036d54b2954ad8d057083 (patch) | |
tree | 39d6e4c5abb32d5d9d54f494bd5a6a29d8080624 | |
parent | 3a3955b5ecbfb27d341e9e0903dff83cffcb3a4d (diff) | |
download | sparse-d50ca778c27ebf10c75036d54b2954ad8d057083.tar.gz |
memops: move rewrite_load_instruction() here
The function rewrite_load_instruction() is defined in flow.c but:
* is not directly related to 'flow'
* it's only used in memops.c
* needs some change related to simplify_loads().
So, move this code to memops.c
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | flow.c | 41 | ||||
-rw-r--r-- | flow.h | 1 | ||||
-rw-r--r-- | memops.c | 41 |
3 files changed, 41 insertions, 42 deletions
@@ -520,47 +520,6 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom return 1; } -/* - * We should probably sort the phi list just to make it easier to compare - * later for equality. - */ -void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators) -{ - pseudo_t new, phi; - - /* - * Check for somewhat common case of duplicate - * phi nodes. - */ - new = first_pseudo(dominators)->def->phi_src; - FOR_EACH_PTR(dominators, phi) { - if (new != phi->def->phi_src) - goto complex_phi; - new->ident = new->ident ? : phi->ident; - } END_FOR_EACH_PTR(phi); - - /* - * All the same pseudo - mark the phi-nodes unused - * and convert the load into a LNOP and replace the - * pseudo. - */ - convert_load_instruction(insn, new); - FOR_EACH_PTR(dominators, phi) { - kill_instruction(phi->def); - } END_FOR_EACH_PTR(phi); - goto end; - -complex_phi: - /* We leave symbol pseudos with a bogus usage list here */ - if (insn->src->type != PSEUDO_SYM) - kill_use(&insn->src); - insn->opcode = OP_PHI; - insn->phi_list = dominators; - -end: - repeat_phase |= REPEAT_CSE; -} - /* Kill a pseudo that is dead on exit from the bb */ // The context is: // * the variable is not global but may have its address used (local/non-local) @@ -39,7 +39,6 @@ static inline int kill_instruction_force(struct instruction *insn) void check_access(struct instruction *insn); void convert_load_instruction(struct instruction *, pseudo_t); -void rewrite_load_instruction(struct instruction *, struct pseudo_list *); int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local); extern void vrfy_flow(struct entrypoint *ep); @@ -16,6 +16,47 @@ #include "linearize.h" #include "flow.h" +/* + * We should probably sort the phi list just to make it easier to compare + * later for equality. + */ +static void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators) +{ + pseudo_t new, phi; + + /* + * Check for somewhat common case of duplicate + * phi nodes. + */ + new = first_pseudo(dominators)->def->phi_src; + FOR_EACH_PTR(dominators, phi) { + if (new != phi->def->phi_src) + goto complex_phi; + new->ident = new->ident ? : phi->ident; + } END_FOR_EACH_PTR(phi); + + /* + * All the same pseudo - mark the phi-nodes unused + * and convert the load into a LNOP and replace the + * pseudo. + */ + convert_load_instruction(insn, new); + FOR_EACH_PTR(dominators, phi) { + kill_instruction(phi->def); + } END_FOR_EACH_PTR(phi); + goto end; + +complex_phi: + /* We leave symbol pseudos with a bogus usage list here */ + if (insn->src->type != PSEUDO_SYM) + kill_use(&insn->src); + insn->opcode = OP_PHI; + insn->phi_list = dominators; + +end: + repeat_phase |= REPEAT_CSE; +} + static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators, int local) |