Skip to content

Commit

Permalink
JIT compile hllboolfor
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed Aug 17, 2018
1 parent 890c9f4 commit c207d10
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/jit/graph.c
Expand Up @@ -2180,6 +2180,20 @@ static MVMint32 consume_ins(MVMThreadContext *tc, MVMJitGraph *jg,
jg_append_call_c(tc, jg, MVM_hll_map, 4, args, MVM_JIT_RV_VOID, -1);
break;
}
case MVM_OP_hllboolfor: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 src = ins->operands[1].reg.orig;
MVMSpeshFacts *facts = MVM_spesh_get_facts(tc, jg->sg, ins->operands[2]);
if (facts->flags & MVM_SPESH_FACT_KNOWN_VALUE) {
MVMHLLConfig *hll_config = MVM_hll_get_config_for(tc, facts->value.s);
ins->operands[2].lit_i64 = (MVMint64)hll_config;
jg_append_primitive(tc, jg, ins);
} else {
MVM_jit_log(tc, "BAIL: op <%s>", ins->info->name);
return 0;
}
break;
}
case MVM_OP_clone: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 obj = ins->operands[1].reg.orig;
Expand Down
17 changes: 17 additions & 0 deletions src/jit/x64/emit.dasc
Expand Up @@ -2225,6 +2225,23 @@ void MVM_jit_emit_primitive(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJ
if (use_cache) {
|2:
}
break;
}
case MVM_OP_hllboolfor: {
MVMint16 target = ins->operands[0].reg.orig;
MVMint16 value = ins->operands[1].reg.orig;
MVMHLLConfig *hll_config = (MVMHLLConfig*)ins->operands[2].lit_i64;
MVMObject *true_value = hll_config->true_value;
MVMObject *false_value = hll_config->false_value;
| mov TMP1, WORK[value];
| test TMP1, TMP1;
| jnz >1;
| mov TMP1, aword false_value;
| jmp >2;
|1:
| mov TMP1, aword true_value;
|2:
| mov WORK[target], TMP1;
break;
}
default:
Expand Down

0 comments on commit c207d10

Please sign in to comment.