simplified the EM con/rom functions (86/03/13)
This commit is contained in:
parent
43e75cec60
commit
6e53274b6a
|
@ -174,9 +174,7 @@ begin_proc(name, def) /* to be called when entering a procedure */
|
|||
if (strcmp(last_fn_given, FileName) != 0) {
|
||||
/* previous function came from other file */
|
||||
C_df_dlb(file_name_label = data_label());
|
||||
C_con_begin();
|
||||
C_scon(last_fn_given = FileName, (arith)0);
|
||||
C_con_end();
|
||||
C_con_scon(last_fn_given = FileName, (arith)0);
|
||||
}
|
||||
/* enable debug trace of EM source */
|
||||
C_fil_dlb(file_name_label, (arith)0);
|
||||
|
|
|
@ -61,30 +61,6 @@ C_busy()
|
|||
return ofd >= 0; /* true if code is being generated */
|
||||
}
|
||||
|
||||
/*** front end for generating long CON/ROM lists ***/
|
||||
static arg_count;
|
||||
static arg_rom;
|
||||
|
||||
DC_start(rom){
|
||||
arg_count = 0;
|
||||
arg_rom = rom;
|
||||
}
|
||||
|
||||
DC_check(){
|
||||
if (arg_count++ >= MAX_ARG_CNT) {
|
||||
switch (arg_rom) {
|
||||
case ps_con:
|
||||
C_con_end();
|
||||
C_con_begin();
|
||||
break;
|
||||
case ps_rom:
|
||||
C_rom_end();
|
||||
C_rom_begin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*** the compact code generating routines ***/
|
||||
#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF)
|
||||
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
|
||||
|
|
|
@ -85,22 +85,35 @@ C_df_ilb(l) | label l; | ILB(l)
|
|||
C_bss_cst(n, w, i) | arith n, w; int i; |
|
||||
PS(ps_bss), DCST(n), CST(w), CST((arith)i)
|
||||
%
|
||||
C_con_begin() | | DC_start(ps_con), PS(ps_con)
|
||||
C_con_end() | | CEND()
|
||||
C_rom_begin() | | DC_start(ps_rom), PS(ps_rom)
|
||||
C_rom_end() | | CEND()
|
||||
C_cst(l) | arith l; | DC_check(), CST(l)
|
||||
C_icon(val, siz) | char *val; arith siz; |
|
||||
DC_check(), WCON(sp_icon, val, siz)
|
||||
C_ucon(val, siz) | char *val; arith siz; |
|
||||
DC_check(), WCON(sp_ucon, val, siz)
|
||||
C_fcon(val, siz) | char *val; arith siz; |
|
||||
DC_check(), WCON(sp_fcon, val, siz)
|
||||
C_scon(str, siz) | char *str; arith siz; | DC_check(), CSTR(str)
|
||||
C_dnam(str, val) | char *str; arith val; | DC_check(), NOFF(str, val)
|
||||
C_dlb(l, val) | label l; arith val; | DC_check(), DOFF(l, val)
|
||||
C_pnam(str) | char *str; | DC_check(), PNAM(str)
|
||||
C_ilb(l) | label l; | DC_check(), ILB(l)
|
||||
C_con_icon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_icon, val, siz), CEND()
|
||||
C_con_ucon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_ucon, val, siz), CEND()
|
||||
C_con_fcon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_fcon, val, siz), CEND()
|
||||
C_con_scon(str, siz) | char *str; arith siz; | PS(ps_con), CSTR(str), CEND()
|
||||
C_con_dnam(str, val) | char *str; arith val; |
|
||||
PS(ps_con), NOFF(str, val), CEND()
|
||||
C_con_dlb(l, val) | label l; arith val; |
|
||||
PS(ps_con), DOFF(l, val), CEND()
|
||||
C_con_pnam(str) | char *str; | PS(ps_con), PNAM(str), CEND()
|
||||
%
|
||||
C_rom_cst(l) | arith l; | PS(ps_rom), CST(l), CEND()
|
||||
C_rom_icon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_rom), WCON(sp_icon, val, siz), CEND()
|
||||
C_rom_fcon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_rom), WCON(sp_fcon, val, siz), CEND()
|
||||
C_rom_ilb(l) | label l; | PS(ps_rom), ILB(l), CEND()
|
||||
%
|
||||
C_cst(l) | arith l; | CST(l)
|
||||
C_icon(val, siz) | char *val; arith siz; | WCON(sp_icon, val, siz)
|
||||
C_ucon(val, siz) | char *val; arith siz; | WCON(sp_ucon, val, siz)
|
||||
C_fcon(val, siz) | char *val; arith siz; | WCON(sp_fcon, val, siz)
|
||||
C_scon(str, siz) | char *str; arith siz; | CSTR(str)
|
||||
C_dnam(str, val) | char *str; arith val; | NOFF(str, val)
|
||||
C_dlb(l, val) | label l; arith val; | DOFF(l, val)
|
||||
C_pnam(str) | char *str; | PNAM(str)
|
||||
C_ilb(l) | label l; | ILB(l)
|
||||
%
|
||||
C_pro_narg(p1) | char *p1; | PS(ps_pro), PNAM(p1), CEND()
|
||||
C_end(l) | arith l; | PS(ps_end), CST(l)
|
||||
|
|
|
@ -88,9 +88,7 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
label datlab = data_label();
|
||||
|
||||
C_df_dlb(datlab);
|
||||
C_con_begin();
|
||||
C_scon(expr->SG_VALUE, (arith)0);
|
||||
C_con_end();
|
||||
C_con_scon(expr->SG_VALUE, (arith)0);
|
||||
C_lae_dlb(datlab, (arith)0);
|
||||
}
|
||||
break;
|
||||
|
@ -100,9 +98,7 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
label datlab = data_label();
|
||||
|
||||
C_df_dlb(datlab);
|
||||
C_rom_begin();
|
||||
C_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
|
||||
C_rom_end();
|
||||
C_rom_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
|
||||
C_lae_dlb(datlab, (arith)0);
|
||||
C_loi(expr->ex_type->tp_size);
|
||||
}
|
||||
|
@ -1019,9 +1015,7 @@ load_cst(val, siz)
|
|||
label datlab;
|
||||
|
||||
C_df_dlb(datlab = data_label());
|
||||
C_rom_begin();
|
||||
C_icon(itos(val), siz);
|
||||
C_rom_end();
|
||||
C_rom_icon(itos(val), siz);
|
||||
C_lae_dlb(datlab, (arith)0);
|
||||
C_loi(siz);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,10 @@
|
|||
|
||||
extern char *symbol2str();
|
||||
|
||||
#define con_byte(c) C_ucon(itos((long)(c) & 0xFF), (arith)1)
|
||||
#define con_byte(c) C_con_ucon(itos((long)(c) & 0xFF), (arith)1)
|
||||
|
||||
struct expr *do_array(), *do_struct(), *IVAL();
|
||||
struct expr *strings = 0; /* list of string constants within initialiser */
|
||||
static ConStarted; /* indicates the generation of a 'con' pseudo */
|
||||
|
||||
/* do_ival() performs the initialisation of a global variable
|
||||
of type tp with the initialisation expression expr by calling IVAL().
|
||||
|
@ -37,9 +36,9 @@ do_ival(tpp, expr)
|
|||
struct type **tpp;
|
||||
struct expr *expr;
|
||||
{
|
||||
ConStarted = 0;
|
||||
if (IVAL(tpp, expr) != 0)
|
||||
too_many_initialisers(expr);
|
||||
|
||||
/* The following loop declares the string constants
|
||||
used in the initialisation.
|
||||
The code for these string constants may not appear in
|
||||
|
@ -47,12 +46,9 @@ do_ival(tpp, expr)
|
|||
in EM causes the current initialisation to be completed.
|
||||
E.g. char *s[] = {"hello", "world"};
|
||||
*/
|
||||
C_con_end();
|
||||
while (strings != 0) {
|
||||
C_df_dlb(strings->SG_DATLAB);
|
||||
C_con_begin();
|
||||
C_scon(strings->SG_VALUE, (arith)0);
|
||||
C_con_end();
|
||||
C_con_scon(strings->SG_VALUE, (arith)0);
|
||||
strings = strings->next;
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +337,7 @@ check_and_pad(expr, tpp)
|
|||
/* no size specified upto here: just
|
||||
set it to the size of one member.
|
||||
*/
|
||||
tp = *tpp =
|
||||
construct_type(ARRAY, tp->tp_up, (arith)1);
|
||||
tp = *tpp = construct_type(ARRAY, tp->tp_up, (arith)1);
|
||||
else {
|
||||
register dim = tp->tp_size / tp->tp_up->tp_size;
|
||||
/* pad remaining members with zeroes */
|
||||
|
@ -376,10 +371,6 @@ check_and_pad(expr, tpp)
|
|||
pad(tp)
|
||||
struct type *tp;
|
||||
{
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
switch (tp->tp_fund) {
|
||||
case ARRAY:
|
||||
{
|
||||
|
@ -420,11 +411,11 @@ pad(tp)
|
|||
case CHAR:
|
||||
case ENUM:
|
||||
case POINTER:
|
||||
C_ucon("0", tp->tp_size);
|
||||
C_con_ucon("0", tp->tp_size);
|
||||
break;
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
C_fcon("0", tp->tp_size);
|
||||
C_con_fcon("0", tp->tp_size);
|
||||
break;
|
||||
case UNION:
|
||||
error("initialisation of unions not allowed");
|
||||
|
@ -463,10 +454,6 @@ check_ival(expr, type)
|
|||
break;
|
||||
}
|
||||
ch7cast(&expr, '=', type);
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
con_int(expr);
|
||||
break;
|
||||
#ifndef NOBITFIELD
|
||||
|
@ -485,26 +472,18 @@ check_ival(expr, type)
|
|||
break;
|
||||
}
|
||||
ch7cast(&expr, '=', type);
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
con_int(expr);
|
||||
break;
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
ch7cast(&expr, '=', type);
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
if (expr->ex_class == Float)
|
||||
C_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
|
||||
C_con_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
|
||||
else
|
||||
if (expr->ex_class == Oper && expr->OP_OPER == INT2FLOAT) {
|
||||
expr = expr->OP_RIGHT;
|
||||
if (expr->ex_class == Value && expr->VL_IDF == 0)
|
||||
C_fcon(itos(expr->VL_VALUE), type->tp_size);
|
||||
C_con_fcon(itos(expr->VL_VALUE), type->tp_size);
|
||||
else
|
||||
illegal_init_cst(expr);
|
||||
}
|
||||
|
@ -521,13 +500,8 @@ check_ival(expr, type)
|
|||
{
|
||||
label datlab = data_label();
|
||||
|
||||
if (ConStarted)
|
||||
C_con_end();
|
||||
else
|
||||
ConStarted = 1; /* ??? */
|
||||
C_ina_pt(datlab);
|
||||
C_con_begin();
|
||||
C_dlb(datlab, (arith)0);
|
||||
C_con_dlb(datlab, (arith)0);
|
||||
expr->SG_DATLAB = datlab;
|
||||
store_string(expr);
|
||||
break;
|
||||
|
@ -538,13 +512,9 @@ check_ival(expr, type)
|
|||
struct idf *idf = vl->vl_idf;
|
||||
|
||||
ASSERT(expr->ex_type->tp_fund == POINTER);
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
if (expr->ex_type->tp_up->tp_fund == FUNCTION) {
|
||||
if (idf)
|
||||
C_pnam(idf->id_text);
|
||||
C_con_pnam(idf->id_text);
|
||||
else /* int (*func)() = 0 */
|
||||
con_int(expr);
|
||||
}
|
||||
|
@ -558,13 +528,16 @@ check_ival(expr, type)
|
|||
static int *p = &a;
|
||||
*/
|
||||
expr_error(expr,
|
||||
"illegal initialisation");
|
||||
"illegal initialisation"
|
||||
);
|
||||
else
|
||||
C_dlb((label)def->df_address,
|
||||
vl->vl_value);
|
||||
C_con_dlb(
|
||||
(label)def->df_address,
|
||||
vl->vl_value
|
||||
);
|
||||
}
|
||||
else
|
||||
C_dnam(idf->id_text, vl->vl_value);
|
||||
C_con_dnam(idf->id_text, vl->vl_value);
|
||||
}
|
||||
else
|
||||
con_int(expr);
|
||||
|
@ -611,10 +584,6 @@ init_string(tpp, expr)
|
|||
expr_error(expr,
|
||||
"too many characters in initialiser string");
|
||||
}
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
/* throw out the characters of the already prepared string */
|
||||
do
|
||||
con_byte(*s++);
|
||||
|
@ -721,10 +690,6 @@ put_bf(tp, val)
|
|||
if (sd->sd_sdef == 0 || sd->sd_sdef->sd_offset != offset) {
|
||||
/* the selector was the last stored at this address */
|
||||
expr.VL_VALUE = field;
|
||||
if (ConStarted == 0) {
|
||||
C_con_begin();
|
||||
ConStarted = 1;
|
||||
}
|
||||
con_int(&expr);
|
||||
field = (arith)0;
|
||||
offset = (arith)-1;
|
||||
|
@ -767,9 +732,9 @@ con_int(expr)
|
|||
register struct type *tp = expr->ex_type;
|
||||
|
||||
if (tp->tp_unsigned)
|
||||
C_ucon(itos(expr->VL_VALUE), tp->tp_size);
|
||||
C_con_ucon(itos(expr->VL_VALUE), tp->tp_size);
|
||||
else
|
||||
C_icon(itos(expr->VL_VALUE), tp->tp_size);
|
||||
C_con_icon(itos(expr->VL_VALUE), tp->tp_size);
|
||||
}
|
||||
|
||||
illegal_init_cst(expr)
|
||||
|
|
|
@ -56,36 +56,33 @@ code_endswitch()
|
|||
C_df_ilb(sh->sh_table); /* switch table entry */
|
||||
tablabel = data_label(); /* the rom must have a label */
|
||||
C_df_dlb(tablabel);
|
||||
C_rom_begin();
|
||||
C_ilb(sh->sh_default);
|
||||
C_rom_ilb(sh->sh_default);
|
||||
if (compact(sh->sh_nrofentries, sh->sh_lowerbd, sh->sh_upperbd)) {
|
||||
/* CSA */
|
||||
register arith val;
|
||||
|
||||
C_cst(sh->sh_lowerbd);
|
||||
C_cst(sh->sh_upperbd - sh->sh_lowerbd);
|
||||
C_rom_cst(sh->sh_lowerbd);
|
||||
C_rom_cst(sh->sh_upperbd - sh->sh_lowerbd);
|
||||
ce = sh->sh_entries;
|
||||
for (val = sh->sh_lowerbd; val <= sh->sh_upperbd; val++) {
|
||||
ASSERT(ce);
|
||||
if (val == ce->ce_value) {
|
||||
C_ilb(ce->ce_label);
|
||||
C_rom_ilb(ce->ce_label);
|
||||
ce = ce->next;
|
||||
}
|
||||
else
|
||||
C_ilb(sh->sh_default);
|
||||
C_rom_ilb(sh->sh_default);
|
||||
}
|
||||
C_rom_end();
|
||||
C_lae_dlb(tablabel, (arith)0); /* perform the switch */
|
||||
C_csa(sh->sh_type->tp_size);
|
||||
}
|
||||
else { /* CSB */
|
||||
C_cst((arith)sh->sh_nrofentries);
|
||||
C_rom_cst((arith)sh->sh_nrofentries);
|
||||
for (ce = sh->sh_entries; ce; ce = ce->next) {
|
||||
/* generate the entries: value + prog.label */
|
||||
C_cst(ce->ce_value);
|
||||
C_ilb(ce->ce_label);
|
||||
C_rom_cst(ce->ce_value);
|
||||
C_rom_ilb(ce->ce_label);
|
||||
}
|
||||
C_rom_end();
|
||||
C_lae_dlb(tablabel, (arith)0); /* perform the switch */
|
||||
C_csb(sh->sh_type->tp_size);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue