From df2b11a6ecec49632c1864f9ec67380ec7d8b0d6 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 6 Dec 2009 00:37:48 +0000 Subject: [PATCH] define Optype for xxc, for instructions whose constant argument is a term, like functor(a,X,T). --- C/absmi.c | 26 +++++++++++++------------- H/YapOpcodes.h | 2 +- H/amidefs.h | 18 ++++++++++++------ H/findclause.h | 14 +++++++------- H/rclause.h | 8 +++++++- H/walkclause.h | 5 ++++- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index 381a40466..fa99478e4 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -12429,23 +12429,23 @@ Yap_absmi(int inp) ENDD(d0); ENDOp(); - Op(p_func2s_cv, xxn); + Op(p_func2s_cv, xxc); /* A1 is a variable */ restart_func2s_cv: #ifdef LOW_LEVEL_TRACER if (Yap_do_low_level_trace) { RESET_VARIABLE(H); - H[1] = PREG->u.xxn.c; - H[2] = XREG(PREG->u.xxn.xi); + H[1] = PREG->u.xxc.c; + H[2] = XREG(PREG->u.xxc.xi); low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(FunctorFunctor,0)),H); } #endif /* LOW_LEVEL_TRACE */ BEGD(d0); /* We have to build the structure */ - d0 = PREG->u.xxn.c; + d0 = PREG->u.xxc.c; /* we do, let's get the third argument */ BEGD(d1); - d1 = XREG(PREG->u.xxn.xi); + d1 = XREG(PREG->u.xxc.xi); deref_head(d1, func2s_unk2_cv); func2s_nvar2_cv: /* Uuuff, the second and third argument are bound */ @@ -12470,8 +12470,8 @@ Yap_absmi(int inp) H += 2; /* else if arity is 0 just pass d0 through */ /* Ding, ding, we made it */ - XREG(PREG->u.xxn.x) = d0; - PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxn),Osbpp),l); + XREG(PREG->u.xxc.x) = d0; + PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxc),Osbpp),l); GONext(); } else if ((Int)d1 > 0) { /* now let's build a compound term */ @@ -12493,7 +12493,7 @@ Yap_absmi(int inp) if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { /* make sure we have something to show for our trouble */ saveregs(); - if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) { + if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) { Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage); setregs(); JMPNext(); @@ -12511,12 +12511,12 @@ Yap_absmi(int inp) ENDP(pt1); /* else if arity is 0 just pass d0 through */ /* Ding, ding, we made it */ - XREG(PREG->u.xxn.x) = d0; - PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxn),Osbpp),l); + XREG(PREG->u.xxc.x) = d0; + PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxc),Osbpp),l); GONext(); } else if (d1 == 0) { - XREG(PREG->u.xxn.x) = d0; - PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxn),Osbpp),l); + XREG(PREG->u.xxc.x) = d0; + PREG = NEXTOP(NEXTOP(NEXTOP(PREG, xxc),Osbpp),l); GONext(); } else { saveregs(); @@ -12545,7 +12545,7 @@ Yap_absmi(int inp) Term ti; CELL *hi = H; - ti = MkIntegerTerm((Int)(PREG->u.xxn.c)); + ti = MkIntegerTerm(PREG->u.xxn.c); RESET_VARIABLE(H); H[1] = XREG(PREG->u.xxn.xi); H[2] = ti; diff --git a/H/YapOpcodes.h b/H/YapOpcodes.h index 8a7ee84b1..679a381a1 100644 --- a/H/YapOpcodes.h +++ b/H/YapOpcodes.h @@ -306,7 +306,7 @@ OPCODE(p_arg_y_vv ,yxx), OPCODE(p_arg_y_cv ,yxn), OPCODE(p_func2s_vv ,xxx), - OPCODE(p_func2s_cv ,xxn), + OPCODE(p_func2s_cv ,xxc), OPCODE(p_func2s_vc ,xxn), OPCODE(p_func2s_y_vv ,yxx), OPCODE(p_func2s_y_cv ,yxn), diff --git a/H/amidefs.h b/H/amidefs.h index 86fe12441..5e7dc7553 100644 --- a/H/amidefs.h +++ b/H/amidefs.h @@ -698,6 +698,18 @@ typedef struct yami { wamreg xr; CELL next; } xx; + struct { + wamreg x; + wamreg xi; + Term c; + CELL next; + } xxc; + struct { + wamreg x; + wamreg xi; + Int c; + CELL next; + } xxn; struct { wamreg x; wamreg x1; @@ -711,12 +723,6 @@ typedef struct yami { wamreg xr2; CELL next; } xxxx; - struct { - wamreg x; - wamreg xi; - Int c; - CELL next; - } xxn; struct { wamreg x; wamreg x1; diff --git a/H/findclause.h b/H/findclause.h index ba7a4265a..4e0edc486 100644 --- a/H/findclause.h +++ b/H/findclause.h @@ -798,6 +798,13 @@ } cl = NEXTOP(cl,xx); break; + case _p_func2s_cv: + if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxc.x))) { + clause->Tag = (CELL)NULL; + return; + } + cl = NEXTOP(cl,xxc); + break; case _p_and_vc: if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxn.x))) { clause->Tag = (CELL)NULL; @@ -826,13 +833,6 @@ } cl = NEXTOP(cl,xxn); break; - case _p_func2s_cv: - if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxn.x))) { - clause->Tag = (CELL)NULL; - return; - } - cl = NEXTOP(cl,xxn); - break; case _p_func2s_vc: if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxn.x))) { clause->Tag = (CELL)NULL; diff --git a/H/rclause.h b/H/rclause.h index 9e509f3ca..167e27759 100644 --- a/H/rclause.h +++ b/H/rclause.h @@ -595,12 +595,18 @@ restore_opcodes(yamop *pc, yamop *max) pc->u.xx.xr = XAdjust(pc->u.xx.xr); pc = NEXTOP(pc,xx); break; + /* instructions type xxc */ + case _p_func2s_cv: + pc->u.xxc.x = XAdjust(pc->u.xxc.x); + pc->u.xxc.xi = XAdjust(pc->u.xxc.xi); + pc->u.xxc.c = ConstantTermAdjust(pc->u.xxc.c); + pc = NEXTOP(pc,xxc); + break; /* instructions type xxn */ case _p_and_vc: case _p_arg_cv: case _p_div_cv: case _p_div_vc: - case _p_func2s_cv: case _p_func2s_vc: case _p_minus_cv: case _p_or_vc: diff --git a/H/walkclause.h b/H/walkclause.h index 34ac60cfd..8138ba865 100644 --- a/H/walkclause.h +++ b/H/walkclause.h @@ -454,12 +454,15 @@ case _put_x_var: pc = NEXTOP(pc,xx); break; + /* instructions type xxc */ + case _p_func2s_cv: + pc = NEXTOP(pc,xxc); + break; /* instructions type xxn */ case _p_and_vc: case _p_arg_cv: case _p_div_cv: case _p_div_vc: - case _p_func2s_cv: case _p_func2s_vc: case _p_minus_cv: case _p_or_vc: