Use insn_is_branch() to determine whether we must insert a spill instruction before or after the last instruction in a basic block.
Cc: Arthur HUILLET <arthur.huil...@free.fr> Cc: Tomek Grabiec <tgrab...@gmail.com> Signed-off-by: Pekka Enberg <penb...@cs.helsinki.fi> --- arch/mmix/include/arch/instruction.h | 5 +++++ arch/x86/include/arch/instruction.h | 17 +++++++++++++++++ jit/spill-reload.c | 8 ++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/arch/mmix/include/arch/instruction.h b/arch/mmix/include/arch/instruction.h index 427131a..d12bf83 100644 --- a/arch/mmix/include/arch/instruction.h +++ b/arch/mmix/include/arch/instruction.h @@ -108,6 +108,11 @@ exception_spill_insn(struct stack_slot *slot) return NULL; } +static inline bool insn_is_branch(struct insn *insn) +{ + return insn->type == INSN_JMP; +} + struct insn *alloc_insn(enum insn_type); void free_insn(struct insn *); diff --git a/arch/x86/include/arch/instruction.h b/arch/x86/include/arch/instruction.h index f2f858c..8d875b1 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -308,6 +308,23 @@ static inline struct insn *jump_insn(struct basic_block *bb) return branch_insn(INSN_JMP_BRANCH, bb); } + +static inline bool insn_is_branch(struct insn *insn) +{ + switch (insn->type) { + case INSN_JE_BRANCH: + case INSN_JGE_BRANCH: + case INSN_JG_BRANCH: + case INSN_JLE_BRANCH: + case INSN_JL_BRANCH: + case INSN_JMP_BRANCH: + case INSN_JNE_BRANCH: + return true; + default: + return false; + } +} + struct insn *alloc_insn(enum insn_type); void free_insn(struct insn *); diff --git a/jit/spill-reload.c b/jit/spill-reload.c index 17b5134..bf31288 100644 --- a/jit/spill-reload.c +++ b/jit/spill-reload.c @@ -68,7 +68,7 @@ static struct insn *last_insn(struct compilation_unit *cu, struct live_interval static struct stack_slot * spill_interval(struct live_interval *interval, struct compilation_unit *cu, - struct insn *last, bool tail) + struct insn *last) { struct stack_slot *slot; struct insn *spill; @@ -83,7 +83,7 @@ spill_interval(struct live_interval *interval, spill->bytecode_offset = last->bytecode_offset; - if (tail) + if (insn_is_branch(last)) list_add_tail(&spill->insn_list_node, &last->insn_list_node); else list_add(&spill->insn_list_node, &last->insn_list_node); @@ -94,7 +94,7 @@ spill_interval(struct live_interval *interval, static int insert_spill_insn(struct live_interval *interval, struct compilation_unit *cu) { - interval->spill_slot = spill_interval(interval, cu, last_insn(cu, interval), false); + interval->spill_slot = spill_interval(interval, cu, last_insn(cu, interval)); if (!interval->spill_slot) return warn("out of memory"), -ENOMEM; @@ -193,7 +193,7 @@ static void insert_mov_insns(struct compilation_unit *cu, if (from_it->need_spill && from_it->range.end < from_bb->end_insn) { slots[i] = from_it->spill_slot; } else { - slots[i] = spill_interval(from_it, cu, spill_at_insn, true); + slots[i] = spill_interval(from_it, cu, spill_at_insn); } } -- 1.5.6.3 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel