Skip to content

Commit

Permalink
Minor improvements in tree generation
Browse files Browse the repository at this point in the history
Don't store right after a load; skip no_op, phi nodes
  • Loading branch information
bdw committed Jul 6, 2015
1 parent 4a6511f commit 009d9e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/jit/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ MVMJitExprTree * MVM_jit_build_expression_tree(MVMThreadContext *tc, MVMSpeshGra
MVMint32 root;
MVMJitTreeBuilder builder;
MVMJitExprTree *tree = NULL;
MVMSpeshIns *ins = bb->first_ins;
MVMSpeshIns *ins;
MVMuint16 i;
/* Hold the tree */
builder.num = 0;
Expand All @@ -157,11 +157,15 @@ MVMJitExprTree * MVM_jit_build_expression_tree(MVMThreadContext *tc, MVMSpeshGra
which is a): filled with nodes coming from operands and b):
internally linked together (relative to absolute indexes).
NB - templates may insert stores internally as needed. */
while (ins != NULL) {
for (ins = bb->first_ins; ins != NULL; ins = ins->next) {
/* NB - we probably will want to involve the spesh info in
selecting a template. And/or add in c function calls to
them mix.. */
const MVMJitExprTemplate *templ = MVM_jit_get_template_for_opcode(ins->info->opcode);
MVMuint16 opcode = ins->info->opcode;
if (opcode == MVM_SSA_PHI || opcode == MVM_OP_no_op) {
continue;
}
const MVMJitExprTemplate *templ = MVM_jit_get_template_for_opcode(opcode);
if (templ == NULL) {
/* we don't have a template for this yet, so we can't
* convert it to an expression */
Expand All @@ -177,14 +181,13 @@ MVMJitExprTree * MVM_jit_build_expression_tree(MVMThreadContext *tc, MVMSpeshGra
/* Terminal, add it to roots */
builder_add_root(&builder, root);
}
ins = ins->next;
}

/* Reached the end correctly? Build a tree */
if (ins == NULL) {
/* Add stores for final values */
for (i = 0; i < sg->num_locals; i++) {
if (builder.computed[i] >= 0) {
if (builder.computed[i] >= 0 && builder.nodes[builder.computed[i]] != MVM_JIT_LOAD) {
MVMint32 root = MVM_jit_expr_add_storereg(tc, &builder, builder.computed[i], i);
builder_add_root(&builder, root);
}
Expand Down
8 changes: 6 additions & 2 deletions src/jit/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ enum MVMJitExprVtype { /* value type */
_(CARG, 1, 1, VOID), \
/* interpreter special variables */ \
_(TC, 0, 0, REG), \
_(VMNULL, 0, 0, REG), \
_(CU, 0, 0, MEM), \
_(FRAME, 0, 0, MEM), \
_(LOCAL, 0, 0, MEM), \
_(FARGS, 0, 0, MEM),
_(FARGS, 0, 0, MEM), \
_(VMNULL, 0, 0, REG), \
_(SPESHSLOT, 0, 0, MEM) \



enum MVMJitExprOp {
Expand Down
8 changes: 8 additions & 0 deletions src/jit/exprlist
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ add_i: (add $1 $2)
sp_getarg_o: (load (idx (fargs) $1 reg_sz) ptr_sz)
sp_getarg_i: (load (idx (fargs) $1 reg_sz) (&sizeof MVMint64))
null_s: (const 0 ptr_sz)
null: (vmnull)
getlex_no: (let (($str (load (idx (addr (cu) (&offsetof MVMCompUnit body.strings)) ptr_sz) ptr_sz))
($res (call (&funcptr &MVM_frame_find_lexical_by_name)
(arglist 3 (carg (tc) ptr_sz)
(carg $str ptr_sz)
(carg 8 ptr_sz))
reg_val)))
(ifelse (nz $res) (load $res ptr_sz) $res))

0 comments on commit 009d9e5

Please sign in to comment.