compiler support for udi including user_index instruction
This commit is contained in:
parent
5d21f7a3d2
commit
8a6e0acedc
12
C/absmi.c
12
C/absmi.c
@ -8422,6 +8422,18 @@ Yap_absmi(int inp)
|
||||
* Indexing in ARG1 *
|
||||
\************************************************************************/
|
||||
|
||||
BOp(user_switch, lp);
|
||||
{
|
||||
yamop *new = Yap_udi_search(PREG->u.lp.p);
|
||||
if (!new) {
|
||||
PREG = PREG->u.lp.l;
|
||||
JMPNext();
|
||||
}
|
||||
PREG = new;
|
||||
JMPNext();
|
||||
}
|
||||
ENDBOp();
|
||||
|
||||
BOp(switch_on_type, llll);
|
||||
BEGD(d0);
|
||||
d0 = CACHED_A1();
|
||||
|
15
C/amasm.c
15
C/amasm.c
@ -530,6 +530,18 @@ a_p0(op_numbers opcode, yamop *code_p, int pass_no, PredEntry *p0)
|
||||
return code_p;
|
||||
}
|
||||
|
||||
inline static yamop *
|
||||
a_lp(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
||||
{
|
||||
if (pass_no) {
|
||||
code_p->opc = emit_op(opcode);
|
||||
code_p->u.lp.p = (PredEntry *)cip->cpc->rnd1;
|
||||
code_p->u.lp.l = (yamop *)cip->cpc->rnd2;
|
||||
}
|
||||
GONEXT(lp);
|
||||
return code_p;
|
||||
}
|
||||
|
||||
inline static yamop *
|
||||
a_ue(op_numbers opcode, op_numbers opcodew, yamop *code_p, int pass_no)
|
||||
{
|
||||
@ -3718,6 +3730,9 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
case jump_nv_op:
|
||||
code_p = a_xigl(_jump_if_nonvar, code_p, pass_no, cip->cpc);
|
||||
break;
|
||||
case user_switch_op:
|
||||
code_p = a_lp(_user_switch, code_p, pass_no, cip);
|
||||
break;
|
||||
case switch_on_type_op:
|
||||
code_p = a_4sw(_switch_on_type, code_p, pass_no, cip);
|
||||
break;
|
||||
|
@ -1181,6 +1181,10 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
|
||||
ipc->u.xll.l1 = release_wcls(ipc->u.xll.l1, ecs);
|
||||
ipc = NEXTOP(ipc,xll);
|
||||
break;
|
||||
/* instructions type p */
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
ipc->u.llll.l1 = release_wcls(ipc->u.llll.l1, ecs);
|
||||
@ -2136,6 +2140,9 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
UNLOCK(p->PELock);
|
||||
return TermNil;
|
||||
}
|
||||
if (pflags & UDIPredFlag) {
|
||||
Yap_new_udi_clause(p, cp, t);
|
||||
}
|
||||
if (!is_dynamic(p)) {
|
||||
if (pflags & LogUpdatePredFlag) {
|
||||
LogUpdClause *clp = ClauseCodeToLogUpdClause(cp);
|
||||
|
@ -656,6 +656,7 @@ static char *opformat[] =
|
||||
"jump_if_nonvar\t\t%g",
|
||||
"cache_arg\t%r",
|
||||
"cache_sub_arg\t%d",
|
||||
"user_index",
|
||||
"switch_on_type\t%h\t%h\t%h\t%h",
|
||||
"switch_on_constant\t%i\n%c",
|
||||
"if_constant\t%i\n%c",
|
||||
|
1
C/grow.c
1
C/grow.c
@ -1059,6 +1059,7 @@ fix_compiler_instructions(PInstr *pcpc)
|
||||
case jump_nv_op:
|
||||
case cache_arg_op:
|
||||
case cache_sub_arg_op:
|
||||
case user_switch_op:
|
||||
case switch_on_type_op:
|
||||
case switch_c_op:
|
||||
case if_c_op:
|
||||
|
21
C/index.c
21
C/index.c
@ -1349,6 +1349,8 @@ has_cut(yamop *pc)
|
||||
pc = NEXTOP(pc,c);
|
||||
break;
|
||||
/* instructions type p */
|
||||
case _user_switch:
|
||||
return FALSE;
|
||||
case _deallocate:
|
||||
case _procceed:
|
||||
pc = NEXTOP(pc,p);
|
||||
@ -3286,6 +3288,10 @@ compile_index(struct intermediates *cint)
|
||||
/* throw away a label */
|
||||
new_label(cint);
|
||||
init_log_upd_clauses(cls,ap);
|
||||
} else if (ap->PredFlags & UDIPredFlag) {
|
||||
UInt lbl = new_label(cint);
|
||||
Yap_emit(user_switch_op, Unsigned(ap), Unsigned(&(ap->cs.p_code.ExpandCode)), cint);
|
||||
return lbl;
|
||||
} else {
|
||||
/* prepare basic data structures */
|
||||
init_clauses(cls,ap);
|
||||
@ -4017,6 +4023,9 @@ expand_index(struct intermediates *cint) {
|
||||
s_reg = NULL;
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
t = Deref(ARG1);
|
||||
@ -5535,6 +5544,9 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
|
||||
ipc = NEXTOP(ipc,l);
|
||||
}
|
||||
break;
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
sp = push_path(sp, &(ipc->u.llll.l4), cls, cint);
|
||||
@ -6078,6 +6090,9 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
|
||||
sp = cross_block(sp, &ipc->u.xll.l1, ap);
|
||||
ipc = ipc->u.xll.l1;
|
||||
break;
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
sp = push_path(sp, &(ipc->u.llll.l4), cls, cint);
|
||||
@ -6812,6 +6827,9 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
}
|
||||
}
|
||||
break;
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
t = Deref(ARG1);
|
||||
@ -7212,6 +7230,9 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
||||
case _jump_if_nonvar:
|
||||
ipc = NEXTOP(ipc,xll);
|
||||
break;
|
||||
case _user_switch:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _switch_on_type:
|
||||
jlbl = &(ipc->u.llll.l4);
|
||||
|
@ -216,6 +216,7 @@
|
||||
OPCODE(try_logical ,OtaLl),
|
||||
OPCODE(retry_logical ,OtaLl),
|
||||
OPCODE(trust_logical ,OtILl),
|
||||
OPCODE(user_switch ,lp),
|
||||
OPCODE(switch_on_type ,llll),
|
||||
OPCODE(switch_list_nl ,ollll),
|
||||
OPCODE(switch_on_arg_type ,xllll),
|
||||
|
@ -438,6 +438,11 @@ typedef struct yami {
|
||||
struct yami *l4;
|
||||
CELL next;
|
||||
} ollll;
|
||||
struct {
|
||||
struct yami *l;
|
||||
struct pred_entry *p;
|
||||
CELL next;
|
||||
} lp;
|
||||
struct {
|
||||
OPCODE opcw;
|
||||
CELL next;
|
||||
|
@ -97,6 +97,7 @@ typedef enum compiler_op {
|
||||
jump_nv_op,
|
||||
cache_arg_op,
|
||||
cache_sub_arg_op,
|
||||
user_switch_op,
|
||||
switch_on_type_op,
|
||||
switch_c_op,
|
||||
if_c_op,
|
||||
|
@ -257,6 +257,12 @@ restore_opcodes(yamop *pc)
|
||||
pc->u.llll.l4 = PtoOpAdjust(pc->u.llll.l4);
|
||||
pc = NEXTOP(pc,llll);
|
||||
break;
|
||||
/* instructions type lp */
|
||||
case _user_switch:
|
||||
pc->u.lp.l = PtoOpAdjust(pc->u.lp.l);
|
||||
pc->u.lp.p = PtoPredAdjust(pc->u.lp.p);
|
||||
pc = NEXTOP(pc,lp);
|
||||
break;
|
||||
/* instructions type o */
|
||||
case _unify_l_list:
|
||||
case _unify_l_list_write:
|
||||
|
@ -197,6 +197,10 @@
|
||||
case _switch_on_type:
|
||||
pc = NEXTOP(pc,llll);
|
||||
break;
|
||||
/* instructions type lp */
|
||||
case _user_switch:
|
||||
pc = NEXTOP(pc,lp);
|
||||
break;
|
||||
/* instructions type o */
|
||||
case _unify_l_list:
|
||||
case _unify_l_list_write:
|
||||
|
@ -223,6 +223,7 @@ PL_SOURCES= \
|
||||
$(srcdir)/pl/statistics.yap \
|
||||
$(srcdir)/pl/strict_iso.yap \
|
||||
$(srcdir)/pl/tabling.yap $(srcdir)/pl/threads.yap \
|
||||
$(srcdir)/pl/udi.yap \
|
||||
$(srcdir)/pl/utils.yap \
|
||||
$(srcdir)/pl/yapor.yap $(srcdir)/pl/yio.yap
|
||||
|
||||
|
Reference in New Issue
Block a user