2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
2004-03-10 14:59:55 +00:00
|
|
|
* YAP Prolog @(#)amidefs.h 1.3 3/15/90 *
|
2001-04-09 20:54:03 +01:00
|
|
|
* *
|
2004-03-10 14:59:55 +00:00
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
2001-04-09 20:54:03 +01:00
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: amidefs.h *
|
|
|
|
* comments: Abstract machine peculiarities *
|
|
|
|
* *
|
2005-12-17 03:25:39 +00:00
|
|
|
* Last rev: $Date: 2005-12-17 03:25:39 $ *
|
2004-03-31 02:03:10 +01:00
|
|
|
* $Log: not supported by cvs2svn $
|
2005-12-17 03:25:39 +00:00
|
|
|
* Revision 1.29 2005/07/06 15:10:15 vsc
|
|
|
|
* improvements to compiler: merged instructions and fixes for ->
|
|
|
|
*
|
2005-07-06 16:10:18 +01:00
|
|
|
* Revision 1.28 2005/05/30 06:07:35 vsc
|
|
|
|
* changes to support more tagging schemes from tabulation.
|
|
|
|
*
|
2005-05-30 07:07:35 +01:00
|
|
|
* Revision 1.27 2005/04/10 04:01:13 vsc
|
|
|
|
* bug fixes, I hope!
|
|
|
|
*
|
2005-04-10 05:01:15 +01:00
|
|
|
* Revision 1.26 2004/09/30 21:37:41 vsc
|
|
|
|
* fixes for thread support
|
|
|
|
*
|
2004-09-30 22:37:41 +01:00
|
|
|
* Revision 1.25 2004/09/27 20:45:04 vsc
|
|
|
|
* Mega clauses
|
|
|
|
* Fixes to sizeof(expand_clauses) which was being overestimated
|
|
|
|
* Fixes to profiling+indexing
|
|
|
|
* Fixes to reallocation of memory after restoring
|
|
|
|
* Make sure all clauses, even for C, end in _Ystop
|
|
|
|
* Don't reuse space for Streams
|
|
|
|
* Fix Stream_F on StreaNo+1
|
|
|
|
*
|
2004-09-27 21:45:04 +01:00
|
|
|
* Revision 1.24 2004/04/14 19:10:40 vsc
|
|
|
|
* expand_clauses: keep a list of clauses to expand
|
|
|
|
* fix new trail scheme for multi-assignment variables
|
|
|
|
*
|
2004-04-14 20:10:40 +01:00
|
|
|
* Revision 1.23 2004/03/31 01:03:10 vsc
|
|
|
|
* support expand group of clauses
|
|
|
|
*
|
2004-03-31 02:03:10 +01:00
|
|
|
* Revision 1.22 2004/03/10 14:59:55 vsc
|
|
|
|
* optimise -> for type tests
|
|
|
|
* *
|
2004-03-10 14:59:55 +00:00
|
|
|
* *
|
2001-04-09 20:54:03 +01:00
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#if ALIGN_LONGS
|
|
|
|
/* */ typedef Int DISPREG;
|
|
|
|
/* */ typedef CELL SMALLUNSGN;
|
|
|
|
/* */ typedef Int OPREG;
|
|
|
|
/* */ typedef CELL UOPREG;
|
|
|
|
|
|
|
|
#else
|
|
|
|
/* */ typedef Short DISPREG;
|
|
|
|
/* */ typedef BITS16 SMALLUNSGN;
|
|
|
|
/* */ typedef SBITS16 OPREG;
|
|
|
|
/* */ typedef SBITS16 UOPREG;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-12-27 16:53:09 +00:00
|
|
|
|
|
|
|
typedef Int (*CPredicate)(void);
|
|
|
|
|
|
|
|
typedef Int (*CmpPredicate)(Term, Term);
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define OpRegSize sizeof(OPREG)
|
|
|
|
|
|
|
|
/*
|
|
|
|
Possible arguments to YAP emulator:
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg describes an A or X register;
|
|
|
|
yslot describes an Y slot
|
2001-04-09 20:54:03 +01:00
|
|
|
COUNT is a small number (eg, number of arguments to a choicepoint,
|
|
|
|
number of permanent variables in a environment
|
|
|
|
*/
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
typedef OPREG wamreg;
|
|
|
|
typedef OPREG yslot;
|
2001-04-09 20:54:03 +01:00
|
|
|
typedef OPREG COUNT;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is a table with the codes for YAP instructions
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
#define OPCODE(OP,TYPE) _##OP
|
|
|
|
#include "YapOpcodes.h"
|
|
|
|
#undef OPCODE
|
|
|
|
} op_numbers;
|
|
|
|
|
2003-01-29 14:47:17 +00:00
|
|
|
#define _std_top _p_execute_tail
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-07-06 16:10:18 +01:00
|
|
|
/* use similar trick for keeping instruction names */
|
|
|
|
#if defined(ANALYST) || defined(DEBUG)
|
|
|
|
extern char *Yap_op_names[_std_top + 1];
|
|
|
|
#endif
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
typedef enum {
|
|
|
|
_atom,
|
|
|
|
_atomic,
|
|
|
|
_integer,
|
|
|
|
_compound,
|
|
|
|
_float,
|
|
|
|
_nonvar,
|
|
|
|
_number,
|
|
|
|
_var,
|
|
|
|
_cut_by,
|
|
|
|
_db_ref,
|
|
|
|
_primitive,
|
|
|
|
_dif,
|
|
|
|
_eq,
|
2005-07-06 16:10:18 +01:00
|
|
|
_equal,
|
2001-04-09 20:54:03 +01:00
|
|
|
_plus,
|
|
|
|
_minus,
|
|
|
|
_times,
|
|
|
|
_div,
|
|
|
|
_and,
|
|
|
|
_or,
|
|
|
|
_sll,
|
2001-04-20 16:48:04 +01:00
|
|
|
_slr,
|
2001-04-23 21:41:58 +01:00
|
|
|
_arg,
|
|
|
|
_functor
|
2001-04-09 20:54:03 +01:00
|
|
|
} basic_preds;
|
|
|
|
|
|
|
|
#if USE_THREADED_CODE
|
|
|
|
|
|
|
|
#if ALIGN_LONGS
|
|
|
|
/* */ typedef CELL OPCODE;
|
|
|
|
#else
|
|
|
|
|
|
|
|
#if LOW_ABSMI
|
|
|
|
/* */ typedef BITS16 OPCODE;
|
|
|
|
#else
|
|
|
|
/* */ typedef CELL OPCODE;
|
|
|
|
#endif
|
|
|
|
#endif /* ALIGN_LONGS */
|
|
|
|
#else /* if does not USE_THREADED_CODE */
|
|
|
|
/* */ typedef op_numbers OPCODE;
|
|
|
|
#endif
|
|
|
|
#define OpCodeSize sizeof(OPCODE)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Types of possible YAAM instructions.
|
|
|
|
|
|
|
|
The meaning of the symbols in a abstract machine instruction is:
|
|
|
|
|
|
|
|
c: constant
|
|
|
|
d: predicate definition
|
|
|
|
f: functor
|
|
|
|
n: small number
|
|
|
|
l: label
|
|
|
|
x: argument or temporary register
|
|
|
|
y: environment slot
|
|
|
|
|
|
|
|
*/
|
|
|
|
typedef struct yami {
|
|
|
|
OPCODE opc;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
CELL next;
|
|
|
|
} e;
|
|
|
|
struct {
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} c;
|
2004-09-27 21:45:04 +01:00
|
|
|
struct {
|
|
|
|
CELL c1;
|
|
|
|
CELL c2;
|
|
|
|
CELL next;
|
|
|
|
} cc;
|
|
|
|
struct {
|
|
|
|
CELL c1;
|
|
|
|
CELL c2;
|
|
|
|
CELL c3;
|
|
|
|
CELL next;
|
|
|
|
} ccc;
|
|
|
|
struct {
|
|
|
|
CELL c1;
|
|
|
|
CELL c2;
|
|
|
|
CELL c3;
|
|
|
|
CELL c4;
|
|
|
|
CELL next;
|
|
|
|
} cccc;
|
|
|
|
struct {
|
|
|
|
CELL c1;
|
|
|
|
CELL c2;
|
|
|
|
CELL c3;
|
|
|
|
CELL c4;
|
|
|
|
CELL c5;
|
|
|
|
CELL next;
|
|
|
|
} ccccc;
|
|
|
|
struct {
|
|
|
|
CELL c1;
|
|
|
|
CELL c2;
|
|
|
|
CELL c3;
|
|
|
|
CELL c4;
|
|
|
|
CELL c5;
|
|
|
|
CELL c6;
|
|
|
|
CELL next;
|
|
|
|
} cccccc;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
CELL c;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
2003-10-02 13:59:05 +01:00
|
|
|
struct yami *l3;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
2003-10-02 13:59:05 +01:00
|
|
|
} clll;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
CODEADDR d;
|
|
|
|
CELL next;
|
|
|
|
} d;
|
2003-04-30 18:46:05 +01:00
|
|
|
struct {
|
|
|
|
CODEADDR d;
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} dp;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
Int ClTrail;
|
|
|
|
Int ClENV;
|
|
|
|
Int ClRefs;
|
2005-12-17 03:25:39 +00:00
|
|
|
struct logic_upd_clause *ClBase;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} EC;
|
|
|
|
struct {
|
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
|
|
|
} f;
|
|
|
|
struct {
|
|
|
|
Functor f;
|
|
|
|
CODEADDR l1;
|
|
|
|
CODEADDR l2;
|
|
|
|
CELL next;
|
|
|
|
} fll;
|
2003-12-27 00:38:53 +00:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
struct yami *f;
|
|
|
|
CELL next;
|
|
|
|
} fx;
|
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
struct yami *f;
|
|
|
|
CELL next;
|
|
|
|
} fy;
|
2003-09-15 02:25:29 +01:00
|
|
|
struct {
|
|
|
|
struct logic_upd_index *I;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
COUNT s;
|
2004-09-30 22:37:41 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
struct pred_entry *p;
|
|
|
|
#endif
|
2003-09-15 02:25:29 +01:00
|
|
|
CELL next;
|
|
|
|
} Ill;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} l;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
|
|
|
struct table_entry *te; /* pointer to table entry */
|
|
|
|
#endif /* TABLING */
|
|
|
|
COUNT s;
|
2002-05-16 21:33:00 +01:00
|
|
|
struct pred_entry *p;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *d;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} ld;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
|
|
|
struct table_entry *te; /* pointer to table entry */
|
|
|
|
#endif /* TABLING */
|
|
|
|
COUNT s;
|
2002-05-16 21:33:00 +01:00
|
|
|
struct pred_entry *p;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *d;
|
|
|
|
struct yami *bl;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} ldl;
|
|
|
|
struct {
|
|
|
|
CODEADDR l;
|
|
|
|
SMALLUNSGN flags;
|
|
|
|
CELL next;
|
|
|
|
} lf;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
|
|
|
struct table_entry *te; /* pointer to table entry */
|
|
|
|
#endif /* TABLING */
|
|
|
|
COUNT s;
|
2002-05-16 21:33:00 +01:00
|
|
|
struct pred_entry *p;
|
2002-12-27 16:53:09 +00:00
|
|
|
CPredicate f;
|
2001-04-09 20:54:03 +01:00
|
|
|
COUNT extra;
|
|
|
|
CELL next;
|
|
|
|
} lds;
|
|
|
|
struct {
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} lll;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
|
|
|
struct table_entry *te; /* pointer to table entry */
|
|
|
|
#endif /* TABLING */
|
|
|
|
COUNT s;
|
2002-05-16 21:33:00 +01:00
|
|
|
struct pred_entry *p;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} slll;
|
|
|
|
struct {
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} llll;
|
2003-04-30 18:46:05 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
|
|
|
CELL next;
|
|
|
|
} xllll;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
|
|
|
CELL next;
|
|
|
|
} sllll;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-12-27 16:53:09 +00:00
|
|
|
struct pred_entry *p;
|
2003-12-27 00:38:53 +00:00
|
|
|
struct yami *f;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
|
|
|
wamreg flags;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
2003-12-27 00:38:53 +00:00
|
|
|
} llxx;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2003-12-27 00:38:53 +00:00
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *f;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2002-12-27 16:53:09 +00:00
|
|
|
yslot y;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg flags;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
2003-12-27 00:38:53 +00:00
|
|
|
} llxy;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2003-12-27 00:38:53 +00:00
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *f;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg y1;
|
2002-12-27 16:53:09 +00:00
|
|
|
yslot y2;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg flags;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
2003-12-27 00:38:53 +00:00
|
|
|
} llyy;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
OPCODE pop;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} ollll;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
CELL next;
|
|
|
|
} o;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} oc;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
|
|
|
} of;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
COUNT s;
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} osc;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
COUNT s;
|
|
|
|
CELL next;
|
|
|
|
} os;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} ox;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg xl;
|
|
|
|
wamreg xr;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} oxx;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} oy;
|
2002-12-27 16:53:09 +00:00
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} p;
|
2005-12-17 03:25:39 +00:00
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct pred_entry *p0;
|
|
|
|
CELL next;
|
|
|
|
} pp;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
CELL next;
|
|
|
|
} s;
|
2003-04-30 18:46:05 +01:00
|
|
|
struct {
|
2004-03-31 02:03:10 +01:00
|
|
|
COUNT s1;
|
|
|
|
COUNT s2;
|
2004-04-14 20:10:40 +01:00
|
|
|
COUNT s3;
|
2004-09-27 21:45:04 +01:00
|
|
|
struct yami *sprev, *snext;
|
2003-04-30 18:46:05 +01:00
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} sp;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} sc;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
2002-12-27 16:53:09 +00:00
|
|
|
CPredicate d;
|
|
|
|
struct yami *l;
|
2002-05-16 21:33:00 +01:00
|
|
|
struct pred_entry *p;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} sdl;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
COUNT s;
|
2002-12-27 16:53:09 +00:00
|
|
|
CELL *bmap;
|
|
|
|
union {
|
|
|
|
struct yami *l;
|
|
|
|
struct pred_entry *p;
|
2004-02-12 12:37:12 +00:00
|
|
|
Term mod;
|
2002-12-27 16:53:09 +00:00
|
|
|
} sla_u;
|
2002-02-26 15:51:54 +00:00
|
|
|
struct pred_entry *p0;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
2002-02-26 15:51:54 +00:00
|
|
|
} sla; /* also check env for yes and trustfail code before making any changes */
|
2004-03-31 02:03:10 +01:00
|
|
|
struct {
|
|
|
|
COUNT s; /* size of table */
|
|
|
|
COUNT e; /* live entries */
|
|
|
|
COUNT w; /* pending suspended blocks */
|
|
|
|
struct yami *l;
|
|
|
|
CELL next;
|
|
|
|
} sssl;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} x;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} xc;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
|
|
|
} xf;
|
2004-03-10 14:59:55 +00:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
struct yami *F;
|
|
|
|
CELL next;
|
|
|
|
} xF;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2003-10-28 01:16:03 +00:00
|
|
|
wamreg x;
|
2005-04-10 05:01:15 +01:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
2003-10-28 01:16:03 +00:00
|
|
|
CELL next;
|
2005-04-10 05:01:15 +01:00
|
|
|
} xll;
|
2003-10-28 01:16:03 +00:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg xl;
|
|
|
|
wamreg xr;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} xx;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} xxx;
|
2005-07-06 16:10:18 +01:00
|
|
|
struct {
|
|
|
|
wamreg xl1;
|
|
|
|
wamreg xl2;
|
|
|
|
wamreg xr1;
|
|
|
|
wamreg xr2;
|
|
|
|
CELL next;
|
|
|
|
} xxxx;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
Int c;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg xi;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} xcx, xxc;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
|
|
|
yslot y;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} xy;
|
2001-04-23 21:41:58 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x;
|
|
|
|
yslot y2;
|
|
|
|
wamreg x1;
|
2001-04-23 21:41:58 +01:00
|
|
|
CELL next;
|
|
|
|
} xyx;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} y;
|
2004-03-10 14:59:55 +00:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
struct yami *F;
|
|
|
|
CELL next;
|
|
|
|
} yF;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
|
|
|
wamreg x;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} yx;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} yxx;
|
2001-04-23 21:41:58 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y1;
|
|
|
|
yslot y2;
|
|
|
|
wamreg x;
|
2001-04-23 21:41:58 +01:00
|
|
|
CELL next;
|
|
|
|
} yyx;
|
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
|
|
|
yslot y1;
|
|
|
|
yslot y2;
|
2001-04-23 21:41:58 +01:00
|
|
|
CELL next;
|
|
|
|
} yyy;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot y;
|
2001-04-09 20:54:03 +01:00
|
|
|
Int c;
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg xi;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL next;
|
|
|
|
} ycx, yxc;
|
|
|
|
} u;
|
|
|
|
} yamop;
|
|
|
|
|
|
|
|
typedef yamop yamopp;
|
|
|
|
|
|
|
|
#define OPCR opc
|
|
|
|
#define OPCW u.ox.opcw
|
|
|
|
|
|
|
|
|
|
|
|
#define NEXTOP(V,TYPE) ((yamop *)(&((V)->u.TYPE.next)))
|
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
#define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE)))
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#if defined(TABLING) || defined(SBA)
|
|
|
|
typedef struct trail_frame {
|
|
|
|
Term term;
|
|
|
|
CELL value;
|
|
|
|
} *tr_fr_ptr;
|
|
|
|
|
|
|
|
#define TrailTerm(X) ((X)->term)
|
|
|
|
#define TrailVal(X) ((X)->value)
|
|
|
|
#else
|
|
|
|
typedef Term *tr_fr_ptr;
|
|
|
|
|
|
|
|
#define TrailTerm(X) (*(X))
|
|
|
|
#define TrailVal(X) OOOOOOPS: this program should not compile
|
|
|
|
#endif /* TABLING || SBA */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Choice Point Structure
|
|
|
|
|
|
|
|
6 fixed fields (TR,AP,H,B,ENV,CP) plus arguments
|
|
|
|
|
|
|
|
*/
|
|
|
|
typedef struct choicept {
|
|
|
|
tr_fr_ptr cp_tr;
|
|
|
|
CELL *cp_h;
|
|
|
|
struct choicept *cp_b;
|
|
|
|
#ifdef DEPTH_LIMIT
|
|
|
|
CELL cp_depth;
|
|
|
|
#endif /* DEPTH_LIMIT */
|
|
|
|
yamop *cp_cp;
|
|
|
|
#ifdef YAPOR
|
|
|
|
int cp_lub; /* local untried branches */
|
|
|
|
struct or_frame *cp_or_fr; /* or-frame pointer */
|
|
|
|
#endif /* YAPOR */
|
|
|
|
yamop *cp_ap;
|
|
|
|
#if MIN_ARRAY == 0
|
|
|
|
CELL *cp_env;
|
|
|
|
/* GNUCC understands empty arrays */
|
|
|
|
CELL cp_args[MIN_ARRAY];
|
|
|
|
#define cp_a1 cp_args[0]
|
|
|
|
#define cp_a2 cp_args[1]
|
|
|
|
#define cp_a3 cp_args[2]
|
|
|
|
#define cp_a4 cp_args[3]
|
|
|
|
#define cp_a5 cp_args[4]
|
|
|
|
#define cp_a6 cp_args[5]
|
|
|
|
#define cp_a7 cp_args[6]
|
|
|
|
#define cp_a8 cp_args[7]
|
|
|
|
#define EXTRA_CBACK_ARG(Arity,Offset) B->cp_args[(Arity)+(Offset)-1]
|
|
|
|
#else
|
|
|
|
/* Otherwise, we need a very dirty trick to access the arguments */
|
|
|
|
union {
|
|
|
|
CELL *cp_uenv;
|
|
|
|
CELL cp_args[1];
|
|
|
|
} cp_last;
|
|
|
|
#define cp_env cp_last.cp_uenv
|
|
|
|
#define cp_a1 cp_last.cp_args[1]
|
|
|
|
#define cp_a2 cp_last.cp_args[2]
|
|
|
|
#define cp_a3 cp_last.cp_args[3]
|
|
|
|
#define cp_a4 cp_last.cp_args[4]
|
|
|
|
#define cp_a5 cp_last.cp_args[5]
|
|
|
|
#define cp_a6 cp_last.cp_args[6]
|
|
|
|
#define cp_a7 cp_last.cp_args[7]
|
|
|
|
#define cp_a8 cp_last.cp_args[8]
|
|
|
|
#define EXTRA_CBACK_ARG(Arity,Offset) B->cp_last.cp_args[(Arity)+(Offset)]
|
|
|
|
#endif
|
|
|
|
} *choiceptr;
|
|
|
|
|
|
|
|
/* This has problems with \+ \+ a, !, b. */
|
|
|
|
#define SHOULD_CUT_UP_TO(X,Y) ((X) != (Y))
|
|
|
|
/* #define SHOULD_CUT_UP_TO(X,Y) ((X) (Y)) */
|
|
|
|
|
|
|
|
#ifdef SBA
|
|
|
|
#define SHARED_CP(CP) ((CP) >= B_FZ || (CP) < (choiceptr)H_FZ)
|
|
|
|
|
|
|
|
#define YOUNGER_CP(CP1, CP2) \
|
|
|
|
(SHARED_CP(CP1) ? \
|
|
|
|
(SHARED_CP(CP2) ? OrFr_depth((CP1)->cp_or_fr) > OrFr_depth((CP2)->cp_or_fr) : FALSE) \
|
|
|
|
: \
|
|
|
|
(SHARED_CP(CP2) ? TRUE : CP1 < CP2) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define EQUAL_OR_YOUNGER_CP(CP1, CP2) \
|
|
|
|
(SHARED_CP(CP1) ? \
|
|
|
|
(SHARED_CP(CP2) ? OrFr_depth((CP1)->cp_or_fr) >= OrFr_depth((CP2)->cp_or_fr) : FALSE) \
|
|
|
|
: \
|
|
|
|
(SHARED_CP(CP2) ? TRUE : CP1 <= CP2) \
|
|
|
|
)
|
2005-05-30 07:07:35 +01:00
|
|
|
|
|
|
|
#define YOUNGER_H(H1, H2) FIXMEE!!!!
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#else /* ENV_COPY || ACOW */
|
|
|
|
#define YOUNGER_CP(CP1, CP2) ((CP1) < (CP2))
|
|
|
|
#define EQUAL_OR_YOUNGER_CP(CP1, CP2) ((CP1) <= (CP2))
|
2005-05-30 07:07:35 +01:00
|
|
|
|
|
|
|
#define YOUNGER_H(H1, H2) ((CELL *)(H1) > (CELL *)(H2))
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* SBA */
|
|
|
|
|
2005-05-30 07:07:35 +01:00
|
|
|
#define YOUNGEST_CP(CP1, CP2) (YOUNGER_CP(CP1,CP2) ? (CP1) : (CP2))
|
|
|
|
|
|
|
|
#define YOUNGEST_H(H1, H2) (YOUNGER_H(H1,H2) ? (CELL *)(H1) : (CELL *)(H2))
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/*
|
|
|
|
Environment Structure (CP, E, and CUT_B). Yap always saves the B
|
|
|
|
where to cut to, even if not needed.
|
|
|
|
*/
|
|
|
|
#define E_CP -1
|
|
|
|
#define E_E -2
|
|
|
|
#define E_CB -3
|
|
|
|
#ifdef TABLING
|
|
|
|
#define E_B -4
|
|
|
|
#ifdef DEPTH_LIMIT
|
|
|
|
#define E_DEPTH -5
|
|
|
|
#define EnvSizeInCells 5
|
|
|
|
#else
|
|
|
|
#define EnvSizeInCells 4
|
|
|
|
#endif /* DEPTH_LIMIT */
|
|
|
|
#else /* TABLING */
|
|
|
|
#ifdef DEPTH_LIMIT
|
|
|
|
#define E_DEPTH -4
|
|
|
|
#define EnvSizeInCells 4
|
|
|
|
#else
|
|
|
|
#define EnvSizeInCells 3
|
|
|
|
#endif /* DEPTH_LIMIT */
|
|
|
|
#endif /* TABLING */
|
|
|
|
|
|
|
|
#if MSHIFTOFFS
|
|
|
|
#define FixedEnvSize EnvSizeInCells
|
|
|
|
#else
|
|
|
|
#define FixedEnvSize (EnvSizeInCells*sizeof(CELL))
|
|
|
|
#endif
|
|
|
|
#define RealEnvSize (EnvSizeInCells*sizeof(CELL))
|
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
#define ENV_Size(cp) (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,sla)))->u.sla.s)
|
|
|
|
#define ENV_ToP(cp) (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,sla)))->u.sla.sla_u.p)
|
|
|
|
#define ENV_ToOp(cp) (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,sla)))->opc)
|
2001-04-09 20:54:03 +01:00
|
|
|
#define EnvSize(cp) ((-ENV_Size(cp))/(OPREG)sizeof(CELL))
|
2003-04-30 18:46:05 +01:00
|
|
|
#define EnvBMap(p) (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,sla)))->u.sla.bmap)
|
|
|
|
#define EnvPreg(p) (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,sla)))->u.sla.p0)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* access to instructions */
|
|
|
|
|
|
|
|
#if USE_THREADED_CODE
|
2002-11-18 18:18:05 +00:00
|
|
|
extern void **Yap_ABSMI_OPCODES;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-11-18 18:18:05 +00:00
|
|
|
#define absmadr(i) ((OPCODE)(Yap_ABSMI_OPCODES[(i)]))
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
|
|
|
#define absmadr(i) ((OPCODE)(i))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* used to find out how many instructions of each kind are executed */
|
|
|
|
#ifdef ANALYST
|
2005-07-06 16:10:18 +01:00
|
|
|
extern YAP_ULONG_LONG Yap_opcount[_std_top + 1];
|
|
|
|
|
|
|
|
extern YAP_ULONG_LONG Yap_2opcount[_std_top + 1][_std_top + 1];
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* ANALYST */
|
|
|
|
|
|
|
|
#if DEPTH_LIMIT
|
|
|
|
/*
|
|
|
|
Make this into an even number so that the system will know
|
|
|
|
it should ignore the depth limit
|
|
|
|
*/
|
|
|
|
#define RESET_DEPTH() DEPTH = MkIntTerm(MAX_ABS_INT-1)
|
|
|
|
#else
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|