Skip to content

Commit

Permalink
added OAsm
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Dec 24, 2023
1 parent 79aa9e5 commit bad09f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
ctx->currentPos = opCount + 1;
jit_buf(ctx);
# ifdef JIT_DEBUG
{
if( opCount == 0 || f->ops[opCount-1].op != OAsm ) {
int uid = opCount + (f->findex<<16);
op32(ctx, PUSH, pconst(&p,uid), UNUSED);
op64(ctx, ADD, PESP, pconst(&p,HL_WSIZE));
Expand Down Expand Up @@ -4329,6 +4329,31 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
}
}
break;
case OAsm:
{
switch( o->p1 ) {
case 0: // byte output
B(o->p2);
break;
case 1: // scratch cpu reg
scratch(REG_AT(o->p2));
break;
case 2: // read vm reg
rb--;
copy(ctx, REG_AT(o->p2), &rb->stack, rb->size);
scratch(REG_AT(o->p2));
break;
case 3: // write vm reg
rb--;
copy(ctx, &rb->stack, REG_AT(o->p2), rb->size);
scratch(rb->current);
break;
default:
ASSERT(o->p1);
break;
}
}
break;
default:
jit_error(hl_op_name(o->op));
break;
Expand Down
1 change: 1 addition & 0 deletions src/opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ OP_BEGIN
OP(ORefOffset,3)
OP(ONop,0)
OP(OPrefetch, 3)
OP(OAsm, 3)
// --
OP(OLast,0)
OP_END
Expand Down

0 comments on commit bad09f5

Please sign in to comment.