2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
2006-10-10 15:08:17 +01:00
|
|
|
* *
|
|
|
|
* YAP Prolog @(#)amidefs.h 1.3 3/15/90 *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: amidefs.h *
|
|
|
|
* comments: Abstract machine peculiarities *
|
|
|
|
* *
|
2008-07-23 00:34:50 +01:00
|
|
|
* Last rev: $Date: 2008-07-22 23:34:49 $ *
|
2006-10-10 15:08:17 +01:00
|
|
|
* $Log: not supported by cvs2svn $
|
2008-07-23 00:34:50 +01:00
|
|
|
* Revision 1.33 2007/11/26 23:43:09 vsc
|
|
|
|
* fixes to support threads and assert correctly, even if inefficiently.
|
|
|
|
*
|
2007-11-26 23:43:10 +00:00
|
|
|
* Revision 1.32 2006/10/10 14:08:17 vsc
|
|
|
|
* small fixes on threaded implementation.
|
|
|
|
*
|
2006-10-10 15:08:17 +01:00
|
|
|
* Revision 1.31 2006/09/20 20:03:51 vsc
|
|
|
|
* improve indexing on floats
|
|
|
|
* fix sending large lists to DB
|
|
|
|
*
|
|
|
|
* Revision 1.30 2005/12/17 03:25:39 vsc
|
|
|
|
* major changes to support online event-based profiling
|
|
|
|
* improve error discovery and restart on scanner.
|
|
|
|
*
|
|
|
|
* Revision 1.29 2005/07/06 15:10:15 vsc
|
|
|
|
* improvements to compiler: merged instructions and fixes for ->
|
|
|
|
*
|
|
|
|
* Revision 1.28 2005/05/30 06:07:35 vsc
|
|
|
|
* changes to support more tagging schemes from tabulation.
|
|
|
|
*
|
|
|
|
* Revision 1.27 2005/04/10 04:01:13 vsc
|
|
|
|
* bug fixes, I hope!
|
|
|
|
*
|
|
|
|
* Revision 1.26 2004/09/30 21:37:41 vsc
|
|
|
|
* fixes for thread support
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* Revision 1.23 2004/03/31 01:03:10 vsc
|
|
|
|
* support expand group of clauses
|
|
|
|
*
|
|
|
|
* Revision 1.22 2004/03/10 14:59:55 vsc
|
|
|
|
* optimise -> for type tests
|
|
|
|
* *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2009-10-31 00:18:13 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2010-03-08 09:24:11 +00:00
|
|
|
#ifdef FROZEN_STACKS
|
|
|
|
#ifdef SBA
|
|
|
|
#define PROTECT_FROZEN_H(CPTR) \
|
|
|
|
((Unsigned((Int)((CPTR)->cp_h)-(Int)(H_FZ)) < \
|
|
|
|
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
|
|
|
|
(CPTR)->cp_h : H_FZ)
|
|
|
|
#define PROTECT_FROZEN_B(CPTR) \
|
|
|
|
((Unsigned((Int)(CPTR)-(Int)(H_FZ)) < \
|
|
|
|
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
|
|
|
|
(CPTR) : B_FZ)
|
|
|
|
/*
|
|
|
|
#define PROTECT_FROZEN_H(CPTR) ((CPTR)->cp_h > H_FZ && (CPTR)->cp_h < (CELL *)B_FZ ? (CPTR)->cp_h : H_FZ )
|
|
|
|
|
|
|
|
#define PROTECT_FROZEN_B(CPTR) ((CPTR) < B_FZ && (CPTR) > (choiceptr)H_FZ ? (CPTR) : B_FZ )
|
|
|
|
*/
|
|
|
|
#else /* TABLING */
|
|
|
|
#define PROTECT_FROZEN_B(CPTR) (YOUNGER_CP(CPTR, B_FZ) ? CPTR : B_FZ)
|
|
|
|
#define PROTECT_FROZEN_H(CPTR) (((CPTR)->cp_h > H_FZ) ? (CPTR)->cp_h : H_FZ)
|
|
|
|
#endif /* SBA */
|
|
|
|
#else
|
|
|
|
#define PROTECT_FROZEN_B(CPTR) (CPTR)
|
|
|
|
#define PROTECT_FROZEN_H(CPTR) (CPTR)->cp_h
|
|
|
|
#endif /* FROZEN_STACKS */
|
|
|
|
|
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
|
|
|
|
|
2011-03-07 16:02:55 +00:00
|
|
|
#if THREADS
|
2002-12-27 16:53:09 +00:00
|
|
|
|
2011-03-07 16:02:55 +00:00
|
|
|
typedef struct regstore_t *regstruct_ptr;
|
|
|
|
|
|
|
|
#define CACHE_TYPE1 regstruct_ptr
|
|
|
|
#define CACHE_TYPE , regstruct_ptr
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define CACHE_TYPE
|
|
|
|
#define CACHE_TYPE1 void
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef Int (*CPredicate)(CACHE_TYPE1);
|
2002-12-27 16:53:09 +00:00
|
|
|
|
|
|
|
typedef Int (*CmpPredicate)(Term, Term);
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define OpRegSize sizeof(OPREG)
|
|
|
|
|
|
|
|
/*
|
2006-10-10 15:08:17 +01:00
|
|
|
Possible arguments to YAP emulator:
|
|
|
|
wamreg describes an A or X register;
|
|
|
|
yslot describes an Y slot
|
|
|
|
COUNT is a small number (eg, number of arguments to a choicepoint,
|
|
|
|
number of permanent variables in a environment
|
2001-04-09 20:54:03 +01:00
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-10-10 15:08:17 +01:00
|
|
|
This is a table with the codes for YAP instructions
|
2001-04-09 20:54:03 +01:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
#define OPCODE(OP,TYPE) _##OP
|
|
|
|
#include "YapOpcodes.h"
|
|
|
|
#undef OPCODE
|
|
|
|
} op_numbers;
|
|
|
|
|
2008-08-21 13:38:25 +01:00
|
|
|
#define _std_top _or_last
|
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 {
|
2006-10-10 15:08:17 +01:00
|
|
|
_atom,
|
|
|
|
_atomic,
|
|
|
|
_integer,
|
|
|
|
_compound,
|
|
|
|
_float,
|
|
|
|
_nonvar,
|
|
|
|
_number,
|
|
|
|
_var,
|
|
|
|
_cut_by,
|
|
|
|
_db_ref,
|
|
|
|
_primitive,
|
|
|
|
_dif,
|
|
|
|
_eq,
|
|
|
|
_equal,
|
|
|
|
_plus,
|
|
|
|
_minus,
|
|
|
|
_times,
|
|
|
|
_div,
|
|
|
|
_and,
|
|
|
|
_or,
|
|
|
|
_sll,
|
|
|
|
_slr,
|
|
|
|
_arg,
|
2008-12-09 12:54:27 +00:00
|
|
|
_functor,
|
|
|
|
_p_put_fi,
|
|
|
|
_p_put_i,
|
|
|
|
_p_put_f,
|
|
|
|
_p_a_eq_float,
|
|
|
|
_p_a_eq_int,
|
|
|
|
_p_a_eq,
|
|
|
|
_p_ltc_float,
|
|
|
|
_p_ltc_int,
|
|
|
|
_p_lt,
|
|
|
|
_p_gtc_float,
|
|
|
|
_p_gtc_int,
|
|
|
|
_p_get_fi,
|
|
|
|
_p_get_i,
|
|
|
|
_p_get_f,
|
|
|
|
_p_add_float_c,
|
|
|
|
_p_add_int_c,
|
|
|
|
_p_add,
|
|
|
|
_p_sub_float_c,
|
|
|
|
_p_sub_int_c,
|
|
|
|
_p_sub,
|
|
|
|
_p_mul_float_c,
|
|
|
|
_p_mul_int_c,
|
|
|
|
_p_mul,
|
|
|
|
_p_fdiv_c1,
|
|
|
|
_p_fdiv_c2,
|
|
|
|
_p_fdiv,
|
|
|
|
_p_idiv_c1,
|
|
|
|
_p_idiv_c2,
|
|
|
|
_p_idiv,
|
|
|
|
_p_mod_c1,
|
|
|
|
_p_mod_c2,
|
|
|
|
_p_mod,
|
|
|
|
_p_rem_c1,
|
|
|
|
_p_rem_c2,
|
|
|
|
_p_rem,
|
|
|
|
_p_land_c,
|
|
|
|
_p_land,
|
|
|
|
_p_lor_c,
|
|
|
|
_p_lor,
|
|
|
|
_p_xor_c,
|
|
|
|
_p_xor,
|
|
|
|
_p_uminus,
|
|
|
|
_p_sr_c1,
|
|
|
|
_p_sr_c2,
|
|
|
|
_p_sr,
|
|
|
|
_p_sl_c1,
|
|
|
|
_p_sl_c2,
|
|
|
|
_p_sl,
|
|
|
|
_p_label_ctl
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
2006-10-10 15:08:17 +01:00
|
|
|
Types of possible YAAM instructions.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-12 14:09:29 +01:00
|
|
|
The meaning and type of the symbols in a abstract machine instruction is:
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-08-29 05:25:36 +01:00
|
|
|
b: arity (Int)
|
2008-08-21 13:38:25 +01:00
|
|
|
b: bitmap (CELL *)
|
2008-08-29 05:25:36 +01:00
|
|
|
c: constant, is a Term
|
2008-08-21 13:38:25 +01:00
|
|
|
d: double (functor + unaligned double)
|
|
|
|
f: functor
|
|
|
|
F: Function, CPredicate
|
|
|
|
i: large integer (functor + long)
|
2008-09-12 14:09:29 +01:00
|
|
|
I: logic upd index (struct logic_upd_index *)
|
2008-08-22 03:01:27 +01:00
|
|
|
l: label, yamop *
|
2008-08-21 13:38:25 +01:00
|
|
|
L: logic upd clause, logic_upd_clause *
|
|
|
|
m: module, Term
|
2008-08-29 17:27:11 +01:00
|
|
|
n: number, Integer
|
2010-12-16 22:21:46 +00:00
|
|
|
N: bigint, Blob (Term)
|
2008-08-21 13:38:25 +01:00
|
|
|
o: opcode, OPCODE
|
2008-09-05 05:22:19 +01:00
|
|
|
O: OR-parallel information, used by YAPOR, unsigned int
|
2008-08-29 05:25:36 +01:00
|
|
|
p: predicate, struct pred_entry *
|
2008-08-21 13:38:25 +01:00
|
|
|
s: small integer, COUNT
|
2008-09-05 05:22:19 +01:00
|
|
|
t: pointer to table entry, used by yaptab, struct table_entry *
|
2008-08-21 13:38:25 +01:00
|
|
|
x: wam register, wamreg
|
2006-10-10 15:08:17 +01:00
|
|
|
y: environment slot
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
*/
|
2008-08-29 05:25:36 +01:00
|
|
|
/* This declaration is going to be parsed by a Prolog program, so:
|
|
|
|
comments are welcome, but they should take a whole line,
|
|
|
|
every field declaration should also take a single line,
|
2008-09-05 05:22:19 +01:00
|
|
|
please check the Prolog program if you come up with a complicated C-type that does not start by unsigned or struct.
|
2008-08-29 05:25:36 +01:00
|
|
|
*/
|
2001-04-09 20:54:03 +01:00
|
|
|
typedef struct yami {
|
|
|
|
OPCODE opc;
|
|
|
|
union {
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
CELL next;
|
|
|
|
} e;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} c;
|
2010-12-16 22:21:46 +00:00
|
|
|
struct {
|
|
|
|
Term D;
|
|
|
|
CELL next;
|
|
|
|
} D;
|
|
|
|
struct {
|
|
|
|
Term b;
|
|
|
|
CELL next;
|
|
|
|
} N;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c1;
|
|
|
|
Term c2;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} cc;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c1;
|
|
|
|
Term c2;
|
|
|
|
Term c3;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} ccc;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c1;
|
|
|
|
Term c2;
|
|
|
|
Term c3;
|
|
|
|
Term c4;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} cccc;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c1;
|
|
|
|
Term c2;
|
|
|
|
Term c3;
|
|
|
|
Term c4;
|
|
|
|
Term c5;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} ccccc;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c1;
|
|
|
|
Term c2;
|
|
|
|
Term c3;
|
|
|
|
Term c4;
|
|
|
|
Term c5;
|
|
|
|
Term c6;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} cccccc;
|
|
|
|
struct {
|
2008-08-22 03:01:27 +01:00
|
|
|
Term c;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
CELL next;
|
|
|
|
} clll;
|
|
|
|
struct {
|
|
|
|
CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
|
|
|
|
CELL next;
|
|
|
|
} d;
|
|
|
|
struct {
|
|
|
|
struct logic_upd_clause *ClBase;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} L;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} fa;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
CELL i[2];
|
|
|
|
CELL next;
|
|
|
|
} i;
|
|
|
|
struct {
|
|
|
|
struct logic_upd_index *I;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
COUNT s;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} Ills;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
struct yami *l;
|
|
|
|
CELL next;
|
|
|
|
} l;
|
|
|
|
struct {
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
unsigned int or_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
2006-10-10 15:08:17 +01:00
|
|
|
struct table_entry *te; /* pointer to table entry */
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
2008-08-21 13:38:25 +01:00
|
|
|
Int s;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *d;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} Otapl;
|
2009-04-07 23:55:16 +01:00
|
|
|
struct {
|
2009-04-08 00:32:36 +01:00
|
|
|
/* call counter */
|
|
|
|
COUNT n;
|
|
|
|
/* native code pointer */
|
|
|
|
CPredicate native;
|
|
|
|
/* next instruction to execute after native code if the predicate was not fully compiled */
|
|
|
|
struct yami *native_next;
|
|
|
|
/* Pointer to pred */
|
|
|
|
struct pred_entry *p;
|
2009-04-07 23:55:16 +01:00
|
|
|
CELL next;
|
|
|
|
} aFlp;
|
2008-08-29 05:25:36 +01:00
|
|
|
/* The next two instructions are twin: they both correspond to the old ldd. */
|
|
|
|
/* The first one, aLl, handles try_logical and retry_logical, */
|
|
|
|
/* Ill handles trust_logical. */
|
|
|
|
/* They must have the same fields. */
|
|
|
|
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
unsigned int or_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2006-09-20 21:03:51 +01:00
|
|
|
#ifdef TABLING
|
2008-08-29 05:25:36 +01:00
|
|
|
/* pointer to table entry */
|
|
|
|
struct table_entry *te;
|
|
|
|
#endif
|
2008-08-21 13:38:25 +01:00
|
|
|
/* number of arguments */
|
|
|
|
COUNT s;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct logic_upd_clause *d;
|
|
|
|
struct yami *n;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} OtaLl;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2006-09-20 21:03:51 +01:00
|
|
|
#ifdef YAPOR
|
2008-08-21 13:38:25 +01:00
|
|
|
unsigned int or_arg;
|
2008-08-29 05:25:36 +01:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
2008-08-29 05:25:36 +01:00
|
|
|
/* pointer to table entry */
|
|
|
|
struct table_entry *te;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
2008-08-21 13:38:25 +01:00
|
|
|
/* number of arguments */
|
|
|
|
struct logic_upd_index *block;
|
|
|
|
struct logic_upd_clause *d;
|
|
|
|
struct yami *n;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} OtILl;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
unsigned int or_arg;
|
2008-08-29 05:25:36 +01:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
2008-08-29 05:25:36 +01:00
|
|
|
/* pointer to table entry */
|
|
|
|
struct table_entry *te;
|
|
|
|
#endif
|
2008-08-21 13:38:25 +01:00
|
|
|
Int s;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct pred_entry *p;
|
|
|
|
CPredicate f;
|
|
|
|
COUNT extra;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} OtapFs;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
CELL next;
|
|
|
|
} lll;
|
|
|
|
struct {
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
|
|
|
CELL next;
|
|
|
|
} llll;
|
|
|
|
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;
|
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *f;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT flags;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} plxxs;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *f;
|
|
|
|
wamreg x;
|
|
|
|
yslot y;
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT flags;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} plxys;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct yami *f;
|
|
|
|
wamreg y1;
|
|
|
|
yslot y2;
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT flags;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} plyys;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
OPCODE pop;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
struct yami *l3;
|
|
|
|
struct yami *l4;
|
|
|
|
CELL next;
|
|
|
|
} ollll;
|
2010-08-02 13:04:30 +01:00
|
|
|
struct {
|
|
|
|
Int i;
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} ip;
|
2009-02-12 21:35:31 +00:00
|
|
|
struct {
|
|
|
|
struct yami *l;
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} lp;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
CELL next;
|
|
|
|
} o;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
2008-08-21 13:38:25 +01:00
|
|
|
Term c;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} oc;
|
2010-12-16 20:39:53 +00:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
Term b;
|
|
|
|
CELL next;
|
2010-12-16 22:21:46 +00:00
|
|
|
} oN;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
|
|
|
|
CELL next;
|
|
|
|
} od;
|
2010-12-16 20:39:53 +00:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
Term D;
|
|
|
|
CELL next;
|
|
|
|
} oD;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} ofa;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
CELL i[2];
|
|
|
|
CELL next;
|
|
|
|
} oi;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
COUNT s;
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} osc;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
COUNT s;
|
|
|
|
CELL next;
|
|
|
|
} os;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
wamreg x;
|
|
|
|
CELL next;
|
|
|
|
} ox;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
wamreg xl;
|
|
|
|
wamreg xr;
|
|
|
|
CELL next;
|
|
|
|
} oxx;
|
|
|
|
struct {
|
|
|
|
OPCODE opcw;
|
|
|
|
yslot y;
|
|
|
|
CELL next;
|
|
|
|
} oy;
|
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
|
|
|
} p;
|
|
|
|
struct {
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct pred_entry *p0;
|
|
|
|
CELL next;
|
|
|
|
} pp;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
CELL next;
|
|
|
|
} s;
|
2008-08-21 13:38:25 +01:00
|
|
|
/* format of expand_clauses */
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
COUNT s1;
|
|
|
|
COUNT s2;
|
|
|
|
COUNT s3;
|
2008-08-29 05:25:36 +01:00
|
|
|
struct yami *sprev;
|
|
|
|
struct yami *snext;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} sssllp;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
CELL c;
|
|
|
|
CELL next;
|
|
|
|
} sc;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
2008-12-09 12:54:27 +00:00
|
|
|
CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
|
|
|
|
struct yami *F;
|
|
|
|
struct yami *T;
|
|
|
|
CELL next;
|
|
|
|
} sdll;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct yami *l;
|
|
|
|
struct pred_entry *p;
|
|
|
|
CELL next;
|
2008-12-09 12:54:27 +00:00
|
|
|
} slp;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
Int I;
|
|
|
|
struct yami *F;
|
|
|
|
struct yami *T;
|
|
|
|
CELL next;
|
|
|
|
} snll;
|
|
|
|
struct {
|
|
|
|
COUNT s0;
|
|
|
|
COUNT s1;
|
|
|
|
CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
|
|
|
|
CELL next;
|
|
|
|
} ssd;
|
|
|
|
struct {
|
|
|
|
COUNT s0;
|
|
|
|
COUNT s1;
|
|
|
|
Int n;
|
|
|
|
CELL next;
|
|
|
|
} ssn;
|
|
|
|
struct {
|
|
|
|
COUNT s0;
|
|
|
|
COUNT s1;
|
|
|
|
COUNT s2;
|
|
|
|
CELL next;
|
|
|
|
} sss;
|
|
|
|
struct {
|
|
|
|
COUNT s1;
|
|
|
|
COUNT s2;
|
|
|
|
struct yami *F;
|
|
|
|
struct yami *T;
|
|
|
|
CELL next;
|
|
|
|
} ssll;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
wamreg x;
|
|
|
|
struct yami *l;
|
|
|
|
CELL next;
|
|
|
|
} sxl;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
wamreg x;
|
|
|
|
struct yami *F;
|
|
|
|
struct yami *T;
|
|
|
|
CELL next;
|
|
|
|
} sxll;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
yslot y;
|
|
|
|
struct yami *l;
|
|
|
|
CELL next;
|
|
|
|
} syl;
|
|
|
|
struct {
|
|
|
|
COUNT s;
|
|
|
|
yslot y;
|
|
|
|
struct yami *F;
|
|
|
|
struct yami *T;
|
|
|
|
CELL next;
|
|
|
|
} syll;
|
2008-08-21 13:38:25 +01:00
|
|
|
/* the next 3 instructions must have same size and have fields in same order! */
|
|
|
|
/* also check env for yes and trustfail code before making any changes */
|
2008-09-05 05:22:19 +01:00
|
|
|
/* last, Osblp is known to the buildops script */
|
2008-08-21 13:38:25 +01:00
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
2008-08-29 05:25:36 +01:00
|
|
|
#endif
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT s;
|
|
|
|
CELL *bmap;
|
|
|
|
struct yami *l;
|
|
|
|
struct pred_entry *p0;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} Osblp;
|
2008-08-21 13:38:25 +01:00
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
2010-08-02 18:20:03 +01:00
|
|
|
#endif
|
|
|
|
COUNT s;
|
|
|
|
CELL *bmap;
|
|
|
|
struct pred_entry *p;
|
|
|
|
Int i;
|
|
|
|
CELL next;
|
|
|
|
} Osbpi;
|
|
|
|
struct {
|
|
|
|
#ifdef YAPOR
|
|
|
|
unsigned int or_arg;
|
2008-08-29 05:25:36 +01:00
|
|
|
#endif
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT s;
|
|
|
|
CELL *bmap;
|
|
|
|
struct pred_entry *p;
|
|
|
|
struct pred_entry *p0;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} Osbpp;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
unsigned int or_arg;
|
2008-08-29 05:25:36 +01:00
|
|
|
#endif
|
2006-10-10 15:08:17 +01:00
|
|
|
COUNT s;
|
|
|
|
CELL *bmap;
|
2008-08-21 13:38:25 +01:00
|
|
|
Term mod;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct pred_entry *p0;
|
|
|
|
CELL next;
|
2008-09-05 05:22:19 +01:00
|
|
|
} Osbmp;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
2008-08-29 05:25:36 +01:00
|
|
|
/* size of table */
|
|
|
|
COUNT s;
|
|
|
|
/* live entries */
|
|
|
|
COUNT e;
|
|
|
|
/* pending suspended blocks */
|
|
|
|
COUNT w;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct yami *l;
|
|
|
|
CELL next;
|
|
|
|
} sssl;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
CELL next;
|
|
|
|
} x;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
2008-08-30 02:39:36 +01:00
|
|
|
struct pred_entry *p0;
|
2011-02-14 19:29:20 +00:00
|
|
|
COUNT s;
|
2008-08-30 02:39:36 +01:00
|
|
|
CELL next;
|
2011-02-14 19:29:20 +00:00
|
|
|
} xps;
|
2008-08-30 02:39:36 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
CELL c;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
|
|
|
} xc;
|
2010-12-16 20:39:53 +00:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
Term b;
|
|
|
|
CELL next;
|
2010-12-16 22:21:46 +00:00
|
|
|
} xN;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
|
|
|
|
CELL next;
|
|
|
|
} xd;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
2010-12-16 20:39:53 +00:00
|
|
|
Term D;
|
|
|
|
CELL next;
|
|
|
|
} xD;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
2006-10-10 15:08:17 +01:00
|
|
|
Functor f;
|
|
|
|
Int a;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} xfa;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
struct yami *F;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} xl;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
CELL i[2];
|
|
|
|
CELL next;
|
|
|
|
} xi;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
struct yami *l1;
|
|
|
|
struct yami *l2;
|
|
|
|
CELL next;
|
|
|
|
} xll;
|
|
|
|
struct {
|
|
|
|
wamreg xl;
|
|
|
|
wamreg xr;
|
|
|
|
CELL next;
|
|
|
|
} xx;
|
2009-12-06 00:37:48 +00:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
wamreg xi;
|
|
|
|
Term c;
|
|
|
|
CELL next;
|
|
|
|
} xxc;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
wamreg xi;
|
|
|
|
Int c;
|
|
|
|
CELL next;
|
|
|
|
} xxn;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
|
|
|
CELL next;
|
|
|
|
} xxx;
|
|
|
|
struct {
|
|
|
|
wamreg xl1;
|
|
|
|
wamreg xl2;
|
|
|
|
wamreg xr1;
|
|
|
|
wamreg xr2;
|
|
|
|
CELL next;
|
|
|
|
} xxxx;
|
|
|
|
struct {
|
|
|
|
wamreg x;
|
|
|
|
wamreg x1;
|
2008-08-21 13:38:25 +01:00
|
|
|
yslot y2;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} xxy;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
CELL next;
|
|
|
|
} y;
|
2008-08-30 02:39:36 +01:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
struct pred_entry *p0;
|
2011-02-14 19:29:20 +00:00
|
|
|
COUNT s;
|
2008-08-30 02:39:36 +01:00
|
|
|
CELL next;
|
2011-02-14 19:29:20 +00:00
|
|
|
} yps;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
struct yami *F;
|
|
|
|
CELL next;
|
2008-08-21 13:38:25 +01:00
|
|
|
} yl;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
wamreg x;
|
|
|
|
CELL next;
|
|
|
|
} yx;
|
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
|
|
|
CELL next;
|
|
|
|
} yxx;
|
|
|
|
struct {
|
|
|
|
yslot y1;
|
|
|
|
yslot y2;
|
|
|
|
wamreg x;
|
|
|
|
CELL next;
|
|
|
|
} yyx;
|
2009-03-03 10:04:13 +00:00
|
|
|
struct {
|
|
|
|
yslot y1;
|
|
|
|
yslot y2;
|
|
|
|
wamreg x1;
|
|
|
|
wamreg x2;
|
|
|
|
CELL next;
|
|
|
|
} yyxx;
|
2006-10-10 15:08:17 +01:00
|
|
|
struct {
|
|
|
|
yslot y;
|
|
|
|
yslot y1;
|
|
|
|
yslot y2;
|
|
|
|
CELL next;
|
|
|
|
} yyy;
|
|
|
|
struct {
|
|
|
|
yslot y;
|
2008-10-07 22:32:15 +01:00
|
|
|
wamreg xi;
|
2008-08-30 23:00:50 +01:00
|
|
|
Int c;
|
2006-10-10 15:08:17 +01:00
|
|
|
CELL next;
|
2008-08-30 23:00:50 +01:00
|
|
|
} yxn;
|
2006-10-10 15:08:17 +01:00
|
|
|
} u;
|
2001-04-09 20:54:03 +01:00
|
|
|
} 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 */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-10-10 15:08:17 +01:00
|
|
|
Choice Point Structure
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2006-10-10 15:08:17 +01:00
|
|
|
6 fixed fields (TR,AP,H,B,ENV,CP) plus arguments
|
2001-04-09 20:54:03 +01:00
|
|
|
*/
|
2009-07-03 00:54:39 +01:00
|
|
|
|
|
|
|
#ifdef DETERMINISTIC_TABLING
|
|
|
|
struct deterministic_choicept {
|
|
|
|
yamop *cp_ap;
|
|
|
|
struct choicept *cp_b;
|
|
|
|
tr_fr_ptr cp_tr;
|
|
|
|
#ifdef DEPTH_LIMIT
|
|
|
|
CELL cp_depth;
|
|
|
|
#endif /* DEPTH_LIMIT */
|
|
|
|
#ifdef YAPOR
|
|
|
|
int cp_lub; /* local untried branches */
|
|
|
|
struct or_frame *cp_or_fr; /* or-frame pointer */
|
|
|
|
#endif /* YAPOR */
|
2009-08-09 03:38:07 +01:00
|
|
|
CELL *cp_h; /* necessary, otherwise we get in trouble */
|
2009-07-03 00:54:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct choicept {
|
|
|
|
yamop *cp_ap;
|
|
|
|
struct choicept *cp_b;
|
|
|
|
tr_fr_ptr cp_tr;
|
|
|
|
#ifdef DEPTH_LIMIT
|
|
|
|
CELL cp_depth;
|
|
|
|
#endif /* DEPTH_LIMIT */
|
|
|
|
#ifdef YAPOR
|
|
|
|
int cp_lub; /* local untried branches */
|
|
|
|
struct or_frame *cp_or_fr; /* or-frame pointer */
|
|
|
|
#endif /* YAPOR */
|
|
|
|
CELL *cp_h;
|
|
|
|
yamop *cp_cp;
|
|
|
|
#else
|
2001-04-09 20:54:03 +01:00
|
|
|
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;
|
2009-07-03 00:54:39 +01:00
|
|
|
#endif /* DETERMINISTIC_TABLING */
|
2001-04-09 20:54:03 +01:00
|
|
|
#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]
|
2011-03-15 23:49:28 +00:00
|
|
|
#define cp_a9 cp_args[8]
|
|
|
|
#define cp_a10 cp_args[9]
|
2001-04-09 20:54:03 +01:00
|
|
|
#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)
|
|
|
|
|
2006-10-10 15:08:17 +01:00
|
|
|
#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) \
|
|
|
|
)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2006-10-10 15:08:17 +01:00
|
|
|
#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
|
|
|
/*
|
2006-10-10 15:08:17 +01:00
|
|
|
Environment Structure (CP, E, and CUT_B). Yap always saves the B
|
|
|
|
where to cut to, even if not needed.
|
2001-04-09 20:54:03 +01:00
|
|
|
*/
|
|
|
|
#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))
|
|
|
|
|
2008-08-28 04:37:18 +01:00
|
|
|
static inline
|
|
|
|
CELL *ENV_Parent(CELL *env)
|
|
|
|
{
|
|
|
|
return (CELL *)env[E_E];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
UInt ENV_Size(yamop *cp)
|
|
|
|
{
|
2008-09-05 05:22:19 +01:00
|
|
|
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.s);
|
2008-08-28 04:37:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
struct pred_entry *ENV_ToP(yamop *cp)
|
|
|
|
{
|
2008-09-05 05:22:19 +01:00
|
|
|
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p);
|
2008-08-28 04:37:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
OPCODE ENV_ToOp(yamop *cp)
|
|
|
|
{
|
2008-09-05 05:22:19 +01:00
|
|
|
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->opc);
|
2008-08-28 04:37:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
UInt EnvSize(yamop *cp)
|
|
|
|
{
|
|
|
|
return ((-ENV_Size(cp))/(OPREG)sizeof(CELL));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
CELL *EnvBMap(yamop *p)
|
|
|
|
{
|
2008-09-05 05:22:19 +01:00
|
|
|
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.bmap);
|
2008-08-28 04:37:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
struct pred_entry *EnvPreg(yamop *p)
|
|
|
|
{
|
2008-09-05 05:22:19 +01:00
|
|
|
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p0);
|
2008-08-28 04:37:18 +01:00
|
|
|
}
|
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
|
2006-10-10 15:08:17 +01:00
|
|
|
it should ignore the depth limit
|
2001-04-09 20:54:03 +01:00
|
|
|
*/
|
2010-07-20 11:20:57 +01:00
|
|
|
#define RESET_DEPTH() MkIntTerm(MAX_ABS_INT-1)
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|