2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2024-07-19 11:43:27 -04:00
|
|
|
* Copyright 2001, 2012 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* This source code contains the intellectual property *
|
|
|
|
* of its copyright holder(s), and is made available *
|
|
|
|
* under a license. If you do not know the terms of *
|
|
|
|
* the license, please stop and do not read further. *
|
|
|
|
* *
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "mdef.h"
|
|
|
|
#include "compiler.h"
|
|
|
|
#include "opcode.h"
|
|
|
|
#include "mdq.h"
|
|
|
|
#include "mmemory.h"
|
|
|
|
|
|
|
|
LITREF octabstruct oc_tab[];
|
|
|
|
|
|
|
|
/* structure of jmps is as follows:
|
2012-03-24 14:06:46 -04:00
|
|
|
*
|
|
|
|
* sense OC_AND OC_OR
|
|
|
|
*
|
|
|
|
* TRUE op1 op1
|
|
|
|
* jmpf next jmpt addr
|
|
|
|
* op2 op2
|
|
|
|
* jmpt addr jmpt addr
|
|
|
|
*
|
|
|
|
* FALSE op1 op1
|
|
|
|
* jmpf addr jmpt next
|
|
|
|
* op2 op2
|
|
|
|
* jmpf addr jmpf addr
|
|
|
|
**/
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
void bx_tail(triple *t, boolean_t sense, oprtype *addr)
|
2012-02-05 11:35:58 -05:00
|
|
|
/*
|
2012-03-24 14:06:46 -04:00
|
|
|
* triple *t; triple to be processed
|
|
|
|
*boolean_t sense; code to be generated is jmpt or jmpf
|
|
|
|
*oprtype *addr; address to jmp
|
|
|
|
*/
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
triple *ref;
|
|
|
|
oprtype *p;
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
assert((1 & sense) == sense);
|
2012-02-05 11:35:58 -05:00
|
|
|
assert(oc_tab[t->opcode].octype & OCT_BOOL);
|
2012-03-24 14:06:46 -04:00
|
|
|
assert(TRIP_REF == t->operand[0].oprclass);
|
2024-07-19 11:43:27 -04:00
|
|
|
assert((TRIP_REF == t->operand[1].oprclass) || (NO_REF == t->operand[1].oprclass));
|
2012-02-05 11:35:58 -05:00
|
|
|
switch (t->opcode)
|
|
|
|
{
|
|
|
|
case OC_COBOOL:
|
|
|
|
ex_tail(&t->operand[0]);
|
2012-03-24 14:06:46 -04:00
|
|
|
if (OC_GETTRUTH == t->operand[0].oprval.tref->opcode)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
dqdel(t->operand[0].oprval.tref, exorder);
|
|
|
|
t->opcode = sense ? OC_JMPTSET : OC_JMPTCLR;
|
|
|
|
t->operand[0] = put_indr(addr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ref = maketriple(sense ? OC_JMPNEQ : OC_JMPEQU);
|
|
|
|
ref->operand[0] = put_indr(addr);
|
|
|
|
dqins(t, exorder, ref);
|
|
|
|
return;
|
|
|
|
case OC_COM:
|
2012-03-24 14:06:46 -04:00
|
|
|
bx_tail(t->operand[0].oprval.tref, !sense, addr);
|
2012-02-05 11:35:58 -05:00
|
|
|
t->opcode = OC_NOOP;
|
2024-07-19 11:43:27 -04:00
|
|
|
t->operand[0].oprclass = NO_REF;
|
2012-02-05 11:35:58 -05:00
|
|
|
return;
|
|
|
|
case OC_NEQU:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_EQU:
|
|
|
|
bx_relop(t, OC_EQU, sense ? OC_JMPNEQ : OC_JMPEQU, addr);
|
|
|
|
break;
|
|
|
|
case OC_NPATTERN:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_PATTERN:
|
|
|
|
bx_relop(t, OC_PATTERN, sense ? OC_JMPNEQ : OC_JMPEQU, addr);
|
|
|
|
break;
|
|
|
|
case OC_NFOLLOW:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_FOLLOW:
|
|
|
|
bx_relop(t, OC_FOLLOW, sense ? OC_JMPGTR : OC_JMPLEQ, addr);
|
|
|
|
break;
|
|
|
|
case OC_NSORTS_AFTER:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_SORTS_AFTER:
|
|
|
|
bx_relop(t, OC_SORTS_AFTER, sense ? OC_JMPGTR : OC_JMPLEQ, addr);
|
|
|
|
break;
|
|
|
|
case OC_NCONTAIN:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_CONTAIN:
|
|
|
|
bx_relop(t, OC_CONTAIN, sense ? OC_JMPNEQ : OC_JMPEQU, addr);
|
|
|
|
break;
|
|
|
|
case OC_NGT:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_GT:
|
|
|
|
bx_relop(t, OC_NUMCMP, sense ? OC_JMPGTR : OC_JMPLEQ, addr);
|
|
|
|
break;
|
|
|
|
case OC_NLT:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_LT:
|
|
|
|
bx_relop(t, OC_NUMCMP, sense ? OC_JMPLSS : OC_JMPGEQ, addr);
|
|
|
|
break;
|
|
|
|
case OC_NAND:
|
2012-03-24 14:06:46 -04:00
|
|
|
sense = !sense;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* caution: fall through */
|
|
|
|
case OC_AND:
|
|
|
|
bx_boolop(t, FALSE, sense, sense, addr);
|
|
|
|
return;
|
|
|
|
case OC_NOR:
|
|
|
|
sense = !sense;
|
|
|
|
/* caution: fall through */
|
|
|
|
case OC_OR:
|
|
|
|
bx_boolop(t, TRUE, !sense, sense, addr);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
GTMASSERT;
|
|
|
|
}
|
|
|
|
for (p = t->operand ; p < ARRAYTOP(t->operand); p++)
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TRIP_REF == p->oprclass)
|
2012-02-05 11:35:58 -05:00
|
|
|
ex_tail(p);
|
|
|
|
return;
|
|
|
|
}
|