2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: amasm.c *
|
|
|
|
* comments: abstract machine assembler *
|
|
|
|
* *
|
2008-08-12 02:27:23 +01:00
|
|
|
* Last rev: $Date: 2008-08-12 01:27:22 $ *
|
2004-03-31 02:03:10 +01:00
|
|
|
* $Log: not supported by cvs2svn $
|
2008-08-12 02:27:23 +01:00
|
|
|
* Revision 1.103 2008/08/07 20:51:16 vsc
|
|
|
|
* more threadin fixes
|
|
|
|
*
|
2008-08-07 21:51:23 +01:00
|
|
|
* Revision 1.102 2008/07/11 17:02:07 vsc
|
|
|
|
* fixes by Bart and Tom: mostly libraries but nasty one in indexing
|
|
|
|
* compilation.
|
|
|
|
*
|
2008-07-11 18:02:10 +01:00
|
|
|
* Revision 1.101 2008/04/01 22:28:41 vsc
|
|
|
|
* put YAPOR back to life.
|
|
|
|
*
|
2008-04-01 23:28:41 +01:00
|
|
|
* Revision 1.100 2008/03/25 16:45:52 vsc
|
|
|
|
* make or-parallelism compile again
|
|
|
|
*
|
2008-03-25 16:45:53 +00:00
|
|
|
* Revision 1.99 2008/01/23 17:57:44 vsc
|
|
|
|
* valgrind it!
|
|
|
|
* enable atom garbage collection.
|
|
|
|
*
|
2008-01-23 17:57:56 +00:00
|
|
|
* Revision 1.98 2007/11/26 23:43:07 vsc
|
|
|
|
* fixes to support threads and assert correctly, even if inefficiently.
|
|
|
|
*
|
2007-11-26 23:43:10 +00:00
|
|
|
* Revision 1.97 2007/11/07 09:25:27 vsc
|
|
|
|
* speedup meta-calls
|
|
|
|
*
|
2007-11-07 09:25:27 +00:00
|
|
|
* Revision 1.96 2007/11/06 17:02:09 vsc
|
|
|
|
* compile ground terms away.
|
|
|
|
*
|
2007-11-06 17:02:13 +00:00
|
|
|
* Revision 1.95 2007/06/23 17:31:50 vsc
|
|
|
|
* pin cluses with floats.
|
|
|
|
*
|
2007-06-23 18:31:50 +01:00
|
|
|
* Revision 1.94 2006/12/27 01:32:37 vsc
|
|
|
|
* diverse fixes
|
|
|
|
*
|
2006-12-27 01:32:38 +00:00
|
|
|
* Revision 1.93 2006/12/13 16:10:14 vsc
|
|
|
|
* several debugger and CLP(BN) improvements.
|
|
|
|
*
|
2006-12-13 16:10:26 +00:00
|
|
|
* Revision 1.92 2006/11/15 00:13:36 vsc
|
|
|
|
* fixes for indexing code.
|
|
|
|
*
|
2006-11-15 00:13:37 +00:00
|
|
|
* Revision 1.91 2006/11/06 18:35:03 vsc
|
|
|
|
* 1estranha
|
|
|
|
*
|
2006-11-06 18:35:05 +00:00
|
|
|
* Revision 1.90 2006/10/11 14:53:57 vsc
|
|
|
|
* fix memory leak
|
|
|
|
* fix overflow handling
|
|
|
|
* VS: ----------------------------------------------------------------------
|
|
|
|
*
|
2006-10-11 15:53:57 +01:00
|
|
|
* Revision 1.89 2006/10/10 14:08:16 vsc
|
|
|
|
* small fixes on threaded implementation.
|
|
|
|
*
|
2006-10-10 15:08:17 +01:00
|
|
|
* Revision 1.88 2006/09/20 20:03:51 vsc
|
|
|
|
* improve indexing on floats
|
|
|
|
* fix sending large lists to DB
|
|
|
|
*
|
2006-09-20 21:03:51 +01:00
|
|
|
* Revision 1.87 2006/03/24 17:13:41 rslopes
|
|
|
|
* New update to BEAM engine.
|
|
|
|
* BEAM now uses YAP Indexing (JITI)
|
|
|
|
*
|
2006-03-24 17:13:41 +00:00
|
|
|
* Revision 1.86 2006/01/02 02:16:17 vsc
|
|
|
|
* support new interface between YAP and GMP, so that we don't rely on our own
|
|
|
|
* allocation routines.
|
|
|
|
* Several big fixes.
|
|
|
|
*
|
2006-01-02 02:16:19 +00:00
|
|
|
* Revision 1.85 2005/12/17 03:25:39 vsc
|
|
|
|
* major changes to support online event-based profiling
|
|
|
|
* improve error discovery and restart on scanner.
|
|
|
|
*
|
2005-12-17 03:25:39 +00:00
|
|
|
* Revision 1.84 2005/09/08 22:06:44 rslopes
|
|
|
|
* BEAM for YAP update...
|
|
|
|
*
|
2005-09-08 23:06:45 +01:00
|
|
|
* Revision 1.83 2005/08/02 03:09:49 vsc
|
|
|
|
* fix debugger to do well nonsource predicates.
|
|
|
|
*
|
2005-08-02 04:09:52 +01:00
|
|
|
* Revision 1.82 2005/07/06 15:10:02 vsc
|
|
|
|
* improvements to compiler: merged instructions and fixes for ->
|
|
|
|
*
|
2005-07-06 16:10:18 +01:00
|
|
|
* Revision 1.81 2005/06/01 21:23:44 vsc
|
|
|
|
* inline compare
|
|
|
|
*
|
2005-06-01 22:23:44 +01:00
|
|
|
* Revision 1.80 2005/06/01 20:25:23 vsc
|
|
|
|
* == and \= should not need a choice-point in ->
|
|
|
|
*
|
2005-06-01 21:25:23 +01:00
|
|
|
* Revision 1.79 2005/06/01 16:42:30 vsc
|
|
|
|
* put switch_list_nl back
|
|
|
|
*
|
2005-06-01 17:42:30 +01:00
|
|
|
* Revision 1.78 2005/06/01 14:02:47 vsc
|
|
|
|
* get_rid of try_me?, retry_me? and trust_me? instructions: they are not
|
|
|
|
* significantly used nowadays.
|
|
|
|
*
|
2005-06-01 15:02:52 +01:00
|
|
|
* Revision 1.77 2005/05/31 19:42:27 vsc
|
|
|
|
* insert some more slack for indices in LU
|
|
|
|
* Use doubly linked list for LU indices so that updating is less cumbersome.
|
|
|
|
*
|
2005-05-31 20:42:28 +01:00
|
|
|
* Revision 1.76 2005/05/30 05:33:43 vsc
|
|
|
|
* get rid of annoying debugging message.
|
|
|
|
*
|
2005-05-30 06:33:43 +01:00
|
|
|
* Revision 1.75 2005/05/30 05:26:49 vsc
|
|
|
|
* fix tabling
|
|
|
|
* allow atom gc again for now.
|
|
|
|
*
|
2005-05-30 06:26:50 +01:00
|
|
|
* Revision 1.74 2005/05/25 21:43:32 vsc
|
|
|
|
* fix compiler bug in 1 << X, found by Nuno Fonseca.
|
|
|
|
* compiler internal errors get their own message.
|
|
|
|
*
|
2005-05-25 22:43:33 +01:00
|
|
|
* Revision 1.73 2005/04/10 04:01:09 vsc
|
|
|
|
* bug fixes, I hope!
|
|
|
|
*
|
2005-04-10 05:01:15 +01:00
|
|
|
* Revision 1.72 2005/03/04 20:30:10 ricroc
|
|
|
|
* bug fixes for YapTab support
|
|
|
|
*
|
2005-03-04 20:30:14 +00:00
|
|
|
* Revision 1.71 2005/01/28 23:14:34 vsc
|
|
|
|
* move to Yap-4.5.7
|
|
|
|
* Fix clause size
|
|
|
|
*
|
2005-01-28 23:14:41 +00:00
|
|
|
* Revision 1.70 2004/12/28 22:20:35 vsc
|
|
|
|
* some extra bug fixes for trail overflows: some cannot be recovered that easily,
|
|
|
|
* some can.
|
|
|
|
*
|
2004-12-28 22:20:37 +00:00
|
|
|
* Revision 1.69 2004/12/20 21:44:56 vsc
|
|
|
|
* more fixes to CLPBN
|
|
|
|
* fix some Yap overflows.
|
|
|
|
*
|
2004-12-20 21:44:58 +00:00
|
|
|
* Revision 1.68 2004/12/07 16:54:57 vsc
|
|
|
|
* fix memory overflow
|
|
|
|
*
|
2004-12-07 16:54:58 +00:00
|
|
|
* Revision 1.67 2004/12/05 05:01:23 vsc
|
|
|
|
* try to reduce overheads when running with goal expansion enabled.
|
|
|
|
* CLPBN fixes
|
|
|
|
* Handle overflows when allocating big clauses properly.
|
|
|
|
*
|
2004-12-05 05:01:45 +00:00
|
|
|
* Revision 1.66 2004/11/19 22:08:41 vsc
|
|
|
|
* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate.
|
|
|
|
*
|
2004-11-19 22:08:43 +00:00
|
|
|
* Revision 1.65 2004/10/26 20:15:48 vsc
|
|
|
|
* More bug fixes for overflow handling
|
|
|
|
*
|
2004-10-26 21:16:18 +01:00
|
|
|
* Revision 1.64 2004/09/30 21:37:40 vsc
|
|
|
|
* fixes for thread support
|
|
|
|
*
|
2004-09-30 22:37:41 +01:00
|
|
|
* Revision 1.63 2004/09/27 20:45:02 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.62 2004/08/20 16:16:23 vsc
|
|
|
|
* growheap was not checking some compiler instructions
|
|
|
|
* source was getting confused in reconsult
|
|
|
|
*
|
2004-08-20 17:16:23 +01:00
|
|
|
* Revision 1.61 2004/04/29 03:45:50 vsc
|
|
|
|
* fix garbage collection in execute_tail
|
|
|
|
*
|
2004-04-29 04:45:50 +01:00
|
|
|
* Revision 1.60 2004/04/22 20:07:04 vsc
|
|
|
|
* more fixes for USE_SYSTEM_MEMORY
|
|
|
|
*
|
2004-04-22 21:07:07 +01:00
|
|
|
* Revision 1.59 2004/03/31 01:03:09 vsc
|
|
|
|
* support expand group of clauses
|
|
|
|
*
|
2004-03-31 02:03:10 +01:00
|
|
|
* Revision 1.58 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
|
|
|
*************************************************************************/
|
|
|
|
#ifdef SCCS
|
|
|
|
static char SccsId[] = "@(#)amasm.c 1.3 3/15/90";
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Yap.h"
|
|
|
|
#include "yapio.h"
|
|
|
|
#include "compile.h"
|
|
|
|
#include "clause.h"
|
2006-03-24 17:13:41 +00:00
|
|
|
#ifdef BEAM
|
|
|
|
#include"eam.h"
|
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
#include "or.macros.h"
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
/* info on compare built-ins */
|
|
|
|
#define TYPE_XX 0
|
|
|
|
#define TYPE_CX 1
|
|
|
|
#define TYPE_XC 2
|
|
|
|
|
|
|
|
typedef struct cmp_op_info_struct {
|
|
|
|
wamreg x1_arg, x2_arg;
|
|
|
|
Int c_arg;
|
|
|
|
int c_type;
|
2004-03-10 14:59:55 +00:00
|
|
|
struct clause_info_struct *cl_info;
|
2004-01-23 02:23:51 +00:00
|
|
|
} cmp_op_info;
|
|
|
|
|
|
|
|
typedef struct clause_info_struct {
|
|
|
|
int alloc_found, dealloc_found;
|
|
|
|
struct pred_entry *CurrentPred;
|
|
|
|
} clause_info;
|
|
|
|
|
|
|
|
STATIC_PROTO(OPREG Var_Ref, (Ventry *, int));
|
2002-11-11 17:38:10 +00:00
|
|
|
STATIC_PROTO(wamreg emit_xreg, (CELL));
|
|
|
|
STATIC_PROTO(yslot emit_yreg, (CELL));
|
|
|
|
STATIC_PROTO(wamreg emit_x, (CELL));
|
|
|
|
STATIC_PROTO(yslot emit_y, (Ventry *));
|
2002-12-27 16:53:09 +00:00
|
|
|
STATIC_PROTO(yamop *emit_a, (CELL));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(CELL *emit_bmlabel, (CELL, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *emit_ilabel, (CELL, struct intermediates *));
|
2001-04-09 20:54:03 +01:00
|
|
|
STATIC_PROTO(Functor emit_f, (CELL));
|
|
|
|
STATIC_PROTO(CELL emit_c, (CELL));
|
|
|
|
STATIC_PROTO(COUNT emit_count, (CELL));
|
|
|
|
STATIC_PROTO(OPCODE emit_op, (op_numbers));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_cle, (op_numbers, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_e, (op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_ue, (op_numbers, op_numbers, yamop *, int));
|
2008-08-21 13:38:25 +01:00
|
|
|
STATIC_PROTO(yamop *a_v, (op_numbers, op_numbers, yamop *, int, struct PSEUDO *));
|
|
|
|
STATIC_PROTO(yamop *a_uv, (Ventry *,op_numbers, op_numbers, op_numbers, op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_vr, (op_numbers, op_numbers, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_rv, (op_numbers, op_numbers, OPREG, yamop *, int, struct PSEUDO *));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_vv, (op_numbers, op_numbers, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_glist, (int *, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(void a_pair, (CELL *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_f, (CELL, op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_c, (CELL, op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_uc, (CELL, op_numbers, op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_n, (op_numbers, int, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_un, (op_numbers, op_numbers, int, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_nc, (CELL, op_numbers, int, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_unc, (CELL, op_numbers, op_numbers, int, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_r, (CELL, op_numbers, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_p, (op_numbers, clause_info *, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_pl, (op_numbers, PredEntry *, yamop *, int));
|
|
|
|
STATIC_PROTO(yamop *a_l, (CELL, op_numbers, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_hx, (op_numbers, union clause_obj *, int, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_if, (op_numbers, union clause_obj *, int, yamop *, int, struct intermediates *cip));
|
|
|
|
STATIC_PROTO(yamop *a_cut, (clause_info *,yamop *, int, struct intermediates *));
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
STATIC_PROTO(yamop *a_try, (op_numbers, CELL, CELL, int, int, yamop *, int, struct intermediates *));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, int, int, yamop *, int, struct intermediates *));
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2006-10-10 15:08:17 +01:00
|
|
|
STATIC_PROTO(yamop *a_try, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2006-10-10 15:08:17 +01:00
|
|
|
STATIC_PROTO(yamop *a_gl, (op_numbers, yamop *, int, struct PSEUDO *, struct intermediates *));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_bfunc, (CELL, clause_info *, yamop *, int, struct intermediates *));
|
2008-08-21 13:38:25 +01:00
|
|
|
STATIC_PROTO(
|
|
|
|
COUNT compile_cmp_flags, (char *));
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *a_igl, (CELL, op_numbers, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_xigl, (op_numbers, yamop *, int, struct PSEUDO *));
|
|
|
|
STATIC_PROTO(yamop *a_ucons, (int *, compiler_vm_op, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_uvar, (yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_wvar, (yamop *, int, struct intermediates *));
|
2007-11-06 17:02:13 +00:00
|
|
|
STATIC_PROTO(yamop *do_pass, (int, yamop **, int, int *, int *,struct intermediates *, UInt));
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef DEBUG_OPCODES
|
|
|
|
STATIC_PROTO(void DumpOpCodes, (void));
|
|
|
|
#endif
|
|
|
|
#ifdef SFUNC
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(void a_vsf, (int, yamop *, int, struct PSEUDO *));
|
|
|
|
STATIC_PROTO(void a_asf, (int, yamop *, int, struct PSEUDO *));
|
2003-03-21 16:18:42 +00:00
|
|
|
#endif
|
2004-01-23 02:23:51 +00:00
|
|
|
STATIC_PROTO(yamop *check_alloc, (clause_info *, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_deallocate, (clause_info *, yamop *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_bmap, (yamop *, int, struct PSEUDO *));
|
|
|
|
STATIC_PROTO(void a_fetch_vv, (cmp_op_info *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(void a_fetch_cv, (cmp_op_info *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(void a_fetch_vc, (cmp_op_info *, int, struct intermediates *));
|
|
|
|
STATIC_PROTO(yamop *a_f2, (int, cmp_op_info *, yamop *, int, struct intermediates *));
|
2003-03-21 16:18:42 +00:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define CELLSIZE sizeof(CELL)
|
|
|
|
|
|
|
|
#define GONEXT(TYPE) code_p = ((yamop *)(&(code_p->u.TYPE.next)))
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
inline static yslot
|
2001-04-09 20:54:03 +01:00
|
|
|
emit_y(Ventry *ve)
|
|
|
|
{
|
|
|
|
#if MSHIFTOFFS
|
|
|
|
return(-FixedEnvSize - ((ve->NoOfVE) & MaskVarAdrs) - 1);
|
|
|
|
#else
|
|
|
|
return(-FixedEnvSize - (((ve->NoOfVE) & MaskVarAdrs) * CELLSIZE) - CELLSIZE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static OPREG
|
|
|
|
Var_Ref(Ventry *ve, int is_y_var)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
#if MSHIFTOFFS
|
2004-01-23 02:23:51 +00:00
|
|
|
return -FixedEnvSize - ((ve->NoOfVE) & MaskVarAdrs) - 1;
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
return -FixedEnvSize - (((ve->NoOfVE) & MaskVarAdrs) * CELLSIZE) - CELLSIZE;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if PRECOMPUTE_REGADDRESS
|
2004-01-23 02:23:51 +00:00
|
|
|
return (CELL) (XREGS + ((ve->NoOfVE) & MaskVarAdrs));
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
|
|
|
#if MSHIFTOFFS
|
2004-01-23 02:23:51 +00:00
|
|
|
return ((ve->NoOfVE) & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
return CELLSIZE * ((ve->NoOfVE) & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
#endif /* PRECOMPUTE_REGADDRESS */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
#define is_void_var() (((Ventry *) (cip->cpc->rnd1))->KindOfVE == VoidVar)
|
2001-04-09 20:54:03 +01:00
|
|
|
#define is_a_void(X) (((Ventry *) (X))->KindOfVE == VoidVar)
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
#define is_temp_var() (((Ventry *) (cip->cpc->rnd1))->KindOfVE == TempVar)
|
2001-04-09 20:54:03 +01:00
|
|
|
#define is_atemp_var(p) (((Ventry *) (p->rnd1))->KindOfVE == TempVar)
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
#define no_ref_var() (((Ventry *) (cip->cpc->rnd1))->NoOfVE == 1)
|
2001-04-09 20:54:03 +01:00
|
|
|
#define no_ref(X) (((Ventry *) (X))->NoOfVE == 1)
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
fill_small(CELL w, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
SMALLUNSGN *ptr = ((SMALLUNSGN *) (code_p));
|
|
|
|
|
|
|
|
if (pass_no)
|
|
|
|
*ptr = (SMALLUNSGN) w;
|
2004-01-23 02:23:51 +00:00
|
|
|
return (yamop *) (++ptr);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
fill_a(CELL a, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
CELL *ptr = ((CELL *) (code_p));
|
|
|
|
|
|
|
|
if (pass_no)
|
|
|
|
*ptr = a;
|
2004-01-23 02:23:51 +00:00
|
|
|
return (yamop *) (++ptr);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
inline static wamreg
|
2001-04-09 20:54:03 +01:00
|
|
|
emit_xreg(CELL w)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return (wamreg) w;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
inline static yslot
|
2001-04-09 20:54:03 +01:00
|
|
|
emit_yreg(CELL w)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return (yslot) w;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
inline static wamreg
|
2001-04-09 20:54:03 +01:00
|
|
|
emit_x(CELL xarg)
|
|
|
|
{
|
|
|
|
#if PRECOMPUTE_REGADDRESS
|
|
|
|
return (emit_xreg((CELL) (XREGS + xarg)));
|
|
|
|
#else
|
|
|
|
#if MSHIFTOFFS
|
|
|
|
return (emit_xreg(xarg));
|
|
|
|
#else
|
|
|
|
return (emit_xreg(CELLSIZE * (xarg)));
|
|
|
|
#endif
|
|
|
|
#endif /* PRECOMPUTE_REGADDRESS */
|
|
|
|
}
|
|
|
|
|
2003-01-13 14:02:50 +00:00
|
|
|
wamreg
|
|
|
|
Yap_emit_x(CELL xarg)
|
|
|
|
{
|
|
|
|
return emit_x(xarg);
|
|
|
|
}
|
|
|
|
|
2002-12-27 16:53:09 +00:00
|
|
|
inline static yamop *
|
2001-04-09 20:54:03 +01:00
|
|
|
emit_a(CELL a)
|
|
|
|
{
|
2002-12-27 16:53:09 +00:00
|
|
|
return ((yamop *) (a));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-05-16 21:33:00 +01:00
|
|
|
inline static struct pred_entry *
|
|
|
|
emit_pe(struct pred_entry *a)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return a;
|
2002-05-16 21:33:00 +01:00
|
|
|
}
|
|
|
|
|
2002-12-27 16:53:09 +00:00
|
|
|
inline static yamop *
|
2004-01-23 02:23:51 +00:00
|
|
|
emit_ilabel(register CELL addr, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (addr & 1)
|
2004-01-23 02:23:51 +00:00
|
|
|
return (emit_a(Unsigned(cip->code_addr) + cip->label_offset[addr]));
|
2004-02-05 16:57:02 +00:00
|
|
|
else {
|
2001-04-09 20:54:03 +01:00
|
|
|
return (emit_a(addr));
|
2004-02-05 16:57:02 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-02-26 15:51:54 +00:00
|
|
|
inline static CELL *
|
2004-01-23 02:23:51 +00:00
|
|
|
emit_bmlabel(register CELL addr, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return (CELL *)(emit_a(Unsigned(cip->code_addr) + cip->label_offset[addr]));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline static Functor
|
|
|
|
emit_f(CELL a)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return (Functor) (a);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline static CELL
|
|
|
|
emit_c(CELL a)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return a;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline COUNT
|
|
|
|
emit_count(CELL count)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return count;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_OPCODES
|
|
|
|
inline static void
|
|
|
|
DumpOpCodes(void)
|
|
|
|
{
|
|
|
|
int i = 0, j;
|
|
|
|
|
|
|
|
while (i < 30) {
|
|
|
|
for (j = i; j <= _std_top; j += 25)
|
2002-11-18 18:18:05 +00:00
|
|
|
fprintf(Yap_stderr, "%5d %6lx", j, absmadr(j));
|
|
|
|
fputc('\n',Yap_stderr);
|
2001-04-09 20:54:03 +01:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline OPCODE
|
|
|
|
emit_op(op_numbers op)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return absmadr((Int) op);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
static OPCODE
|
2001-04-09 20:54:03 +01:00
|
|
|
opcode(op_numbers op)
|
|
|
|
{
|
|
|
|
return (emit_op(op));
|
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
OPCODE
|
2002-11-18 18:18:05 +00:00
|
|
|
Yap_opcode(op_numbers op)
|
2002-11-11 17:38:10 +00:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
return opcode(op);
|
2002-11-11 17:38:10 +00:00
|
|
|
}
|
|
|
|
|
2003-08-27 14:37:10 +01:00
|
|
|
static void
|
2004-01-23 02:23:51 +00:00
|
|
|
add_clref(CELL clause_code, int pass_no)
|
2003-08-27 14:37:10 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
LogUpdClause *cl = ClauseCodeToLogUpdClause(clause_code);
|
|
|
|
cl->ClRefCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
static void
|
|
|
|
add_to_dbtermsl(struct intermediates *cip, Term t)
|
|
|
|
{
|
|
|
|
DBTerm *dbt = TermToDBTerm(t);
|
|
|
|
dbt->ag.NextDBT = cip->dbterml->dbterms;
|
|
|
|
cip->dbterml->dbterms = dbt;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
2006-10-10 15:08:17 +01:00
|
|
|
a_lucl(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip, clause_info *cla)
|
2003-09-15 02:25:29 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
2008-01-23 17:57:56 +00:00
|
|
|
LogUpdIndex *lcl = (LogUpdIndex *)cip->code_addr;
|
2003-09-15 02:25:29 +01:00
|
|
|
code_p->opc = emit_op(opcode);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.Ills.I = lcl;
|
2009-02-09 21:56:40 +00:00
|
|
|
cip->cpc->rnd4 = (CELL)code_p;
|
2008-08-21 13:38:25 +01:00
|
|
|
cip->current_try_lab = &code_p->u.Ills.l1;
|
|
|
|
cip->current_trust_lab = &code_p->u.Ills.l2;
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.Ills.l1 = NULL;
|
|
|
|
code_p->u.Ills.l2 = NULL;
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.Ills.s = cip->cpc->rnd3;
|
2003-09-15 02:25:29 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(Ills);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2003-09-15 02:25:29 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_cle(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
LogUpdClause *cl = (LogUpdClause *)cip->code_addr;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.L.ClBase = cl;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl->ClExt = code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
cl->ClFlags |= LogUpdRuleMask;
|
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(L);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_e(op_numbers opcode, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2003-10-17 03:11:21 +01:00
|
|
|
if (pass_no) {
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->opc = emit_op(opcode);
|
2003-10-17 03:11:21 +01:00
|
|
|
}
|
|
|
|
GONEXT(e);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-08-30 16:24:44 +01:00
|
|
|
inline static yamop *
|
|
|
|
a_p0(op_numbers opcode, yamop *code_p, int pass_no, PredEntry *p0)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.p.p = p0;
|
|
|
|
}
|
|
|
|
GONEXT(p);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_ue(op_numbers opcode, op_numbers opcodew, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.o.opcw = emit_op(opcodew);
|
|
|
|
}
|
|
|
|
GONEXT(o);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-12-09 14:23:19 +00:00
|
|
|
inline static yamop *
|
|
|
|
emit_fail(struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (cip->failure_handler) {
|
|
|
|
return emit_a(Unsigned(cip->code_addr) + cip->label_offset[cip->failure_handler]);
|
|
|
|
} else {
|
|
|
|
return FAILCODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
2008-08-21 13:38:25 +01:00
|
|
|
a_v(op_numbers opcodex, op_numbers opcodey, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2008-08-21 13:38:25 +01:00
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodey);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.y.y = emit_yreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(y);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodex);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.x.x = emit_xreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(x);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-12-09 12:54:27 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_fi(op_numbers opcodex, op_numbers opcodey, yamop *code_p, int pass_no, struct PSEUDO *cpc, UInt lab, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodey);
|
|
|
|
code_p->u.syl.y = emit_yreg(var_offset);
|
|
|
|
code_p->u.syl.l = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab]);
|
|
|
|
code_p->u.syl.s = cpc->rnd2;
|
|
|
|
}
|
|
|
|
GONEXT(syl);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodex);
|
|
|
|
code_p->u.sxl.x = emit_xreg(var_offset);
|
|
|
|
code_p->u.sxl.l = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab]);
|
|
|
|
code_p->u.sxl.s = cpc->rnd2;
|
|
|
|
}
|
|
|
|
GONEXT(sxl);
|
|
|
|
}
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static yamop *
|
|
|
|
a_fil(op_numbers opcodex, op_numbers opcodey, yamop *code_p, int pass_no, struct PSEUDO *cpc, UInt lab1, UInt lab2, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodey);
|
|
|
|
code_p->u.syll.s = cpc->rnd2;
|
|
|
|
code_p->u.syll.y = emit_yreg(var_offset);
|
|
|
|
if (lab1)
|
|
|
|
code_p->u.syll.T = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab1]);
|
|
|
|
else
|
|
|
|
code_p->u.syll.T = emit_a(Unsigned(NEXTOP(code_p,syll)));
|
|
|
|
if (lab2)
|
|
|
|
code_p->u.syll.F = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab2]);
|
|
|
|
else
|
|
|
|
code_p->u.syll.F = FAILCODE;
|
|
|
|
}
|
|
|
|
GONEXT(syll);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodex);
|
|
|
|
code_p->u.sxll.s = cpc->rnd2;
|
|
|
|
code_p->u.sxll.x = emit_xreg(var_offset);
|
|
|
|
if (lab1)
|
|
|
|
code_p->u.sxll.T = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab1]);
|
|
|
|
else
|
|
|
|
code_p->u.sxll.T = emit_a(Unsigned(NEXTOP(code_p,sxll)));
|
|
|
|
if (lab2)
|
|
|
|
code_p->u.sxll.F = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab2]);
|
|
|
|
else
|
|
|
|
code_p->u.sxll.F = FAILCODE;
|
|
|
|
}
|
|
|
|
GONEXT(sxll);
|
|
|
|
}
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_sdll(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, UInt lab1, UInt lab2, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.sdll.s = cpc->rnd2;
|
|
|
|
code_p->u.sdll.d[0] = (CELL)FunctorDouble;
|
|
|
|
code_p->u.sdll.d[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
|
|
|
code_p->u.sdll.d[2] = RepAppl(cpc->rnd1)[2];
|
|
|
|
#endif
|
|
|
|
if (lab1)
|
|
|
|
code_p->u.sdll.T = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab1]);
|
|
|
|
else
|
|
|
|
code_p->u.sdll.T = emit_a(Unsigned(NEXTOP(code_p,sdll)));
|
|
|
|
if (lab2)
|
|
|
|
code_p->u.sdll.F = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab2]);
|
|
|
|
else
|
|
|
|
code_p->u.sdll.F = FAILCODE;
|
|
|
|
}
|
|
|
|
GONEXT(sdll);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_snll(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, UInt lab1, UInt lab2, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.snll.s = cpc->rnd2;
|
|
|
|
code_p->u.snll.I = IntegerOfTerm(cpc->rnd1);
|
|
|
|
if (lab1)
|
|
|
|
code_p->u.snll.T = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab1]);
|
|
|
|
else
|
|
|
|
code_p->u.snll.T = emit_a(Unsigned(NEXTOP(code_p,snll)));
|
|
|
|
if (lab2)
|
|
|
|
code_p->u.snll.F = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab2]);
|
|
|
|
else
|
|
|
|
code_p->u.snll.F = FAILCODE;
|
|
|
|
}
|
|
|
|
GONEXT(snll);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_ssll(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, UInt lab1, UInt lab2, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.ssll.s1 = cpc->rnd1;
|
|
|
|
code_p->u.ssll.s2 = cpc->rnd2;
|
|
|
|
if (lab1)
|
|
|
|
code_p->u.ssll.T = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab1]);
|
|
|
|
else
|
|
|
|
code_p->u.ssll.T = emit_a(Unsigned(NEXTOP(code_p,ssll)));
|
|
|
|
if (lab2)
|
|
|
|
code_p->u.ssll.F = emit_a(Unsigned(cip->code_addr) + cip->label_offset[lab2]);
|
|
|
|
else
|
|
|
|
code_p->u.ssll.F = FAILCODE;
|
|
|
|
}
|
|
|
|
GONEXT(ssll);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_ssd(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.ssd.s0 = IntegerOfTerm(cpc->rnd1);
|
|
|
|
code_p->u.ssd.s1 = IntegerOfTerm(cpc->rnd2);
|
2008-12-09 12:54:27 +00:00
|
|
|
code_p->u.ssd.d[0] = (CELL)FunctorDouble;
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.ssd.d[1] = RepAppl(cpc->rnd3)[1];
|
2008-12-09 12:54:27 +00:00
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.ssd.d[2] = RepAppl(cpc->rnd3)[2];
|
2008-12-09 12:54:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
GONEXT(ssd);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_ssn(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.ssn.s0 = IntegerOfTerm(cpc->rnd1);
|
|
|
|
code_p->u.ssn.s1 = IntegerOfTerm(cpc->rnd2);
|
|
|
|
code_p->u.ssn.n = IntegerOfTerm(cpc->rnd3);
|
2008-12-09 12:54:27 +00:00
|
|
|
}
|
|
|
|
GONEXT(ssn);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_sss(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2009-02-09 21:56:40 +00:00
|
|
|
code_p->u.sss.s0 = IntegerOfTerm(cpc->rnd1);
|
|
|
|
code_p->u.sss.s1 = IntegerOfTerm(cpc->rnd2);
|
|
|
|
code_p->u.sss.s2 = IntegerOfTerm(cpc->rnd3);
|
2008-12-09 12:54:27 +00:00
|
|
|
}
|
|
|
|
GONEXT(sss);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2008-08-30 02:39:36 +01:00
|
|
|
inline static yamop *
|
|
|
|
a_vp(op_numbers opcodex, op_numbers opcodey, yamop *code_p, int pass_no, struct PSEUDO *cpc, clause_info *clinfo)
|
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodey);
|
|
|
|
code_p->u.yp.y = emit_yreg(var_offset);
|
|
|
|
code_p->u.yp.p0 = clinfo->CurrentPred;
|
|
|
|
}
|
|
|
|
GONEXT(yp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcodex);
|
|
|
|
code_p->u.xp.x = emit_xreg(var_offset);
|
|
|
|
code_p->u.xp.p0 = clinfo->CurrentPred;
|
|
|
|
}
|
|
|
|
GONEXT(xp);
|
|
|
|
}
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
2008-08-21 13:38:25 +01:00
|
|
|
a_uv(Ventry *ve, op_numbers opcodex, op_numbers opcodexw, op_numbers opcodey, op_numbers opcodeyw, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodey);
|
|
|
|
code_p->u.oy.opcw = emit_op(opcodeyw);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.oy.y = emit_yreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(oy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodex);
|
|
|
|
code_p->u.ox.opcw = emit_op(opcodexw);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.ox.x = emit_xreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(ox);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_vv(op_numbers opcode, op_numbers opcodew, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
Ventry *ve = (Ventry *) cip->cpc->rnd1;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset = Var_Ref(ve, is_y_var);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.oxx.opcw = emit_op(opcodew);
|
|
|
|
code_p->u.oxx.xl = emit_xreg(var_offset);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
if (pass_no) {
|
|
|
|
OPREG var_offset;
|
2004-04-22 21:07:07 +01:00
|
|
|
int is_y_var;
|
2004-01-23 02:23:51 +00:00
|
|
|
|
2004-04-22 21:07:07 +01:00
|
|
|
ve = (Ventry *) cip->cpc->rnd1;
|
|
|
|
is_y_var = (ve->KindOfVE == PermVar);
|
2004-01-23 02:23:51 +00:00
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.oxx.xr = emit_xreg(var_offset);
|
2004-01-23 02:23:51 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
GONEXT(oxx);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
2008-08-21 13:38:25 +01:00
|
|
|
a_vr(op_numbers opcodex, op_numbers opcodey, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2005-07-06 16:10:18 +01:00
|
|
|
struct PSEUDO *cpc = cip->cpc;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodey);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.yx.y = emit_yreg(var_offset);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.yx.x = emit_x(cpc->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(yx);
|
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
else if (opcodex == _put_x_val &&
|
2005-07-06 16:10:18 +01:00
|
|
|
cpc->nextInst &&
|
|
|
|
cpc->nextInst->op == put_val_op &&
|
|
|
|
!(((Ventry *) cpc->nextInst->rnd1)->KindOfVE == PermVar)) {
|
|
|
|
/* peephole! two put_x_vars in a row */
|
|
|
|
if (pass_no) {
|
|
|
|
OPREG var_offset;
|
|
|
|
OPREG var_offset2;
|
|
|
|
Ventry *ve2 = (Ventry *) cpc->nextInst->rnd1;
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
code_p->opc = emit_op(_put_xx_val);
|
|
|
|
code_p->u.xxxx.xl1 = emit_xreg(var_offset);
|
|
|
|
code_p->u.xxxx.xr1 = emit_x(cpc->rnd2);
|
|
|
|
var_offset2 = Var_Ref(ve2, is_y_var);
|
|
|
|
code_p->u.xxxx.xl2 = emit_xreg(var_offset2);
|
|
|
|
code_p->u.xxxx.xr2 = emit_x(cpc->nextInst->rnd2);
|
|
|
|
}
|
|
|
|
cip->cpc = cpc->nextInst;
|
|
|
|
GONEXT(xxxx);
|
|
|
|
} else {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodex);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.xx.xl = emit_xreg(var_offset);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xx.xr = emit_x(cpc->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(xx);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
2008-08-21 13:38:25 +01:00
|
|
|
a_rv(op_numbers opcodex, op_numbers opcodey, OPREG var_offset, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodey);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xy.x = emit_x(cpc->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.xy.y = emit_yreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(xy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->opc = emit_op(opcodex);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xx.xl = emit_x(cpc->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->u.xx.xr = emit_xreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(xx);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SFUNC
|
|
|
|
|
|
|
|
/* vsc: I don't understand these instructions */
|
|
|
|
|
|
|
|
inline static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_vsf(int opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
Ventry *ve = (Ventry *) cpc->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op((op_numbers)((int)opcode + is_y_var));
|
|
|
|
code_p->u.fy.f = emit_f(cpc->rnd2);
|
|
|
|
code_p->u.fy.a = ArityOfFunctor(emit_f(cpc->rnd2));
|
|
|
|
code_p->u.fy.y = emit_yreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(fy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op((op_numbers)((int)opcode + is_y_var));
|
|
|
|
code_p->u.fx.f = emit_f(cpc->rnd2);
|
|
|
|
code_p->u.fx.a = ArityOfFunctor(emit_f(cpc->rnd2));
|
|
|
|
code_p->u.fx.x = emit_xreg(var_offset);
|
|
|
|
}
|
|
|
|
GONEXT(fx);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_asf(int opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op((op_numbers)((int)opcode + is_y_var));
|
|
|
|
code_p->u.fn.f = emit_f(cpc->rnd2);
|
|
|
|
code_p->u.fn.a = ArityOfFunctor(emit_f(cpc->rnd2));
|
|
|
|
code_p->u.fn.n = emit_count(cpc->rnd1);
|
|
|
|
}
|
|
|
|
GONEXT(fn);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_pair(CELL *seq_ptr, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
2004-02-05 16:57:02 +00:00
|
|
|
CELL lab, lab0 = seq_ptr[1];
|
|
|
|
lab = (CELL) emit_ilabel(lab0, cip);
|
2003-08-27 14:37:10 +01:00
|
|
|
seq_ptr[0] = (CELL) emit_a(seq_ptr[0]);
|
2004-02-05 16:57:02 +00:00
|
|
|
seq_ptr[1] = lab;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_n(op_numbers opcode, int count, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.s.s = count;
|
|
|
|
}
|
|
|
|
GONEXT(s);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2006-03-24 17:13:41 +00:00
|
|
|
#ifdef BEAM
|
|
|
|
inline static yamop *
|
|
|
|
a_eam(op_numbers opcode, int pred, long cl, yamop *code_p, int pass_no)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.os.opcw = cl;
|
|
|
|
code_p->u.os.s = pred;
|
|
|
|
}
|
|
|
|
GONEXT(os);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_un(op_numbers opcode, op_numbers opcodew, int count, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.os.opcw = emit_op(opcodew);
|
|
|
|
code_p->u.os.s = count;
|
|
|
|
}
|
|
|
|
GONEXT(os);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_f(CELL rnd1, op_numbers opcode, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
Functor f = emit_f(rnd1);
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->opc = emit_op(opcode);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.fa.f = f;
|
|
|
|
code_p->u.fa.a = ArityOfFunctor(f);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(fa);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_uf(CELL rnd1, op_numbers opcode, op_numbers opcodew, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
Functor f = emit_f(rnd1);
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->opc = emit_op(opcode);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.ofa.opcw = emit_op(opcodew);
|
|
|
|
code_p->u.ofa.f = f;
|
|
|
|
code_p->u.ofa.a = ArityOfFunctor(f);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(ofa);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_c(CELL rnd1, op_numbers opcode, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.c.c = emit_c(rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(c);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_uc(CELL rnd1, op_numbers opcode, op_numbers opcode_w, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.oc.opcw = emit_op(opcode_w);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.oc.c = emit_c(rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(oc);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_blob(CELL rnd1, op_numbers opcode, int *clause_has_blobsp, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.c.c =
|
2004-01-23 02:23:51 +00:00
|
|
|
AbsAppl((CELL *)(Unsigned(cip->code_addr) + cip->label_offset[rnd1]));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
*clause_has_blobsp = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
GONEXT(c);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_wdbt(CELL rnd1, op_numbers opcode, int *clause_has_dbtermp, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.c.c = rnd1;
|
|
|
|
add_to_dbtermsl(cip, cip->cpc->rnd1);
|
|
|
|
}
|
|
|
|
*clause_has_dbtermp = TRUE;
|
|
|
|
GONEXT(c);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_ublob(CELL rnd1, op_numbers opcode, op_numbers opcode_w, int *clause_has_blobsp, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.oc.opcw = emit_op(opcode_w);
|
|
|
|
code_p->u.oc.c =
|
2004-01-23 02:23:51 +00:00
|
|
|
AbsAppl((CELL *)(Unsigned(cip->code_addr) + cip->label_offset[rnd1]));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
*clause_has_blobsp = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
GONEXT(oc);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_udbt(CELL rnd1, op_numbers opcode, op_numbers opcode_w, int *clause_has_dbtermp, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.oc.opcw = emit_op(opcode_w);
|
|
|
|
code_p->u.oc.c = cip->cpc->rnd1;
|
|
|
|
add_to_dbtermsl(cip, cip->cpc->rnd1);
|
|
|
|
}
|
|
|
|
*clause_has_dbtermp = TRUE;
|
|
|
|
GONEXT(oc);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2006-09-20 21:03:51 +01:00
|
|
|
inline static yamop *
|
|
|
|
a_ud(op_numbers opcode, op_numbers opcode_w, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-12-09 12:54:27 +00:00
|
|
|
code_p->u.od.opcw = emit_op(opcode_w);
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p->u.od.d[0] = (CELL)FunctorDouble;
|
|
|
|
code_p->u.od.d[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
|
|
|
code_p->u.od.d[2] = RepAppl(cpc->rnd1)[2];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
GONEXT(od);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static yamop *
|
|
|
|
a_ui(op_numbers opcode, op_numbers opcode_w, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-12-09 12:54:27 +00:00
|
|
|
code_p->u.oi.opcw = emit_op(opcode_w);
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p->u.oi.i[0] = (CELL)FunctorLongInt;
|
|
|
|
code_p->u.oi.i[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
}
|
|
|
|
GONEXT(oi);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static yamop *
|
|
|
|
a_wd(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.d.d[0] = (CELL)FunctorDouble;
|
|
|
|
code_p->u.d.d[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
|
|
|
code_p->u.d.d[2] = RepAppl(cpc->rnd1)[2];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
GONEXT(d);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static yamop *
|
|
|
|
a_wi(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.i.i[0] = (CELL)FunctorLongInt;
|
|
|
|
code_p->u.i.i[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
}
|
|
|
|
GONEXT(i);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_nc(CELL rnd1, op_numbers opcode, int i, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.sc.s = i;
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.sc.c = emit_c(rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(sc);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_unc(CELL rnd1, op_numbers opcode, op_numbers opcodew, int i, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.osc.opcw = emit_op(opcodew);
|
|
|
|
code_p->u.osc.s = i;
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.osc.c = emit_c(rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(osc);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_rf(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.xfa.x = emit_x(cpc->rnd2);
|
|
|
|
code_p->u.xfa.f = emit_f(cpc->rnd1);
|
|
|
|
code_p->u.xfa.a = ArityOfFunctor(emit_f(cpc->rnd1));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(xfa);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2006-09-20 21:03:51 +01:00
|
|
|
inline static yamop *
|
|
|
|
a_rd(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.xd.x = emit_x(cpc->rnd2);
|
|
|
|
code_p->u.xd.d[0] = (CELL)FunctorDouble;
|
|
|
|
code_p->u.xd.d[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
|
|
|
code_p->u.xd.d[2] = RepAppl(cpc->rnd1)[2];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
GONEXT(xd);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static yamop *
|
|
|
|
a_ri(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.xi.x = emit_x(cpc->rnd2);
|
|
|
|
code_p->u.xi.i[0] = (CELL)FunctorLongInt;
|
|
|
|
code_p->u.xi.i[1] = RepAppl(cpc->rnd1)[1];
|
|
|
|
}
|
|
|
|
GONEXT(xi);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-09-27 21:45:04 +01:00
|
|
|
static yamop *
|
|
|
|
a_rc(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (cip->cpc->rnd2 == 1 &&
|
|
|
|
cip->cpc->nextInst->rnd2 == 2 &&
|
|
|
|
(cip->cpc->nextInst->op == get_atom_op ||
|
|
|
|
cip->cpc->nextInst->op == get_num_op)) {
|
|
|
|
struct PSEUDO *next;
|
|
|
|
next = cip->cpc->nextInst;
|
|
|
|
if (next->nextInst->rnd2 == 3 &&
|
|
|
|
(next->nextInst->op == get_atom_op ||
|
|
|
|
next->nextInst->op == get_num_op)) {
|
|
|
|
struct PSEUDO *snext = next->nextInst;
|
|
|
|
|
|
|
|
if (snext->nextInst->rnd2 == 4 &&
|
|
|
|
(snext->nextInst->op == get_atom_op ||
|
|
|
|
snext->nextInst->op == get_num_op)) {
|
|
|
|
struct PSEUDO *s2next = snext->nextInst;
|
|
|
|
if (s2next->nextInst->rnd2 == 5 &&
|
|
|
|
(s2next->nextInst->op == get_atom_op ||
|
|
|
|
s2next->nextInst->op == get_num_op)) {
|
|
|
|
struct PSEUDO *s3next = s2next->nextInst;
|
|
|
|
if (s3next->nextInst->rnd2 == 6 &&
|
|
|
|
(s3next->nextInst->op == get_atom_op ||
|
|
|
|
s3next->nextInst->op == get_num_op)) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_get_6atoms);
|
|
|
|
code_p->u.cccccc.c1 = emit_c(cip->cpc->rnd1);
|
|
|
|
code_p->u.cccccc.c2 = emit_c(next->rnd1);
|
|
|
|
code_p->u.cccccc.c3 = emit_c(snext->rnd1);
|
|
|
|
code_p->u.cccccc.c4 = emit_c(s2next->rnd1);
|
|
|
|
code_p->u.cccccc.c5 = emit_c(s3next->rnd1);
|
|
|
|
code_p->u.cccccc.c6 = emit_c(s3next->nextInst->rnd1);
|
|
|
|
}
|
|
|
|
cip->cpc = s3next->nextInst;
|
|
|
|
GONEXT(cccccc);
|
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_get_5atoms);
|
|
|
|
code_p->u.ccccc.c1 = emit_c(cip->cpc->rnd1);
|
|
|
|
code_p->u.ccccc.c2 = emit_c(next->rnd1);
|
|
|
|
code_p->u.ccccc.c3 = emit_c(snext->rnd1);
|
|
|
|
code_p->u.ccccc.c4 = emit_c(s2next->rnd1);
|
|
|
|
code_p->u.ccccc.c5 = emit_c(s3next->rnd1);
|
|
|
|
}
|
|
|
|
cip->cpc = s3next;
|
|
|
|
GONEXT(ccccc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_get_4atoms);
|
|
|
|
code_p->u.cccc.c1 = emit_c(cip->cpc->rnd1);
|
|
|
|
code_p->u.cccc.c2 = emit_c(next->rnd1);
|
|
|
|
code_p->u.cccc.c3 = emit_c(snext->rnd1);
|
|
|
|
code_p->u.cccc.c4 = emit_c(s2next->rnd1);
|
|
|
|
}
|
|
|
|
cip->cpc = s2next;
|
|
|
|
GONEXT(cccc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_get_3atoms);
|
|
|
|
code_p->u.ccc.c1 = emit_c(cip->cpc->rnd1);
|
|
|
|
code_p->u.ccc.c2 = emit_c(next->rnd1);
|
|
|
|
code_p->u.ccc.c3 = emit_c(snext->rnd1);
|
|
|
|
}
|
|
|
|
cip->cpc = snext;
|
|
|
|
GONEXT(ccc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_get_2atoms);
|
|
|
|
code_p->u.cc.c1 = emit_c(cip->cpc->rnd1);
|
|
|
|
code_p->u.cc.c2 = emit_c(next->rnd1);
|
|
|
|
}
|
|
|
|
cip->cpc = next;
|
|
|
|
GONEXT(cc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.xc.x = emit_x(cip->cpc->rnd2);
|
|
|
|
code_p->u.xc.c = emit_c(cip->cpc->rnd1);
|
|
|
|
}
|
|
|
|
GONEXT(xc);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2005-07-06 16:10:18 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_rb(op_numbers opcode, int *clause_has_blobsp, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xc.x = emit_x(cip->cpc->rnd2);
|
|
|
|
code_p->u.xc.c = AbsAppl((CELL *)(Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1]));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
*clause_has_blobsp = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
GONEXT(xc);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_dbt(op_numbers opcode, int *clause_has_dbtermp, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.xc.x = emit_x(cip->cpc->rnd2);
|
|
|
|
code_p->u.xc.c = cip->cpc->rnd1;
|
|
|
|
add_to_dbtermsl(cip, cip->cpc->rnd1);
|
|
|
|
}
|
|
|
|
*clause_has_dbtermp = TRUE;
|
|
|
|
GONEXT(xc);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2006-09-20 21:03:51 +01:00
|
|
|
inline static yamop *
|
|
|
|
a_rli(op_numbers opcode, int *clause_has_blobsp, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.xc.x = emit_x(cip->cpc->rnd2);
|
|
|
|
code_p->u.xc.c = AbsAppl((CELL *)(Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1]));
|
|
|
|
}
|
|
|
|
GONEXT(xc);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
inline static yamop *
|
|
|
|
a_r(CELL arnd2, op_numbers opcode, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.x.x = emit_x(arnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(x);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
check_alloc(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
if (clinfo->alloc_found == 2) {
|
|
|
|
if (clinfo->CurrentPred->PredFlags & LogUpdatePredFlag)
|
|
|
|
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
|
|
|
code_p = a_e(_allocate, code_p, pass_no);
|
|
|
|
clinfo->alloc_found = 1;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2005-06-01 21:25:23 +01:00
|
|
|
static yamop *
|
|
|
|
a_l(CELL rnd1, op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.l.l = emit_a(Unsigned(cip->code_addr) + cip->label_offset[rnd1]);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static yamop *
|
|
|
|
a_il(CELL rnd1, op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
code_p->u.l.l = emit_ilabel(rnd1, cip);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{ /* emit opcode & predicate code address */
|
2004-01-23 02:23:51 +00:00
|
|
|
Prop fe = (Prop) (cip->cpc->rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL Flags = RepPredProp(fe)->PredFlags;
|
2002-05-28 17:26:00 +01:00
|
|
|
if (Flags & AsmPredFlag) {
|
2001-04-09 20:54:03 +01:00
|
|
|
op_numbers op;
|
2005-06-01 21:25:23 +01:00
|
|
|
int is_test = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
switch (Flags & 0x7f) {
|
|
|
|
case _equal:
|
|
|
|
op = _p_equal;
|
|
|
|
break;
|
|
|
|
case _dif:
|
|
|
|
op = _p_dif;
|
2005-06-01 21:25:23 +01:00
|
|
|
is_test = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _eq:
|
|
|
|
op = _p_eq;
|
2005-06-01 21:25:23 +01:00
|
|
|
is_test = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _functor:
|
2005-07-06 16:10:18 +01:00
|
|
|
code_p = check_alloc(clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
op = _p_functor;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
op = _p_equal; /* just to make some compilers happy */
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-06-01 21:25:23 +01:00
|
|
|
if (is_test) {
|
2008-12-09 14:23:19 +00:00
|
|
|
UInt lab;
|
|
|
|
|
|
|
|
if ((lab = cip->failure_handler)) {
|
2005-07-06 16:10:18 +01:00
|
|
|
return a_l(lab, op, code_p, pass_no, cip);
|
2005-06-01 21:25:23 +01:00
|
|
|
} else {
|
2005-07-06 16:10:18 +01:00
|
|
|
return a_il((CELL)FAILCODE, op, code_p, pass_no, cip);
|
2005-06-01 21:25:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return a_e(op, code_p, pass_no);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-28 04:43:00 +01:00
|
|
|
if (Flags & CPredFlag &&
|
|
|
|
opcode == _call) {
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = check_alloc(clinfo, code_p, pass_no, cip);
|
2008-12-09 14:23:19 +00:00
|
|
|
if (cip->failure_handler && (Flags & TestPredFlag)) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
if (Flags & UserCPredFlag) {
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil,
|
2001-04-09 20:54:03 +01:00
|
|
|
"user defined predicate cannot be a test predicate");
|
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else
|
|
|
|
code_p->opc = emit_op(_call_c_wfail);
|
2008-12-09 12:54:27 +00:00
|
|
|
code_p->u.slp.s =
|
2004-01-23 02:23:51 +00:00
|
|
|
emit_count(-Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2);
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.slp.l = emit_fail(cip);
|
2008-12-09 12:54:27 +00:00
|
|
|
code_p->u.slp.p =
|
2002-05-16 21:33:00 +01:00
|
|
|
emit_pe(RepPredProp(fe));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-12-09 12:54:27 +00:00
|
|
|
GONEXT(slp);
|
2004-01-23 02:23:51 +00:00
|
|
|
} else {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2001-10-30 16:42:05 +00:00
|
|
|
if (Flags & UserCPredFlag) {
|
2001-04-09 20:54:03 +01:00
|
|
|
code_p->opc = emit_op(_call_usercpred);
|
2001-10-30 16:42:05 +00:00
|
|
|
} else {
|
2003-01-29 14:47:17 +00:00
|
|
|
if (RepPredProp(fe)->FunctorOfPred == FunctorExecuteInMod) {
|
2001-10-30 16:42:05 +00:00
|
|
|
code_p->opc = emit_op(_p_execute);
|
2007-11-07 09:25:27 +00:00
|
|
|
} else if (RepPredProp(fe)->FunctorOfPred == FunctorExecute2InMod) {
|
|
|
|
code_p->opc = emit_op(_p_execute2);
|
2003-01-29 14:47:17 +00:00
|
|
|
} else {
|
2001-10-30 16:42:05 +00:00
|
|
|
code_p->opc = emit_op(_call_cpred);
|
2003-01-29 14:47:17 +00:00
|
|
|
}
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize) - CELLSIZE
|
2004-01-23 02:23:51 +00:00
|
|
|
* (cip->cpc->rnd2));
|
2003-01-29 14:47:17 +00:00
|
|
|
if (RepPredProp(fe)->FunctorOfPred != FunctorExecuteInMod) {
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.p = RepPredProp(fe);
|
2003-01-29 14:47:17 +00:00
|
|
|
} else {
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbmp.mod = cip->cpc->rnd4;
|
2003-01-29 14:47:17 +00:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.p0 = clinfo->CurrentPred;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd2) {
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = emit_bmlabel(cip->cpc->arnds[1], cip);
|
2003-01-29 14:47:17 +00:00
|
|
|
} else {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* there is no bitmap as there are no variables in the environment */
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
2003-01-29 14:47:17 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Osbpp);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (opcode == _call && clinfo->alloc_found == 2) {
|
|
|
|
if (clinfo->CurrentPred->PredFlags & LogUpdatePredFlag)
|
|
|
|
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_fcall);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo->alloc_found = 1;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
else {
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = check_alloc(clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no)
|
|
|
|
code_p->opc = emit_op(opcode);
|
|
|
|
}
|
|
|
|
if (opcode == _call) {
|
|
|
|
if (pass_no) {
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize) - CELLSIZE *
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc->rnd2);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.p = RepPredProp(fe);
|
|
|
|
code_p->u.Osbpp.p0 = clinfo->CurrentPred;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd2)
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = emit_bmlabel(cip->cpc->arnds[1], cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
|
|
|
/* there is no bitmap as there are no variables in the environment */
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Osbpp);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-12-17 03:25:39 +00:00
|
|
|
else if (opcode == _execute ||
|
2008-10-08 13:15:09 +01:00
|
|
|
opcode == _dexecute) {
|
2005-12-17 03:25:39 +00:00
|
|
|
if (pass_no) {
|
2008-10-08 13:15:09 +01:00
|
|
|
if (Flags & CPredFlag) {
|
2008-08-28 04:43:00 +01:00
|
|
|
code_p->opc = emit_op(_execute_cpred);
|
|
|
|
}
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p->u.pp.p = RepPredProp(fe);
|
|
|
|
code_p->u.pp.p0 = clinfo->CurrentPred;
|
|
|
|
}
|
|
|
|
GONEXT(pp);
|
2008-10-08 13:15:09 +01:00
|
|
|
} else {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no)
|
2002-12-27 16:53:09 +00:00
|
|
|
code_p->u.p.p = RepPredProp(fe);
|
|
|
|
GONEXT(p);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
emit a false call so that the garbage collector and friends will find
|
|
|
|
reasonable information on the stack.
|
|
|
|
*/
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_empty_call(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
if (clinfo->alloc_found == 1 && !clinfo->dealloc_found) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* we have a solid environment under us, just trust it */
|
|
|
|
if (pass_no)
|
|
|
|
code_p->opc = emit_op(_call);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/** oops, our environment is crap */
|
|
|
|
if (pass_no)
|
|
|
|
code_p->opc = emit_op(_fcall);
|
|
|
|
}
|
|
|
|
if (pass_no) {
|
2002-11-18 18:18:05 +00:00
|
|
|
PredEntry *pe = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,0));
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize) - CELLSIZE *
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc->rnd2);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.p = pe;
|
|
|
|
code_p->u.Osbpp.p0 = clinfo->CurrentPred;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd2)
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = emit_bmlabel(cip->cpc->rnd1, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
|
|
|
/* there is no bitmap as there are no variables in the environment */
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Osbpp);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_pl(op_numbers opcode, PredEntry *pred, yamop *code_p, int pass_no)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.p.p = pred;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-01-29 14:47:17 +00:00
|
|
|
GONEXT(p);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-08-21 13:38:25 +01:00
|
|
|
static COUNT
|
2001-04-09 20:54:03 +01:00
|
|
|
compile_cmp_flags(char *s)
|
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,"=<") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return EQ_OK_IN_CMP|LT_OK_IN_CMP;
|
|
|
|
if (strcmp(s,"is") == 0)
|
|
|
|
return EQ_OK_IN_CMP;
|
2005-06-01 22:23:44 +01:00
|
|
|
if (strcmp(s,"@=<") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return EQ_OK_IN_CMP|LT_OK_IN_CMP;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,"<") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return LT_OK_IN_CMP;
|
2005-06-01 22:23:44 +01:00
|
|
|
if (strcmp(s,"@<") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return LT_OK_IN_CMP;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,">=") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return EQ_OK_IN_CMP|GT_OK_IN_CMP;
|
2005-06-01 22:23:44 +01:00
|
|
|
if (strcmp(s,"@>=") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return EQ_OK_IN_CMP|GT_OK_IN_CMP;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,">") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return GT_OK_IN_CMP;
|
2005-06-01 22:23:44 +01:00
|
|
|
if (strcmp(s,"@>") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return GT_OK_IN_CMP;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,"=:=") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return EQ_OK_IN_CMP;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (strcmp(s,"=\\=") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return GT_OK_IN_CMP|LT_OK_IN_CMP;
|
2005-06-01 22:23:44 +01:00
|
|
|
if (strcmp(s,"\\==") == 0)
|
2009-02-09 22:21:58 +00:00
|
|
|
return GT_OK_IN_CMP|LT_OK_IN_CMP;
|
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error, %s/2 not recognised as binary op", s);
|
|
|
|
return 0;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-08-21 13:38:25 +01:00
|
|
|
COUNT
|
2003-01-13 14:02:50 +00:00
|
|
|
Yap_compile_cmp_flags(PredEntry *pred)
|
|
|
|
{
|
2006-12-13 16:10:26 +00:00
|
|
|
return
|
|
|
|
compile_cmp_flags(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE);
|
2003-01-13 14:02:50 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_bfunc(CELL pred, clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
Ventry *ve = (Ventry *) cip->cpc->rnd1;
|
|
|
|
OPREG var_offset;
|
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (ve->KindOfVE == PermVar) {
|
2002-11-11 17:38:10 +00:00
|
|
|
yslot v1 = emit_yreg(var_offset);
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
ve = (Ventry *) cip->cpc->rnd1;
|
|
|
|
is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_call_bfunc_yy);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plyys.p = RepPredProp(((Prop)pred));
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.plyys.f = emit_fail(cip);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plyys.y1 = v1;
|
|
|
|
code_p->u.plyys.y2 = emit_yreg(var_offset);
|
|
|
|
code_p->u.plyys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(plyys);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_call_bfunc_yx);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxys.p = RepPredProp(((Prop)pred));
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.plxys.f = emit_fail(cip);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxys.x = emit_xreg(var_offset);
|
|
|
|
code_p->u.plxys.y = v1;
|
|
|
|
code_p->u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(plxys);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
2002-11-11 17:38:10 +00:00
|
|
|
wamreg x1 = emit_xreg(var_offset);
|
2004-01-23 02:23:51 +00:00
|
|
|
OPREG var_offset;
|
|
|
|
|
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
ve = (Ventry *) cip->cpc->rnd1;
|
|
|
|
is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
|
|
|
if (is_y_var) {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_call_bfunc_xy);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxys.p = RepPredProp(((Prop)pred));
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.plxys.f = emit_fail(cip);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxys.x = x1;
|
|
|
|
code_p->u.plxys.y = emit_yreg(var_offset);
|
|
|
|
code_p->u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(plxys);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_call_bfunc_xx);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxxs.p = RepPredProp(((Prop)pred));
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.plxxs.f = emit_fail(cip);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.plxxs.x1 = x1;
|
|
|
|
code_p->u.plxxs.x2 = emit_xreg(var_offset);
|
|
|
|
code_p->u.plxxs.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(plxxs);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_igl(CELL rnd1, op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.l.l = emit_ilabel(rnd1, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(l);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_xigl(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2003-10-28 01:16:03 +00:00
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2005-04-10 05:01:15 +01:00
|
|
|
code_p->u.xll.x = emit_x(cpc->rnd2);
|
|
|
|
code_p->u.xll.l1 = emit_a(cpc->rnd1);
|
|
|
|
code_p->u.xll.l2 = NEXTOP(code_p,xll);
|
2003-10-28 01:16:03 +00:00
|
|
|
}
|
2005-04-10 05:01:15 +01:00
|
|
|
GONEXT(xll);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2003-10-28 01:16:03 +00:00
|
|
|
}
|
|
|
|
|
2005-06-01 17:42:30 +01:00
|
|
|
/* enable peephole optimisation for switch_on_term to switch_on_list */
|
|
|
|
static int
|
|
|
|
is_switch_on_list(op_numbers opcode, struct intermediates *cip)
|
|
|
|
{
|
|
|
|
struct PSEUDO *cpc = cip->cpc, *ncpc, *n2cpc;
|
|
|
|
CELL *if_table;
|
|
|
|
|
|
|
|
/* only do this is indexing code is stable */
|
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag)
|
|
|
|
return FALSE;
|
|
|
|
/* check if we are transforming a switch_on_type */
|
|
|
|
if (opcode != _switch_on_type)
|
|
|
|
return FALSE;
|
|
|
|
/* should have two instructions next */
|
|
|
|
if ((ncpc = cpc->nextInst) == NULL ||
|
|
|
|
(n2cpc = ncpc->nextInst) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
/* one a label, the other an if_constant */
|
|
|
|
if (ncpc->op != label_op ||
|
|
|
|
n2cpc->op != if_c_op)
|
|
|
|
return FALSE;
|
|
|
|
/* the label for the constant case should be the if_c label
|
|
|
|
(this should always hold) */
|
|
|
|
if (cpc->arnds[1] != ncpc->rnd1)
|
|
|
|
return FALSE;
|
|
|
|
if_table = (CELL *)(n2cpc->rnd2);
|
|
|
|
/* the constant switch should only have the empty list */
|
|
|
|
if (n2cpc->rnd1 != 1 ||
|
|
|
|
if_table[0] !=TermNil)
|
|
|
|
return FALSE;
|
|
|
|
/*
|
|
|
|
should be pointing to a clause so that we can push the clause opcode,
|
|
|
|
this should be fixable;
|
|
|
|
also, we need to go what's in there, so it cannot be suspend code!
|
|
|
|
*/
|
|
|
|
if (cpc->arnds[0] & 1 ||
|
|
|
|
(yamop *)(cpc->arnds[0]) == (yamop *)(&(cip->CurrentPred->cs.p_code.ExpandCode)))
|
|
|
|
return FALSE;
|
|
|
|
/* Appl alternative should be pointing to same point as [] alternative,
|
|
|
|
usually FAILCODE */
|
|
|
|
if (if_table[3] != cpc->arnds[2])
|
|
|
|
return FALSE;
|
|
|
|
/* yesss!! */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_4sw(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
CELL *seq_ptr;
|
|
|
|
|
2005-06-01 17:42:30 +01:00
|
|
|
if (is_switch_on_list(opcode, cip)) {
|
2003-04-30 18:46:05 +01:00
|
|
|
if (pass_no) {
|
2005-06-01 17:42:30 +01:00
|
|
|
CELL *ars = (CELL *)(cip->cpc->nextInst->nextInst->rnd2);
|
2003-04-30 18:46:05 +01:00
|
|
|
code_p->opc = emit_op(_switch_list_nl);
|
2004-01-23 02:23:51 +00:00
|
|
|
seq_ptr = cip->cpc->arnds;
|
2003-04-30 18:46:05 +01:00
|
|
|
code_p->u.ollll.pop = ((yamop *)(seq_ptr[0]))->opc;
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.ollll.l1 = emit_ilabel(seq_ptr[0], cip);
|
2005-06-01 17:42:30 +01:00
|
|
|
code_p->u.ollll.l2 = emit_ilabel(ars[1], cip);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.ollll.l3 = emit_ilabel(seq_ptr[2], cip);
|
|
|
|
code_p->u.ollll.l4 = emit_ilabel(seq_ptr[3], cip);
|
2005-06-01 17:42:30 +01:00
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag) {
|
2006-11-06 18:35:05 +00:00
|
|
|
LogUpdIndex *icl = ClauseCodeToLogUpdIndex(ars);
|
|
|
|
|
|
|
|
Yap_LUIndexSpace_Tree -= icl->ClSize;
|
|
|
|
Yap_FreeCodeSpace((char *)icl);
|
2005-06-01 17:42:30 +01:00
|
|
|
} else {
|
2006-11-06 18:35:05 +00:00
|
|
|
StaticIndex *icl = ClauseCodeToStaticIndex(ars);
|
|
|
|
|
|
|
|
Yap_IndexSpace_Tree -= icl->ClSize;
|
|
|
|
Yap_FreeCodeSpace((char *)icl);
|
2005-06-01 17:42:30 +01:00
|
|
|
}
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
GONEXT(ollll);
|
2005-06-01 17:42:30 +01:00
|
|
|
/* skip if_cons */
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst->nextInst;
|
2003-04-30 18:46:05 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
seq_ptr = cip->cpc->arnds;
|
|
|
|
code_p->u.llll.l1 = emit_ilabel(seq_ptr[0], cip);
|
|
|
|
code_p->u.llll.l2 = emit_ilabel(seq_ptr[1], cip);
|
|
|
|
code_p->u.llll.l3 = emit_ilabel(seq_ptr[2], cip);
|
|
|
|
code_p->u.llll.l4 = emit_ilabel(seq_ptr[3], cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
GONEXT(llll);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_4sw_x(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
CELL *seq_ptr;
|
|
|
|
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xllll.x = emit_x(cip->cpc->rnd2);
|
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
seq_ptr = cip->cpc->arnds;
|
|
|
|
code_p->u.xllll.l1 = emit_ilabel(seq_ptr[0], cip);
|
|
|
|
code_p->u.xllll.l2 = emit_ilabel(seq_ptr[1], cip);
|
|
|
|
code_p->u.xllll.l3 = emit_ilabel(seq_ptr[2], cip);
|
|
|
|
code_p->u.xllll.l4 = emit_ilabel(seq_ptr[3], cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
} else {
|
|
|
|
/* skip one */
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-04-30 18:46:05 +01:00
|
|
|
GONEXT(xllll);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_4sw_s(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
CELL *seq_ptr;
|
|
|
|
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.sllll.s = cip->cpc->rnd2;
|
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
seq_ptr = cip->cpc->arnds;
|
|
|
|
code_p->u.sllll.l1 = emit_ilabel(seq_ptr[0], cip);
|
|
|
|
code_p->u.sllll.l2 = emit_ilabel(seq_ptr[1], cip);
|
|
|
|
code_p->u.sllll.l3 = emit_ilabel(seq_ptr[2], cip);
|
|
|
|
code_p->u.sllll.l4 = emit_ilabel(seq_ptr[3], cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2003-04-30 18:46:05 +01:00
|
|
|
/* skip one */
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-04-30 18:46:05 +01:00
|
|
|
GONEXT(sllll);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-08-27 14:37:10 +01:00
|
|
|
init_log_upd_table(LogUpdIndex *ic, union clause_obj *cl_u)
|
|
|
|
{
|
|
|
|
/* insert myself in the indexing code chain */
|
|
|
|
ic->SiblingIndex = cl_u->lui.ChildIndex;
|
2005-05-31 20:42:28 +01:00
|
|
|
if (ic->SiblingIndex) {
|
|
|
|
ic->SiblingIndex->PrevSiblingIndex = ic;
|
|
|
|
}
|
|
|
|
cl_u->lui.ChildIndex = ic;
|
|
|
|
ic->PrevSiblingIndex = NULL;
|
2003-08-27 14:37:10 +01:00
|
|
|
ic->ChildIndex = NULL;
|
|
|
|
ic->ClRefCount = 0;
|
2005-12-17 03:25:39 +00:00
|
|
|
ic->ParentIndex = (LogUpdIndex *)cl_u;
|
2008-08-07 21:51:23 +01:00
|
|
|
// INIT_LOCK(ic->ClLock);
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->lui.ChildIndex = ic;
|
|
|
|
cl_u->lui.ClRefCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_static_table(StaticIndex *ic, union clause_obj *cl_u)
|
|
|
|
{
|
|
|
|
/* insert myself in the indexing code chain */
|
|
|
|
ic->SiblingIndex = cl_u->si.ChildIndex;
|
|
|
|
ic->ChildIndex = NULL;
|
|
|
|
cl_u->si.ChildIndex = ic;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_hx(op_numbers opcode, union clause_obj *cl_u, int log_update, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
register CELL i, imax;
|
2004-01-23 02:23:51 +00:00
|
|
|
register CELL *seq_ptr = (CELL *)cip->cpc->rnd2;
|
2004-03-31 02:03:10 +01:00
|
|
|
int j = 0;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
imax = cip->cpc->rnd1;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-03-31 02:03:10 +01:00
|
|
|
code_p->u.sssl.s = emit_c(imax);
|
|
|
|
code_p->u.sssl.l = emit_a(cip->cpc->rnd2);
|
2003-08-27 14:37:10 +01:00
|
|
|
if (log_update) {
|
2004-01-23 02:23:51 +00:00
|
|
|
init_log_upd_table(ClauseCodeToLogUpdIndex(cip->cpc->rnd2), cl_u);
|
2003-08-27 14:37:10 +01:00
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
init_static_table(ClauseCodeToStaticIndex(cip->cpc->rnd2), cl_u);
|
2003-08-27 14:37:10 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-08-27 14:37:10 +01:00
|
|
|
if (pass_no) {
|
|
|
|
for (i = 0; i < imax; i++) {
|
2004-03-31 02:03:10 +01:00
|
|
|
yamop *ipc = (yamop *)seq_ptr[1];
|
2004-01-23 02:23:51 +00:00
|
|
|
a_pair(seq_ptr, pass_no, cip);
|
2004-03-31 02:03:10 +01:00
|
|
|
if (ipc != FAILCODE) {
|
|
|
|
j++;
|
|
|
|
}
|
2003-08-27 14:37:10 +01:00
|
|
|
seq_ptr += 2;
|
|
|
|
}
|
2004-03-31 02:03:10 +01:00
|
|
|
code_p->u.sssl.e = j;
|
|
|
|
code_p->u.sssl.w = 0;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-03-31 02:03:10 +01:00
|
|
|
GONEXT(sssl);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_if(op_numbers opcode, union clause_obj *cl_u, int log_update, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
register CELL i, imax;
|
2004-01-23 02:23:51 +00:00
|
|
|
register CELL *seq_ptr = (CELL *)cip->cpc->rnd2;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
imax = cip->cpc->rnd1;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-03-31 02:03:10 +01:00
|
|
|
code_p->u.sssl.s = code_p->u.sssl.e = emit_count(imax);
|
|
|
|
code_p->u.sssl.w = 0;
|
|
|
|
code_p->u.sssl.l = emit_a(cip->cpc->rnd2);
|
2003-08-27 14:37:10 +01:00
|
|
|
if (log_update) {
|
2004-01-23 02:23:51 +00:00
|
|
|
init_log_upd_table(ClauseCodeToLogUpdIndex(cip->cpc->rnd2), cl_u);
|
2003-08-27 14:37:10 +01:00
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
init_static_table(ClauseCodeToStaticIndex(cip->cpc->rnd2), cl_u);
|
2003-08-27 14:37:10 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-03-31 02:03:10 +01:00
|
|
|
GONEXT(sssl);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
2004-02-05 16:57:02 +00:00
|
|
|
CELL lab, lab0;
|
2003-08-27 14:37:10 +01:00
|
|
|
for (i = 0; i < imax; i++) {
|
2004-01-23 02:23:51 +00:00
|
|
|
a_pair(seq_ptr, pass_no, cip);
|
2003-08-27 14:37:10 +01:00
|
|
|
seq_ptr += 2;
|
|
|
|
}
|
2004-02-05 16:57:02 +00:00
|
|
|
lab0 = seq_ptr[1];
|
|
|
|
lab = (CELL) emit_ilabel(lab0, cip);
|
|
|
|
seq_ptr[1] = lab;
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_ifnot(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2003-04-30 18:46:05 +01:00
|
|
|
{
|
2004-02-05 16:57:02 +00:00
|
|
|
CELL *seq_ptr = cip->cpc->arnds;
|
2003-04-30 18:46:05 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2004-02-05 16:57:02 +00:00
|
|
|
code_p->u.clll.c = seq_ptr[0]; /* tag */
|
|
|
|
code_p->u.clll.l1 = emit_ilabel(seq_ptr[1], cip); /* success point */
|
|
|
|
code_p->u.clll.l2 = emit_ilabel(seq_ptr[2], cip); /* fail point */
|
|
|
|
code_p->u.clll.l3 = emit_ilabel(seq_ptr[3], cip); /* delay point */
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-10-02 13:59:05 +01:00
|
|
|
GONEXT(clll);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_cut(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2003-10-17 03:11:21 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = check_alloc(clinfo, code_p, pass_no, cip);
|
|
|
|
if (clinfo->dealloc_found) {
|
|
|
|
return a_e(_cut_e, code_p, pass_no);
|
2005-07-06 16:10:18 +01:00
|
|
|
} else if (clinfo->alloc_found == 1) {
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_e(_cut, code_p, pass_no);
|
|
|
|
} else {
|
|
|
|
return a_e(_cut_t, code_p, pass_no);
|
2003-10-17 03:11:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
a_try(op_numbers opcode, CELL lab, CELL opr, int nofalts, int hascut, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2006-10-10 15:08:17 +01:00
|
|
|
a_try(op_numbers opcode, CELL lab, CELL opr, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
{
|
2006-10-10 15:08:17 +01:00
|
|
|
PredEntry *ap = cip->CurrentPred;
|
|
|
|
|
|
|
|
/* if predicates are logical do it in a different way */
|
|
|
|
if (ap->PredFlags & LogUpdatePredFlag) {
|
|
|
|
yamop *newcp;
|
|
|
|
/* emit a special instruction and then a label for backpatching */
|
|
|
|
if (pass_no) {
|
2008-09-05 05:22:19 +01:00
|
|
|
UInt size = (UInt)NEXTOP((yamop *)NULL,OtaLl);
|
2006-10-10 15:08:17 +01:00
|
|
|
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
|
|
|
/* OOOPS, got in trouble, must do a longjmp and recover space */
|
|
|
|
save_machine_regs();
|
|
|
|
longjmp(cip->CompilerBotch,2);
|
|
|
|
}
|
2006-11-06 18:35:05 +00:00
|
|
|
Yap_LUIndexSpace_CP += size;
|
2006-10-11 15:53:57 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
Yap_NewCps++;
|
|
|
|
Yap_LiveCps++;
|
|
|
|
#endif
|
2009-02-09 21:56:40 +00:00
|
|
|
newcp->u.OtaLl.n = NULL;
|
|
|
|
*cip->current_try_lab = newcp;
|
2006-10-10 15:08:17 +01:00
|
|
|
if (opcode == _try_clause) {
|
|
|
|
newcp->opc = emit_op(_try_logical);
|
2008-09-05 05:22:19 +01:00
|
|
|
newcp->u.OtaLl.s = emit_count(opr);
|
2006-10-10 15:08:17 +01:00
|
|
|
} else if (opcode == _retry) {
|
|
|
|
if (ap->PredFlags & CountPredFlag)
|
|
|
|
newcp->opc = emit_op(_count_retry_logical);
|
|
|
|
else if (ap->PredFlags & ProfiledPredFlag)
|
|
|
|
newcp->opc = emit_op(_profiled_retry_logical);
|
|
|
|
else
|
|
|
|
newcp->opc = emit_op(_retry_logical);
|
2008-09-05 05:22:19 +01:00
|
|
|
newcp->u.OtaLl.s = emit_count(opr);
|
2006-10-10 15:08:17 +01:00
|
|
|
} else {
|
2009-02-09 21:56:40 +00:00
|
|
|
/* trust */
|
2006-10-10 15:08:17 +01:00
|
|
|
if (ap->PredFlags & CountPredFlag)
|
|
|
|
newcp->opc = emit_op(_count_trust_logical);
|
|
|
|
else if (ap->PredFlags & ProfiledPredFlag)
|
|
|
|
newcp->opc = emit_op(_profiled_trust_logical);
|
|
|
|
else
|
|
|
|
newcp->opc = emit_op(_trust_logical);
|
2008-09-05 05:22:19 +01:00
|
|
|
newcp->u.OtILl.block = (LogUpdIndex *)(cip->code_addr);
|
2006-12-27 01:32:38 +00:00
|
|
|
*cip->current_trust_lab = newcp;
|
2006-10-10 15:08:17 +01:00
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
newcp->u.OtaLl.d = ClauseCodeToLogUpdClause(emit_a(lab));
|
|
|
|
cip->current_try_lab = &(newcp->u.OtaLl.n);
|
2006-10-10 15:08:17 +01:00
|
|
|
}
|
|
|
|
return code_p;
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
switch (opr) {
|
|
|
|
case 2:
|
|
|
|
if (opcode == _try_clause) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_try_clause2);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
} else if (opcode == _retry) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_retry2);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
if (opcode == _try_clause) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_try_clause3);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
} else if (opcode == _retry) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_retry3);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
if (opcode == _try_clause) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_try_clause4);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
} else if (opcode == _retry) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_retry4);
|
|
|
|
code_p->u.l.l = emit_a(lab);
|
|
|
|
}
|
|
|
|
GONEXT(l);
|
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Otapl.d = emit_a(lab);
|
|
|
|
code_p->u.Otapl.s = emit_count(opr);
|
|
|
|
code_p->u.Otapl.p = ap;
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Otapl.te = ap->TableOfPred;
|
2003-12-18 16:38:40 +00:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
INIT_YAMOP_LTT(code_p, nofalts);
|
|
|
|
if (hascut)
|
|
|
|
PUT_YAMOP_CUT(code_p);
|
2006-10-10 15:08:17 +01:00
|
|
|
if (ap->PredFlags & SequentialPredFlag)
|
2001-04-09 20:54:03 +01:00
|
|
|
PUT_YAMOP_SEQ(code_p);
|
|
|
|
#endif /* YAPOR */
|
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Otapl);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2004-01-23 02:23:51 +00:00
|
|
|
a_either(op_numbers opcode, CELL opr, CELL lab, int nofalts, int hascut, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
a_either(op_numbers opcode, CELL opr, CELL lab, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
{
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(opcode);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osblp.s = emit_count(opr);
|
|
|
|
code_p->u.Osblp.l = emit_a(lab);
|
|
|
|
code_p->u.Osblp.p0 = cip->CurrentPred;
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
INIT_YAMOP_LTT(code_p, nofalts);
|
|
|
|
if (hascut)
|
|
|
|
PUT_YAMOP_CUT(code_p);
|
2008-03-25 16:45:53 +00:00
|
|
|
if (cip->CurrentPred->PredFlags & SequentialPredFlag)
|
2001-04-09 20:54:03 +01:00
|
|
|
PUT_YAMOP_SEQ(code_p);
|
|
|
|
if(opcode != _or_last) {
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osblp.bmap = emit_bmlabel(cip->cpc->arnds[1], cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
#else
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osblp.bmap = emit_bmlabel(cip->cpc->arnds[1], cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
}
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Osblp);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
2006-10-10 15:08:17 +01:00
|
|
|
a_gl(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
return a_try(opcode, cpc->rnd1, IPredArity, cpc->rnd2 >> 1, cpc->rnd2 & 1, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2006-10-10 15:08:17 +01:00
|
|
|
return a_try(opcode, cpc->rnd1, IPredArity, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* optimizes several unify_cons for the same constant. It must be avoided for
|
|
|
|
* the head of the first argument, because of indexing
|
|
|
|
*/
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_ucons(int *do_not_optimise_uatomp, compiler_vm_op opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
#if AGGREGATE_OPS
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *np = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
register int i = 0;
|
2004-01-23 02:23:51 +00:00
|
|
|
CELL my_cons = cip->cpc->rnd1;
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (*do_not_optimise_uatomp) {
|
|
|
|
*do_not_optimise_uatomp = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (opcode == unify_atom_op)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_uc(cip->cpc->rnd1, _unify_atom, _unify_atom_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_c(cip->cpc->rnd1, _write_atom, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (np->op == opcode && np->rnd1 == my_cons) {
|
|
|
|
i++;
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = np;
|
2001-04-09 20:54:03 +01:00
|
|
|
np = np->nextInst;
|
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
if (opcode == unify_atom_op)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_uc(cip->cpc->rnd1, _unify_atom, _unify_atom_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_c(cip->cpc->rnd1, _write_atom, code_p, pass_no);
|
|
|
|
} else {
|
2001-04-09 20:54:03 +01:00
|
|
|
if (opcode == unify_atom_op)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_unc(cip->cpc->rnd1, _unify_n_atoms, _unify_n_atoms_write, i + 1, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_nc(cip->cpc->rnd1, _write_n_atoms, i + 1, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
*do_not_optimise_uatomp = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (opcode == unify_atom_op)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_uc(cip->cpc->rnd1, _unify_atom, _unify_atom_write, code_p);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_c(cip->cpc->rnd1, _write_atom, code_p);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_uvar(yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (!is_void_var()) {
|
|
|
|
#if AGGREGATE_OPS
|
|
|
|
if (is_temp_var()) {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *np = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
if (np->op == unify_var_op &&
|
|
|
|
is_atemp_var(np)) {
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_vv(_unify_x_var2, _unify_x_var2_write, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
else if (np->op == unify_last_var_op &&
|
|
|
|
is_atemp_var(np)) {
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_vv(_unify_l_x_var2,
|
|
|
|
_unify_l_x_var2_write, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* AGGREGATE_OPS */
|
2008-08-21 13:38:25 +01:00
|
|
|
return a_uv((Ventry *) cip->cpc->rnd1, _unify_x_var, _unify_x_var_write, _unify_y_var, _unify_y_var_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if AGGREGATE_OPS
|
|
|
|
int i = 1;
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *np = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* skip void vars */
|
|
|
|
while (np->op == unify_var_op && is_a_void(np->rnd1)) {
|
|
|
|
i++;
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = np;
|
2001-04-09 20:54:03 +01:00
|
|
|
np = np->nextInst;
|
|
|
|
}
|
|
|
|
if (np->op == unify_last_var_op &&
|
|
|
|
is_a_void(np->rnd1)) {
|
|
|
|
if (i == 0)
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ue(_unify_l_void, _unify_l_void_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_un(_unify_l_n_voids, _unify_l_n_voids_write, i + 1, code_p, pass_no);
|
|
|
|
cip->cpc = np;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
else if (i == 1)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_ue(_unify_void, _unify_void_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else {
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_un(_unify_n_voids, _unify_n_voids_write, i, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_ue(_unify_void, _unify_void_write);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_wvar(yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
if (!no_ref_var())
|
2008-08-21 13:38:25 +01:00
|
|
|
return a_v(_write_x_var, _write_y_var, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
else {
|
|
|
|
#if AGGREGATE_OPS
|
|
|
|
int i = 0;
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *np = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
while (np->op == write_var_op && no_ref(np->rnd1)) {
|
|
|
|
i++;
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = np;
|
2001-04-09 20:54:03 +01:00
|
|
|
np = np->nextInst;
|
|
|
|
}
|
|
|
|
if (i == 0)
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_e(_write_void, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else {
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_n(_write_n_voids, i + 1, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_e(_write_void, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_glist(int *do_not_optimise_uatomp, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
#if AGGREGATE_OPS
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *pnext = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd2 != 1 && pnext->op == unify_val_op) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve = (Ventry *) pnext->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
int is_y_var;
|
|
|
|
OPREG var_offset;
|
|
|
|
|
|
|
|
pnext->rnd2 = cip->cpc->rnd2;
|
|
|
|
cip->cpc = pnext;
|
|
|
|
is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2008-08-21 13:38:25 +01:00
|
|
|
return a_rv(_glist_valx, _glist_valy, var_offset, code_p, pass_no, cip->cpc);
|
2004-01-23 02:23:51 +00:00
|
|
|
} else if (cip->cpc->rnd2 == 1 && pnext->op == unify_atom_op) {
|
|
|
|
*do_not_optimise_uatomp = TRUE;
|
|
|
|
return a_r(cip->cpc->rnd2, _get_list, code_p, pass_no);
|
|
|
|
} else if (cip->cpc->rnd2 != 1 && pnext->op == unify_var_op
|
2001-04-09 20:54:03 +01:00
|
|
|
&& is_a_void(pnext->rnd1)) {
|
|
|
|
PInstr *ppnext = pnext->nextInst;
|
|
|
|
|
|
|
|
if (ppnext && (ppnext->op == unify_last_var_op
|
|
|
|
|| ppnext->op == unify_last_val_op)) {
|
|
|
|
Ventry *ve = (Ventry *) ppnext->rnd1;
|
2004-01-23 02:23:51 +00:00
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
OPREG var_offset;
|
|
|
|
|
|
|
|
ppnext->rnd2 = cip->cpc->rnd2;
|
|
|
|
cip->cpc = ppnext;
|
|
|
|
var_offset = Var_Ref(ve, is_y_var);
|
2008-08-21 13:38:25 +01:00
|
|
|
if (cip->cpc->op == unify_last_var_op)
|
|
|
|
return a_rv(_gl_void_varx, _gl_void_vary, var_offset, code_p, pass_no, cip->cpc);
|
|
|
|
else
|
|
|
|
return a_rv(_gl_void_valx, _gl_void_valy, var_offset, code_p, pass_no, cip->cpc);
|
2004-01-23 02:23:51 +00:00
|
|
|
} else {
|
|
|
|
return a_r(cip->cpc->rnd2, _get_list, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
} else
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* AGGREGATE_OPS */
|
2004-01-23 02:23:51 +00:00
|
|
|
return a_r(cip->cpc->rnd2, _get_list, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-08-28 04:43:00 +01:00
|
|
|
#define NEXTOPC (cip->cpc->nextInst->op)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_deallocate(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2005-07-06 16:10:18 +01:00
|
|
|
if (clinfo->alloc_found == 1) {
|
2008-08-28 04:43:00 +01:00
|
|
|
if (NEXTOPC == execute_op &&
|
|
|
|
!(RepPredProp((Prop)(cip->cpc->nextInst->rnd1))->PredFlags & CPredFlag)) {
|
2005-07-06 16:10:18 +01:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
code_p = a_p(_dexecute, clinfo, code_p, pass_no, cip);
|
|
|
|
} else
|
2008-08-30 16:24:44 +01:00
|
|
|
code_p = a_p0(_deallocate, code_p, pass_no, cip->CurrentPred);
|
2005-07-06 16:10:18 +01:00
|
|
|
clinfo->dealloc_found = TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_bmap(yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* how much space do we need to reserve */
|
|
|
|
int i, max = (cpc->rnd1)/(8*sizeof(CELL));
|
2004-01-23 02:23:51 +00:00
|
|
|
for (i = 0; i <= max; i++)
|
|
|
|
code_p = fill_a(cpc->arnds[i], code_p, pass_no);
|
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_bregs(yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* how much space do we need to reserve */
|
|
|
|
int i, max = (cpc->rnd1)/(8*sizeof(CELL));
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = fill_a(cpc->rnd1, code_p, pass_no);
|
|
|
|
for (i = 0; i <= max; i++)
|
|
|
|
code_p = fill_a(cpc->arnds[i], code_p, pass_no);
|
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
copy_blob(yamop *code_p, int pass_no, struct PSEUDO *cpc)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* copy the blob to code space, making no effort to align if a double */
|
|
|
|
int max = cpc->rnd1, i;
|
|
|
|
for (i = 0; i < max; i++)
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = fill_a(cpc->arnds[i], code_p, pass_no);
|
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_vv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* the next three instructions must be a get_val, get_val, and BIP */
|
|
|
|
if (pass_no == 0) {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE != PermVar)
|
|
|
|
p->op = nop_op;
|
|
|
|
p = p->nextInst;
|
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE != PermVar)
|
|
|
|
p->op = nop_op;
|
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->c_type = TYPE_XX;
|
2001-04-09 20:54:03 +01:00
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE == PermVar) {
|
|
|
|
/* don't get rid of get_val_op */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(p->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
/* and use it directly as a second argument */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
p = p->nextInst;
|
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE == PermVar) {
|
|
|
|
/* don't get rid of get_val_op */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x2_arg = emit_x(p->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
/* and use it directly as a second argument */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x2_arg = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_vc(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* the next two instructions must be a get_val and BIP */
|
|
|
|
if (pass_no == 0) {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE != PermVar)
|
|
|
|
p->op = nop_op;
|
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->c_type = TYPE_XC;
|
2005-04-10 05:01:15 +01:00
|
|
|
cmp_info->c_arg = cip->cpc->rnd1;
|
2001-04-09 20:54:03 +01:00
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE == PermVar) {
|
|
|
|
/* don't get rid of get_val_op */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(p->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
/* and use it directly as a second argument */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_cv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/* the next two instructions must be a get_val and BIP */
|
|
|
|
if (pass_no == 0) {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE != PermVar)
|
|
|
|
p->op = nop_op;
|
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
PInstr *p = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
Ventry *ve;
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->c_type = TYPE_CX;
|
2005-04-10 05:01:15 +01:00
|
|
|
cmp_info->c_arg = cip->cpc->rnd1;
|
2001-04-09 20:54:03 +01:00
|
|
|
ve = (Ventry *) p->rnd1;
|
|
|
|
if (ve->KindOfVE == PermVar) {
|
|
|
|
/* don't get rid of get_val_op */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(p->rnd2);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
/* and use it directly as a second argument */
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info->x1_arg = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
static yamop *
|
|
|
|
a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
2004-01-23 02:23:51 +00:00
|
|
|
Int opc = cip->cpc->rnd2;
|
|
|
|
Ventry *ve = (Ventry *)(cip->cpc->rnd1);
|
2001-04-09 20:54:03 +01:00
|
|
|
int is_y_var = (ve->KindOfVE == PermVar);
|
|
|
|
|
|
|
|
if (opc <= _primitive) {
|
|
|
|
if (is_y_var) {
|
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.yl.y = emit_y(ve);
|
2001-04-09 20:54:03 +01:00
|
|
|
switch (opc) {
|
|
|
|
case _atom:
|
|
|
|
code_p->opc = opcode(_p_atom_y);
|
|
|
|
break;
|
|
|
|
case _atomic:
|
|
|
|
code_p->opc = opcode(_p_atomic_y);
|
|
|
|
break;
|
|
|
|
case _compound:
|
|
|
|
code_p->opc = opcode(_p_compound_y);
|
|
|
|
break;
|
|
|
|
case _float:
|
|
|
|
code_p->opc = opcode(_p_float_y);
|
|
|
|
break;
|
|
|
|
case _integer:
|
|
|
|
code_p->opc = opcode(_p_integer_y);
|
|
|
|
break;
|
|
|
|
case _nonvar:
|
|
|
|
code_p->opc = opcode(_p_nonvar_y);
|
|
|
|
break;
|
|
|
|
case _number:
|
|
|
|
code_p->opc = opcode(_p_number_y);
|
|
|
|
break;
|
|
|
|
case _var:
|
|
|
|
code_p->opc = opcode(_p_var_y);
|
|
|
|
break;
|
|
|
|
case _db_ref:
|
|
|
|
code_p->opc = opcode(_p_db_ref_y);
|
|
|
|
break;
|
|
|
|
case _cut_by:
|
|
|
|
code_p->opc = opcode(_p_cut_by_y);
|
|
|
|
break;
|
|
|
|
case _primitive:
|
|
|
|
code_p->opc = opcode(_p_primitive_y);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.yl.F = emit_fail(cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(yl);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.xl.x = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2001-04-09 20:54:03 +01:00
|
|
|
switch (opc) {
|
|
|
|
case _atom:
|
|
|
|
code_p->opc = opcode(_p_atom_x);
|
|
|
|
break;
|
|
|
|
case _atomic:
|
|
|
|
code_p->opc = opcode(_p_atomic_x);
|
|
|
|
break;
|
|
|
|
case _compound:
|
|
|
|
code_p->opc = opcode(_p_compound_x);
|
|
|
|
break;
|
|
|
|
case _float:
|
|
|
|
code_p->opc = opcode(_p_float_x);
|
|
|
|
break;
|
|
|
|
case _integer:
|
|
|
|
code_p->opc = opcode(_p_integer_x);
|
|
|
|
break;
|
|
|
|
case _nonvar:
|
|
|
|
code_p->opc = opcode(_p_nonvar_x);
|
|
|
|
break;
|
|
|
|
case _number:
|
|
|
|
code_p->opc = opcode(_p_number_x);
|
|
|
|
break;
|
|
|
|
case _var:
|
|
|
|
code_p->opc = opcode(_p_var_x);
|
|
|
|
break;
|
|
|
|
case _db_ref:
|
|
|
|
code_p->opc = opcode(_p_db_ref_x);
|
|
|
|
break;
|
|
|
|
case _cut_by:
|
|
|
|
code_p->opc = opcode(_p_cut_by_x);
|
|
|
|
break;
|
|
|
|
case _primitive:
|
|
|
|
code_p->opc = opcode(_p_primitive_x);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-09 14:23:19 +00:00
|
|
|
code_p->u.xl.F = emit_fail(cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(xl);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
if (opc == _functor && cip->cpc->nextInst->op == f_var_op) {
|
2001-04-23 21:41:58 +01:00
|
|
|
Ventry *nve;
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
|
|
|
nve = (Ventry *)(cip->cpc->rnd1);
|
2001-04-23 21:41:58 +01:00
|
|
|
if (is_y_var) {
|
|
|
|
if (nve->KindOfVE == PermVar) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_p_func2f_yy);
|
|
|
|
code_p->u.yyx.y1 = emit_y(ve);
|
|
|
|
code_p->u.yyx.y2 = emit_y(nve);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.yyx.x = cmp_info->x1_arg;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
|
|
|
GONEXT(yyx);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-23 21:41:58 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_p_func2f_yx);
|
|
|
|
code_p->u.yxx.y = emit_y(ve);
|
|
|
|
code_p->u.yxx.x1 = emit_x(nve->NoOfVE & MaskVarAdrs);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.yxx.x2 = cmp_info->x1_arg;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
|
|
|
GONEXT(yxx);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (nve->KindOfVE == PermVar) {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_p_func2f_xy);
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p->u.xxy.x1 = emit_x(ve->NoOfVE & MaskVarAdrs);
|
|
|
|
code_p->u.xxy.y2 = emit_y(nve);
|
|
|
|
code_p->u.xxy.x = cmp_info->x1_arg;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
2008-08-21 13:38:25 +01:00
|
|
|
GONEXT(xxy);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-23 21:41:58 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
|
|
|
code_p->opc = emit_op(_p_func2f_xx);
|
|
|
|
code_p->u.xxx.x1 = emit_x(ve->NoOfVE & MaskVarAdrs);
|
|
|
|
code_p->u.xxx.x2 = emit_x(nve->NoOfVE & MaskVarAdrs);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xxx.x = cmp_info->x1_arg;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
|
|
|
GONEXT(xxx);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-23 21:41:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
if (is_y_var) {
|
2004-01-23 02:23:51 +00:00
|
|
|
switch (cmp_info->c_type) {
|
2001-04-09 20:54:03 +01:00
|
|
|
case TYPE_XX:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
|
|
|
code_p->opc = emit_op(_p_plus_y_vv);
|
|
|
|
break;
|
|
|
|
case _minus:
|
|
|
|
code_p->opc = emit_op(_p_minus_y_vv);
|
|
|
|
break;
|
|
|
|
case _times:
|
|
|
|
code_p->opc = emit_op(_p_times_y_vv);
|
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_y_vv);
|
|
|
|
break;
|
|
|
|
case _and:
|
|
|
|
code_p->opc = emit_op(_p_and_y_vv);
|
|
|
|
break;
|
|
|
|
case _or:
|
|
|
|
code_p->opc = emit_op(_p_or_y_vv);
|
|
|
|
break;
|
|
|
|
case _sll:
|
|
|
|
code_p->opc = emit_op(_p_sll_y_vv);
|
|
|
|
break;
|
|
|
|
case _slr:
|
|
|
|
code_p->opc = emit_op(_p_slr_y_vv);
|
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
|
|
|
code_p->opc = emit_op(_p_arg_y_vv);
|
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_y_vv);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
code_p->u.yxx.y = emit_y(ve);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.yxx.x1 = cmp_info->x1_arg;
|
|
|
|
code_p->u.yxx.x2 = cmp_info->x2_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(yxx);
|
|
|
|
break;
|
|
|
|
case TYPE_CX:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2 (should be XC)");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _minus:
|
|
|
|
code_p->opc = emit_op(_p_minus_y_cv);
|
|
|
|
break;
|
|
|
|
case _times:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2 (should be XC)");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_y_cv);
|
|
|
|
break;
|
|
|
|
case _and:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2 (should be XC)");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _or:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2 (should be XC)");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _sll:
|
|
|
|
code_p->opc = emit_op(_p_sll_y_cv);
|
|
|
|
break;
|
|
|
|
case _slr:
|
|
|
|
code_p->opc = emit_op(_p_slr_y_cv);
|
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
|
|
|
code_p->opc = emit_op(_p_arg_y_cv);
|
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_y_cv);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-30 23:00:50 +01:00
|
|
|
code_p->u.yxn.y = emit_y(ve);
|
|
|
|
code_p->u.yxn.c = cmp_info->c_arg;
|
|
|
|
code_p->u.yxn.xi = cmp_info->x1_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-30 23:00:50 +01:00
|
|
|
GONEXT(yxn);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case TYPE_XC:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
|
|
|
code_p->opc = emit_op(_p_plus_y_vc);
|
|
|
|
break;
|
|
|
|
case _minus:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _times:
|
|
|
|
code_p->opc = emit_op(_p_times_y_vc);
|
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_y_vc);
|
|
|
|
break;
|
|
|
|
case _and:
|
|
|
|
code_p->opc = emit_op(_p_and_y_vc);
|
|
|
|
break;
|
|
|
|
case _or:
|
|
|
|
code_p->opc = emit_op(_p_or_y_vc);
|
|
|
|
break;
|
|
|
|
case _sll:
|
2006-01-02 02:16:19 +00:00
|
|
|
if ((Int)cmp_info->c_arg < 0) {
|
|
|
|
code_p->opc = emit_op(_p_slr_y_vc);
|
|
|
|
cmp_info->c_arg = -(Int)cmp_info->c_arg;
|
|
|
|
} else {
|
|
|
|
code_p->opc = emit_op(_p_sll_y_vc);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _slr:
|
2006-01-02 02:16:19 +00:00
|
|
|
if ((Int)cmp_info->c_arg < 0) {
|
|
|
|
code_p->opc = emit_op(_p_sll_y_vc);
|
|
|
|
cmp_info->c_arg = -(Int)cmp_info->c_arg;
|
|
|
|
} else {
|
|
|
|
code_p->opc = emit_op(_p_slr_y_vc);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
2001-04-20 16:48:04 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-20 16:48:04 +01:00
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_y_vc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-30 23:00:50 +01:00
|
|
|
code_p->u.yxn.y = emit_y(ve);
|
|
|
|
code_p->u.yxn.c = cmp_info->c_arg;
|
|
|
|
code_p->u.yxn.xi = cmp_info->x1_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-30 23:00:50 +01:00
|
|
|
GONEXT(yxn);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
switch (cmp_info->c_type) {
|
2001-04-09 20:54:03 +01:00
|
|
|
case TYPE_XX:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
|
|
|
code_p->opc = emit_op(_p_plus_vv);
|
|
|
|
break;
|
|
|
|
case _minus:
|
|
|
|
code_p->opc = emit_op(_p_minus_vv);
|
|
|
|
break;
|
|
|
|
case _times:
|
|
|
|
code_p->opc = emit_op(_p_times_vv);
|
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_vv);
|
|
|
|
break;
|
|
|
|
case _and:
|
|
|
|
code_p->opc = emit_op(_p_and_vv);
|
|
|
|
break;
|
|
|
|
case _or:
|
|
|
|
code_p->opc = emit_op(_p_or_vv);
|
|
|
|
break;
|
|
|
|
case _sll:
|
|
|
|
code_p->opc = emit_op(_p_sll_vv);
|
|
|
|
break;
|
|
|
|
case _slr:
|
|
|
|
code_p->opc = emit_op(_p_slr_vv);
|
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
|
|
|
code_p->opc = emit_op(_p_arg_vv);
|
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_vv);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
code_p->u.xxx.x = emit_x(ve->NoOfVE & MaskVarAdrs);
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p->u.xxx.x1 = cmp_info->x1_arg;
|
|
|
|
code_p->u.xxx.x2 = cmp_info->x2_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
GONEXT(xxx);
|
|
|
|
break;
|
|
|
|
case TYPE_CX:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _minus:
|
|
|
|
code_p->opc = emit_op(_p_minus_cv);
|
|
|
|
break;
|
|
|
|
case _times:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_cv);
|
|
|
|
break;
|
|
|
|
case _and:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _or:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _sll:
|
|
|
|
code_p->opc = emit_op(_p_sll_cv);
|
|
|
|
break;
|
|
|
|
case _slr:
|
|
|
|
code_p->opc = emit_op(_p_slr_cv);
|
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
|
|
|
code_p->opc = emit_op(_p_arg_cv);
|
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_cv);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-29 17:27:11 +01:00
|
|
|
code_p->u.xxn.x = emit_x(ve->NoOfVE & MaskVarAdrs);
|
|
|
|
code_p->u.xxn.c = cmp_info->c_arg;
|
|
|
|
code_p->u.xxn.xi = cmp_info->x1_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-29 17:27:11 +01:00
|
|
|
GONEXT(xxn);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case TYPE_XC:
|
|
|
|
if (pass_no) {
|
|
|
|
switch (opc) {
|
|
|
|
case _plus:
|
|
|
|
code_p->opc = emit_op(_p_plus_vc);
|
|
|
|
break;
|
|
|
|
case _minus:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _times:
|
|
|
|
code_p->opc = emit_op(_p_times_vc);
|
|
|
|
break;
|
|
|
|
case _div:
|
|
|
|
code_p->opc = emit_op(_p_div_vc);
|
|
|
|
break;
|
|
|
|
case _and:
|
|
|
|
code_p->opc = emit_op(_p_and_vc);
|
|
|
|
break;
|
|
|
|
case _or:
|
|
|
|
code_p->opc = emit_op(_p_or_vc);
|
|
|
|
break;
|
|
|
|
case _sll:
|
2006-01-02 02:16:19 +00:00
|
|
|
if ((Int)cmp_info->c_arg < 0) {
|
|
|
|
code_p->opc = emit_op(_p_slr_vc);
|
|
|
|
cmp_info->c_arg = -(Int)cmp_info->c_arg;
|
|
|
|
} else {
|
|
|
|
code_p->opc = emit_op(_p_sll_vc);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case _slr:
|
2006-01-02 02:16:19 +00:00
|
|
|
if ((Int)cmp_info->c_arg < 0) {
|
|
|
|
code_p->opc = emit_op(_p_sll_vc);
|
|
|
|
cmp_info->c_arg = -(Int)cmp_info->c_arg;
|
|
|
|
} else {
|
|
|
|
code_p->opc = emit_op(_p_slr_vc);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2001-04-20 16:48:04 +01:00
|
|
|
case _arg:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
2001-04-20 16:48:04 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-20 16:48:04 +01:00
|
|
|
break;
|
2001-04-23 21:41:58 +01:00
|
|
|
case _functor:
|
|
|
|
code_p->opc = emit_op(_p_func2s_vc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-29 17:27:11 +01:00
|
|
|
code_p->u.xxn.x = emit_x(ve->NoOfVE & MaskVarAdrs);
|
|
|
|
code_p->u.xxn.c = cmp_info->c_arg;
|
|
|
|
code_p->u.xxn.xi = cmp_info->x1_arg;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2008-08-29 17:27:11 +01:00
|
|
|
GONEXT(xxn);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2008-12-09 12:54:27 +00:00
|
|
|
static yamop *
|
|
|
|
a_special_label(yamop *code_p, int pass_no, struct intermediates *cip)
|
|
|
|
{
|
2008-12-09 14:23:19 +00:00
|
|
|
special_label_op lab_op = cip->cpc->rnd1;
|
|
|
|
special_label_id lab_id = cip->cpc->rnd2;
|
|
|
|
UInt lab_val = cip->cpc->rnd3;
|
2008-12-09 12:54:27 +00:00
|
|
|
|
2008-12-09 14:23:19 +00:00
|
|
|
switch (lab_op) {
|
|
|
|
case SPECIAL_LABEL_INIT:
|
|
|
|
switch (lab_id) {
|
|
|
|
case SPECIAL_LABEL_EXCEPTION:
|
|
|
|
cip->exception_handler = lab_val;
|
|
|
|
break;
|
|
|
|
case SPECIAL_LABEL_SUCCESS:
|
|
|
|
cip->success_handler = lab_val;
|
|
|
|
break;
|
|
|
|
case SPECIAL_LABEL_FAILURE:
|
|
|
|
cip->failure_handler = lab_val;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SPECIAL_LABEL_SET:
|
2008-12-09 12:54:27 +00:00
|
|
|
break;
|
2008-12-09 14:23:19 +00:00
|
|
|
case SPECIAL_LABEL_CLEAR:
|
|
|
|
switch (lab_id) {
|
|
|
|
case SPECIAL_LABEL_EXCEPTION:
|
|
|
|
cip->exception_handler = 0;
|
|
|
|
break;
|
|
|
|
case SPECIAL_LABEL_SUCCESS:
|
|
|
|
cip->success_handler = 0;
|
|
|
|
break;
|
|
|
|
case SPECIAL_LABEL_FAILURE:
|
|
|
|
cip->failure_handler = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-09 12:54:27 +00:00
|
|
|
return code_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
|
|
|
|
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2006-10-10 15:08:17 +01:00
|
|
|
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], IPredArity, code_p, pass_no, cip)
|
|
|
|
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), IPredArity, code_p, pass_no, cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
static yamop *
|
2007-11-06 17:02:13 +00:00
|
|
|
do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp, int *clause_has_dbtermp, struct intermediates *cip, UInt size)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
#ifdef YAPOR
|
2008-04-01 23:28:41 +01:00
|
|
|
#define MAX_DISJ_BRANCHES 256
|
|
|
|
yamop *either_inst[MAX_DISJ_BRANCHES];
|
2001-04-09 20:54:03 +01:00
|
|
|
int either_cont = 0;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
int log_update;
|
|
|
|
int dynamic;
|
2003-12-18 16:38:40 +00:00
|
|
|
int tabled;
|
2001-04-09 20:54:03 +01:00
|
|
|
int ystop_found = FALSE;
|
2003-04-30 18:46:05 +01:00
|
|
|
union clause_obj *cl_u;
|
2004-01-23 02:23:51 +00:00
|
|
|
yamop *code_p;
|
|
|
|
cmp_op_info cmp_info;
|
|
|
|
clause_info clinfo;
|
|
|
|
int do_not_optimise_uatom;
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = cip->code_addr;
|
2003-04-30 18:46:05 +01:00
|
|
|
cl_u = (union clause_obj *)code_p;
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->CodeStart;
|
2005-07-06 16:10:18 +01:00
|
|
|
clinfo.alloc_found = 0;
|
|
|
|
clinfo.dealloc_found = FALSE;
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo.CurrentPred = cip->CurrentPred;
|
2006-10-10 15:08:17 +01:00
|
|
|
cip->current_try_lab = NULL;
|
2008-12-09 12:54:27 +00:00
|
|
|
cip->exception_handler = 0;
|
|
|
|
cip->success_handler = 0;
|
|
|
|
cip->failure_handler = 0;
|
2006-10-10 15:08:17 +01:00
|
|
|
cip->try_instructions = NULL;
|
2004-01-23 02:23:51 +00:00
|
|
|
cmp_info.c_type = TYPE_XX;
|
2004-03-10 14:59:55 +00:00
|
|
|
cmp_info.cl_info = &clinfo;
|
2004-01-23 02:23:51 +00:00
|
|
|
do_not_optimise_uatom = FALSE;
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* Space while for the clause flags */
|
2004-01-23 02:23:51 +00:00
|
|
|
log_update = cip->CurrentPred->PredFlags & LogUpdatePredFlag;
|
|
|
|
dynamic = cip->CurrentPred->PredFlags & DynamicPredFlag;
|
|
|
|
tabled = cip->CurrentPred->PredFlags & TabledPredFlag;
|
2004-02-05 16:57:02 +00:00
|
|
|
if (assembling == ASSEMBLING_CLAUSE) {
|
2003-04-30 18:46:05 +01:00
|
|
|
if (log_update) {
|
|
|
|
if (pass_no) {
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->luc.Id = FunctorDBRef;
|
2003-04-30 18:46:05 +01:00
|
|
|
cl_u->luc.ClFlags = LogUpdMask;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->luc.ClRefCount = 0;
|
2004-01-23 02:23:51 +00:00
|
|
|
cl_u->luc.ClPred = cip->CurrentPred;
|
2004-03-05 15:26:33 +00:00
|
|
|
cl_u->luc.ClSize = size;
|
2006-10-10 15:08:17 +01:00
|
|
|
/* Support for timestamps */
|
|
|
|
if (cip->CurrentPred->LastCallOfPred != LUCALL_ASSERT) {
|
2006-11-15 00:13:37 +00:00
|
|
|
if (cip->CurrentPred->TimeStampOfPred >= TIMESTAMP_RESET)
|
|
|
|
Yap_UpdateTimestamps(cip->CurrentPred);
|
2006-10-10 15:08:17 +01:00
|
|
|
++cip->CurrentPred->TimeStampOfPred;
|
|
|
|
/* fprintf(stderr,"+ %x--%d--%ul\n",cip->CurrentPred,cip->CurrentPred->TimeStampOfPred,cip->CurrentPred->ArityOfPE);*/
|
|
|
|
cip->CurrentPred->LastCallOfPred = LUCALL_ASSERT;
|
2006-09-20 21:03:51 +01:00
|
|
|
}
|
2006-10-10 15:08:17 +01:00
|
|
|
cl_u->luc.ClTimeStart = cip->CurrentPred->TimeStampOfPred;
|
2006-11-15 00:13:37 +00:00
|
|
|
cl_u->luc.ClTimeEnd = TIMESTAMP_EOT;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (*clause_has_blobsp) {
|
2003-04-30 18:46:05 +01:00
|
|
|
cl_u->luc.ClFlags |= HasBlobsMask;
|
|
|
|
}
|
2007-11-06 17:02:13 +00:00
|
|
|
if (*clause_has_dbtermp) {
|
|
|
|
cl_u->luc.ClFlags |= HasDBTMask;
|
|
|
|
}
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->luc.ClExt = NULL;
|
|
|
|
cl_u->luc.ClPrev = cl_u->luc.ClNext = NULL;
|
2003-04-30 18:46:05 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2008-08-07 21:51:23 +01:00
|
|
|
//INIT_LOCK(cl_u->luc.ClLock);
|
2003-12-18 17:23:22 +00:00
|
|
|
INIT_CLREF_COUNT(&(cl_u->luc));
|
2003-04-30 18:46:05 +01:00
|
|
|
#endif
|
2002-06-11 06:30:47 +01:00
|
|
|
}
|
2003-04-30 18:46:05 +01:00
|
|
|
code_p = cl_u->luc.ClCode;
|
|
|
|
} else if (dynamic) {
|
|
|
|
if (pass_no) {
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->ic.ClFlags = DynamicMask;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (*clause_has_blobsp) {
|
2003-04-30 18:46:05 +01:00
|
|
|
cl_u->ic.ClFlags |= HasBlobsMask;
|
|
|
|
}
|
2007-11-06 17:02:13 +00:00
|
|
|
if (*clause_has_dbtermp) {
|
|
|
|
cl_u->ic.ClFlags |= HasDBTMask;
|
|
|
|
}
|
2004-03-05 15:26:33 +00:00
|
|
|
cl_u->ic.ClSize = size;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->ic.ClRefCount = 0;
|
2001-04-09 20:54:03 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2003-12-18 17:23:22 +00:00
|
|
|
INIT_LOCK(cl_u->ic.ClLock);
|
|
|
|
INIT_CLREF_COUNT(&(cl_u->ic));
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
code_p = cl_u->ic.ClCode;
|
|
|
|
} else {
|
|
|
|
/* static clause */
|
|
|
|
if (pass_no) {
|
2003-11-24 00:00:43 +00:00
|
|
|
cl_u->sc.ClFlags = StaticMask;
|
2003-11-26 18:36:35 +00:00
|
|
|
cl_u->sc.ClNext = NULL;
|
2004-03-05 15:26:33 +00:00
|
|
|
cl_u->sc.ClSize = size;
|
2005-08-02 04:09:52 +01:00
|
|
|
cl_u->sc.usc.ClPred = cip->CurrentPred;
|
2004-01-23 02:23:51 +00:00
|
|
|
if (*clause_has_blobsp) {
|
2003-04-30 18:46:05 +01:00
|
|
|
cl_u->sc.ClFlags |= HasBlobsMask;
|
|
|
|
}
|
2007-11-06 17:02:13 +00:00
|
|
|
if (*clause_has_dbtermp) {
|
|
|
|
cl_u->sc.ClFlags |= HasDBTMask;
|
|
|
|
}
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
code_p = cl_u->sc.ClCode;
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
IPredArity = cip->cpc->rnd2; /* number of args */
|
|
|
|
*entry_codep = code_p;
|
2005-05-30 06:26:50 +01:00
|
|
|
if (tabled) {
|
|
|
|
#if TABLING
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), IPredArity, code_p, pass_no, cip);
|
2005-05-30 06:26:50 +01:00
|
|
|
#endif
|
|
|
|
}
|
2003-11-26 18:36:35 +00:00
|
|
|
if (dynamic) {
|
2003-04-30 18:46:05 +01:00
|
|
|
#ifdef YAPOR
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_try(_try_me, 0, IPredArity, 1, 0, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_try(_try_me, 0, IPredArity, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2003-08-27 14:37:10 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2003-08-27 14:37:10 +01:00
|
|
|
/* index code */
|
2003-04-30 18:46:05 +01:00
|
|
|
if (log_update) {
|
|
|
|
if (pass_no) {
|
2003-10-31 00:20:52 +00:00
|
|
|
cl_u->lui.ClFlags = LogUpdMask|IndexedPredFlag|IndexMask|SwitchRootMask;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->lui.ChildIndex = NULL;
|
|
|
|
cl_u->lui.SiblingIndex = NULL;
|
2005-05-31 20:42:28 +01:00
|
|
|
cl_u->lui.PrevSiblingIndex = NULL;
|
2005-12-17 03:25:39 +00:00
|
|
|
cl_u->lui.ClPred = cip->CurrentPred;
|
|
|
|
cl_u->lui.ParentIndex = NULL;
|
2004-03-05 15:26:33 +00:00
|
|
|
cl_u->lui.ClSize = size;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->lui.ClRefCount = 0;
|
2008-08-07 21:51:23 +01:00
|
|
|
// INIT_LOCK(cl_u->lui.ClLock);
|
2004-02-06 02:26:23 +00:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2003-12-27 00:38:53 +00:00
|
|
|
INIT_CLREF_COUNT(&(cl_u->lui));
|
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-08-27 14:37:10 +01:00
|
|
|
code_p = cl_u->lui.ClCode;
|
2004-02-05 16:57:02 +00:00
|
|
|
*entry_codep = code_p;
|
2003-04-30 18:46:05 +01:00
|
|
|
} else {
|
|
|
|
if (pass_no) {
|
2004-03-05 15:26:33 +00:00
|
|
|
cl_u->si.ClSize = size;
|
2003-08-27 14:37:10 +01:00
|
|
|
cl_u->si.ClFlags = IndexMask;
|
|
|
|
cl_u->si.ChildIndex = NULL;
|
|
|
|
cl_u->si.SiblingIndex = NULL;
|
2005-12-17 03:25:39 +00:00
|
|
|
cl_u->si.ClPred = cip->CurrentPred;
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
2003-08-27 14:37:10 +01:00
|
|
|
code_p = cl_u->si.ClCode;
|
2004-02-05 16:57:02 +00:00
|
|
|
*entry_codep = code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
while (cip->cpc) {
|
|
|
|
switch ((int) cip->cpc->op) {
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
case sync_op:
|
2008-03-25 16:45:53 +00:00
|
|
|
code_p = a_try(_sync, cip->cpc->rnd1, cip->cpc->rnd2, 1, Zero, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
|
|
|
case table_new_answer_op:
|
2005-03-04 20:30:14 +00:00
|
|
|
code_p = a_n(_table_new_answer, (int) cip->cpc->rnd2, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-12-18 16:38:40 +00:00
|
|
|
case table_try_single_op:
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_table_try_single, code_p, pass_no, cip->cpc, cip);
|
2003-12-18 16:38:40 +00:00
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
2003-11-07 16:31:08 +00:00
|
|
|
#ifdef TABLING_INNER_CUTS
|
|
|
|
case clause_with_cut_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_clause_with_cut, code_p);
|
2003-11-07 16:31:08 +00:00
|
|
|
break;
|
|
|
|
#endif /* TABLING_INNER_CUTS */
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef SFUNC
|
|
|
|
case get_s_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rf(_get_s_f, code_p, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_s_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rf(_put_s_f, code_p, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_s_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_d(_unify_s_f, code_p);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_s_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_f(cip->cpc->rnd1, _write_s_f);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_s_var_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_vsf(_unify_s_xvar);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_s_var_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_vsf(_write_s_xvar);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_s_val_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_vsf(_unify_s_xval);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_s_val_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_vsf(_write_s_xval);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_s_a_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_asf(_unify_s_a);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_s_a_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_asf(_write_s_a);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_s_end_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_n(_get_s_end, Unsigned(0));
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_s_end_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_n(_put_s_end, Unsigned(0));
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_s_end_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_n(_write_s_end, Unsigned(0));
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_s_end_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_n(_write_s_end, Unsigned(0));
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
#endif
|
2005-07-06 16:10:18 +01:00
|
|
|
case get_var_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_vr(_get_x_var, _get_y_var, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_var_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_vr(_put_x_var, _put_y_var, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_val_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_vr(_get_x_val, _get_y_val, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_val_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_vr(_put_x_val, _put_y_val, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_num_op:
|
|
|
|
case get_atom_op:
|
2004-09-27 21:45:04 +01:00
|
|
|
code_p = a_rc(_get_atom, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_float_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_rd(_get_float, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2008-12-09 12:54:27 +00:00
|
|
|
case get_fi_op:
|
|
|
|
code_p = a_fi(_get_fi_x, _get_fi_y, code_p, pass_no, cip->cpc, cip->exception_handler, cip);
|
|
|
|
break;
|
|
|
|
case get_f_op:
|
|
|
|
code_p = a_fi(_get_f_x, _get_f_y, code_p, pass_no, cip->cpc, cip->exception_handler, cip);
|
|
|
|
break;
|
|
|
|
case get_i_op:
|
|
|
|
code_p = a_fi(_get_i_x, _get_i_y, code_p, pass_no, cip->cpc, cip->exception_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_fi_var_op:
|
|
|
|
code_p = a_fi(_put_fi_var_x, _put_fi_var_y, code_p, pass_no, cip->cpc, cip->success_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_f_var_op:
|
|
|
|
code_p = a_fi(_put_f_var_x, _put_f_var_y, code_p, pass_no, cip->cpc, cip->success_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_i_var_op:
|
|
|
|
code_p = a_fi(_put_i_var_x, _put_i_var_y, code_p, pass_no, cip->cpc, cip->success_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_fi_val_op:
|
|
|
|
code_p = a_fil(_put_fi_val_x, _put_fi_val_y, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_f_val_op:
|
|
|
|
code_p = a_fil(_put_f_val_x, _put_f_val_y, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case put_i_val_op:
|
|
|
|
code_p = a_fil(_put_i_val_x, _put_i_val_y, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case a_eqc_float_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_sdll(_a_eqc_float, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case a_eqc_int_op:
|
|
|
|
code_p = a_snll(_a_eqc_int, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case a_eq_op:
|
|
|
|
code_p = a_ssll(_a_eq, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case ltc_float_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_sdll(_ltc_float, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case ltc_int_op:
|
|
|
|
code_p = a_snll(_ltc_int, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case lt_op:
|
|
|
|
code_p = a_ssll(_lt, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case gtc_float_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_sdll(_gtc_float, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case gtc_int_op:
|
|
|
|
code_p = a_snll(_gtc_int, code_p, pass_no, cip->cpc, cip->success_handler, cip->failure_handler, cip);
|
|
|
|
break;
|
|
|
|
case add_float_c_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_ssd(_add_float_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case add_int_c_op:
|
|
|
|
code_p = a_ssn(_add_int_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case add_op:
|
|
|
|
code_p = a_sss(_add, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sub_float_c_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_ssd(_sub_float_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sub_int_c_op:
|
|
|
|
code_p = a_ssn(_sub_int_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sub_op:
|
|
|
|
code_p = a_sss(_sub, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mul_float_c_op:
|
|
|
|
*clause_has_blobsp = TRUE;
|
|
|
|
code_p = a_ssd(_mul_float_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mul_int_c_op:
|
|
|
|
code_p = a_ssn(_mul_int_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mul_op:
|
|
|
|
code_p = a_sss(_mul, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sr_c1_op:
|
|
|
|
code_p = a_ssn(_sr_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sr_c2_op:
|
|
|
|
code_p = a_ssn(_sr_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sr_op:
|
|
|
|
code_p = a_sss(_sr, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sl_c1_op:
|
|
|
|
code_p = a_ssn(_sl_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sl_c2_op:
|
|
|
|
code_p = a_ssn(_sl_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case sl_op:
|
|
|
|
code_p = a_sss(_sl, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case rem_c1_op:
|
|
|
|
code_p = a_ssn(_rem_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case rem_c2_op:
|
|
|
|
code_p = a_ssn(_rem_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case rem_op:
|
|
|
|
code_p = a_sss(_rem, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mod_c1_op:
|
|
|
|
code_p = a_ssn(_mod_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mod_c2_op:
|
|
|
|
code_p = a_ssn(_mod_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case mod_op:
|
|
|
|
code_p = a_sss(_mod, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case idiv_c1_op:
|
|
|
|
code_p = a_ssn(_idiv_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case idiv_c2_op:
|
|
|
|
code_p = a_ssn(_idiv_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case idiv_op:
|
|
|
|
code_p = a_sss(_idiv, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case fdiv_c1_op:
|
|
|
|
code_p = a_ssd(_fdiv_c1, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case fdiv_c2_op:
|
|
|
|
code_p = a_ssd(_fdiv_c2, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case fdiv_op:
|
|
|
|
code_p = a_sss(_fdiv, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case a_and_c_op:
|
|
|
|
code_p = a_ssn(_a_and_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case a_and_op:
|
|
|
|
code_p = a_sss(_a_and, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case a_or_c_op:
|
|
|
|
code_p = a_ssn(_a_or_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case a_or_op:
|
|
|
|
code_p = a_sss(_a_or, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case xor_c_op:
|
|
|
|
code_p = a_ssn(_xor_c, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case xor_op:
|
|
|
|
code_p = a_sss(_xor, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case uminus_op:
|
|
|
|
code_p = a_sss(_uminus, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
|
|
|
case label_ctl_op:
|
|
|
|
code_p = a_special_label(code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case get_longint_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ri(_get_longint, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_bigint_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rb(_get_bigint, clause_has_blobsp, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2007-11-06 17:02:13 +00:00
|
|
|
case get_dbterm_op:
|
|
|
|
code_p = a_dbt(_get_dbterm, clause_has_dbtermp, code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case put_num_op:
|
|
|
|
case put_atom_op:
|
2004-09-27 21:45:04 +01:00
|
|
|
code_p = a_rc(_put_atom, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_float_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_rd(_put_float, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case put_longint_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ri(_put_longint, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case put_bigint_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rb(_put_atom, clause_has_blobsp, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2007-11-06 17:02:13 +00:00
|
|
|
case put_dbterm_op:
|
|
|
|
code_p = a_dbt(_put_atom, clause_has_dbtermp, code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case get_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_glist(&do_not_optimise_uatom, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_r(cip->cpc->rnd2, _put_list, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case get_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rf(_get_struct, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_rf(_put_struct, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case put_unsafe_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_vr(_put_unsafe, _put_unsafe, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_var_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_uvar(code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_var_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _unify_l_x_var, _unify_l_x_var_write, _unify_l_y_var, _unify_l_y_var_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_var_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_wvar(code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_local_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _unify_x_loc, _unify_x_loc_write, _unify_y_loc, _unify_y_loc_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_val_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _unify_x_val, _unify_x_val_write, _unify_y_val, _unify_y_val_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_local_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _unify_l_x_loc, _unify_l_x_loc_write, _unify_l_y_loc, _unify_l_y_loc_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_val_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _unify_l_x_val, _unify_l_x_val_write, _unify_l_y_val, _unify_l_y_val_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_local_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_v(_write_x_loc, _write_y_loc, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_val_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_v(_write_x_val, _write_y_val, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_num_op:
|
|
|
|
case unify_atom_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ucons(&do_not_optimise_uatom, unify_atom_op, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_float_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ud(_unify_float, _unify_float_write, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_longint_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ui(_unify_longint, _unify_longint_write, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_bigint_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ublob(cip->cpc->rnd1, _unify_bigint, _unify_atom_write, clause_has_blobsp, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2007-11-06 17:02:13 +00:00
|
|
|
case unify_dbterm_op:
|
|
|
|
code_p = a_udbt(cip->cpc->rnd1, _unify_dbterm, _unify_atom_write, clause_has_dbtermp, code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case unify_last_num_op:
|
|
|
|
case unify_last_atom_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_uc(cip->cpc->rnd1, _unify_l_atom, _unify_l_atom_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_float_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ud(_unify_l_float, _unify_l_float_write, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_longint_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_ui(_unify_l_longint, _unify_l_longint_write, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_bigint_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ublob(cip->cpc->rnd1, _unify_l_bigint, _unify_l_atom_write, clause_has_blobsp, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2007-11-06 17:02:13 +00:00
|
|
|
case unify_last_dbterm_op:
|
|
|
|
code_p = a_udbt(cip->cpc->rnd1, _unify_l_dbterm, _unify_l_atom_write, clause_has_dbtermp, code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case write_num_op:
|
|
|
|
case write_atom_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ucons(&do_not_optimise_uatom, write_atom_op, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_float_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_wd(_write_float, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case write_longint_op:
|
2007-06-23 18:31:50 +01:00
|
|
|
*clause_has_blobsp = TRUE;
|
2006-09-20 21:03:51 +01:00
|
|
|
code_p = a_wi(_write_longint, code_p, pass_no, cip->cpc);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case write_bigint_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_blob(cip->cpc->rnd1, _write_atom, clause_has_blobsp, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2007-11-06 17:02:13 +00:00
|
|
|
case write_dbterm_op:
|
|
|
|
code_p = a_wdbt(cip->cpc->rnd1, _write_atom, clause_has_dbtermp, code_p, pass_no, cip);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case unify_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ue(_unify_list, _unify_list_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ue(_unify_l_list, _unify_l_list_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_write_list, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_last_list_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_write_l_list, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_uf(cip->cpc->rnd1, _unify_struct, _unify_struct_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case unify_last_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_uf(cip->cpc->rnd1, _unify_l_struc, _unify_l_struc_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_f(cip->cpc->rnd1, _write_struct, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case write_last_struct_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_f(cip->cpc->rnd1, _write_l_struc, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case save_b_op:
|
|
|
|
case patch_b_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_v(_save_b_x, _save_b_y, code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-12-27 00:38:53 +00:00
|
|
|
case commit_b_op:
|
2008-08-30 02:39:36 +01:00
|
|
|
code_p = a_vp(_commit_b_x, _commit_b_y, code_p, pass_no, cip->cpc, &clinfo);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case save_pair_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _save_pair_x, _save_pair_x_write, _save_pair_y, _save_pair_y_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case save_appl_op:
|
2008-08-21 13:38:25 +01:00
|
|
|
code_p = a_uv((Ventry *) cip->cpc->rnd1, _save_appl_x, _save_appl_x_write, _save_appl_y, _save_appl_y_write, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case fail_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_op_fail, code_p, pass_no);
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case cut_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_cut(&clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case cutexit_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_cut(&clinfo, code_p, pass_no, cip);
|
2004-02-09 14:19:05 +00:00
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
2007-11-06 17:02:13 +00:00
|
|
|
(*clause_has_blobsp || *clause_has_dbtermp) &&
|
2004-01-23 02:23:51 +00:00
|
|
|
!clinfo.alloc_found)
|
|
|
|
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
2008-04-01 23:28:41 +01:00
|
|
|
#if defined(THREADS) || defined(YAPOR)
|
2004-02-09 14:19:05 +00:00
|
|
|
else
|
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
2008-08-12 02:27:23 +01:00
|
|
|
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
|
|
|
!clinfo.alloc_found)
|
2007-11-26 23:43:10 +00:00
|
|
|
code_p = a_e(_unlock_lu, code_p, pass_no);
|
2004-02-09 14:19:05 +00:00
|
|
|
#endif
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case allocate_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo.alloc_found = 2;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case deallocate_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_deallocate(&clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case tryme_op:
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TABLE_TRYCODE(_table_try_me);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TRYCODE(_try_me, _try_me0);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case retryme_op:
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TABLE_TRYCODE(_table_retry_me);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TRYCODE(_retry_me, _retry_me0);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case trustme_op:
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TABLE_TRYCODE(_table_trust_me);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = TRYCODE(_trust_me, _trust_me0);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-09-15 02:25:29 +01:00
|
|
|
case enter_lu_op:
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_lucl(_enter_lu_pred, code_p, pass_no, cip, &clinfo);
|
2003-09-15 02:25:29 +01:00
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case try_op:
|
2006-10-10 15:08:17 +01:00
|
|
|
if (log_update) {
|
|
|
|
add_clref(cip->cpc->rnd1, pass_no);
|
|
|
|
}
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_table_try, code_p, pass_no, cip->cpc, cip);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_try_clause, code_p, pass_no, cip->cpc, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case retry_op:
|
2003-08-27 14:37:10 +01:00
|
|
|
if (log_update) {
|
2004-01-23 02:23:51 +00:00
|
|
|
add_clref(cip->cpc->rnd1, pass_no);
|
2003-08-27 14:37:10 +01:00
|
|
|
}
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_table_retry, code_p, pass_no, cip->cpc, cip);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_retry, code_p, pass_no, cip->cpc, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case trust_op:
|
2003-08-27 14:37:10 +01:00
|
|
|
if (log_update) {
|
2004-01-23 02:23:51 +00:00
|
|
|
add_clref(cip->cpc->rnd1, pass_no);
|
2003-08-27 14:37:10 +01:00
|
|
|
}
|
2003-12-18 16:38:40 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
if (tabled)
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_table_trust, code_p, pass_no, cip->cpc, cip);
|
2003-12-18 16:38:40 +00:00
|
|
|
else
|
|
|
|
#endif
|
2006-10-10 15:08:17 +01:00
|
|
|
code_p = a_gl(_trust, code_p, pass_no, cip->cpc, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-04-30 18:46:05 +01:00
|
|
|
case try_in_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_il(cip->cpc->rnd1, _try_in, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case jump_op:
|
2003-04-30 18:46:05 +01:00
|
|
|
/* don't assemble jumps to next instruction */
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->nextInst == NULL ||
|
|
|
|
cip->cpc->nextInst->op != label_op ||
|
|
|
|
cip->cpc->rnd1 != cip->cpc->nextInst->rnd1) {
|
|
|
|
code_p = a_l(cip->cpc->rnd1, _jump, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case jumpi_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_il(cip->cpc->rnd1, _jump, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case restore_tmps_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_l(cip->cpc->rnd1, _move_back, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case restore_tmps_and_skip_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_l(cip->cpc->rnd1, _skip, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case procceed_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
2007-11-06 17:02:13 +00:00
|
|
|
(*clause_has_blobsp || *clause_has_dbtermp) &&
|
2004-01-23 02:23:51 +00:00
|
|
|
!clinfo.alloc_found)
|
|
|
|
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
2008-04-01 23:28:41 +01:00
|
|
|
#if defined(THREADS) || defined(YAPOR)
|
2004-02-09 14:19:05 +00:00
|
|
|
else
|
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
2008-08-12 02:27:23 +01:00
|
|
|
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
|
|
|
!clinfo.alloc_found)
|
2004-02-09 14:19:05 +00:00
|
|
|
code_p = a_e(_unlock_lu, code_p, pass_no);
|
|
|
|
#endif
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case call_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_p(_call, &clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case execute_op:
|
2008-04-01 23:28:41 +01:00
|
|
|
#if defined(THREADS) || defined(YAPOR)
|
2004-02-09 14:19:05 +00:00
|
|
|
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
2008-08-12 02:27:23 +01:00
|
|
|
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
|
|
|
!clinfo.alloc_found)
|
2004-02-09 14:19:05 +00:00
|
|
|
code_p = a_e(_unlock_lu, code_p, pass_no);
|
|
|
|
#endif
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_p(_execute, &clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case safe_call_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_p(_call, &clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case label_op:
|
|
|
|
if (!ystop_found &&
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc->nextInst != NULL &&
|
|
|
|
(cip->cpc->nextInst->op == mark_initialised_pvars_op ||
|
|
|
|
cip->cpc->nextInst->op == blob_op)) {
|
2001-04-09 20:54:03 +01:00
|
|
|
ystop_found = TRUE;
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p = a_il((CELL)*entry_codep, _Ystop, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
if (!pass_no) {
|
2004-01-23 02:23:51 +00:00
|
|
|
if (CellPtr(cip->label_offset+cip->cpc->rnd1) > ASP-256) {
|
|
|
|
Yap_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)H);
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 3);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2001-11-25 21:44:42 +00:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if ( (char *)(cip->label_offset+cip->cpc->rnd1) >= cip->freep)
|
|
|
|
cip->freep = (char *)(cip->label_offset+(cip->cpc->rnd1+1));
|
|
|
|
cip->label_offset[cip->cpc->rnd1] = (CELL) code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
/* reset dealloc_found in case there was a branch */
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo.dealloc_found = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case pop_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd1 == 1)
|
|
|
|
code_p = a_e(_pop, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
else {
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_n(_pop_n, 2 * CELLSIZE * (cip->cpc->rnd1 - 1), code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case either_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = check_alloc(&clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
if (pass_no)
|
|
|
|
either_inst[either_cont++] = code_p;
|
2008-04-01 23:28:41 +01:00
|
|
|
if (either_cont == MAX_DISJ_BRANCHES) {
|
|
|
|
Yap_Error(FATAL_ERROR,TermNil,"Too Many Branches in disjunction: please increase MAX_DISJ_BRANCHES in amasm.c\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_either(_either,
|
|
|
|
-Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2,
|
|
|
|
Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], 0, 0, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_either(_either,
|
|
|
|
-Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2,
|
|
|
|
Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
break;
|
|
|
|
case orelse_op:
|
|
|
|
#ifdef YAPOR
|
|
|
|
if (pass_no)
|
|
|
|
either_inst[either_cont++] = code_p;
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_either(_or_else,
|
|
|
|
-Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2,
|
|
|
|
Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], 0, 0, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#else
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_either(_or_else,
|
|
|
|
-Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2,
|
|
|
|
Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo.dealloc_found = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case orlast_op:
|
|
|
|
#ifdef YAPOR
|
|
|
|
if (pass_no)
|
|
|
|
either_inst[either_cont++] = code_p;
|
2008-03-25 16:45:53 +00:00
|
|
|
code_p = a_either(_or_last, 0, 0, 0, 0, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (pass_no) {
|
|
|
|
int cont = 1;
|
|
|
|
do {
|
|
|
|
either_cont--;
|
|
|
|
PUT_YAMOP_LTT(either_inst[either_cont], cont++);
|
|
|
|
} while (either_inst[either_cont]->opc != opcode(_either));
|
|
|
|
}
|
|
|
|
#else
|
2004-10-26 21:16:18 +01:00
|
|
|
code_p = a_pl(_or_last, cip->CurrentPred, code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2004-01-23 02:23:51 +00:00
|
|
|
clinfo.dealloc_found = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-04-30 18:46:05 +01:00
|
|
|
case cache_arg_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_4sw_x(_switch_on_arg_type, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
break;
|
|
|
|
case cache_sub_arg_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_4sw_s(_switch_on_sub_arg_type, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case jump_v_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_igl(cip->cpc->rnd1, _jump_if_var, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-10-28 01:16:03 +00:00
|
|
|
case jump_nv_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_xigl(_jump_if_nonvar, code_p, pass_no, cip->cpc);
|
2003-10-28 01:16:03 +00:00
|
|
|
break;
|
2003-04-30 18:46:05 +01:00
|
|
|
case switch_on_type_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_4sw(_switch_on_type, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case switch_c_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_hx(_switch_on_cons, cl_u, log_update, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case switch_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_hx(_switch_on_func, cl_u, log_update, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case if_c_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd1 == 1) {
|
|
|
|
code_p = a_if(_go_on_cons, cl_u, log_update, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_if(_if_cons, cl_u, log_update, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case if_f_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->rnd1 == 1) {
|
|
|
|
code_p = a_if(_go_on_func, cl_u, log_update, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_if(_if_func, cl_u, log_update, code_p, pass_no, cip);
|
2003-04-30 18:46:05 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case if_not_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_ifnot(_if_not_then, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-08-27 14:37:10 +01:00
|
|
|
case index_dbref_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_index_dbref, code_p, pass_no);
|
2003-08-27 14:37:10 +01:00
|
|
|
break;
|
|
|
|
case index_blob_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_e(_index_blob, code_p, pass_no);
|
2003-08-27 14:37:10 +01:00
|
|
|
break;
|
2009-02-09 21:56:40 +00:00
|
|
|
case index_long_op:
|
|
|
|
code_p = a_e(_index_long, code_p, pass_no);
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case mark_initialised_pvars_op:
|
2005-12-17 03:25:39 +00:00
|
|
|
if (!ystop_found) {
|
|
|
|
code_p = a_il((CELL)*entry_codep, _Ystop, code_p, pass_no, cip);
|
|
|
|
ystop_found = TRUE;
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_bmap(code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case mark_live_regs_op:
|
2005-12-17 03:25:39 +00:00
|
|
|
if (!ystop_found) {
|
|
|
|
code_p = a_il((CELL)*entry_codep, _Ystop, code_p, pass_no, cip);
|
|
|
|
ystop_found = TRUE;
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_bregs(code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case fetch_args_vv_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_vv(&cmp_info, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case fetch_args_vc_op:
|
2006-11-06 18:35:05 +00:00
|
|
|
case fetch_args_vi_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_vc(&cmp_info, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case fetch_args_cv_op:
|
2006-11-06 18:35:05 +00:00
|
|
|
case fetch_args_iv_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
a_fetch_cv(&cmp_info, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case f_val_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_f2(FALSE, &cmp_info, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case f_var_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_f2(TRUE, &cmp_info, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case enter_profiling_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_pl(_enter_profiling, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case retry_profiled_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_pl(_retry_profiled, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2002-09-03 15:28:09 +01:00
|
|
|
case count_call_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_pl(_count_call, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
2002-09-03 15:28:09 +01:00
|
|
|
break;
|
|
|
|
case count_retry_op:
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_pl(_count_retry, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
2002-09-03 15:28:09 +01:00
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case fetch_args_for_bccall:
|
2004-01-23 02:23:51 +00:00
|
|
|
if (cip->cpc->nextInst->op != bccall_op) {
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "compiling binary test", (int) cip->cpc->op);
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_bfunc(cip->cpc->nextInst->rnd2, &clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
2003-12-27 00:38:53 +00:00
|
|
|
case align_float_op:
|
|
|
|
/* install a blob */
|
|
|
|
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
|
2004-01-23 02:23:51 +00:00
|
|
|
if (!((CELL)code_p & 0x4))
|
|
|
|
GONEXT(e);
|
2003-12-27 00:38:53 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2001-04-09 20:54:03 +01:00
|
|
|
case blob_op:
|
|
|
|
/* install a blob */
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = copy_blob(code_p, pass_no, cip->cpc);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case empty_call_op:
|
|
|
|
/* create an empty call */
|
2004-01-23 02:23:51 +00:00
|
|
|
code_p = a_empty_call(&clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
break;
|
|
|
|
case push_or_op:
|
2004-01-29 13:37:10 +00:00
|
|
|
/* be sure to allocate if we have an ;, even if it is
|
|
|
|
compiled inline.
|
|
|
|
*/
|
|
|
|
code_p = check_alloc(&clinfo, code_p, pass_no, cip);
|
2001-04-09 20:54:03 +01:00
|
|
|
case pushpop_or_op:
|
2004-01-29 13:37:10 +00:00
|
|
|
case pop_or_op:
|
2001-04-09 20:54:03 +01:00
|
|
|
case nop_op:
|
|
|
|
case name_op:
|
|
|
|
break;
|
2005-09-08 23:06:45 +01:00
|
|
|
#ifdef BEAM
|
|
|
|
case body_op:
|
|
|
|
case endgoal_op:
|
|
|
|
break;
|
|
|
|
case run_op:
|
2006-03-24 17:13:41 +00:00
|
|
|
code_p=a_eam(_run_eam,cip->cpc->rnd2,(long) ((PredEntry *) cip->cpc->rnd2)->beamTable->last, code_p,pass_no);
|
2005-09-08 23:06:45 +01:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
default:
|
2005-05-25 22:43:33 +01:00
|
|
|
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "instruction %d found while assembling", (int) cip->cpc->op);
|
2001-04-09 20:54:03 +01:00
|
|
|
save_machine_regs();
|
2004-01-23 02:23:51 +00:00
|
|
|
longjmp(cip->CompilerBotch, 1);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->cpc = cip->cpc->nextInst;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
if (!ystop_found)
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p = a_il((CELL)*entry_codep, _Ystop, code_p, pass_no, cip);
|
2004-01-23 02:23:51 +00:00
|
|
|
return code_p;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-12-05 05:01:45 +00:00
|
|
|
|
|
|
|
static DBTerm *
|
2006-11-06 18:35:05 +00:00
|
|
|
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep)
|
2004-12-05 05:01:45 +00:00
|
|
|
{
|
|
|
|
CELL *h0 = H;
|
|
|
|
DBTerm *x;
|
|
|
|
|
|
|
|
/* This stuff should be just about fetching the space from the data-base,
|
|
|
|
unfortunately we have to do all sorts of error handling :-( */
|
|
|
|
H = (CELL *)cip->freep;
|
2006-11-06 18:35:05 +00:00
|
|
|
while ((x = Yap_StoreTermInDBPlusExtraSpace(*tp, size, osizep)) == NULL) {
|
2004-12-05 05:01:45 +00:00
|
|
|
|
|
|
|
H = h0;
|
|
|
|
switch (Yap_Error_TYPE) {
|
|
|
|
case OUT_OF_STACK_ERROR:
|
|
|
|
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
|
|
|
save_machine_regs();
|
|
|
|
longjmp(cip->CompilerBotch,3);
|
|
|
|
case OUT_OF_TRAIL_ERROR:
|
|
|
|
/* don't just return NULL */
|
|
|
|
ARG1 = *tp;
|
2004-12-28 22:20:37 +00:00
|
|
|
if (!Yap_growtrail(64 * 1024L, FALSE)) {
|
2004-12-05 05:01:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
|
|
|
*tp = ARG1;
|
|
|
|
break;
|
|
|
|
case OUT_OF_AUXSPACE_ERROR:
|
|
|
|
ARG1 = *tp;
|
|
|
|
if (!Yap_ExpandPreAllocCodeSpace(Yap_Error_Size, (void *)cip)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
|
|
|
*tp = ARG1;
|
|
|
|
break;
|
|
|
|
case OUT_OF_HEAP_ERROR:
|
|
|
|
/* don't just return NULL */
|
|
|
|
ARG1 = *tp;
|
|
|
|
if (!Yap_growheap(TRUE, size, cip)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
|
|
|
*tp = ARG1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
h0 = H;
|
|
|
|
H = (CELL *)cip->freep;
|
|
|
|
}
|
|
|
|
H = h0;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
static DBTermList *
|
|
|
|
init_dbterms_list(yamop *code_p, PredEntry *ap)
|
|
|
|
{
|
|
|
|
DBTermList *new;
|
|
|
|
if ((new = (DBTermList *)Yap_AllocCodeSpace(sizeof(DBTermList))) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
new->dbterms = NULL;
|
|
|
|
new->clause_code = code_p;
|
|
|
|
new->p = ap;
|
|
|
|
LOCK(DBTermsListLock);
|
|
|
|
new->next_dbl = DBTermsList;
|
|
|
|
DBTermsList = new;
|
|
|
|
UNLOCK(DBTermsListLock);
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2004-12-05 05:01:45 +00:00
|
|
|
|
2002-12-27 16:53:09 +00:00
|
|
|
yamop *
|
2004-01-23 02:23:51 +00:00
|
|
|
Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates *cip)
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* the assembly proccess is done in two passes: 1 - a first pass
|
|
|
|
* computes labels offsets and total code size 2 - the second pass
|
|
|
|
* produces the final version of the code
|
|
|
|
*/
|
2004-03-05 15:26:33 +00:00
|
|
|
UInt size = 0;
|
2003-04-30 18:46:05 +01:00
|
|
|
yamop *entry_code;
|
2004-01-23 02:23:51 +00:00
|
|
|
yamop *code_p;
|
|
|
|
int clause_has_blobs = FALSE;
|
2007-11-06 17:02:13 +00:00
|
|
|
int clause_has_dbterm = FALSE;
|
2004-01-23 02:23:51 +00:00
|
|
|
|
|
|
|
cip->label_offset = (int *)cip->freep;
|
|
|
|
cip->code_addr = NULL;
|
2007-11-06 17:02:13 +00:00
|
|
|
code_p = do_pass(0, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
|
|
|
if (clause_has_dbterm) {
|
|
|
|
cip->dbterml = init_dbterms_list(code_p, ap);
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
if (ap->PredFlags & DynamicPredFlag) {
|
|
|
|
size =
|
2008-09-05 05:22:19 +01:00
|
|
|
(CELL)NEXTOP(NEXTOP(NEXTOP((yamop *)(((DynamicClause *)NULL)->ClCode),Otapl ),Osbpp),e);
|
2004-09-27 21:45:04 +01:00
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
if ((CELL)code_p > size)
|
|
|
|
size = (CELL)code_p;
|
2003-11-18 19:22:26 +00:00
|
|
|
if (mode == ASSEMBLING_CLAUSE &&
|
|
|
|
ap->PredFlags & LogUpdatePredFlag &&
|
|
|
|
!is_fact) {
|
|
|
|
DBTerm *x;
|
|
|
|
LogUpdClause *cl;
|
2006-11-06 18:35:05 +00:00
|
|
|
UInt osize;
|
2003-11-21 16:56:20 +00:00
|
|
|
|
2006-11-06 18:35:05 +00:00
|
|
|
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
2004-12-05 05:01:45 +00:00
|
|
|
return NULL;
|
2004-12-20 21:44:58 +00:00
|
|
|
}
|
2003-11-18 19:22:26 +00:00
|
|
|
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
|
|
|
cl->ClSource = x;
|
2006-11-06 18:35:05 +00:00
|
|
|
cl->ClSize = osize;
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->code_addr = (yamop *)cl;
|
2003-11-21 16:56:20 +00:00
|
|
|
} else if (mode == ASSEMBLING_CLAUSE &&
|
|
|
|
(ap->PredFlags & SourcePredFlag ||
|
2004-08-20 17:16:23 +01:00
|
|
|
yap_flags[SOURCE_MODE_FLAG]) &&
|
2003-11-21 16:56:20 +00:00
|
|
|
!is_fact) {
|
|
|
|
DBTerm *x;
|
|
|
|
StaticClause *cl;
|
2006-11-06 18:35:05 +00:00
|
|
|
UInt osize;
|
|
|
|
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
2004-12-05 05:01:45 +00:00
|
|
|
return NULL;
|
2004-12-20 21:44:58 +00:00
|
|
|
}
|
2003-11-21 16:56:20 +00:00
|
|
|
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
2004-01-23 02:23:51 +00:00
|
|
|
cip->code_addr = (yamop *)cl;
|
2007-11-06 17:02:13 +00:00
|
|
|
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
2003-11-26 18:36:35 +00:00
|
|
|
/* make sure we copy after second pass */
|
|
|
|
cl->usc.ClSource = x;
|
2006-11-06 18:35:05 +00:00
|
|
|
cl->ClSize = osize;
|
2004-01-23 02:23:51 +00:00
|
|
|
ProfEnd=code_p;
|
2003-11-26 18:36:35 +00:00
|
|
|
return entry_code;
|
2003-11-18 19:22:26 +00:00
|
|
|
} else {
|
2004-01-23 02:23:51 +00:00
|
|
|
while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
|
2004-08-20 17:16:23 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
if (!Yap_growheap(TRUE, size, cip)) {
|
2004-11-19 22:08:43 +00:00
|
|
|
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
|
2004-12-20 21:44:58 +00:00
|
|
|
Yap_Error_Size = size;
|
2003-11-18 19:22:26 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-10 06:58:49 +01:00
|
|
|
}
|
2006-11-06 18:35:05 +00:00
|
|
|
if (mode == ASSEMBLING_CLAUSE) {
|
|
|
|
if (ap->PredFlags & LogUpdatePredFlag) {
|
|
|
|
Yap_LUClauseSpace += size;
|
|
|
|
} else
|
|
|
|
Yap_ClauseSpace += size;
|
|
|
|
} else {
|
|
|
|
if (ap->PredFlags & LogUpdatePredFlag) {
|
|
|
|
Yap_LUIndexSpace_Tree += size;
|
|
|
|
} else
|
|
|
|
Yap_IndexSpace_Tree += size;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2007-11-06 17:02:13 +00:00
|
|
|
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
2004-01-23 02:23:51 +00:00
|
|
|
ProfEnd=code_p;
|
2005-12-17 03:25:39 +00:00
|
|
|
#ifdef LOW_PROF
|
|
|
|
if (ProfilerOn &&
|
|
|
|
Yap_OffLineProfiler) {
|
|
|
|
Yap_inform_profiler_of_clause(entry_code, ProfEnd, ap, mode == ASSEMBLING_INDEX);
|
|
|
|
}
|
|
|
|
#endif /* LOW_PROF */
|
2003-04-30 18:46:05 +01:00
|
|
|
return entry_code;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2003-01-29 14:47:17 +00:00
|
|
|
void
|
|
|
|
Yap_InitComma(void)
|
|
|
|
{
|
|
|
|
yamop *code_p = COMMA_CODE;
|
|
|
|
code_p->opc = opcode(_call);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize) - sizeof(CELL) * 3);
|
|
|
|
code_p->u.Osbpp.p =
|
|
|
|
code_p->u.Osbpp.p0 =
|
2004-02-13 23:53:20 +00:00
|
|
|
RepPredProp(PredPropByFunc(FunctorComma,0));
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
|
|
|
GONEXT(Osbpp);
|
2003-01-29 14:47:17 +00:00
|
|
|
if (PRED_GOAL_EXPANSION_ON) {
|
2008-12-23 01:53:52 +00:00
|
|
|
Functor fp = FunctorGeneratePredInfo;
|
2003-01-29 14:47:17 +00:00
|
|
|
code_p->opc = emit_op(_call_cpred);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize));
|
|
|
|
code_p->u.Osbpp.p =
|
|
|
|
code_p->u.Osbpp.p0 =
|
2006-12-13 16:10:26 +00:00
|
|
|
RepPredProp(Yap_GetPredPropByFunc(fp,0));
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
|
|
|
GONEXT(Osbpp);
|
2003-01-29 14:47:17 +00:00
|
|
|
code_p->opc = emit_op(_call);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize));
|
|
|
|
code_p->u.Osbpp.p =
|
|
|
|
code_p->u.Osbpp.p0 =
|
2006-12-13 16:10:26 +00:00
|
|
|
PredMetaCall;
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
|
|
|
GONEXT(Osbpp);
|
2003-01-29 14:47:17 +00:00
|
|
|
code_p->opc = emit_op(_deallocate);
|
2008-08-30 16:24:44 +01:00
|
|
|
code_p->u.p.p = PredMetaCall;
|
|
|
|
GONEXT(p);
|
2003-01-29 14:47:17 +00:00
|
|
|
code_p->opc = emit_op(_procceed);
|
2005-12-17 03:25:39 +00:00
|
|
|
code_p->u.p.p = PredMetaCall;
|
|
|
|
GONEXT(p);
|
2003-01-29 14:47:17 +00:00
|
|
|
} else {
|
|
|
|
if (PROFILING) {
|
|
|
|
code_p->opc = opcode(_enter_a_profiling);
|
|
|
|
GONEXT(e);
|
|
|
|
}
|
|
|
|
if (CALL_COUNTING) {
|
|
|
|
code_p->opc = opcode(_count_a_call);
|
|
|
|
GONEXT(e);
|
|
|
|
}
|
|
|
|
code_p->opc = opcode(_p_execute_tail);
|
2008-09-05 05:22:19 +01:00
|
|
|
code_p->u.Osbpp.s = emit_count(-Signed(RealEnvSize)-3*sizeof(CELL));
|
|
|
|
code_p->u.Osbpp.bmap = NULL;
|
|
|
|
code_p->u.Osbpp.p =
|
|
|
|
code_p->u.Osbpp.p0 =
|
2004-04-29 04:45:50 +01:00
|
|
|
RepPredProp(PredPropByFunc(FunctorComma,0));
|
2008-09-05 05:22:19 +01:00
|
|
|
GONEXT(Osbpp);
|
2003-01-29 14:47:17 +00:00
|
|
|
}
|
|
|
|
}
|