1987-04-29 10:22:07 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Ceriel J.H. Jacobs
|
|
|
|
*/
|
|
|
|
|
1986-05-21 18:32:20 +00:00
|
|
|
/* C O D E G E N E R A T I O N R O U T I N E S */
|
|
|
|
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1987-04-29 10:22:07 +00:00
|
|
|
|
1986-05-21 18:32:20 +00:00
|
|
|
/* Code generation for expressions and coercions
|
|
|
|
*/
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "parameters.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "em_arith.h"
|
|
|
|
#include "em_label.h"
|
|
|
|
#include "em_code.h"
|
|
|
|
#include "em_abs.h"
|
|
|
|
#include "alloc.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "code.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
#include "type.h"
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "error.h"
|
1987-07-30 13:37:39 +00:00
|
|
|
#include "LLlex.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
#include "def.h"
|
|
|
|
#include "scope.h"
|
|
|
|
#include "desig.h"
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "chk_expr.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
#include "node.h"
|
|
|
|
#include "Lpars.h"
|
2019-03-01 17:39:25 +00:00
|
|
|
#include "tmpvar.h"
|
1986-05-30 18:48:00 +00:00
|
|
|
#include "standards.h"
|
1986-06-20 14:36:49 +00:00
|
|
|
#include "walk.h"
|
1986-05-21 18:32:20 +00:00
|
|
|
|
|
|
|
extern int proclevel;
|
1987-08-11 10:50:30 +00:00
|
|
|
extern char options[];
|
1991-03-14 11:10:40 +00:00
|
|
|
extern t_desig null_desig;
|
1986-06-06 02:22:09 +00:00
|
|
|
int fp_used;
|
1986-05-21 18:32:20 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
static void CodeParameters(t_param *, register t_node *);
|
|
|
|
static void CodeStd(t_node *);
|
|
|
|
static void compare(int, label);
|
|
|
|
static void truthvalue(int);
|
|
|
|
static void CodeUoper(register t_node *);
|
|
|
|
static void CodeSet(register t_node *, int);
|
|
|
|
static void CodeEl(register t_node *, register t_type *, int);
|
|
|
|
static void CodeDAddress(t_node *, int);
|
|
|
|
static void DoHIGH(register t_def *);
|
|
|
|
|
|
|
|
void CodeConst(arith cst, int size)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1987-07-21 13:54:33 +00:00
|
|
|
if (size <= (int) word_size) {
|
1986-05-21 18:32:20 +00:00
|
|
|
C_loc(cst);
|
|
|
|
}
|
1987-07-21 13:54:33 +00:00
|
|
|
else if (size == (int) dword_size) {
|
1986-05-21 18:32:20 +00:00
|
|
|
C_ldc(cst);
|
|
|
|
}
|
|
|
|
else {
|
1986-10-06 20:36:30 +00:00
|
|
|
crash("(CodeConst)");
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeString(register t_node *nd)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1986-09-25 19:39:06 +00:00
|
|
|
if (nd->nd_type->tp_fund != T_STRING) {
|
1987-05-18 15:57:33 +00:00
|
|
|
/* Character constant */
|
1996-11-19 09:12:36 +00:00
|
|
|
CodeConst(nd->nd_INT, nd->nd_type->tp_size);
|
1987-07-21 13:54:33 +00:00
|
|
|
return;
|
1986-05-23 09:46:31 +00:00
|
|
|
}
|
1987-07-21 13:54:33 +00:00
|
|
|
C_df_dlb(++data_label);
|
1988-04-13 18:37:45 +00:00
|
|
|
C_rom_scon(nd->nd_STR, WA((arith)(nd->nd_SLE + 1)));
|
1987-09-23 16:39:43 +00:00
|
|
|
c_lae_dlb(data_label);
|
1986-06-04 09:01:48 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeExpr(t_node *nd, t_desig *ds, label true_label, label false_label)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *tp = nd->nd_type;
|
1986-05-21 18:32:20 +00:00
|
|
|
|
1988-01-28 16:15:16 +00:00
|
|
|
DoLineno(nd);
|
1986-06-06 02:22:09 +00:00
|
|
|
if (tp->tp_fund == T_REAL) fp_used = 1;
|
1986-05-21 18:32:20 +00:00
|
|
|
switch(nd->nd_class) {
|
|
|
|
case Def:
|
1986-11-17 11:41:28 +00:00
|
|
|
if (nd->nd_def->df_kind & (D_PROCEDURE|D_PROCHEAD)) {
|
1991-03-12 16:52:00 +00:00
|
|
|
C_lpi(nd->nd_def->prc_name);
|
1986-05-30 18:48:00 +00:00
|
|
|
ds->dsg_kind = DSG_LOADED;
|
|
|
|
break;
|
|
|
|
}
|
1986-06-04 09:01:48 +00:00
|
|
|
/* Fall through */
|
|
|
|
|
|
|
|
case Link:
|
1986-06-10 13:18:52 +00:00
|
|
|
case Arrsel:
|
|
|
|
case Arrow:
|
1986-05-21 18:32:20 +00:00
|
|
|
CodeDesig(nd, ds);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Oper:
|
|
|
|
CodeOper(nd, true_label, false_label);
|
1987-05-18 15:57:33 +00:00
|
|
|
ds->dsg_kind = DSG_LOADED;
|
|
|
|
true_label = NO_LABEL;
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Uoper:
|
|
|
|
CodeUoper(nd);
|
|
|
|
ds->dsg_kind = DSG_LOADED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Value:
|
|
|
|
switch(nd->nd_symb) {
|
1987-05-18 15:57:33 +00:00
|
|
|
case REAL:
|
|
|
|
C_df_dlb(++data_label);
|
1991-03-06 10:52:34 +00:00
|
|
|
if (! nd->nd_RSTR) {
|
1989-12-19 09:40:25 +00:00
|
|
|
static char buf[FLT_STRLEN];
|
|
|
|
|
|
|
|
flt_flt2str(&nd->nd_RVAL, buf, FLT_STRLEN);
|
|
|
|
C_rom_fcon(buf, tp->tp_size);
|
|
|
|
}
|
1991-03-06 10:52:34 +00:00
|
|
|
else C_rom_fcon(nd->nd_RSTR, tp->tp_size);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_lae_dlb(data_label);
|
1987-07-21 13:54:33 +00:00
|
|
|
C_loi(tp->tp_size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case STRING:
|
|
|
|
CodeString(nd);
|
|
|
|
break;
|
|
|
|
case INTEGER:
|
1987-07-21 13:54:33 +00:00
|
|
|
CodeConst(nd->nd_INT, (int) (tp->tp_size));
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("Value error");
|
|
|
|
}
|
|
|
|
ds->dsg_kind = DSG_LOADED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Call:
|
|
|
|
CodeCall(nd);
|
|
|
|
ds->dsg_kind = DSG_LOADED;
|
|
|
|
break;
|
|
|
|
|
1986-05-23 19:25:21 +00:00
|
|
|
case Set: {
|
1987-07-21 13:54:33 +00:00
|
|
|
register unsigned i = (unsigned) (tp->tp_size) / (int) word_size;
|
1987-05-18 15:57:33 +00:00
|
|
|
register arith *st = nd->nd_set + i;
|
1991-03-25 13:28:50 +00:00
|
|
|
int null_set = 1;
|
1986-05-23 19:25:21 +00:00
|
|
|
|
1986-05-28 18:36:51 +00:00
|
|
|
ds->dsg_kind = DSG_LOADED;
|
1987-07-21 13:54:33 +00:00
|
|
|
for (; i; i--) {
|
1991-03-25 13:28:50 +00:00
|
|
|
if (*--st != 0) null_set = 0;
|
|
|
|
}
|
|
|
|
if (! null_set) {
|
|
|
|
i = (unsigned) (tp->tp_size) / (int) word_size;
|
|
|
|
st = nd->nd_set + i;
|
|
|
|
for (; i; i--) {
|
|
|
|
C_loc(*--st);
|
|
|
|
}
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
1987-09-23 16:39:43 +00:00
|
|
|
FreeSet(nd->nd_set);
|
1991-03-25 13:28:50 +00:00
|
|
|
CodeSet(nd, null_set);
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1986-05-21 18:32:20 +00:00
|
|
|
default:
|
|
|
|
crash("(CodeExpr) bad node type");
|
|
|
|
}
|
|
|
|
|
1987-05-18 15:57:33 +00:00
|
|
|
if (true_label != NO_LABEL) {
|
1986-10-06 20:36:30 +00:00
|
|
|
/* Only for boolean expressions
|
|
|
|
*/
|
1987-06-23 17:12:25 +00:00
|
|
|
CodeValue(ds, tp);
|
1986-05-21 18:32:20 +00:00
|
|
|
C_zne(true_label);
|
1993-11-19 09:53:47 +00:00
|
|
|
c_bra(false_label);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeCoercion(t_type *t1, t_type *t2)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1991-03-18 16:30:49 +00:00
|
|
|
int fund1, fund2;
|
|
|
|
int sz1 = t1->tp_size;
|
|
|
|
int sz2;
|
1986-05-28 18:36:51 +00:00
|
|
|
|
1986-06-26 09:39:36 +00:00
|
|
|
t1 = BaseType(t1);
|
|
|
|
t2 = BaseType(t2);
|
1988-03-21 16:47:51 +00:00
|
|
|
sz2 = t2->tp_size;
|
1987-06-23 17:12:25 +00:00
|
|
|
switch(fund1 = t1->tp_fund) {
|
|
|
|
case T_WORD:
|
|
|
|
fund1 = T_INTEGER;
|
|
|
|
break;
|
|
|
|
case T_CHAR:
|
|
|
|
case T_ENUMERATION:
|
1988-03-21 16:47:51 +00:00
|
|
|
case T_CARDINAL:
|
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
if (sz1 < (int) word_size) sz1 = word_size;
|
1988-03-21 16:47:51 +00:00
|
|
|
/* fall through */
|
|
|
|
case T_EQUAL:
|
1987-06-23 17:12:25 +00:00
|
|
|
case T_POINTER:
|
|
|
|
fund1 = T_CARDINAL;
|
|
|
|
break;
|
|
|
|
}
|
1987-06-29 12:46:00 +00:00
|
|
|
switch(fund2 = t2->tp_fund) {
|
1987-06-23 17:12:25 +00:00
|
|
|
case T_WORD:
|
|
|
|
fund2 = T_INTEGER;
|
|
|
|
break;
|
|
|
|
case T_CHAR:
|
|
|
|
case T_ENUMERATION:
|
1988-03-21 16:47:51 +00:00
|
|
|
sz2 = word_size;
|
|
|
|
/* fall through */
|
|
|
|
case T_EQUAL:
|
1987-06-23 17:12:25 +00:00
|
|
|
case T_POINTER:
|
|
|
|
fund2 = T_CARDINAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1986-05-28 18:36:51 +00:00
|
|
|
switch(fund1) {
|
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
if (sz1 < (int) word_size) {
|
|
|
|
c_loc(sz1);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc((int) word_size);
|
1987-06-23 17:12:25 +00:00
|
|
|
C_cii();
|
1988-03-21 16:47:51 +00:00
|
|
|
sz1 = word_size;
|
1987-06-23 17:12:25 +00:00
|
|
|
}
|
1991-03-18 16:30:49 +00:00
|
|
|
c_loc(sz1);
|
|
|
|
c_loc(sz2);
|
|
|
|
switch(fund2) {
|
|
|
|
case T_REAL:
|
1988-03-21 16:47:51 +00:00
|
|
|
C_cif();
|
1986-05-28 18:36:51 +00:00
|
|
|
break;
|
1991-03-18 16:30:49 +00:00
|
|
|
case T_INTEGER:
|
|
|
|
C_cii();
|
|
|
|
break;
|
|
|
|
case T_CARDINAL:
|
|
|
|
C_ciu();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("Funny integer conversion");
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
c_loc(sz1);
|
|
|
|
c_loc(sz2);
|
|
|
|
switch(fund2) {
|
|
|
|
case T_REAL:
|
1988-03-21 16:47:51 +00:00
|
|
|
C_cuf();
|
1986-05-28 18:36:51 +00:00
|
|
|
break;
|
1991-03-18 16:30:49 +00:00
|
|
|
case T_CARDINAL:
|
|
|
|
case T_INTORCARD:
|
|
|
|
C_cuu();
|
|
|
|
break;
|
|
|
|
case T_INTEGER:
|
|
|
|
C_cui();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("Funny cardinal conversion");
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_REAL:
|
|
|
|
switch(fund2) {
|
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
c_loc(sz1);
|
|
|
|
c_loc(sz2);
|
|
|
|
C_cff();
|
1986-05-28 18:36:51 +00:00
|
|
|
break;
|
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
c_loc(sz1);
|
|
|
|
c_loc(sz2);
|
1986-05-28 18:36:51 +00:00
|
|
|
C_cfi();
|
|
|
|
break;
|
|
|
|
case T_CARDINAL:
|
1987-08-11 10:50:30 +00:00
|
|
|
if (! options['R']) {
|
|
|
|
label lb = ++text_label;
|
1991-03-18 16:30:49 +00:00
|
|
|
arith asz1 = sz1;
|
1987-08-11 10:50:30 +00:00
|
|
|
|
1991-03-18 16:30:49 +00:00
|
|
|
C_dup(asz1);
|
|
|
|
C_zrf(asz1);
|
|
|
|
C_cmf(asz1);
|
1987-08-11 10:50:30 +00:00
|
|
|
C_zge(lb);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(ECONV);
|
1987-08-11 10:50:30 +00:00
|
|
|
C_trp();
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(lb);
|
1987-08-11 10:50:30 +00:00
|
|
|
}
|
1991-03-18 16:30:49 +00:00
|
|
|
c_loc(sz1);
|
|
|
|
c_loc(sz2);
|
1986-05-28 18:36:51 +00:00
|
|
|
C_cfu();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("Funny REAL conversion");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeCall(t_node *nd)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
2019-03-01 17:39:25 +00:00
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
register t_node *left = nd->nd_LEFT;
|
1989-03-03 16:13:45 +00:00
|
|
|
t_type *result_tp;
|
1988-10-25 17:43:19 +00:00
|
|
|
int needs_fn;
|
1986-05-21 18:32:20 +00:00
|
|
|
|
|
|
|
if (left->nd_type == std_type) {
|
|
|
|
CodeStd(nd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1989-03-03 16:13:45 +00:00
|
|
|
assert(IsProc(left));
|
1986-05-21 18:32:20 +00:00
|
|
|
|
1989-03-22 09:53:47 +00:00
|
|
|
result_tp = ResultType(left->nd_type);
|
|
|
|
#ifdef BIG_RESULT_ON_STACK
|
|
|
|
if (result_tp && TooBigForReturnArea(result_tp)) {
|
|
|
|
C_asp(-WA(result_tp->tp_size));
|
1989-03-10 10:40:07 +00:00
|
|
|
}
|
1989-03-22 09:53:47 +00:00
|
|
|
#endif
|
1989-03-10 10:40:07 +00:00
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
if (nd->nd_RIGHT) {
|
|
|
|
CodeParameters(ParamList(left->nd_type), nd->nd_RIGHT);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
1986-08-26 14:33:24 +00:00
|
|
|
switch(left->nd_class) {
|
|
|
|
case Def: {
|
1989-03-03 16:13:45 +00:00
|
|
|
register t_def *df = left->nd_def;
|
|
|
|
|
|
|
|
if (df->df_kind == D_CONST) {
|
1991-03-18 16:30:49 +00:00
|
|
|
/* a procedure address */
|
1989-03-03 16:13:45 +00:00
|
|
|
df = df->con_const.tk_data.tk_def;
|
|
|
|
}
|
|
|
|
if (df->df_kind & (D_PROCEDURE|D_PROCHEAD)) {
|
|
|
|
int level = df->df_scope->sc_level;
|
1986-08-26 14:33:24 +00:00
|
|
|
|
|
|
|
if (level > 0) {
|
1987-05-18 15:57:33 +00:00
|
|
|
C_lxl((arith) (proclevel - level));
|
1986-08-26 14:33:24 +00:00
|
|
|
}
|
1989-03-03 16:13:45 +00:00
|
|
|
needs_fn = df->df_scope->sc_defmodule;
|
1991-03-12 16:52:00 +00:00
|
|
|
C_cal(df->prc_name);
|
1986-08-26 14:33:24 +00:00
|
|
|
break;
|
|
|
|
}}
|
|
|
|
/* Fall through */
|
|
|
|
default:
|
1988-10-25 17:43:19 +00:00
|
|
|
needs_fn = 1;
|
1986-05-30 18:48:00 +00:00
|
|
|
CodePExpr(left);
|
1986-05-21 18:32:20 +00:00
|
|
|
C_cai();
|
|
|
|
}
|
1987-05-18 15:57:33 +00:00
|
|
|
C_asp(left->nd_type->prc_nbpar);
|
1989-03-10 10:40:07 +00:00
|
|
|
if (result_tp) {
|
1989-03-22 09:53:47 +00:00
|
|
|
arith sz = WA(result_tp->tp_size);
|
1989-03-10 10:40:07 +00:00
|
|
|
if (TooBigForReturnArea(result_tp)) {
|
1989-03-22 09:53:47 +00:00
|
|
|
#ifndef BIG_RESULT_ON_STACK
|
|
|
|
C_lfr(pointer_size);
|
|
|
|
C_loi(sz);
|
|
|
|
#endif
|
1986-06-20 14:36:49 +00:00
|
|
|
}
|
1989-03-22 09:53:47 +00:00
|
|
|
else C_lfr(sz);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
1988-10-25 17:43:19 +00:00
|
|
|
DoFilename(needs_fn);
|
1988-03-23 17:44:25 +00:00
|
|
|
DoLineno(nd);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
/* Generates code to setup the parameters of a procedure call. */
|
|
|
|
static void CodeParameters(t_param *param, register t_node *arg)
|
1986-06-17 12:04:05 +00:00
|
|
|
{
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *tp;
|
1991-03-12 16:52:00 +00:00
|
|
|
register t_type *arg_type;
|
1986-09-25 19:39:06 +00:00
|
|
|
|
1986-06-17 12:04:05 +00:00
|
|
|
assert(param != 0 && arg != 0);
|
|
|
|
|
1987-07-16 19:51:40 +00:00
|
|
|
if (param->par_next) {
|
1991-03-12 16:52:00 +00:00
|
|
|
CodeParameters(param->par_next, arg->nd_RIGHT);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tp = TypeOfParam(param);
|
1991-03-12 16:52:00 +00:00
|
|
|
arg = arg->nd_LEFT;
|
|
|
|
arg_type = arg->nd_type;
|
1986-06-17 12:04:05 +00:00
|
|
|
if (IsConformantArray(tp)) {
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *elem = tp->arr_elem;
|
1986-11-26 16:40:45 +00:00
|
|
|
|
1986-06-17 12:04:05 +00:00
|
|
|
C_loc(tp->arr_elsize);
|
1991-03-12 16:52:00 +00:00
|
|
|
if (IsConformantArray(arg_type)) {
|
|
|
|
DoHIGH(arg->nd_def);
|
|
|
|
if (elem->tp_size != arg_type->arr_elem->tp_size) {
|
1986-06-17 12:04:05 +00:00
|
|
|
/* This can only happen if the formal type is
|
1986-11-26 16:40:45 +00:00
|
|
|
ARRAY OF (WORD|BYTE)
|
1986-06-17 12:04:05 +00:00
|
|
|
*/
|
1991-03-12 16:52:00 +00:00
|
|
|
C_loc(arg_type->arr_elem->tp_size);
|
1991-03-18 16:30:49 +00:00
|
|
|
C_mlu(word_size);
|
1986-11-26 16:40:45 +00:00
|
|
|
if (elem == word_type) {
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc((int) word_size - 1);
|
1991-03-18 16:30:49 +00:00
|
|
|
C_adu(word_size);
|
|
|
|
c_loc((int) word_size - 1);
|
|
|
|
C_and(word_size);
|
1986-11-26 16:40:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(elem == byte_type);
|
|
|
|
}
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
1991-03-12 16:52:00 +00:00
|
|
|
else if (arg->nd_symb == STRING) {
|
1991-03-13 17:26:07 +00:00
|
|
|
c_loc((int) arg->nd_SLE - 1);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1986-11-26 16:40:45 +00:00
|
|
|
else if (elem == word_type) {
|
1991-03-12 16:52:00 +00:00
|
|
|
C_loc((arg_type->tp_size+word_size-1) / word_size - 1);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1986-11-26 16:40:45 +00:00
|
|
|
else if (elem == byte_type) {
|
1991-03-12 16:52:00 +00:00
|
|
|
C_loc(arg_type->tp_size - 1);
|
1986-11-26 16:40:45 +00:00
|
|
|
}
|
1986-06-17 12:04:05 +00:00
|
|
|
else {
|
1991-03-12 16:52:00 +00:00
|
|
|
C_loc(arg_type->arr_high - arg_type->arr_low);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(0);
|
1989-03-20 13:32:06 +00:00
|
|
|
}
|
1991-03-13 13:49:56 +00:00
|
|
|
if (IsConformantArray(tp) || IsVarParam(param)) {
|
1991-03-12 16:52:00 +00:00
|
|
|
if (arg->nd_symb == STRING) {
|
|
|
|
CodeString(arg);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1991-03-12 16:52:00 +00:00
|
|
|
else switch(arg->nd_class) {
|
1987-07-22 10:59:24 +00:00
|
|
|
case Arrsel:
|
|
|
|
case Arrow:
|
|
|
|
case Def:
|
1991-03-12 16:52:00 +00:00
|
|
|
CodeDAddress(arg, IsVarParam(param));
|
1987-07-22 10:59:24 +00:00
|
|
|
break;
|
|
|
|
default:{
|
1986-11-26 16:40:45 +00:00
|
|
|
arith tmp, TmpSpace();
|
1991-03-18 16:30:49 +00:00
|
|
|
arith sz = WA(arg->nd_type->tp_size);
|
1986-11-26 16:40:45 +00:00
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(arg);
|
1991-03-18 16:30:49 +00:00
|
|
|
tmp = TmpSpace(sz, arg->nd_type->tp_align);
|
|
|
|
STL(tmp, sz);
|
1986-11-26 16:40:45 +00:00
|
|
|
C_lal(tmp);
|
1987-07-22 10:59:24 +00:00
|
|
|
}
|
|
|
|
break;
|
1986-11-26 16:40:45 +00:00
|
|
|
}
|
|
|
|
return;
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1991-03-12 16:52:00 +00:00
|
|
|
if (arg_type->tp_fund == T_STRING) {
|
|
|
|
CodePString(arg, tp);
|
1986-11-26 16:40:45 +00:00
|
|
|
return;
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(arg);
|
1986-06-17 12:04:05 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodePString(t_node *nd, t_type *tp)
|
1986-12-01 10:06:53 +00:00
|
|
|
{
|
|
|
|
arith szarg = WA(nd->nd_type->tp_size);
|
|
|
|
register arith zersz = WA(tp->tp_size) - szarg;
|
|
|
|
|
|
|
|
if (zersz) {
|
|
|
|
/* null padding required */
|
|
|
|
assert(zersz > 0);
|
|
|
|
C_zer(zersz);
|
|
|
|
}
|
|
|
|
CodeString(nd); /* push address of string */
|
|
|
|
C_loi(szarg);
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void subu(int sz)
|
1987-11-26 14:15:24 +00:00
|
|
|
{
|
1991-03-05 11:55:22 +00:00
|
|
|
if (! options['R']) {
|
1991-03-13 17:26:07 +00:00
|
|
|
C_cal(sz == (int) word_size ? "subuchk" : "subulchk");
|
1987-11-26 14:15:24 +00:00
|
|
|
}
|
1991-03-13 17:26:07 +00:00
|
|
|
C_sbu((arith) sz);
|
1987-11-26 14:15:24 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static void addu(int sz)
|
1987-11-26 14:15:24 +00:00
|
|
|
{
|
1991-03-05 11:55:22 +00:00
|
|
|
if (! options['R']) {
|
1991-03-13 17:26:07 +00:00
|
|
|
C_cal(sz == (int) word_size ? "adduchk" : "addulchk");
|
1987-11-26 14:15:24 +00:00
|
|
|
}
|
1991-03-13 17:26:07 +00:00
|
|
|
C_adu((arith)sz);
|
1987-11-26 14:15:24 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static int complex_lhs(register t_node *nd)
|
1992-01-31 13:44:57 +00:00
|
|
|
{
|
|
|
|
switch(nd->nd_class) {
|
|
|
|
case Value:
|
|
|
|
case Name:
|
|
|
|
case Set:
|
|
|
|
case Def:
|
|
|
|
return 0;
|
|
|
|
case Select:
|
|
|
|
return complex_lhs(nd->nd_NEXT);
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
/* Generate code for internal procedures */
|
|
|
|
static void CodeStd(t_node *nd)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1991-03-12 16:52:00 +00:00
|
|
|
register t_node *arg = nd->nd_RIGHT;
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_node *left = 0;
|
1988-10-13 15:43:23 +00:00
|
|
|
register t_type *tp = 0;
|
1991-03-12 16:52:00 +00:00
|
|
|
int std = nd->nd_LEFT->nd_def->df_value.df_stdname;
|
1986-05-30 18:48:00 +00:00
|
|
|
|
|
|
|
if (arg) {
|
1991-03-12 16:52:00 +00:00
|
|
|
left = arg->nd_LEFT;
|
1986-06-26 09:39:36 +00:00
|
|
|
tp = BaseType(left->nd_type);
|
1991-03-12 16:52:00 +00:00
|
|
|
arg = arg->nd_RIGHT;
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
|
1986-10-06 20:36:30 +00:00
|
|
|
switch(std) {
|
1988-04-06 18:14:50 +00:00
|
|
|
case S_ORD:
|
|
|
|
case S_VAL:
|
|
|
|
CodePExpr(left);
|
|
|
|
break;
|
|
|
|
|
1986-05-30 18:48:00 +00:00
|
|
|
case S_ABS:
|
|
|
|
CodePExpr(left);
|
|
|
|
if (tp->tp_fund == T_INTEGER) {
|
1988-06-13 10:29:36 +00:00
|
|
|
CAL((int)(tp->tp_size) == (int)int_size ? "absi" : "absl", (int)(tp->tp_size));
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
else if (tp->tp_fund == T_REAL) {
|
1988-06-13 10:29:36 +00:00
|
|
|
CAL((int)(tp->tp_size) == (int)float_size ? "absf" : "absd", (int)(tp->tp_size));
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
C_lfr(tp->tp_size);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CAP:
|
|
|
|
CodePExpr(left);
|
1988-04-06 18:14:50 +00:00
|
|
|
C_cal("cap");
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_HIGH:
|
|
|
|
assert(IsConformantArray(tp));
|
1987-05-18 15:57:33 +00:00
|
|
|
DoHIGH(left->nd_def);
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
|
|
|
|
1986-11-28 11:59:08 +00:00
|
|
|
case S_SIZE:
|
|
|
|
case S_TSIZE:
|
|
|
|
assert(IsConformantArray(tp));
|
1987-05-18 15:57:33 +00:00
|
|
|
DoHIGH(left->nd_def);
|
1986-11-28 11:59:08 +00:00
|
|
|
C_inc();
|
|
|
|
C_loc(tp->arr_elem->tp_size);
|
|
|
|
C_mlu(word_size);
|
|
|
|
break;
|
|
|
|
|
1986-05-30 18:48:00 +00:00
|
|
|
case S_ODD:
|
1986-08-26 14:33:24 +00:00
|
|
|
CodePExpr(left);
|
1991-03-18 16:30:49 +00:00
|
|
|
if ((int) tp->tp_size == (int) word_size) {
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(1);
|
1986-05-30 18:48:00 +00:00
|
|
|
C_and(word_size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(tp->tp_size == dword_size);
|
|
|
|
C_ldc((arith) 1);
|
|
|
|
C_and(dword_size);
|
|
|
|
C_ior(word_size);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ADR:
|
1988-04-11 18:32:47 +00:00
|
|
|
CodeDAddress(left, 1);
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_DEC:
|
1986-10-06 20:36:30 +00:00
|
|
|
case S_INC: {
|
1987-07-30 13:37:39 +00:00
|
|
|
register arith size;
|
1992-01-31 13:44:57 +00:00
|
|
|
int compl = complex_lhs(left);
|
|
|
|
arith tmp = 0;
|
1986-10-06 20:36:30 +00:00
|
|
|
|
1987-07-30 13:37:39 +00:00
|
|
|
size = left->nd_type->tp_size;
|
1991-03-13 17:26:07 +00:00
|
|
|
if ((int) size < (int) word_size) size = word_size;
|
1992-01-31 13:44:57 +00:00
|
|
|
if (compl) {
|
|
|
|
tmp = NewPtr();
|
|
|
|
CodeDAddress(left, 1);
|
|
|
|
STL(tmp, pointer_size);
|
|
|
|
LOL(tmp, pointer_size);
|
|
|
|
C_loi(left->nd_type->tp_size);
|
|
|
|
}
|
|
|
|
else CodePExpr(left);
|
1987-10-28 11:10:30 +00:00
|
|
|
CodeCoercion(left->nd_type, tp);
|
1987-06-23 17:12:25 +00:00
|
|
|
if (arg) {
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(arg->nd_LEFT);
|
|
|
|
CodeCoercion(arg->nd_LEFT->nd_type, tp);
|
1987-06-23 17:12:25 +00:00
|
|
|
}
|
|
|
|
else {
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(1);
|
1987-06-23 17:12:25 +00:00
|
|
|
CodeCoercion(intorcard_type, tp);
|
|
|
|
}
|
1986-10-06 20:36:30 +00:00
|
|
|
if (std == S_DEC) {
|
|
|
|
if (tp->tp_fund == T_INTEGER) C_sbi(size);
|
1991-03-13 17:26:07 +00:00
|
|
|
else subu((int) size);
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
else {
|
1986-10-06 20:36:30 +00:00
|
|
|
if (tp->tp_fund == T_INTEGER) C_adi(size);
|
1991-03-13 17:26:07 +00:00
|
|
|
else addu((int) size);
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
1991-03-13 17:26:07 +00:00
|
|
|
if ((int) size == (int) word_size) {
|
1987-07-30 13:37:39 +00:00
|
|
|
RangeCheck(left->nd_type, tp->tp_fund == T_INTEGER ?
|
1987-06-29 12:46:00 +00:00
|
|
|
int_type : card_type);
|
|
|
|
}
|
1992-01-31 13:44:57 +00:00
|
|
|
if (compl) {
|
|
|
|
LOL(tmp, pointer_size);
|
|
|
|
C_sti(left->nd_type->tp_size);
|
|
|
|
FreePtr(tmp);
|
|
|
|
}
|
|
|
|
else CodeDStore(left);
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
1986-10-06 20:36:30 +00:00
|
|
|
}
|
1986-05-30 18:48:00 +00:00
|
|
|
|
|
|
|
case S_HALT:
|
1988-03-23 17:44:25 +00:00
|
|
|
C_cal("halt");
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_INCL:
|
1992-01-31 13:44:57 +00:00
|
|
|
case S_EXCL: {
|
|
|
|
int compl = complex_lhs(left);
|
|
|
|
arith tmp = 0;
|
|
|
|
|
|
|
|
if (compl) {
|
|
|
|
tmp = NewPtr();
|
|
|
|
CodeDAddress(left, 1);
|
|
|
|
STL(tmp, pointer_size);
|
|
|
|
LOL(tmp, pointer_size);
|
|
|
|
C_loi(left->nd_type->tp_size);
|
|
|
|
}
|
|
|
|
else CodePExpr(left);
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(arg->nd_LEFT);
|
1987-10-28 16:03:56 +00:00
|
|
|
C_loc(tp->set_low);
|
|
|
|
C_sbi(word_size);
|
1986-05-30 18:48:00 +00:00
|
|
|
C_set(tp->tp_size);
|
|
|
|
if (std == S_INCL) {
|
|
|
|
C_ior(tp->tp_size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
C_com(tp->tp_size);
|
|
|
|
C_and(tp->tp_size);
|
|
|
|
}
|
1992-01-31 13:44:57 +00:00
|
|
|
if (compl) {
|
|
|
|
LOL(tmp, pointer_size);
|
|
|
|
C_sti(left->nd_type->tp_size);
|
|
|
|
FreePtr(tmp);
|
|
|
|
}
|
|
|
|
else CodeDStore(left);
|
1986-05-30 18:48:00 +00:00
|
|
|
break;
|
1992-01-31 13:44:57 +00:00
|
|
|
}
|
1986-05-30 18:48:00 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
crash("(CodeStd)");
|
|
|
|
}
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static int needs_rangecheck(register t_type *tpl, t_type *tpr)
|
1986-05-28 18:36:51 +00:00
|
|
|
{
|
1988-04-13 18:37:45 +00:00
|
|
|
arith rlo, rhi;
|
1986-05-28 18:36:51 +00:00
|
|
|
|
|
|
|
if (bounded(tpl)) {
|
1988-04-13 18:37:45 +00:00
|
|
|
/* In this case we might need a range check.
|
|
|
|
If both types are restricted. check the bounds
|
1987-07-30 13:37:39 +00:00
|
|
|
to see wether we need a range check.
|
|
|
|
We don't need one if the range of values of the
|
|
|
|
right hand side is a subset of the range of values
|
|
|
|
of the left hand side.
|
|
|
|
*/
|
1988-04-13 18:37:45 +00:00
|
|
|
if (bounded(tpr)) {
|
|
|
|
getbounds(tpr, &rlo, &rhi);
|
|
|
|
if (in_range(rlo, tpl) && in_range(rhi, tpl)) {
|
1993-11-16 16:31:27 +00:00
|
|
|
return 0;
|
1988-04-13 18:37:45 +00:00
|
|
|
}
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
1993-11-16 16:31:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void RangeCheck(register t_type *tpl, t_type *tpr)
|
1993-11-16 16:31:27 +00:00
|
|
|
{
|
|
|
|
arith rlo, rhi;
|
|
|
|
|
|
|
|
if (options['R']) return;
|
|
|
|
|
|
|
|
if (needs_rangecheck(tpl, tpr)) {
|
1988-04-13 18:37:45 +00:00
|
|
|
genrck(tpl);
|
1987-07-30 13:37:39 +00:00
|
|
|
return;
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
1989-08-21 17:08:54 +00:00
|
|
|
tpr = BaseType(tpr);
|
1996-08-14 07:42:40 +00:00
|
|
|
if ((tpl->tp_fund == T_INTEGER && tpr->tp_fund == T_CARDINAL) ||
|
|
|
|
(tpr->tp_fund == T_INTEGER && tpl->tp_fund == T_CARDINAL)) {
|
1987-06-18 17:42:47 +00:00
|
|
|
label lb = ++text_label;
|
|
|
|
|
1989-08-21 17:08:54 +00:00
|
|
|
C_dup(tpr->tp_size);
|
|
|
|
C_zer(tpr->tp_size);
|
|
|
|
C_cmi(tpr->tp_size);
|
1987-06-18 17:42:47 +00:00
|
|
|
C_zge(lb);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(ECONV);
|
1987-06-18 17:42:47 +00:00
|
|
|
C_trp();
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(lb);
|
1987-06-18 17:42:47 +00:00
|
|
|
}
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void Operands(register t_node *nd)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(nd->nd_LEFT);
|
|
|
|
CodePExpr(nd->nd_RIGHT);
|
1988-01-28 16:15:16 +00:00
|
|
|
DoLineno(nd);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeOper(
|
|
|
|
register t_node *expr, /* the expression tree itself */
|
|
|
|
label true_label,
|
|
|
|
label false_label /* labels to jump to in logical expr's */
|
|
|
|
)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1991-03-12 16:52:00 +00:00
|
|
|
register t_node *leftop = expr->nd_LEFT;
|
|
|
|
register t_node *rightop = expr->nd_RIGHT;
|
1991-03-18 16:30:49 +00:00
|
|
|
int fund = expr->nd_type->tp_fund;
|
|
|
|
arith size = expr->nd_type->tp_size;
|
1986-05-21 18:32:20 +00:00
|
|
|
|
1986-08-26 14:33:24 +00:00
|
|
|
switch (expr->nd_symb) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case '+':
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch (fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_adi(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_adf(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_POINTER:
|
1986-09-25 19:39:06 +00:00
|
|
|
case T_EQUAL:
|
1988-03-21 16:47:51 +00:00
|
|
|
C_ads(rightop->nd_type->tp_size);
|
|
|
|
break;
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
addu((int) size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_SET:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_ior(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type +");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '-':
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch (fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_sbi(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_sbf(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
1988-04-06 18:14:50 +00:00
|
|
|
case T_POINTER:
|
|
|
|
case T_EQUAL:
|
1988-03-21 16:47:51 +00:00
|
|
|
if (rightop->nd_type == address_type) {
|
1991-03-18 16:30:49 +00:00
|
|
|
C_sbs(size);
|
1988-03-21 16:47:51 +00:00
|
|
|
break;
|
|
|
|
}
|
1988-04-06 18:14:50 +00:00
|
|
|
C_ngi(rightop->nd_type->tp_size);
|
|
|
|
C_ads(rightop->nd_type->tp_size);
|
|
|
|
break;
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1988-04-06 18:14:50 +00:00
|
|
|
case T_CARDINAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
subu((int) size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_SET:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_com(size);
|
|
|
|
C_and(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type -");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '*':
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch (fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_mli(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_POINTER:
|
1986-09-25 19:39:06 +00:00
|
|
|
case T_EQUAL:
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-05 11:55:22 +00:00
|
|
|
if (! options['R']) {
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cal((int)(size) <= (int)word_size ?
|
1991-03-06 10:52:34 +00:00
|
|
|
"muluchk" :
|
|
|
|
"mululchk");
|
1987-11-26 14:15:24 +00:00
|
|
|
}
|
1991-03-18 16:30:49 +00:00
|
|
|
C_mlu(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_mlf(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_SET:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_and(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type *");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '/':
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch (fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_dvf(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_SET:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_xor(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type /");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DIV:
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch(fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cal((int)(size) == (int)word_size
|
1990-07-16 09:05:19 +00:00
|
|
|
? "dvi"
|
|
|
|
: "dvil");
|
1991-03-18 16:30:49 +00:00
|
|
|
C_asp(2*size);
|
|
|
|
C_lfr(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_POINTER:
|
1986-09-25 19:39:06 +00:00
|
|
|
case T_EQUAL:
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_dvu(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type DIV");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOD:
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1991-03-18 16:30:49 +00:00
|
|
|
switch(fund) {
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cal((int)(size) == (int)word_size
|
1990-07-16 09:05:19 +00:00
|
|
|
? "rmi"
|
|
|
|
: "rmil");
|
1991-03-18 16:30:49 +00:00
|
|
|
C_asp(2*size);
|
|
|
|
C_lfr(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_POINTER:
|
1986-09-25 19:39:06 +00:00
|
|
|
case T_EQUAL:
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_rmu(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type MOD");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '<':
|
|
|
|
case LESSEQUAL:
|
|
|
|
case '>':
|
|
|
|
case GREATEREQUAL:
|
|
|
|
case '=':
|
1991-03-18 16:30:49 +00:00
|
|
|
case '#': {
|
|
|
|
t_type *tp;
|
|
|
|
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(expr);
|
1986-08-26 14:33:24 +00:00
|
|
|
tp = BaseType(leftop->nd_type);
|
1996-08-14 07:42:40 +00:00
|
|
|
if (tp->tp_fund == T_INTORCARD) tp = BaseType(rightop->nd_type);
|
1991-03-18 16:30:49 +00:00
|
|
|
size = tp->tp_size;
|
1986-05-21 18:32:20 +00:00
|
|
|
switch (tp->tp_fund) {
|
|
|
|
case T_INTEGER:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cmi(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_POINTER:
|
1986-09-25 19:39:06 +00:00
|
|
|
case T_HIDDEN:
|
1986-12-01 10:06:53 +00:00
|
|
|
case T_EQUAL:
|
1988-02-01 10:17:51 +00:00
|
|
|
C_cmp();
|
|
|
|
break;
|
1986-05-21 18:32:20 +00:00
|
|
|
case T_CARDINAL:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cmu(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_ENUMERATION:
|
|
|
|
case T_CHAR:
|
|
|
|
C_cmu(word_size);
|
|
|
|
break;
|
|
|
|
case T_REAL:
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cmf(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
case T_SET:
|
1986-08-26 14:33:24 +00:00
|
|
|
if (expr->nd_symb == GREATEREQUAL) {
|
1986-05-28 18:36:51 +00:00
|
|
|
/* A >= B is the same as A equals A + B
|
|
|
|
*/
|
1991-03-18 16:30:49 +00:00
|
|
|
C_dup(size << 1);
|
|
|
|
C_asp(size);
|
|
|
|
C_ior(size);
|
1987-06-18 15:46:08 +00:00
|
|
|
expr->nd_symb = '=';
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
1986-08-26 14:33:24 +00:00
|
|
|
else if (expr->nd_symb == LESSEQUAL) {
|
1986-05-28 18:36:51 +00:00
|
|
|
/* A <= B is the same as A - B = {}
|
|
|
|
*/
|
1991-03-18 16:30:49 +00:00
|
|
|
C_com(size);
|
|
|
|
C_and(size);
|
|
|
|
C_zer(size);
|
1987-06-18 15:46:08 +00:00
|
|
|
expr->nd_symb = '=';
|
1986-05-28 18:36:51 +00:00
|
|
|
}
|
1991-03-18 16:30:49 +00:00
|
|
|
C_cms(size);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("bad type COMPARE");
|
|
|
|
}
|
1987-05-18 15:57:33 +00:00
|
|
|
if (true_label != NO_LABEL) {
|
1986-08-26 14:33:24 +00:00
|
|
|
compare(expr->nd_symb, true_label);
|
1993-11-19 09:53:47 +00:00
|
|
|
c_bra(false_label);
|
1987-07-21 13:54:33 +00:00
|
|
|
break;
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
1987-07-21 13:54:33 +00:00
|
|
|
truthvalue(expr->nd_symb);
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
1991-03-18 16:30:49 +00:00
|
|
|
}
|
1987-07-21 13:54:33 +00:00
|
|
|
|
1993-11-16 16:31:27 +00:00
|
|
|
case IN: {
|
1986-05-28 18:36:51 +00:00
|
|
|
/* In this case, evaluate right hand side first! The
|
|
|
|
INN instruction expects the bit number on top of the
|
|
|
|
stack
|
|
|
|
*/
|
1993-11-19 09:53:47 +00:00
|
|
|
label l_toolarge = NO_LABEL, l_cont = NO_LABEL;
|
|
|
|
t_type *ltp = leftop->nd_type;
|
|
|
|
|
|
|
|
if (leftop->nd_symb == COERCION) {
|
|
|
|
/* Could be coercion to word_type. */
|
|
|
|
ltp = leftop->nd_RIGHT->nd_type;
|
|
|
|
}
|
|
|
|
if (leftop->nd_class == Value) {
|
|
|
|
if (! in_range(leftop->nd_INT, ElementType(rightop->nd_type))) {
|
|
|
|
if (true_label != NO_LABEL) {
|
|
|
|
c_bra(false_label);
|
|
|
|
}
|
|
|
|
else c_loc(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
CodePExpr(rightop);
|
1994-12-20 16:00:57 +00:00
|
|
|
C_loc(leftop->nd_INT - rightop->nd_type->set_low);
|
1993-11-19 09:53:47 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
CodePExpr(rightop);
|
|
|
|
CodePExpr(leftop);
|
|
|
|
C_loc(rightop->nd_type->set_low);
|
|
|
|
C_sbu(word_size);
|
|
|
|
if (needs_rangecheck(ElementType(rightop->nd_type), ltp)) {
|
|
|
|
l_toolarge = ++text_label;
|
|
|
|
C_dup(word_size);
|
|
|
|
C_loc(rightop->nd_type->tp_size*8);
|
|
|
|
C_cmu(word_size);
|
|
|
|
C_zge(l_toolarge);
|
|
|
|
}
|
1993-11-16 16:31:27 +00:00
|
|
|
}
|
1986-05-28 18:36:51 +00:00
|
|
|
C_inn(rightop->nd_type->tp_size);
|
1987-05-18 15:57:33 +00:00
|
|
|
if (true_label != NO_LABEL) {
|
1986-06-10 13:18:52 +00:00
|
|
|
C_zne(true_label);
|
1993-11-19 09:53:47 +00:00
|
|
|
c_bra(false_label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
l_cont = ++text_label;
|
|
|
|
c_bra(l_cont);
|
1986-06-10 13:18:52 +00:00
|
|
|
}
|
1993-11-16 16:31:27 +00:00
|
|
|
if (l_toolarge != NO_LABEL) {
|
1993-11-19 09:53:47 +00:00
|
|
|
def_ilb(l_toolarge);
|
1993-11-16 16:31:27 +00:00
|
|
|
C_asp(word_size+rightop->nd_type->tp_size);
|
|
|
|
if (true_label != NO_LABEL) {
|
1993-11-19 09:53:47 +00:00
|
|
|
c_bra(false_label);
|
1993-11-16 16:31:27 +00:00
|
|
|
}
|
1993-11-19 09:53:47 +00:00
|
|
|
else c_loc(0);
|
|
|
|
}
|
|
|
|
if (l_cont != NO_LABEL) {
|
|
|
|
def_ilb(l_cont);
|
1993-11-16 16:31:27 +00:00
|
|
|
}
|
1986-05-21 18:32:20 +00:00
|
|
|
break;
|
1993-11-16 16:31:27 +00:00
|
|
|
}
|
1986-10-06 20:36:30 +00:00
|
|
|
case OR:
|
1987-07-30 13:37:39 +00:00
|
|
|
case AND: {
|
1988-10-13 15:43:23 +00:00
|
|
|
label l_maybe = ++text_label, l_end = NO_LABEL;
|
1991-03-14 11:10:40 +00:00
|
|
|
t_desig Des;
|
|
|
|
|
|
|
|
Des = null_desig;
|
1986-08-26 14:33:24 +00:00
|
|
|
|
1987-05-18 15:57:33 +00:00
|
|
|
if (true_label == NO_LABEL) {
|
1986-11-26 16:40:45 +00:00
|
|
|
true_label = ++text_label;
|
|
|
|
false_label = ++text_label;
|
1986-08-26 14:33:24 +00:00
|
|
|
l_end = ++text_label;
|
|
|
|
}
|
|
|
|
|
1986-10-06 20:36:30 +00:00
|
|
|
if (expr->nd_symb == OR) {
|
1991-03-14 11:10:40 +00:00
|
|
|
CodeExpr(leftop, &Des, true_label, l_maybe);
|
1986-10-06 20:36:30 +00:00
|
|
|
}
|
1991-03-14 11:10:40 +00:00
|
|
|
else CodeExpr(leftop, &Des, l_maybe, false_label);
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(l_maybe);
|
1991-03-14 11:10:40 +00:00
|
|
|
Des = null_desig;
|
|
|
|
CodeExpr(rightop, &Des, true_label, false_label);
|
1988-10-13 15:43:23 +00:00
|
|
|
if (l_end != NO_LABEL) {
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(true_label);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(1);
|
1993-11-19 09:53:47 +00:00
|
|
|
c_bra(l_end);
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(false_label);
|
1987-09-23 16:39:43 +00:00
|
|
|
c_loc(0);
|
1988-01-28 16:15:16 +00:00
|
|
|
def_ilb(l_end);
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
break;
|
1986-08-26 14:33:24 +00:00
|
|
|
}
|
1986-05-21 18:32:20 +00:00
|
|
|
default:
|
1991-03-18 16:30:49 +00:00
|
|
|
crash("(CodeOper) Bad operator");
|
1986-05-21 18:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
/* Serves as an auxiliary function of CodeOper */
|
|
|
|
static void compare(int relop, label lbl)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
|
|
|
switch (relop) {
|
|
|
|
case '<':
|
|
|
|
C_zlt(lbl);
|
|
|
|
break;
|
|
|
|
case LESSEQUAL:
|
|
|
|
C_zle(lbl);
|
|
|
|
break;
|
|
|
|
case '>':
|
|
|
|
C_zgt(lbl);
|
|
|
|
break;
|
|
|
|
case GREATEREQUAL:
|
|
|
|
C_zge(lbl);
|
|
|
|
break;
|
|
|
|
case '=':
|
|
|
|
C_zeq(lbl);
|
|
|
|
break;
|
|
|
|
case '#':
|
|
|
|
C_zne(lbl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("(compare)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
/* Serves as an auxiliary function of CodeOper */
|
|
|
|
static void truthvalue(int relop)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
|
|
|
switch (relop) {
|
|
|
|
case '<':
|
|
|
|
C_tlt();
|
|
|
|
break;
|
|
|
|
case LESSEQUAL:
|
|
|
|
C_tle();
|
|
|
|
break;
|
|
|
|
case '>':
|
|
|
|
C_tgt();
|
|
|
|
break;
|
|
|
|
case GREATEREQUAL:
|
|
|
|
C_tge();
|
|
|
|
break;
|
|
|
|
case '=':
|
|
|
|
C_teq();
|
|
|
|
break;
|
|
|
|
case '#':
|
|
|
|
C_tne();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("(truthvalue)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
|
|
|
|
/* Generates code for an unary expression */
|
|
|
|
void CodeUoper(register t_node *nd)
|
1986-05-21 18:32:20 +00:00
|
|
|
{
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *tp = nd->nd_type;
|
1986-05-21 18:32:20 +00:00
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
CodePExpr(nd->nd_RIGHT);
|
1986-05-21 18:32:20 +00:00
|
|
|
switch(nd->nd_symb) {
|
|
|
|
case NOT:
|
|
|
|
C_teq();
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
switch(tp->tp_fund) {
|
|
|
|
case T_INTEGER:
|
1986-08-26 14:33:24 +00:00
|
|
|
case T_INTORCARD:
|
1986-05-21 18:32:20 +00:00
|
|
|
C_ngi(tp->tp_size);
|
|
|
|
break;
|
|
|
|
case T_REAL:
|
|
|
|
C_ngf(tp->tp_size);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
crash("Bad operand to unary -");
|
|
|
|
}
|
|
|
|
break;
|
1987-07-30 13:37:39 +00:00
|
|
|
case COERCION:
|
1991-03-12 16:52:00 +00:00
|
|
|
CodeCoercion(nd->nd_RIGHT->nd_type, tp);
|
|
|
|
RangeCheck(tp, nd->nd_RIGHT->nd_type);
|
1987-07-30 13:37:39 +00:00
|
|
|
break;
|
1988-04-06 18:14:50 +00:00
|
|
|
case CAST:
|
|
|
|
break;
|
1986-05-21 18:32:20 +00:00
|
|
|
default:
|
|
|
|
crash("Bad unary operator");
|
|
|
|
}
|
|
|
|
}
|
1986-05-23 19:25:21 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static void CodeSet(register t_node *nd, int null_set)
|
1986-05-23 19:25:21 +00:00
|
|
|
{
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *tp = nd->nd_type;
|
1986-05-23 19:25:21 +00:00
|
|
|
|
1991-03-12 16:52:00 +00:00
|
|
|
nd = nd->nd_NEXT;
|
1986-05-23 19:25:21 +00:00
|
|
|
while (nd) {
|
|
|
|
assert(nd->nd_class == Link && nd->nd_symb == ',');
|
|
|
|
|
1991-03-25 13:28:50 +00:00
|
|
|
if (nd->nd_LEFT) {
|
|
|
|
CodeEl(nd->nd_LEFT, tp, null_set);
|
|
|
|
null_set = 0;
|
|
|
|
}
|
1991-03-12 16:52:00 +00:00
|
|
|
nd = nd->nd_RIGHT;
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
1991-03-25 13:28:50 +00:00
|
|
|
if (null_set) C_zer(tp->tp_size);
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static void CodeEl(register t_node *nd, register t_type *tp, int null_set)
|
1986-05-23 19:25:21 +00:00
|
|
|
{
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_type *eltype = ElementType(tp);
|
1986-05-23 19:25:21 +00:00
|
|
|
|
|
|
|
if (nd->nd_class == Link && nd->nd_symb == UPTO) {
|
1991-03-25 13:28:50 +00:00
|
|
|
if (null_set) C_zer(tp->tp_size);
|
1987-10-28 16:03:56 +00:00
|
|
|
C_loc(tp->set_low);
|
1986-06-06 02:22:09 +00:00
|
|
|
C_loc(tp->tp_size); /* push size */
|
1986-06-26 09:39:36 +00:00
|
|
|
if (eltype->tp_fund == T_SUBRANGE) {
|
|
|
|
C_loc(eltype->sub_ub);
|
1986-06-04 09:01:48 +00:00
|
|
|
}
|
1993-11-19 09:53:47 +00:00
|
|
|
else C_loc(eltype->enm_ncst - 1);
|
1988-01-28 16:15:16 +00:00
|
|
|
Operands(nd);
|
1988-06-13 10:29:36 +00:00
|
|
|
CAL("LtoUset", 5 * (int) word_size);
|
|
|
|
/* library routine to fill set */
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
|
|
|
else {
|
1986-05-30 18:48:00 +00:00
|
|
|
CodePExpr(nd);
|
1987-10-28 16:03:56 +00:00
|
|
|
C_loc(tp->set_low);
|
|
|
|
C_sbi(word_size);
|
1986-05-23 19:25:21 +00:00
|
|
|
C_set(tp->tp_size);
|
1991-03-25 13:28:50 +00:00
|
|
|
if (! null_set) C_ior(tp->tp_size);
|
1986-05-23 19:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
1986-05-30 18:48:00 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodePExpr(register t_node *nd)
|
1986-05-30 18:48:00 +00:00
|
|
|
{
|
2019-03-01 17:39:25 +00:00
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
t_desig designator;
|
1986-05-30 18:48:00 +00:00
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
designator = null_desig;
|
|
|
|
CodeExpr(nd, &designator, NO_LABEL, NO_LABEL);
|
|
|
|
CodeValue(&designator, nd->nd_type);
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static void CodeDAddress(t_node *nd, int chk_controlvar)
|
1986-05-30 18:48:00 +00:00
|
|
|
{
|
|
|
|
/* Generate code to push the address of the designator "nd"
|
|
|
|
on the stack.
|
|
|
|
*/
|
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
t_desig designator;
|
1988-04-11 18:32:47 +00:00
|
|
|
int chkptr;
|
1986-05-30 18:48:00 +00:00
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
designator = null_desig;
|
1988-04-11 18:32:47 +00:00
|
|
|
if (chk_controlvar) ChkForFOR(nd);
|
1991-03-14 11:10:40 +00:00
|
|
|
CodeDesig(nd, &designator);
|
|
|
|
chkptr = designator.dsg_kind==DSG_PLOADED ||
|
|
|
|
designator.dsg_kind==DSG_PFIXED;
|
|
|
|
CodeAddress(&designator);
|
1988-04-11 18:32:47 +00:00
|
|
|
|
|
|
|
/* Generate dummy use of pointer, to get possible error message
|
|
|
|
as soon as possible
|
|
|
|
*/
|
|
|
|
if (chkptr && ! options['R']) {
|
|
|
|
C_dup(pointer_size);
|
|
|
|
C_loi((arith) 1);
|
1988-06-13 10:29:36 +00:00
|
|
|
C_asp(word_size);
|
1988-04-11 18:32:47 +00:00
|
|
|
}
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CodeDStore(register t_node *nd)
|
1986-05-30 18:48:00 +00:00
|
|
|
{
|
2019-03-01 17:39:25 +00:00
|
|
|
|
1986-05-30 18:48:00 +00:00
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
t_desig designator;
|
1986-05-30 18:48:00 +00:00
|
|
|
|
1991-03-14 11:10:40 +00:00
|
|
|
designator = null_desig;
|
1987-08-10 13:01:54 +00:00
|
|
|
ChkForFOR(nd);
|
1991-03-14 11:10:40 +00:00
|
|
|
CodeDesig(nd, &designator);
|
|
|
|
CodeStore(&designator, nd->nd_type);
|
1986-05-30 18:48:00 +00:00
|
|
|
}
|
1986-06-04 09:01:48 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
static void DoHIGH(register t_def *df)
|
1986-06-04 09:01:48 +00:00
|
|
|
{
|
1986-08-26 14:33:24 +00:00
|
|
|
/* Get the high index of a conformant array, indicated by "nd".
|
|
|
|
The high index is the second field in the descriptor of
|
|
|
|
the array, so it is easily found.
|
|
|
|
*/
|
1986-06-20 14:36:49 +00:00
|
|
|
register arith highoff;
|
1986-06-04 09:01:48 +00:00
|
|
|
|
|
|
|
assert(df->df_kind == D_VARIABLE);
|
1986-08-26 14:33:24 +00:00
|
|
|
assert(IsConformantArray(df->df_type));
|
1986-06-04 09:01:48 +00:00
|
|
|
|
1986-08-26 14:33:24 +00:00
|
|
|
highoff = df->var_off /* base address and descriptor */
|
1988-03-21 16:47:51 +00:00
|
|
|
+ word_size + pointer_size;
|
|
|
|
/* skip base and first field of
|
1986-11-28 11:59:08 +00:00
|
|
|
descriptor
|
|
|
|
*/
|
1986-06-04 09:01:48 +00:00
|
|
|
if (df->df_scope->sc_level < proclevel) {
|
1986-06-10 13:18:52 +00:00
|
|
|
C_lxa((arith) (proclevel - df->df_scope->sc_level));
|
1986-06-04 09:01:48 +00:00
|
|
|
C_lof(highoff);
|
|
|
|
}
|
|
|
|
else C_lol(highoff);
|
|
|
|
}
|
1987-09-23 16:39:43 +00:00
|
|
|
|
|
|
|
#ifdef SQUEEZE
|
2019-03-01 17:39:25 +00:00
|
|
|
void c_bra(label l)
|
1993-11-19 09:53:47 +00:00
|
|
|
{
|
|
|
|
C_bra((label) l);
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void c_loc(int n)
|
1987-09-23 16:39:43 +00:00
|
|
|
{
|
|
|
|
C_loc((arith) n);
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void c_lae_dlb(label l)
|
1987-09-23 16:39:43 +00:00
|
|
|
{
|
|
|
|
C_lae_dlb(l, (arith) 0);
|
|
|
|
}
|
1988-04-11 18:32:47 +00:00
|
|
|
|
2019-03-01 17:39:25 +00:00
|
|
|
void CAL(char *name, int ssp)
|
1988-04-11 18:32:47 +00:00
|
|
|
{
|
1988-06-13 10:29:36 +00:00
|
|
|
C_cal(name);
|
|
|
|
C_asp((arith) ssp);
|
1988-04-11 18:32:47 +00:00
|
|
|
}
|
1987-09-23 16:39:43 +00:00
|
|
|
#endif
|