YAP 7.1.0
amidefs.h
1/*************************************************************************
2 * *
3 * YAP Prolog @(#)amidefs.h 1.3 3/15/90 *
4 * *
5 * Yap Prolog was developed at NCCUP - Universidade do Porto *
6 * *
7 * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8 * *
9 **************************************************************************
10 * *
11 * File: amidefs.h *
12 * comments: Abstract machine peculiarities *
13 * *
14 * Last rev: $Date: 2008-07-22 23:34:49 $ *
15 * $Log: not supported by cvs2svn $
16 * Revision 1.33 2007/11/26 23:43:09 vsc
17 * fixes to support threads and assert correctly, even if inefficiently.
18 *
19 * Revision 1.32 2006/10/10 14:08:17 vsc
20 * small fixes on threaded implementation.
21 *
22 * Revision 1.31 2006/09/20 20:03:51 vsc
23 * improve indexing on floats
24 * fix sending large lists to DB
25 *
26 * Revision 1.30 2005/12/17 03:25:39 vsc
27 * major changes to support online event-based profiling
28 * improve error discovery and restart on scanner.
29 *
30 * Revision 1.29 2005/07/06 15:10:15 vsc
31 * improvements to compiler: merged instructions and fixes for ->
32 *
33 * Revision 1.28 2005/05/30 06:07:35 vsc
34 * changes to support more tagging schemes from tabulation.
35 *
36 * Revision 1.27 2005/04/10 04:01:13 vsc
37 * bug fixes, I hope!
38 *
39 * Revision 1.26 2004/09/30 21:37:41 vsc
40 * fixes for thread support
41 *
42 * Revision 1.25 2004/09/27 20:45:04 vsc
43 * Mega clauses
44 * Fixes to sizeof(expand_clauses) which was being overestimated
45 * Fixes to profiling+indexing
46 * Fixes to reallocation of memory after restoring
47 * Make sure all clauses, even for C, end in _Ystop
48 * Don't reuse space for Streams
49 * Fix Stream_F on StreaNo+1
50 *
51 * Revision 1.24 2004/04/14 19:10:40 vsc
52 * expand_clauses: keep a list of clauses to expand
53 * fix new trail scheme for multi-assignment variables
54 *
55 * Revision 1.23 2004/03/31 01:03:10 vsc
56 * support expand group of clauses
57 *
58 * Revision 1.22 2004/03/10 14:59:55 vsc
59 * optimise -> for type tests
60 * *
61 * *
62 *************************************************************************/
63
64#ifndef AMIDEFS_H
65
66#define AMIDEFS_H 1
67
68#ifndef NULL
69#include <stdio.h>
70#endif
71
72#if ALIGN_LONGS
73/* */ typedef Int DISPREG;
74/* */ typedef CELL SMALLUNSGN;
75/* */ typedef Int OPREG;
76/* */ typedef CELL UOPREG;
77
78#else
79/* */ typedef Short DISPREG;
80/* */ typedef BITS16 SMALLUNSGN;
81/* */ typedef SBITS16 OPREG;
82/* */ typedef SBITS16 UOPREG;
83
84#endif
85
86#if THREADS
87
88typedef struct regstore_t *regstruct_ptr;
89
90#define CACHE_TYPE1 regstruct_ptr
91#define CACHE_TYPE , regstruct_ptr
92
93#else
94
95#define CACHE_TYPE
96#define CACHE_TYPE1 void
97
98#endif
99
100typedef Int (*CPredicate)(CACHE_TYPE1);
101
102typedef Int (*CmpPredicate)(Term, Term);
103
104#define OpRegSize sizeof(OPREG)
105
106/*
107 Possible arguments to YAP emulator:
108 wamreg describes an A or X register;
109 yslot describes an Y slot
110 COUNT is a small number (eg, number of arguments to a choicepoint,
111 number of permanent variables in a environment
112*/
113
114typedef OPREG wamreg;
115typedef OPREG yslot;
116typedef OPREG COUNT;
117/*
118 This is a table with the codes for YAP instructions
119*/
120typedef enum {
121#define OPCODE(OP,TYPE) _##OP
122#include "YapOpcodes.h"
123#undef OPCODE
124} op_numbers;
125
126#define _std_top _or_last
127
128/* use similar trick for keeping instruction names */
129#if defined(ANALYST) || defined(DEBUG)
130extern char *Yap_op_names[_std_top + 1];
131#endif
132
133typedef enum {
134 _atom,
135 _atomic,
136 _integer,
137 _compound,
138 _float,
139 _nonvar,
140 _number,
141 _var,
142 _cut_by,
143 _soft_cut_by,
144 _save_by,
145 _db_ref,
146 _primitive,
147 _dif,
148 _eq,
149 _equal,
150 _plus,
151 _minus,
152 _times,
153 _div,
154 _and,
155 _or,
156 _sll,
157 _slr,
158 _arg,
159 _functor,
160 _p_put_fi,
161 _p_put_i,
162 _p_put_f,
163 _p_a_eq_float,
164 _p_a_eq_int,
165 _p_a_eq,
166 _p_ltc_float,
167 _p_ltc_int,
168 _p_lt,
169 _p_gtc_float,
170 _p_gtc_int,
171 _p_get_fi,
172 _p_get_i,
173 _p_get_f,
174 _p_add_float_c,
175 _p_add_int_c,
176 _p_add,
177 _p_sub_float_c,
178 _p_sub_int_c,
179 _p_sub,
180 _p_mul_float_c,
181 _p_mul_int_c,
182 _p_mul,
183 _p_fdiv_c1,
184 _p_fdiv_c2,
185 _p_fdiv,
186 _p_idiv_c1,
187 _p_idiv_c2,
188 _p_idiv,
189 _p_mod_c1,
190 _p_mod_c2,
191 _p_mod,
192 _p_rem_c1,
193 _p_rem_c2,
194 _p_rem,
195 _p_land_c,
196 _p_land,
197 _p_lor_c,
198 _p_lor,
199 _p_xor_c,
200 _p_xor,
201 _p_uminus,
202 _p_sr_c1,
203 _p_sr_c2,
204 _p_sr,
205 _p_sl_c1,
206 _p_sl_c2,
207 _p_sl,
208 _p_label_ctl
209} basic_preds;
210
211#if USE_THREADED_CODE
212
213#if ALIGN_LONGS
214/* */ typedef CELL OPCODE;
215#else
216
217#if LOW_ABSMI
218/* */ typedef BITS16 OPCODE;
219#else
220/* */ typedef CELL OPCODE;
221#endif
222#endif /* ALIGN_LONGS */
223#else /* if does not USE_THREADED_CODE */
224/* */ typedef op_numbers OPCODE;
225#endif
226#define OpCodeSize sizeof(OPCODE)
227
228/*
229
230 Types of possible YAAM instructions.
231
232 The meaning and type of the symbols in a abstract machine instruction is:
233
234 A: Atom
235 b: arity (Int)
236 b: bitmap (CELL *)
237 c: constant, is a Term
238 d: double (functor + unaligned double)
239 f: functor
240 F: Function, CPredicate
241 J: JIT interface
242 i: large integer (functor + long)
243 I: logic upd index (struct logic_upd_index *)
244 l: label, yamop *
245 L: logic upd clause, logic_upd_clause *
246 m: module, Term
247 n: number, Integer
248 N: bigint, Blob (Term)
249 o: opcode, OPCODE
250 O: OR-parallel information, used by YAPOR, unsigned int
251 p: predicate, struct pred_entry *
252 s: small integer, COUNT
253 t: pointer to table entry, used by yaptab, struct table_entry *
254 u: utf-8 string
255 x: wam register, wamreg
256 y: environment slot
257
258*/
259/* This declaration is going to be parsed by a Prolog program, so:
260 comments are welcome, but they should take a whole line,
261 every field declaration should also take a single line,
262 please check the Prolog program if you come up with a complicated C-type that does not start by unsigned or struct.
263*/
264typedef struct yami {
265 OPCODE opc;
266#if YAP_JIT
267 CELL next_native_r;
268 CELL next_native_w;
269#endif
270 union {
271 struct {
272 CELL next;
273 } e;
274 struct {
275 Term c;
276 CELL next;
277 } c;
278 struct {
279 Term D;
280 CELL next;
281 } D;
282 struct {
283 Term b;
284 CELL next;
285 } N;
286 struct {
287 Term c1;
288 Term c2;
289 CELL next;
290 } cc;
291 struct {
292 Term c1;
293 Term c2;
294 Term c3;
295 CELL next;
296 } ccc;
297 struct {
298 Term c1;
299 Term c2;
300 Term c3;
301 Term c4;
302 CELL next;
303 } cccc;
304 struct {
305 Term c1;
306 Term c2;
307 Term c3;
308 Term c4;
309 Term c5;
310 CELL next;
311 } ccccc;
312 struct {
313 Term c1;
314 Term c2;
315 Term c3;
316 Term c4;
317 Term c5;
318 Term c6;
319 CELL next;
320 } cccccc;
321 struct {
322 Term c;
323 struct yami *l1;
324 struct yami *l2;
325 struct yami *l3;
326 CELL next;
327 } clll;
328 struct {
329 CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
330 CELL next;
331 } d;
332 struct {
333 struct logic_upd_clause *ClBase;
334 CELL next;
335 } L;
336 struct {
337 Functor f;
338 Int a;
339 CELL next;
340 } fa;
341 struct {
342 CELL i[2];
343 CELL next;
344 } i;
345 struct {
346 struct logic_upd_index *I;
347 struct yami *l1;
348 struct yami *l2;
349 COUNT s;
350 COUNT e;
351 CELL next;
352 } Illss;
353 struct {
354 struct yami *l;
355 CELL next;
356 } l;
357 struct {
358#ifdef YAPOR
359 unsigned int or_arg;
360#endif /* YAPOR */
361#ifdef TABLING
362 struct table_entry *te; /* pointer to table entry */
363#endif /* TABLING */
364 Int s;
365 struct pred_entry *p;
366 struct yami *d;
367 CELL next;
368 } Otapl;
369 struct {
370 /* jit_handler */
371#if YAP_JIT
372 struct jit_handl_context *jh;
373#endif
374 CELL next;
375 } J;
376 /* The next two instructions are twin: they both correspond to the old ldd. */
377 /* The first one, aLl, handles try_logical and retry_logical, */
378 /* Ill handles trust_logical. */
379 /* They must have the same fields. */
380
381 struct {
382#ifdef YAPOR
383 unsigned int or_arg;
384#endif /* YAPOR */
385#ifdef TABLING
386 /* pointer to table entry */
387 struct table_entry *te;
388#endif
389 /* number of arguments */
390 COUNT s;
391 struct logic_upd_clause *d;
392 struct yami *n;
393 CELL next;
394 } OtaLl;
395 struct {
396#ifdef YAPOR
397 unsigned int or_arg;
398#endif
399#ifdef TABLING
400 /* pointer to table entry */
401 struct table_entry *te;
402#endif /* TABLING */
403 /* number of arguments */
404 struct logic_upd_index *block;
405 struct logic_upd_clause *d;
406 struct yami *n;
407 CELL next;
408 } OtILl;
409 struct {
410#ifdef YAPOR
411 unsigned int or_arg;
412#endif
413#ifdef TABLING
414 /* pointer to table entry */
415 struct table_entry *te;
416#endif
417 Int s;
418 struct pred_entry *p;
419 CPredicate f;
420 COUNT extra;
421 CELL next;
422 } OtapFs;
423 struct {
424 struct yami *l1;
425 struct yami *l2;
426 struct yami *l3;
427 CELL next;
428 } lll;
429 struct {
430 struct yami *l1;
431 struct yami *l2;
432 struct yami *l3;
433 struct yami *l4;
434 CELL next;
435 } llll;
436 struct {
437 wamreg x;
438 struct yami *l1;
439 struct yami *l2;
440 struct yami *l3;
441 struct yami *l4;
442 CELL next;
443 } xllll;
444 struct {
445 COUNT s;
446 struct yami *l1;
447 struct yami *l2;
448 struct yami *l3;
449 struct yami *l4;
450 CELL next;
451 } sllll;
452 struct {
453 struct pred_entry *p;
454 struct yami *f;
455 wamreg x1;
456 wamreg x2;
457 COUNT flags;
458 CELL next;
459 } plxxs;
460 struct {
461 struct pred_entry *p;
462 struct yami *f;
463 wamreg x;
464 yslot y;
465 COUNT flags;
466 CELL next;
467 } plxys;
468 struct {
469 struct pred_entry *p;
470 struct yami *f;
471 wamreg y1;
472 yslot y2;
473 COUNT flags;
474 CELL next;
475 } plyys;
476 struct {
477 OPCODE pop;
478 struct yami *l1;
479 struct yami *l2;
480 struct yami *l3;
481 struct yami *l4;
482 CELL next;
483 } ollll;
484 struct {
485 Int i;
486 struct pred_entry *p;
487 CELL next;
488 } ip;
489 struct {
490 struct yami *l;
491 struct pred_entry *p;
492 CELL next;
493 } lp;
494 struct {
495 OPCODE opcw;
496 CELL next;
497 } o;
498 struct {
499 OPCODE opcw;
500 Term c;
501 CELL next;
502 } oc;
503 struct {
504 OPCODE opcw;
505 Term b;
506 CELL next;
507 } oN;
508 struct {
509 OPCODE opcw;
510 CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
511 CELL next;
512 } od;
513 struct {
514 OPCODE opcw;
515 Term D;
516 CELL next;
517 } oD;
518 struct {
519 OPCODE opcw;
520 Functor f;
521 Int a;
522 CELL next;
523 } ofa;
524 struct {
525 OPCODE opcw;
526 CELL i[2];
527 CELL next;
528 } oi;
529 struct {
530 OPCODE opcw;
531 COUNT s;
532 CELL c;
533 CELL next;
534 } osc;
535 struct {
536 OPCODE opcw;
537 COUNT s;
538 CELL next;
539 } os;
540 struct {
541 OPCODE opcw;
542 Term ut;
543 CELL next;
544 } ou;
545 struct {
546 OPCODE opcw;
547 wamreg x;
548 CELL next;
549 } ox;
550 struct {
551 OPCODE opcw;
552 wamreg xl;
553 wamreg xr;
554 CELL next;
555 } oxx;
556 struct {
557 OPCODE opcw;
558 yslot y;
559 CELL next;
560 } oy;
561 struct {
562 struct pred_entry *p;
563 CELL next;
564 } p;
565 struct {
566 COUNT s;
567 CELL next;
568 } s;
569 /* format of expand_clauses */
570 struct {
571 COUNT s1;
572 COUNT s2;
573 COUNT s3;
574 struct yami *sprev;
575 struct yami *snext;
576 struct pred_entry *p;
577 CELL next;
578 } sssllp;
579 struct {
580 COUNT s;
581 CELL c;
582 CELL next;
583 } sc;
584 struct {
585 COUNT s;
586 CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
587 struct yami *F;
588 struct yami *T;
589 CELL next;
590 } sdll;
591 struct {
592 COUNT s;
593 struct yami *l;
594 struct pred_entry *p;
595 struct pred_entry *p0;
596 CELL next;
597 } slpp;
598 struct {
599 COUNT s;
600 Int I;
601 struct yami *F;
602 struct yami *T;
603 CELL next;
604 } snll;
605 struct {
606 COUNT s0;
607 COUNT s1;
608 CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
609 CELL next;
610 } ssd;
611 struct {
612 COUNT s0;
613 COUNT s1;
614 Int n;
615 CELL next;
616 } ssn;
617 struct {
618 COUNT s0;
619 COUNT s1;
620 COUNT s2;
621 CELL next;
622 } sss;
623 struct {
624 COUNT s1;
625 COUNT s2;
626 struct yami *F;
627 struct yami *T;
628 CELL next;
629 } ssll;
630 struct {
631 COUNT s;
632 wamreg x;
633 struct yami *l;
634 CELL next;
635 } sxl;
636 struct {
637 COUNT s;
638 wamreg x;
639 struct yami *F;
640 struct yami *T;
641 CELL next;
642 } sxll;
643 struct {
644 COUNT s;
645 yslot y;
646 struct yami *l;
647 CELL next;
648 } syl;
649 struct {
650 COUNT s;
651 yslot y;
652 struct yami *F;
653 struct yami *T;
654 CELL next;
655 } syll;
656 /* the next 3 instructions must have same size and have fields in same order! */
657 /* also check env for yes and trustfail code before making any changes */
658 /* last, Osblp is known to the buildops script */
659 struct {
660#ifdef YAPOR
661 unsigned int or_arg;
662#endif
663 COUNT s;
664 CELL *bmap;
665 struct yami *l;
666 struct pred_entry *p0;
667 CELL next;
668 } Osblp;
669 struct {
670#ifdef YAPOR
671 unsigned int or_arg;
672#endif
673 COUNT s;
674 CELL *bmap;
675 struct pred_entry *p;
676 Int i;
677 CELL next;
678 } Osbpa;
679 struct {
680#ifdef YAPOR
681 unsigned int or_arg;
682#endif
683 COUNT s;
684 CELL *bmap;
685 struct pred_entry *p;
686 struct pred_entry *p0;
687 CELL next;
688 } Osbpp;
689 struct {
690#ifdef YAPOR
691 unsigned int or_arg;
692#endif
693 COUNT s;
694 CELL *bmap;
695 Term mod;
696 struct pred_entry *p0;
697 CELL next;
698 } Osbmp;
699 struct {
700 /* size of table */
701 COUNT s;
702 /* live entries */
703 COUNT e;
704 /* pending suspended blocks */
705 COUNT w;
706 struct yami *l;
707 CELL next;
708 } sssl;
709 struct {
710 wamreg x;
711 CELL next;
712 } x;
713 struct {
714 wamreg x;
715 struct pred_entry *p0;
716 COUNT s;
717 CELL next;
718 } xps;
719 struct {
720 wamreg x;
721 CELL c;
722 CELL next;
723 } xc;
724 struct {
725 wamreg x;
726 Term b;
727 CELL next;
728 } xN;
729 struct {
730 wamreg x;
731 CELL d[1+SIZEOF_DOUBLE/SIZEOF_INT_P];
732 CELL next;
733 } xd;
734 struct {
735 wamreg x;
736 Term D;
737 CELL next;
738 } xD;
739 struct {
740 wamreg x;
741 Functor f;
742 Int a;
743 CELL next;
744 } xfa;
745 struct {
746 wamreg x;
747 struct yami *F;
748 CELL next;
749 } xl;
750 struct {
751 wamreg x;
752 CELL i[2];
753 CELL next;
754 } xi;
755 struct {
756 wamreg x;
757 struct yami *l1;
758 struct yami *l2;
759 CELL next;
760 } xll;
761 struct {
762 wamreg xl;
763 wamreg xr;
764 CELL next;
765 } xx;
766 struct {
767 wamreg x;
768 Term ut;
769 CELL next;
770 } xu;
771 struct {
772 wamreg x;
773 wamreg xi;
774 Term c;
775 CELL next;
776 } xxc;
777 struct {
778 wamreg x;
779 wamreg xi;
780 Int c;
781 CELL next;
782 } xxn;
783 struct {
784 wamreg x;
785 wamreg x1;
786 wamreg x2;
787 CELL next;
788 } xxx;
789 struct {
790 wamreg xl1;
791 wamreg xl2;
792 wamreg xr1;
793 wamreg xr2;
794 CELL next;
795 } xxxx;
796 struct {
797 wamreg x;
798 wamreg x1;
799 yslot y2;
800 CELL next;
801 } xxy;
802 struct {
803 yslot y;
804 CELL next;
805 } y;
806 struct {
807 yslot y;
808 struct pred_entry *p0;
809 COUNT s;
810 CELL next;
811 } yps;
812 struct {
813 yslot y;
814 struct yami *F;
815 CELL next;
816 } yl;
817 struct {
818 yslot y;
819 wamreg x;
820 CELL next;
821 } yx;
822 struct {
823 yslot y;
824 wamreg x1;
825 wamreg x2;
826 CELL next;
827 } yxx;
828 struct {
829 yslot y1;
830 yslot y2;
831 wamreg x;
832 CELL next;
833 } yyx;
834 struct {
835 yslot y1;
836 yslot y2;
837 wamreg x1;
838 wamreg x2;
839 CELL next;
840 } yyxx;
841 struct {
842 yslot y;
843 yslot y1;
844 yslot y2;
845 CELL next;
846 } yyy;
847 struct {
848 yslot y;
849 wamreg xi;
850 Int c;
851 CELL next;
852 } yxn;
853 struct {
854 yslot y;
855 wamreg xi;
856 Term c;
857 CELL next;
858 } yxc;
859 } y_u;
860} yamop;
861
862typedef yamop yamopp;
863
864#define OPCR opc
865#define OPCW u.ox.opcw
866
867
868#define NEXTOP(V,TYPE) ((yamop *)(&((V)->y_u.TYPE.next)))
869
870#define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE)))
871
872#if defined(TABLING) || defined(YAPOR_SBA)
873typedef struct trail_frame {
874 Term term;
875 CELL value;
876} *tr_fr_ptr;
877
878#define TrailTerm(X) ((X)->term)
879#define TrailVal(X) ((X)->value)
880#else
881typedef Term *tr_fr_ptr;
882
883#define TrailTerm(X) (*(X))
884#define TrailVal(X) OOOOOOPS: this program should not compile
885#endif /* TABLING || YAPOR_SBA */
886
887
888/*
889 Choice Point Structure
890
891 6 fixed fields (TR,AP,H,B,ENV,CP) plus arguments
892*/
893
894#ifdef DETERMINISTIC_TABLING
895struct deterministic_choicept {
896 yamop *cp_ap;
897 struct choicept *cp_b;
898 tr_fr_ptr cp_tr;
899#ifdef DEPTH_LIMIT
900 CELL cp_depth;
901#endif /* DEPTH_LIMIT */
902#ifdef YAPOR
903 int cp_lub; /* local untried branches */
904 struct or_frame *cp_or_fr; /* or-frame pointer */
905#endif /* YAPOR */
906 CELL *cp_h; /* necessary, otherwise we get in trouble */
907};
908
909typedef struct choicept {
910 yamop *cp_ap;
911 struct choicept *cp_b;
912 tr_fr_ptr cp_tr;
913#ifdef DEPTH_LIMIT
914 CELL cp_depth;
915#endif /* DEPTH_LIMIT */
916#ifdef YAPOR
917 int cp_lub; /* local untried branches */
918 struct or_frame *cp_or_fr; /* or-frame pointer */
919#endif /* YAPOR */
920 CELL *cp_h;
921 yamop *cp_cp;
922#else
923typedef struct choicept {
924 tr_fr_ptr cp_tr;
925 CELL *cp_h;
926 struct choicept *cp_b;
927#ifdef DEPTH_LIMIT
928 CELL cp_depth;
929#endif /* DEPTH_LIMIT */
930 yamop *cp_cp;
931#ifdef YAPOR
932 int cp_lub; /* local untried branches */
933 struct or_frame *cp_or_fr; /* or-frame pointer */
934#endif /* YAPOR */
935 yamop *cp_ap;
936#endif /* DETERMINISTIC_TABLING */
937#if MIN_ARRAY == 0
938 CELL *cp_env;
939 /* GNUCC understands empty arrays */
940 CELL cp_args[MIN_ARRAY];
941#else
942 /* Otherwise, we need a very dirty trick to access the arguments */
943 union {
944 CELL *cp_uenv;
945 CELL cp_xargs[1];
946 } cp_last;
947#define cp_env cp_last.cp_uenv
948#define cp_args cp_last.cp_xargs
949#endif
950#define cp_a1 cp_args[0]
951#define cp_a2 cp_args[1]
952#define cp_a3 cp_args[2]
953#define cp_a4 cp_args[3]
954#define cp_a5 cp_args[4]
955#define cp_a6 cp_args[5]
956#define cp_a7 cp_args[6]
957#define cp_a8 cp_args[7]
958#define cp_a9 cp_args[8]
959#define cp_a10 cp_args[9]
960#define EXTRA_CBACK_ARG(Arity,Offset) B->cp_args[(Arity)+(Offset)-1]
961} *choiceptr;
962
963/* This has problems with \+ \+ a, !, b. */
964#define SHOULD_CUT_UP_TO(X,Y) ((X) != (Y))
965/* #define SHOULD_CUT_UP_TO(X,Y) ((X) (Y)) */
966
967#ifdef YAPOR_SBA
968#define SHARED_CP(CP) ((CP) >= B_FZ || (CP) < (choiceptr)H_FZ)
969
970#define YOUNGER_CP(CP1, CP2) \
971 (SHARED_CP(CP1) ? \
972 (SHARED_CP(CP2) ? OrFr_depth((CP1)->cp_or_fr) > OrFr_depth((CP2)->cp_or_fr) : FALSE) \
973 : \
974 (SHARED_CP(CP2) ? TRUE : CP1 < CP2) \
975 )
976
977#define EQUAL_OR_YOUNGER_CP(CP1, CP2) \
978 (SHARED_CP(CP1) ? \
979 (SHARED_CP(CP2) ? OrFr_depth((CP1)->cp_or_fr) >= OrFr_depth((CP2)->cp_or_fr) : FALSE) \
980 : \
981 (SHARED_CP(CP2) ? TRUE : CP1 <= CP2) \
982 )
983
984#define YOUNGER_H(H1, H2) FIXMEE!!!!
985
986
987#else /* YAPOR_COPY || YAPOR_COW */
988#define YOUNGER_CP(CP1, CP2) ((CP1) < (CP2))
989#define EQUAL_OR_YOUNGER_CP(CP1, CP2) ((CP1) <= (CP2))
990
991#define YOUNGER_H(H1, H2) ((CELL *)(H1) > (CELL *)(H2))
992
993#endif /* YAPOR_SBA */
994
995#define YOUNGEST_CP(CP1, CP2) (YOUNGER_CP(CP1,CP2) ? (CP1) : (CP2))
996
997#define YOUNGEST_H(H1, H2) (YOUNGER_H(H1,H2) ? (CELL *)(H1) : (CELL *)(H2))
998
999
1000
1001/*
1002 Environment Structure (CP, E, and CUT_B). Yap always saves the B
1003 where to cut to, even if not needed.
1004*/
1005#define E_CP -1
1006#define E_E -2
1007#define E_CB -3
1008#ifdef TABLING
1009#define E_B -4
1010#ifdef DEPTH_LIMIT
1011#define E_DEPTH -5
1012#define EnvSizeInCells 5
1013#else
1014#define EnvSizeInCells 4
1015#endif /* DEPTH_LIMIT */
1016#else /* TABLING */
1017#ifdef DEPTH_LIMIT
1018#define E_DEPTH -4
1019#define EnvSizeInCells 4
1020#else
1021#define EnvSizeInCells 3
1022#endif /* DEPTH_LIMIT */
1023#endif /* TABLING */
1024
1025#if MSHIFTOFFS
1026#define FixedEnvSize EnvSizeInCells
1027#else
1028#define FixedEnvSize (EnvSizeInCells*sizeof(CELL))
1029#endif
1030
1031#define RealEnvSize (EnvSizeInCells*sizeof(CELL))
1032
1033static inline
1034CELL *ENV_Parent(CELL *env)
1035{
1036 return (CELL *)env[E_E];
1037}
1038
1039static inline
1040Int ENV_Size(yamop *cp)
1041{
1042 Int sz = ((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.s;
1043 return sz==0 ? EnvSizeInCells : sz;
1044}
1045
1046static inline
1047struct pred_entry *ENV_ToP(yamop *cp)
1048{
1049 return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p);
1050}
1051
1052static inline
1053OPCODE ENV_ToOp(yamop *cp)
1054{
1055 return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->opc);
1056}
1057
1058static inline
1059int64_t EnvSize(yamop *cp)
1060{
1061 return (-ENV_Size(cp)/sizeof(CELL));
1062}
1063
1064static inline
1065CELL *EnvBMap(yamop *p)
1066{
1067 return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
1068}
1069
1070static inline
1071struct pred_entry *EnvPreg(yamop *p)
1072{
1073 return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p0);
1074}
1075
1076/* access to instructions */
1077
1078#if USE_THREADED_CODE
1079extern void **Yap_ABSMI_OPCODES;
1080
1081#define absmadr(i) ((OPCODE)(Yap_ABSMI_OPCODES[(i)]))
1082#else
1083#define absmadr(i) ((OPCODE)(i))
1084#endif
1085
1086 bool is_cleanup_cp(choiceptr cp_b);
1087
1088#if DEPTH_LIMIT
1089/*
1090 Make this into an even number so that the system will know
1091 it should ignore the depth limit
1092*/
1093#define RESET_DEPTH() MkIntTerm(MAX_ABS_INT-1)
1094#else
1095
1096#endif
1097
1098typedef enum {
1099DEBUG_CREEP_LEAP_OR_ZIP = 0,
1100DEBUG_GOAL_NUMBER = 1,
1101DEBUG_SPY = 2,
1102DEBUG_TRACE = 3,
1103DEBUG_DEBUG = 4,
1104DEBUG_NUMBER_OF_OPTS = 5
1105} debug_key_t ;
1106
1107
1108#endif
1109
If you like being short, use T instead of YapTerm.
Definition: yapt.hh:266
Definition: Yatom.h:544
Definition: tab.structs.h:22
Definition: amidefs.h:264