put heavily used pointer variables in registers

This commit is contained in:
erikb 1986-09-24 13:53:16 +00:00
parent bfad7d30f0
commit c967d1ab3a
29 changed files with 275 additions and 280 deletions

View file

@ -1,12 +1,12 @@
/* $Header$ */ /* $Header$ */
/* L E X I C A L A N A L Y Z E R */ /* L E X I C A L A N A L Y Z E R */
#include "nofloat.h"
#include "idfsize.h" #include "idfsize.h"
#include "numsize.h" #include "numsize.h"
#include "debug.h" #include "debug.h"
#include "strsize.h" #include "strsize.h"
#include "nopp.h" #include "nopp.h"
#include "input.h" #include "input.h"
#include "alloc.h" #include "alloc.h"
#include "arith.h" #include "arith.h"

View file

@ -6,6 +6,8 @@
to it. to it.
*/ */
#include "nofloat.h"
/* the structure of a token: */ /* the structure of a token: */
struct token { struct token {
int tok_symb; /* the token itself */ int tok_symb; /* the token itself */

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* PARSER ERROR ADMINISTRATION */ /* PARSER ERROR ADMINISTRATION */
#include "nofloat.h"
#include "idf.h" #include "idf.h"
#include "alloc.h" #include "alloc.h"
#include "arith.h" #include "arith.h"

View file

@ -75,7 +75,7 @@ GSRC = char.c symbol2str.c next.c \
# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE! # .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \ GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \ idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \
maxincl.h myalloc.h nobitfield.h nopp.h \ maxincl.h myalloc.h nobitfield.h nofloat.h nopp.h \
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \ nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h static.h strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h static.h
@ -205,47 +205,47 @@ sim: cfiles
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC) $(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: LLlex.h Lpars.h alloc.h arith.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nopp.h spec_arith.h specials.h target_sizes.h tokenname.h type.h use_tmp.h LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nofloat.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nofloat.h nopp.h spec_arith.h
declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h spec_arith.h type.h
struct.o: LLlex.h Lpars.h align.h arith.h assert.h botch_free.h debug.h def.h field.h idf.h level.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h storage.h struct.h type.h
expr.o: LLlex.h Lpars.h alloc.h arith.h botch_free.h declar.h decspecs.h def.h expr.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h struct.h type.h
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h
cstoper.o: Lpars.h arith.h assert.h debug.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h
alloc.o: alloc.h assert.h debug.h myalloc.h
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h stmt.h storage.h type.h use_tmp.h
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h static.h struct.h type.h
error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nopp.h spec_arith.h tokenname.h use_tmp.h
field.o: Lpars.h arith.h assert.h code.h debug.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h
LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h
input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h static.h
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h static.h strsize.h
init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h use_tmp.h
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h
stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h idf.h level.h mes.h nobitfield.h nopp.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h
eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h type.h
switch.o: Lpars.h arith.h assert.h botch_free.h code.h debug.h density.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h switch.h type.h
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h
blocks.o: arith.h atw.h sizes.h spec_arith.h
dataflow.o: dataflow.h
tokenfile.o: Lpars.h
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h struct.h type.h
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h
expression.o: LLlex.h Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h
program.o: LLlex.h Lpars.h alloc.h arith.h code.h declar.h decspecs.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h
Lpars.o: Lpars.h Lpars.o: Lpars.h
alloc.o: alloc.h assert.h debug.h myalloc.h
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nofloat.h nopp.h spec_arith.h storage.h type.h
blocks.o: arith.h atw.h nofloat.h sizes.h spec_arith.h
ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h struct.h type.h
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h storage.h struct.h type.h
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h storage.h type.h
char.o: class.h char.o: class.h
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h specials.h stack.h stmt.h storage.h type.h use_tmp.h
conversion.o: Lpars.h arith.h nobitfield.h nofloat.h sizes.h spec_arith.h type.h
cstoper.o: Lpars.h arith.h assert.h debug.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
dataflow.o: dataflow.h
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h storage.h struct.h type.h
declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h storage.h type.h
decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h nofloat.h spec_arith.h type.h
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nofloat.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h stack.h static.h struct.h type.h
error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nofloat.h nopp.h spec_arith.h tokenname.h use_tmp.h
eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h stack.h type.h
expr.o: LLlex.h Lpars.h alloc.h arith.h botch_free.h declar.h decspecs.h def.h expr.h idf.h label.h level.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h storage.h type.h
expression.o: LLlex.h Lpars.h arith.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h type.h
field.o: Lpars.h arith.h assert.h code.h debug.h expr.h field.h idf.h label.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h type.h
idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h
init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h
input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nofloat.h nopp.h pathlength.h spec_arith.h static.h
ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h struct.h type.h
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nofloat.h nopp.h spec_arith.h type.h
main.o: LLlex.h Lpars.h alloc.h arith.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nofloat.h nopp.h spec_arith.h specials.h target_sizes.h tokenname.h type.h use_tmp.h
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h storage.h use_tmp.h
program.o: LLlex.h Lpars.h alloc.h arith.h code.h declar.h decspecs.h def.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h type.h
replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nofloat.h nopp.h pathlength.h spec_arith.h static.h strsize.h
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
skip.o: LLlex.h arith.h class.h input.h interface.h nofloat.h nopp.h spec_arith.h
stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h idf.h level.h mes.h nobitfield.h nofloat.h nopp.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h stack.h storage.h type.h
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
struct.o: LLlex.h Lpars.h align.h arith.h assert.h botch_free.h debug.h def.h field.h idf.h level.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h stack.h storage.h struct.h type.h
switch.o: Lpars.h arith.h assert.h botch_free.h code.h debug.h density.h expr.h idf.h label.h nobitfield.h nofloat.h nopp.h spec_arith.h storage.h switch.h type.h
symbol2str.o: Lpars.h symbol2str.o: Lpars.h
tokenfile.o: Lpars.h
tokenname.o: LLlex.h Lpars.h arith.h idf.h nofloat.h nopp.h spec_arith.h tokenname.h
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nofloat.h nopp.h sizes.h spec_arith.h storage.h type.h

View file

@ -133,3 +133,8 @@
!File: static.h !File: static.h
#define GSTATIC /* for large global "static" arrays */ #define GSTATIC /* for large global "static" arrays */
!File: nofloat.h
#undef NOFLOAT /* floats implemented by default */

View file

@ -1,6 +1,8 @@
/* $Header$ */ /* $Header$ */
/* A L I G N M E N T D E F I N I T I O N S */ /* A L I G N M E N T D E F I N I T I O N S */
#include "nofloat.h"
extern int extern int
short_align, word_align, int_align, long_align, short_align, word_align, int_align, long_align,
#ifndef NOFLOAT #ifndef NOFLOAT

View file

@ -7,6 +7,7 @@
semantics of C is a mess. semantics of C is a mess.
*/ */
#include "nofloat.h"
#include "botch_free.h" #include "botch_free.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "alloc.h" #include "alloc.h"
@ -25,7 +26,8 @@ extern char options[];
int int
arithbalance(e1p, oper, e2p) /* RM 6.6 */ arithbalance(e1p, oper, e2p) /* RM 6.6 */
struct expr **e1p, **e2p; register struct expr **e1p, **e2p;
int oper;
{ {
/* The expressions *e1p and *e2p are balanced to be operands /* The expressions *e1p and *e2p are balanced to be operands
of the arithmetic operator oper. of the arithmetic operator oper.
@ -127,9 +129,9 @@ any2arith(expp, oper)
/* Turns any expression into int_type, long_type or /* Turns any expression into int_type, long_type or
double_type. double_type.
*/ */
int fund = (*expp)->ex_type->tp_fund; int fund;
switch (fund) { switch (fund = (*expp)->ex_type->tp_fund) {
case CHAR: case CHAR:
case SHORT: case SHORT:
int2int(expp, int2int(expp,
@ -174,7 +176,7 @@ any2arith(expp, oper)
} }
erroneous2int(expp) erroneous2int(expp)
struct expr **expp; register struct expr **expp;
{ {
/* the (erroneous) expression *expp is replaced by an /* the (erroneous) expression *expp is replaced by an
int expression int expression
@ -190,7 +192,7 @@ struct expr *
arith2arith(tp, oper, expr) arith2arith(tp, oper, expr)
struct type *tp; struct type *tp;
int oper; int oper;
struct expr *expr; register struct expr *expr;
{ {
/* arith2arith constructs a new expression containing a /* arith2arith constructs a new expression containing a
run-time conversion between some arithmetic types. run-time conversion between some arithmetic types.
@ -280,7 +282,7 @@ array2pointer(expp)
} }
function2pointer(expp) function2pointer(expp)
struct expr **expp; register struct expr **expp;
{ {
/* The expression, which must be a function, is converted /* The expression, which must be a function, is converted
to a pointer to the function. to a pointer to the function.
@ -295,7 +297,7 @@ string2pointer(expp)
/* The expression, which must be a string constant, is converted /* The expression, which must be a string constant, is converted
to a pointer to the string-containing area. to a pointer to the string-containing area.
*/ */
struct expr *ex = *expp; register struct expr *ex = *expp;
label lbl = data_label(); label lbl = data_label();
code_string(ex->SG_VALUE, ex->SG_LEN, lbl); code_string(ex->SG_VALUE, ex->SG_LEN, lbl);
@ -306,7 +308,7 @@ string2pointer(expp)
} }
opnd2integral(expp, oper) opnd2integral(expp, oper)
struct expr **expp; register struct expr **expp;
int oper; int oper;
{ {
register int fund = (*expp)->ex_type->tp_fund; register int fund = (*expp)->ex_type->tp_fund;
@ -320,7 +322,7 @@ opnd2integral(expp, oper)
} }
opnd2logical(expp, oper) opnd2logical(expp, oper)
struct expr **expp; register struct expr **expp;
int oper; int oper;
{ {
register int fund; register int fund;
@ -332,11 +334,7 @@ opnd2logical(expp, oper)
if ((*expp)->ex_type->tp_fund == FIELD) if ((*expp)->ex_type->tp_fund == FIELD)
field2arith(expp); field2arith(expp);
#endif NOBITFIELD #endif NOBITFIELD
switch (fund = (*expp)->ex_type->tp_fund) {
fund = (*expp)->ex_type->tp_fund;
switch (fund) {
case CHAR: case CHAR:
case SHORT: case SHORT:
case INT: case INT:
@ -358,7 +356,7 @@ opnd2logical(expp, oper)
} }
opnd2test(expp, oper) opnd2test(expp, oper)
struct expr **expp; register struct expr **expp;
{ {
opnd2logical(expp, oper); opnd2logical(expp, oper);
if ((*expp)->ex_class == Oper && is_test_op((*expp)->OP_OPER)) if ((*expp)->ex_class == Oper && is_test_op((*expp)->OP_OPER))
@ -429,7 +427,7 @@ is_asgn_op(oper)
} }
any2opnd(expp, oper) any2opnd(expp, oper)
struct expr **expp; register struct expr **expp;
{ {
if (!*expp) if (!*expp)
return; return;

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* S E M A N T I C A N A L Y S I S -- C H A P T E R 7 RM */ /* S E M A N T I C A N A L Y S I S -- C H A P T E R 7 RM */
#include "nofloat.h"
#include "debug.h" #include "debug.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "idf.h" #include "idf.h"

View file

@ -1,7 +1,8 @@
/* $Header$ */ /* $Header$ */
/* SEMANTIC ANALYSIS (CHAPTER 7RM) -- BINARY OPERATORS */ /* SEMANTIC ANALYSIS (CHAPTER 7RM) -- BINARY OPERATORS */
#include "botch_free.h" /* UF */ #include "nofloat.h"
#include "botch_free.h"
#include "idf.h" #include "idf.h"
#include "arith.h" #include "arith.h"
#include "type.h" #include "type.h"

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* SEMANTIC ANALYSIS (CHAPTER 7RM) -- MONADIC OPERATORS */ /* SEMANTIC ANALYSIS (CHAPTER 7RM) -- MONADIC OPERATORS */
#include "nofloat.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "botch_free.h" #include "botch_free.h"
#include "Lpars.h" #include "Lpars.h"

View file

@ -1,12 +1,11 @@
/* $Header$ */ /* $Header$ */
/* C O D E - G E N E R A T I N G R O U T I N E S */ /* C O D E - G E N E R A T I N G R O U T I N E S */
#include "nofloat.h"
#include <em.h> #include <em.h>
#include "dataflow.h" #include "dataflow.h"
#include "use_tmp.h" #include "use_tmp.h"
#include "botch_free.h" #include "botch_free.h"
#include "arith.h" #include "arith.h"
#include "type.h" #include "type.h"
#include "idf.h" #include "idf.h"
@ -67,7 +66,7 @@ code_string(val, len, dlb)
int len; int len;
label dlb; label dlb;
{ {
struct string_cst *sc = new_string_cst(); register struct string_cst *sc = new_string_cst();
C_ina_dlb(dlb); C_ina_dlb(dlb);
sc->next = str_list; sc->next = str_list;
@ -107,14 +106,14 @@ prepend_scopes(dst_file)
and generates those exa's, exp's, ina's and inp's and generates those exa's, exp's, ina's and inp's
that superior hindsight has provided, on the file dst_file. that superior hindsight has provided, on the file dst_file.
*/ */
struct stack_entry *se = local_level->sl_entry; register struct stack_entry *se = local_level->sl_entry;
if (C_open(dst_file) == 0) if (C_open(dst_file) == 0)
fatal("cannot create %s", dst_file ? dst_file : "stdout"); fatal("cannot create %s", dst_file ? dst_file : "stdout");
famous_first_words(); famous_first_words();
while (se != 0) { while (se != 0) {
struct idf *idf = se->se_idf; register struct idf *idf = se->se_idf;
struct def *def = idf->id_def; register struct def *def = idf->id_def;
if (def && if (def &&
( def->df_initialized || ( def->df_initialized ||
@ -131,7 +130,7 @@ prepend_scopes(dst_file)
code_scope(text, def) code_scope(text, def)
char *text; char *text;
struct def *def; register struct def *def;
{ {
/* generates code for one name, text, of the storage class /* generates code for one name, text, of the storage class
as given by def, if meaningful. as given by def, if meaningful.
@ -165,7 +164,7 @@ static label file_name_label;
begin_proc(name, def) /* to be called when entering a procedure */ begin_proc(name, def) /* to be called when entering a procedure */
char *name; char *name;
struct def *def; register struct def *def;
{ {
/* begin_proc() is called at the entrance of a new function /* begin_proc() is called at the entrance of a new function
and performs the necessary code generation: and performs the necessary code generation:
@ -291,7 +290,7 @@ do_return_expr(expr)
} }
code_declaration(idf, expr, lvl, sc) code_declaration(idf, expr, lvl, sc)
struct idf *idf; /* idf to be declared */ register struct idf *idf; /* idf to be declared */
struct expr *expr; /* initialisation; NULL if absent */ struct expr *expr; /* initialisation; NULL if absent */
int lvl; /* declaration level */ int lvl; /* declaration level */
int sc; /* storage class, as in the declaration */ int sc; /* storage class, as in the declaration */
@ -319,7 +318,7 @@ code_declaration(idf, expr, lvl, sc)
extern int a = 5; extern int a = 5;
*/ */
char *text = idf->id_text; char *text = idf->id_text;
struct def *def = idf->id_def; register struct def *def = idf->id_def;
arith size = def->df_type->tp_size; arith size = def->df_type->tp_size;
int def_sc = def->df_sc; int def_sc = def->df_sc;
@ -437,7 +436,7 @@ loc_init(expr, id)
} }
bss(idf) bss(idf)
struct idf *idf; register struct idf *idf;
{ {
/* bss() allocates bss space for the global idf. /* bss() allocates bss space for the global idf.
*/ */
@ -456,21 +455,21 @@ bss(idf)
C_bss_cst(align(size, word_align), (arith)0, 1); C_bss_cst(align(size, word_align), (arith)0, 1);
} }
formal_cvt(def) formal_cvt(df)
struct def *def; register struct def *df;
{ {
/* formal_cvt() converts a formal parameter of type char or /* formal_cvt() converts a formal parameter of type char or
short from int to that type. short from int to that type.
*/ */
register struct type* tp = def->df_type; register struct type *tp = df->df_type;
if (tp->tp_size != int_size) if (tp->tp_size != int_size)
if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) { if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) {
C_lol(def->df_address); C_lol(df->df_address);
conversion(int_type, def->df_type); conversion(int_type, df->df_type);
C_lal(def->df_address); C_lal(df->df_address);
C_sti(tp->tp_size); C_sti(tp->tp_size);
def->df_register = REG_NONE; df->df_register = REG_NONE;
} }
} }

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* C O N V E R S I O N - C O D E G E N E R A T O R */ /* C O N V E R S I O N - C O D E G E N E R A T O R */
#include "nofloat.h"
#include <em.h> #include <em.h>
#include "arith.h" #include "arith.h"
#include "type.h" #include "type.h"
@ -29,30 +30,23 @@ conversion(from_type, to_type)
arith from_size; arith from_size;
arith to_size; arith to_size;
if (from_type == to_type) { /* a little optimisation */ if (from_type == to_type) /* a little optimisation */
return; return;
}
from_size = from_type->tp_size; from_size = from_type->tp_size;
to_size = to_type->tp_size; to_size = to_type->tp_size;
switch (fundamental(from_type)) { switch (fundamental(from_type)) {
case T_SIGNED: case T_SIGNED:
switch (fundamental(to_type)) { switch (fundamental(to_type)) {
case T_SIGNED: case T_SIGNED:
C_loc(from_size); C_loc(from_size);
C_loc(to_size < word_size ? word_size : to_size); C_loc(to_size < word_size ? word_size : to_size);
C_cii(); C_cii();
break; break;
case T_UNSIGNED: case T_UNSIGNED:
C_loc(from_size < word_size ? word_size : from_size); C_loc(from_size < word_size ? word_size : from_size);
C_loc(to_size < word_size ? word_size : to_size); C_loc(to_size < word_size ? word_size : to_size);
C_ciu(); C_ciu();
break; break;
#ifndef NOFLOAT #ifndef NOFLOAT
case T_FLOATING: case T_FLOATING:
C_loc(from_size < word_size ? word_size : from_size); C_loc(from_size < word_size ? word_size : from_size);
@ -62,21 +56,16 @@ conversion(from_type, to_type)
#endif NOFLOAT #endif NOFLOAT
} }
break; break;
case T_UNSIGNED: case T_UNSIGNED:
C_loc(from_size < word_size ? word_size : from_size); C_loc(from_size < word_size ? word_size : from_size);
C_loc(to_size < word_size ? word_size : to_size); C_loc(to_size < word_size ? word_size : to_size);
switch (fundamental(to_type)) { switch (fundamental(to_type)) {
case T_SIGNED: case T_SIGNED:
C_cui(); C_cui();
break; break;
case T_UNSIGNED: case T_UNSIGNED:
C_cuu(); C_cuu();
break; break;
#ifndef NOFLOAT #ifndef NOFLOAT
case T_FLOATING: case T_FLOATING:
C_cuf(); C_cuf();
@ -84,22 +73,17 @@ conversion(from_type, to_type)
#endif NOFLOAT #endif NOFLOAT
} }
break; break;
#ifndef NOFLOAT #ifndef NOFLOAT
case T_FLOATING: case T_FLOATING:
C_loc(from_size < word_size ? word_size : from_size); C_loc(from_size < word_size ? word_size : from_size);
C_loc(to_size < word_size ? word_size : to_size); C_loc(to_size < word_size ? word_size : to_size);
switch (fundamental(to_type)) { switch (fundamental(to_type)) {
case T_SIGNED: case T_SIGNED:
C_cfi(); C_cfi();
break; break;
case T_UNSIGNED: case T_UNSIGNED:
C_cfu(); C_cfu();
break; break;
case T_FLOATING: case T_FLOATING:
C_cff(); C_cff();
break; break;
@ -116,10 +100,9 @@ conversion(from_type, to_type)
*/ */
int int
fundamental(tp) fundamental(tp)
struct type *tp; register struct type *tp;
{ {
switch (tp->tp_fund) { switch (tp->tp_fund) {
case CHAR: case CHAR:
case SHORT: case SHORT:
case INT: case INT:
@ -127,13 +110,11 @@ fundamental(tp)
case LONG: case LONG:
case ENUM: case ENUM:
return tp->tp_unsigned ? T_UNSIGNED : T_SIGNED; return tp->tp_unsigned ? T_UNSIGNED : T_SIGNED;
#ifndef NOFLOAT #ifndef NOFLOAT
case FLOAT: case FLOAT:
case DOUBLE: case DOUBLE:
return T_FLOATING; return T_FLOATING;
#endif NOFLOAT #endif NOFLOAT
case POINTER: /* pointer : signed / unsigned ??? */ case POINTER: /* pointer : signed / unsigned ??? */
return T_SIGNED; return T_SIGNED;
} }

View file

@ -1,8 +1,7 @@
/* $Header$ */ /* $Header$ */
/* C O N S T A N T E X P R E S S I O N H A N D L I N G */ /* C O N S T A N T E X P R E S S I O N H A N D L I N G */
#include "target_sizes.h" /* UF */ #include "target_sizes.h"
#include "idf.h" #include "idf.h"
#include "arith.h" #include "arith.h"
#include "type.h" #include "type.h"
@ -19,14 +18,14 @@ arith max_int; /* maximum integer on target machine */
arith max_unsigned; /* maximum unsigned on target machine */ arith max_unsigned; /* maximum unsigned on target machine */
cstbin(expp, oper, expr) cstbin(expp, oper, expr)
struct expr **expp, *expr; register struct expr **expp, *expr;
{ {
/* The operation oper is performed on the constant /* The operation oper is performed on the constant
expressions *expp(ld) and expr(ct), and the result restored in expressions *expp(ld) and expr(ct), and the result restored in
*expp. *expp.
*/ */
arith o1 = (*expp)->VL_VALUE; register arith o1 = (*expp)->VL_VALUE;
arith o2 = expr->VL_VALUE; register arith o2 = expr->VL_VALUE;
int uns = (*expp)->ex_type->tp_unsigned; int uns = (*expp)->ex_type->tp_unsigned;
ASSERT(is_ld_cst(*expp) && is_cp_cst(expr)); ASSERT(is_ld_cst(*expp) && is_cp_cst(expr));
@ -184,7 +183,7 @@ cstbin(expp, oper, expr)
} }
cut_size(expr) cut_size(expr)
struct expr *expr; register struct expr *expr;
{ {
/* The constant value of the expression expr is made to /* The constant value of the expression expr is made to
conform to the size of the type of the expression. conform to the size of the type of the expression.
@ -214,8 +213,8 @@ cut_size(expr)
init_cst() init_cst()
{ {
int i = 0; register int i = 0;
arith bt = (arith)0; register arith bt = (arith)0;
while (!(bt < 0)) { while (!(bt < 0)) {
bt = (bt << 8) + 0377, i++; bt = (bt << 8) + 0377, i++;
@ -227,8 +226,6 @@ init_cst()
mach_long_sign = 1 << (mach_long_size * 8 - 1); mach_long_sign = 1 << (mach_long_size * 8 - 1);
if (long_size < mach_long_size) if (long_size < mach_long_size)
fatal("sizeof (long) insufficient on this machine"); fatal("sizeof (long) insufficient on this machine");
max_int = full_mask[int_size] & ~(1 << (int_size * 8 - 1)); max_int = full_mask[int_size] & ~(1 << (int_size * 8 - 1));
max_unsigned = full_mask[int_size]; max_unsigned = full_mask[int_size];
} }

View file

@ -33,7 +33,7 @@ declare_type(tp, dc)
} }
add_decl_unary(dc, fund, count, fm) add_decl_unary(dc, fund, count, fm)
struct declarator *dc; register struct declarator *dc;
arith count; arith count;
struct formal *fm; struct formal *fm;
{ {
@ -77,7 +77,7 @@ remove_declarator(dc)
} }
reject_params(dc) reject_params(dc)
struct declarator *dc; register struct declarator *dc;
{ {
/* The declarator is checked to have no parameters, if it /* The declarator is checked to have no parameters, if it
is a function. is a function.
@ -90,7 +90,7 @@ reject_params(dc)
} }
array_subscript(expr) array_subscript(expr)
struct expr *expr; register struct expr *expr;
{ {
arith size = expr->VL_VALUE; arith size = expr->VL_VALUE;

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* D E C L A R A T I O N S P E C I F I E R C H E C K I N G */ /* D E C L A R A T I O N S P E C I F I E R C H E C K I N G */
#include "nofloat.h"
#include "Lpars.h" #include "Lpars.h"
#include "decspecs.h" #include "decspecs.h"
#include "arith.h" #include "arith.h"
@ -15,12 +16,12 @@ extern char *symbol2str();
struct decspecs null_decspecs; struct decspecs null_decspecs;
do_decspecs(ds) do_decspecs(ds)
struct decspecs *ds; register struct decspecs *ds;
{ {
/* The provisional decspecs ds as obtained from the program /* The provisional decspecs ds as obtained from the program
is turned into a legal consistent decspecs. is turned into a legal consistent decspecs.
*/ */
struct type *tp = ds->ds_type; register struct type *tp = ds->ds_type;
if (level == L_FORMAL1) if (level == L_FORMAL1)
crash("do_decspecs"); crash("do_decspecs");

View file

@ -4,6 +4,7 @@
#include "debug.h" #include "debug.h"
#ifdef DEBUG #ifdef DEBUG
#include "nofloat.h"
#include "nopp.h" #include "nopp.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "arith.h" #include "arith.h"
@ -41,7 +42,7 @@ static int dumplevel;
static static
newline() { newline() {
int dl = dumplevel; register int dl = dumplevel;
print("\n"); print("\n");
while (dl >= 2) { while (dl >= 2) {
@ -66,7 +67,7 @@ dumpidftab(msg, opt)
print(">>> DUMPIDF, %s (start)", msg); print(">>> DUMPIDF, %s (start)", msg);
dumpstack(); dumpstack();
for (i = 0; i < HASHSIZE; i++) { for (i = 0; i < HASHSIZE; i++) {
struct idf *notch = idf_hashtable[i]; register struct idf *notch = idf_hashtable[i];
while (notch) { while (notch) {
dumpidf(notch, opt); dumpidf(notch, opt);
@ -77,13 +78,14 @@ dumpidftab(msg, opt)
print(">>> DUMPIDF, %s (end)\n", msg); print(">>> DUMPIDF, %s (end)\n", msg);
} }
dumpstack() { dumpstack()
{
/* Dumps the identifier stack, starting at the top. /* Dumps the identifier stack, starting at the top.
*/ */
struct stack_level *stl = local_level; register struct stack_level *stl = local_level;
while (stl) { while (stl) {
struct stack_entry *se = stl->sl_entry; register struct stack_entry *se = stl->sl_entry;
newline(); newline();
print("%3d: ", stl->sl_level); print("%3d: ", stl->sl_level);
@ -97,7 +99,7 @@ dumpstack() {
} }
dumpidf(idf, opt) dumpidf(idf, opt)
struct idf *idf; register struct idf *idf;
{ {
/* All information about the identifier idf is divulged in a /* All information about the identifier idf is divulged in a
hopefully readable format. hopefully readable format.
@ -174,7 +176,7 @@ dumpdefs(def, opt)
} }
dumptags(tag) dumptags(tag)
struct tag *tag; register struct tag *tag;
{ {
dumplevel++; dumplevel++;
while (tag) { while (tag) {
@ -202,7 +204,7 @@ dumptags(tag)
} }
dumpsdefs(sdef, sdk) dumpsdefs(sdef, sdk)
struct sdef *sdef; register struct sdef *sdef;
enum sdef_kind sdk; enum sdef_kind sdk;
{ {
/* Since sdef's are members of two chains, there are actually /* Since sdef's are members of two chains, there are actually
@ -235,7 +237,7 @@ dumpsdefs(sdef, sdk)
char * char *
type2str(tp) type2str(tp)
struct type *tp; register struct type *tp;
{ {
/* Yields a pointer to a one-line description of the type tp. /* Yields a pointer to a one-line description of the type tp.
*/ */
@ -312,7 +314,7 @@ print_expr(msg, expr)
} }
p1_expr(lvl, expr) p1_expr(lvl, expr)
struct expr *expr; register struct expr *expr;
{ {
extern char *type2str(), *symbol2str(); extern char *type2str(), *symbol2str();
@ -389,7 +391,9 @@ p1_expr(lvl, expr)
} }
} }
p1_indent(lvl) { p1_indent(lvl)
register int lvl;
{
while (lvl--) while (lvl--)
print(" "); print(" ");
} }

View file

@ -12,11 +12,10 @@
compare() compare()
*/ */
#include "nofloat.h"
#include <em.h> #include <em.h>
#include "debug.h" #include "debug.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "dataflow.h" #include "dataflow.h"
#include "arith.h" #include "arith.h"
#include "type.h" #include "type.h"
@ -71,13 +70,13 @@ arith tmp_pointer_var();
*/ */
EVAL(expr, val, code, true_label, false_label) EVAL(expr, val, code, true_label, false_label)
struct expr *expr; /* the expression tree itself */ register struct expr *expr; /* the expression tree itself */
int val; /* either RVAL or LVAL */ int val; /* either RVAL or LVAL */
int code; /* generate explicit code or not */ int code; /* generate explicit code or not */
label true_label; label true_label;
label false_label; /* labels to jump to in logical expr's */ label false_label; /* labels to jump to in logical expr's */
{ {
register gencode = (code == TRUE); register int gencode = (code == TRUE);
switch (expr->ex_class) { switch (expr->ex_class) {
case Value: /* just a simple value */ case Value: /* just a simple value */
@ -87,7 +86,9 @@ EVAL(expr, val, code, true_label, false_label)
case String: /* a string constant */ case String: /* a string constant */
expr_warning(expr, "(DEBUG) value-class 'String' seen"); expr_warning(expr, "(DEBUG) value-class 'String' seen");
if (gencode) { if (gencode) {
string2pointer(&expr); struct expr *ex = expr;
string2pointer(&ex);
expr = ex;
C_lae_dlb(expr->VL_LBL, expr->VL_VALUE); C_lae_dlb(expr->VL_LBL, expr->VL_VALUE);
} }
break; break;
@ -105,7 +106,7 @@ EVAL(expr, val, code, true_label, false_label)
#endif NOFLOAT #endif NOFLOAT
case Oper: /* compound expression */ case Oper: /* compound expression */
{ {
register int oper = expr->OP_OPER; int oper = expr->OP_OPER;
register struct expr *leftop = expr->OP_LEFT; register struct expr *leftop = expr->OP_LEFT;
register struct expr *rightop = expr->OP_RIGHT; register struct expr *rightop = expr->OP_RIGHT;
register struct type *tp = expr->OP_TYPE; register struct type *tp = expr->OP_TYPE;
@ -250,12 +251,11 @@ EVAL(expr, val, code, true_label, false_label)
EVAL(leftop, RVAL, code, NO_LABEL, NO_LABEL); EVAL(leftop, RVAL, code, NO_LABEL, NO_LABEL);
EVAL(rightop, RVAL, code, NO_LABEL, NO_LABEL); EVAL(rightop, RVAL, code, NO_LABEL, NO_LABEL);
ASSERT(tp->tp_fund==INT || tp->tp_fund==LONG); ASSERT(tp->tp_fund==INT || tp->tp_fund==LONG);
if (gencode) { if (gencode)
if (tp->tp_unsigned) if (tp->tp_unsigned)
C_rmu(tp->tp_size); C_rmu(tp->tp_size);
else else
C_rmi(tp->tp_size); C_rmi(tp->tp_size);
}
break; break;
case LEFT: case LEFT:
EVAL(leftop, RVAL, code, NO_LABEL, NO_LABEL); EVAL(leftop, RVAL, code, NO_LABEL, NO_LABEL);
@ -429,22 +429,21 @@ EVAL(expr, val, code, true_label, false_label)
} }
case '(': case '(':
{ {
register struct expr *expr; register struct expr *ex;
arith ParSize = (arith)0; arith ParSize = (arith)0;
if (expr = rightop) { if ((ex = rightop) != NILEXPR) {
/* function call with parameters*/ /* function call with parameters*/
while ( expr->ex_class == Oper && while ( ex->ex_class == Oper &&
expr->OP_OPER == PARCOMMA ex->OP_OPER == PARCOMMA
) { ) {
EVAL(expr->OP_RIGHT, RVAL, TRUE, EVAL(ex->OP_RIGHT, RVAL, TRUE,
NO_LABEL, NO_LABEL); NO_LABEL, NO_LABEL);
ParSize += ParSize += ATW(ex->ex_type->tp_size);
ATW(expr->ex_type->tp_size); ex = ex->OP_LEFT;
expr = expr->OP_LEFT;
} }
EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL); EVAL(ex, RVAL, TRUE, NO_LABEL, NO_LABEL);
ParSize += ATW(expr->ex_type->tp_size); ParSize += ATW(ex->ex_type->tp_size);
} }
if ( leftop->ex_class == Value if ( leftop->ex_class == Value
&& leftop->VL_CLASS == Name && leftop->VL_CLASS == Name
@ -469,14 +468,14 @@ EVAL(expr, val, code, true_label, false_label)
/* remove parameters from stack */ /* remove parameters from stack */
if (ParSize > (arith)0) if (ParSize > (arith)0)
C_asp(ParSize); C_asp(ParSize);
if (!gencode) if (gencode) {
break; if (is_struct_or_union(tp->tp_fund)) {
if (is_struct_or_union(tp->tp_fund)) { C_lfr(pointer_size);
C_lfr(pointer_size); load_block(tp->tp_size, tp->tp_align);
load_block(tp->tp_size, tp->tp_align); }
else
C_lfr(ATW(tp->tp_size));
} }
else
C_lfr(ATW(tp->tp_size));
break; break;
} }
case '.': case '.':
@ -507,22 +506,32 @@ EVAL(expr, val, code, true_label, false_label)
{ {
arith old_offset, tmp; arith old_offset, tmp;
arith esize = tp->tp_size; arith esize = tp->tp_size;
int compl; /* Complexity of left operand */
#ifndef NOBITFIELD #ifndef NOBITFIELD
if (leftop->ex_type->tp_fund == FIELD) { if (leftop->ex_type->tp_fund == FIELD) {
eval_field(expr, code); eval_field(expr, code);
break; break;
} }
#endif NOBITFIELD #endif NOBITFIELD
if (leftop->ex_class != Value) { if (leftop->ex_class == Value) {
compl = 0; /* Value */
load_val(leftop, RVAL);
}
else
if (leftop->ex_depth == 1 && leftop->OP_OPER == ARROW) {
compl = 1; /* Value->sel */
ASSERT(leftop->OP_LEFT->ex_class == Value);
EVAL(leftop, RVAL, TRUE, NO_LABEL, NO_LABEL);
}
else {
compl = 2; /* otherwise */
tmp = tmp_pointer_var(&old_offset); tmp = tmp_pointer_var(&old_offset);
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL); EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
C_dup(pointer_size); C_dup(pointer_size);
C_lal(tmp); C_lal(tmp);
C_sti(pointer_size); C_sti(pointer_size);
C_loi(tp->tp_size); C_loi(esize);
} }
else
load_val(leftop, RVAL);
/* We made the choice to put this stuff here /* We made the choice to put this stuff here
and not to put the conversion in the expression and not to put the conversion in the expression
@ -542,17 +551,23 @@ EVAL(expr, val, code, true_label, false_label)
C_dup(esize); C_dup(esize);
if (tp->tp_size < word_size) if (tp->tp_size < word_size)
conversion(word_type, tp); conversion(word_type, tp);
if (leftop->ex_class != Value) { if (compl == 0) {
store_val(
&(leftop->ex_object.ex_value),
leftop->ex_type
);
}
else
if (compl == 1) {
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
C_sti(tp->tp_size);
}
else {
C_lal(tmp); /* always init'd */ C_lal(tmp); /* always init'd */
C_loi(pointer_size); C_loi(pointer_size);
C_sti(tp->tp_size); C_sti(tp->tp_size);
free_tmp_var(old_offset); free_tmp_var(old_offset);
} }
else
store_val(
&(leftop->ex_object.ex_value),
leftop->ex_type
);
break; break;
} }
case '?': /* must be followed by ':' */ case '?': /* must be followed by ':' */
@ -685,7 +700,6 @@ EVAL(expr, val, code, true_label, false_label)
expr->ex_type->tp_align); expr->ex_type->tp_align);
break; break;
} }
case Type:
default: default:
crash("(EVAL) bad expression class"); crash("(EVAL) bad expression class");
} }
@ -722,13 +736,13 @@ compare(relop, lbl)
/* assop() generates the opcode of an assignment operators op= */ /* assop() generates the opcode of an assignment operators op= */
assop(type, oper) assop(type, oper)
struct type *type; register struct type *type;
int oper; int oper;
{ {
register arith size = type->tp_size; register arith size;
register uns = type->tp_unsigned; register uns = type->tp_unsigned;
if (size < word_size) if ((size = type->tp_size) < word_size)
size = word_size; size = word_size;
switch (type->tp_fund) { switch (type->tp_fund) {
case CHAR: case CHAR:
@ -837,7 +851,7 @@ arith
tmp_pointer_var(oldoffset) tmp_pointer_var(oldoffset)
arith *oldoffset; /* previous allocated address */ arith *oldoffset; /* previous allocated address */
{ {
struct stack_level *stl = local_level; register struct stack_level *stl = local_level;
*oldoffset = stl->sl_local_offset; *oldoffset = stl->sl_local_offset;
stl->sl_local_offset = stl->sl_local_offset =
@ -940,16 +954,16 @@ store_val(vl, tp)
- local variable - local variable
*/ */
load_val(expr, val) load_val(expr, val)
struct expr *expr; /* expression containing the value */ register struct expr *expr; /* expression containing the value */
int val; /* generate either LVAL or RVAL */ int val; /* generate either LVAL or RVAL */
{ {
register struct type *tp = expr->ex_type; register struct type *tp = expr->ex_type;
register int rvalue = (val == RVAL && expr->ex_lvalue != 0); int rvalue = (val == RVAL && expr->ex_lvalue != 0);
register arith size = tp->tp_size; arith size = tp->tp_size;
register int tpalign = tp->tp_align; int tpalign = tp->tp_align;
register int al_on_word; int al_on_word;
register int inword, indword; register int inword, indword;
register arith val = expr->VL_VALUE; arith val = expr->VL_VALUE;
if (expr->VL_CLASS == Const) { if (expr->VL_CLASS == Const) {
if (rvalue) { /* absolute addressing */ if (rvalue) { /* absolute addressing */

View file

@ -1,7 +1,8 @@
/* $Header$ */ /* $Header$ */
/* EXPRESSION TREE HANDLING */ /* EXPRESSION TREE HANDLING */
#include "botch_free.h" /* UF */ #include "nofloat.h"
#include "botch_free.h"
#include "alloc.h" #include "alloc.h"
#include "idf.h" #include "idf.h"
#include "arith.h" #include "arith.h"
@ -92,7 +93,7 @@ rank_of(oper)
int int
rank_of_expression(expr) rank_of_expression(expr)
struct expr *expr; register struct expr *expr;
{ {
/* Returns the rank of the top node in the expression. /* Returns the rank of the top node in the expression.
*/ */
@ -115,7 +116,7 @@ check_conditional(expr, oper, pos_descr)
} }
dot2expr(expp) dot2expr(expp)
struct expr **expp; register struct expr **expp;
{ {
/* The token in dot is converted into an expression, a /* The token in dot is converted into an expression, a
pointer to which is stored in *expp. pointer to which is stored in *expp.
@ -146,7 +147,7 @@ dot2expr(expp)
} }
idf2expr(expr) idf2expr(expr)
struct expr *expr; register struct expr *expr;
{ {
/* Dot contains an identifier which is turned into an /* Dot contains an identifier which is turned into an
expression. expression.
@ -205,7 +206,7 @@ idf2expr(expr)
} }
string2expr(expr) string2expr(expr)
struct expr *expr; register struct expr *expr;
{ {
/* Dot contains a string which is turned into an expression. /* Dot contains a string which is turned into an expression.
*/ */
@ -228,7 +229,7 @@ int2expr(expr)
#ifndef NOFLOAT #ifndef NOFLOAT
float2expr(expr) float2expr(expr)
struct expr *expr; register struct expr *expr;
{ {
/* Dot contains a floating point constant which is turned /* Dot contains a floating point constant which is turned
into an expression. into an expression.
@ -243,11 +244,12 @@ float2expr(expr)
struct expr* struct expr*
intexpr(ivalue, fund) intexpr(ivalue, fund)
arith ivalue; arith ivalue;
int fund;
{ {
/* The value ivalue is turned into an integer expression of /* The value ivalue is turned into an integer expression of
the size indicated by fund. the size indicated by fund.
*/ */
struct expr *expr = new_expr(); register struct expr *expr = new_expr();
clear((char *)expr, sizeof(struct expr)); clear((char *)expr, sizeof(struct expr));
expr->ex_file = dot.tk_file; expr->ex_file = dot.tk_file;
@ -258,8 +260,9 @@ intexpr(ivalue, fund)
} }
fill_int_expr(expr, ivalue, fund) fill_int_expr(expr, ivalue, fund)
struct expr *expr; register struct expr *expr;
arith ivalue; arith ivalue;
int fund;
{ {
/* Details derived from ivalue and fund are put into the /* Details derived from ivalue and fund are put into the
constant integer expression expr. constant integer expression expr.
@ -308,12 +311,12 @@ new_oper(tp, e1, oper, e2)
During the construction of the right recursive initialisation During the construction of the right recursive initialisation
tree it is possible for e2 to be NILEXPR. tree it is possible for e2 to be NILEXPR.
*/ */
struct expr *expr = new_expr(); register struct expr *expr = new_expr();
struct oper *op; register struct oper *op;
clear((char *)expr, sizeof(struct expr)); clear((char *)expr, sizeof(struct expr));
if (e2) { if (e2) {
struct expr *e = e2; register struct expr *e = e2;
while (e->ex_class == Oper && e->OP_LEFT) while (e->ex_class == Oper && e->OP_LEFT)
e = e->OP_LEFT; e = e->OP_LEFT;
@ -322,7 +325,7 @@ new_oper(tp, e1, oper, e2)
} }
else else
if (e1) { if (e1) {
struct expr *e = e1; register struct expr *e = e1;
while (e->ex_class == Oper && e->OP_RIGHT) while (e->ex_class == Oper && e->OP_RIGHT)
e = e->OP_RIGHT; e = e->OP_RIGHT;
@ -387,7 +390,7 @@ chk_cst_expr(expp)
register struct expr *expr = *expp; register struct expr *expr = *expp;
register int fund = expr->ex_type->tp_fund; register int fund = expr->ex_type->tp_fund;
register int flags = expr->ex_flags; register int flags = expr->ex_flags;
register int err = 0; int err = 0;
#ifdef DEBUG #ifdef DEBUG
print_expr("constant_expression", expr); print_expr("constant_expression", expr);
@ -417,7 +420,7 @@ chk_cst_expr(expp)
} }
init_expression(eppp, expr) init_expression(eppp, expr)
struct expr ***eppp, *expr; register struct expr ***eppp, *expr;
{ {
/* The expression expr is added to the tree designated /* The expression expr is added to the tree designated
indirectly by **eppp. indirectly by **eppp.
@ -468,7 +471,7 @@ is_fp_cst(expr)
#endif NOFLOAT #endif NOFLOAT
free_expression(expr) free_expression(expr)
struct expr *expr; register struct expr *expr;
{ {
/* The expression expr is freed recursively. /* The expression expr is freed recursively.
*/ */

View file

@ -5,6 +5,8 @@
a union of various goodies, we define them first; so be patient. a union of various goodies, we define them first; so be patient.
*/ */
#include "nofloat.h"
/* classes of value */ /* classes of value */
#define Const 1 #define Const 1
#define Name 2 #define Name 2

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* IDENTIFIER FIDDLING & SYMBOL TABLE HANDLING */ /* IDENTIFIER FIDDLING & SYMBOL TABLE HANDLING */
#include "nofloat.h"
#include "debug.h" #include "debug.h"
#include "idfsize.h" #include "idfsize.h"
#include "botch_free.h" #include "botch_free.h"
@ -86,11 +87,11 @@ idf_hashed(tg, size, hc)
hash_stat() hash_stat()
{ {
if (options['h']) { if (options['h']) {
int i; register int i;
print("Hash table tally:\n"); print("Hash table tally:\n");
for (i = 0; i < HASHSIZE; i++) { for (i = 0; i < HASHSIZE; i++) {
struct idf *notch = idf_hashtable[i]; register struct idf *notch = idf_hashtable[i];
int cnt = 0; int cnt = 0;
while (notch) { while (notch) {
@ -374,8 +375,8 @@ actual_declaration(sc, tp)
} }
global_redecl(idf, new_sc, tp) global_redecl(idf, new_sc, tp)
struct idf *idf; register struct idf *idf;
struct type *tp; register struct type *tp;
{ {
/* A global identifier may be declared several times, /* A global identifier may be declared several times,
provided the declarations do not conflict; they might provided the declarations do not conflict; they might
@ -386,7 +387,7 @@ global_redecl(idf, new_sc, tp)
register struct def *def = idf->id_def; register struct def *def = idf->id_def;
if (tp != def->df_type) { if (tp != def->df_type) {
struct type *otp = def->df_type; register struct type *otp = def->df_type;
if ( tp->tp_fund != ARRAY || otp->tp_fund != ARRAY || if ( tp->tp_fund != ARRAY || otp->tp_fund != ARRAY ||
tp->tp_up != otp->tp_up tp->tp_up != otp->tp_up
@ -425,10 +426,8 @@ global_redecl(idf, new_sc, tp)
return; /* no new information */ return; /* no new information */
switch (def->df_sc) { /* the old storage class */ switch (def->df_sc) { /* the old storage class */
case EXTERN: case EXTERN:
switch (new_sc) { /* the new storage class */ switch (new_sc) { /* the new storage class */
case EXTERN: case EXTERN:
case GLOBAL: case GLOBAL:
break; break;
@ -449,10 +448,8 @@ global_redecl(idf, new_sc, tp)
break; break;
} }
break; break;
case GLOBAL: case GLOBAL:
switch (new_sc) { /* the new storage class */ switch (new_sc) { /* the new storage class */
case EXTERN: case EXTERN:
def->df_sc = EXTERN; def->df_sc = EXTERN;
break; break;
@ -475,10 +472,8 @@ global_redecl(idf, new_sc, tp)
break; break;
} }
break; break;
case STATIC: case STATIC:
switch (new_sc) { /* the new storage class */ switch (new_sc) { /* the new storage class */
case EXTERN: case EXTERN:
if (def->df_initialized) { if (def->df_initialized) {
error("cannot redeclare %s to extern", error("cannot redeclare %s to extern",
@ -501,10 +496,8 @@ global_redecl(idf, new_sc, tp)
break; break;
} }
break; break;
case IMPLICIT: case IMPLICIT:
switch (new_sc) { /* the new storage class */ switch (new_sc) { /* the new storage class */
case EXTERN: case EXTERN:
case GLOBAL: case GLOBAL:
def->df_sc = new_sc; def->df_sc = new_sc;
@ -520,7 +513,6 @@ global_redecl(idf, new_sc, tp)
break; break;
} }
break; break;
case ENUM: case ENUM:
case TYPEDEF: case TYPEDEF:
error("illegal redeclaration of %s", idf->id_text); error("illegal redeclaration of %s", idf->id_text);
@ -550,7 +542,7 @@ good_formal(def, idf)
} }
declare_params(dc) declare_params(dc)
struct declarator *dc; register struct declarator *dc;
{ {
/* Declares the formal parameters if they exist. /* Declares the formal parameters if they exist.
*/ */
@ -607,7 +599,7 @@ declare_formals(fp)
An address is assigned to each formal parameter. An address is assigned to each formal parameter.
The total size of the formals is returned in *fp; The total size of the formals is returned in *fp;
*/ */
struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry; register struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
arith f_offset = (arith)0; arith f_offset = (arith)0;
#ifdef DEBUG #ifdef DEBUG
@ -615,8 +607,7 @@ declare_formals(fp)
dumpidftab("start declare_formals", 0); dumpidftab("start declare_formals", 0);
#endif DEBUG #endif DEBUG
while (se) { while (se) {
struct idf *idf = se->se_idf; register struct def *def = se->se_idf->id_def;
struct def *def = idf->id_def;
def->df_address = f_offset; def->df_address = f_offset;
@ -624,8 +615,7 @@ declare_formals(fp)
word boundaries, i.e. take care that the following word boundaries, i.e. take care that the following
parameter starts on a new word boundary. parameter starts on a new word boundary.
*/ */
f_offset = align(f_offset + def->df_type->tp_size, f_offset = align(f_offset + def->df_type->tp_size, word_align);
word_align);
/* the following is absurd: any char or short formal /* the following is absurd: any char or short formal
must be converted from integer to that type must be converted from integer to that type
@ -673,7 +663,7 @@ update_ahead(idf)
} }
free_formals(fm) free_formals(fm)
struct formal *fm; register struct formal *fm;
{ {
while (fm) { while (fm) {
register struct formal *tmp = fm->next; register struct formal *tmp = fm->next;
@ -684,11 +674,12 @@ free_formals(fm)
char hmask[IDFSIZE]; char hmask[IDFSIZE];
init_hmask() { init_hmask()
{
/* A simple congruence random number generator, as /* A simple congruence random number generator, as
described in Knuth, vol 2. described in Knuth, vol 2.
*/ */
int h, rnd = HASH_X; register int h, rnd = HASH_X;
for (h = 0; h < IDFSIZE; h++) { for (h = 0; h < IDFSIZE; h++) {
hmask[h] = rnd; hmask[h] = rnd;

View file

@ -1,11 +1,10 @@
/* $Header$ */ /* $Header$ */
/* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ /* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */
#include "nofloat.h"
#include <em.h> #include <em.h>
#include "debug.h" #include "debug.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "arith.h" #include "arith.h"
#include "align.h" #include "align.h"
#include "label.h" #include "label.h"
@ -54,7 +53,7 @@ do_ival(tpp, ex)
struct expr * struct expr *
IVAL(tpp, ex) IVAL(tpp, ex)
struct type **tpp; /* type of global variable */ struct type **tpp; /* type of global variable */
struct expr *ex; /* initialiser expression */ register struct expr *ex; /* initialiser expression */
{ {
register struct type *tp = *tpp; register struct type *tp = *tpp;
@ -116,7 +115,7 @@ IVAL(tpp, ex)
*/ */
struct expr * struct expr *
do_array(ex, tpp) do_array(ex, tpp)
struct expr *ex; register struct expr *ex;
struct type **tpp; struct type **tpp;
{ {
register struct type *tp = *tpp; register struct type *tp = *tpp;
@ -215,10 +214,10 @@ do_array(ex, tpp)
*/ */
struct expr * struct expr *
do_struct(ex, tp) do_struct(ex, tp)
struct expr *ex; register struct expr *ex;
struct type *tp; register struct type *tp;
{ {
struct sdef *sd = tp->tp_sdef; register struct sdef *sd = tp->tp_sdef;
arith bytes_upto_here = (arith)0; arith bytes_upto_here = (arith)0;
arith last_offset = (arith)-1; arith last_offset = (arith)-1;
@ -248,8 +247,7 @@ do_struct(ex, tp)
put_bf(sd->sd_type, (arith)0); put_bf(sd->sd_type, (arith)0);
else { else {
/* fundamental type, not embraced */ /* fundamental type, not embraced */
check_ival(ex->OP_LEFT, check_ival(ex->OP_LEFT, sd->sd_type);
sd->sd_type);
ex = ex->OP_RIGHT; ex = ex->OP_RIGHT;
} }
#endif NOBITFIELD #endif NOBITFIELD
@ -293,11 +291,11 @@ do_struct(ex, tp)
the rest is zeroed. the rest is zeroed.
*/ */
check_and_pad(ex, tpp) check_and_pad(ex, tpp)
struct expr *ex; register struct expr *ex;
struct type **tpp; struct type **tpp;
{ {
/* ex is of a fundamental type */ /* ex is of a fundamental type */
struct type *tp = *tpp; register struct type *tp = *tpp;
if (tp->tp_fund == ARRAY) { if (tp->tp_fund == ARRAY) {
if (valid_type(tp->tp_up, "array element") == 0) if (valid_type(tp->tp_up, "array element") == 0)
@ -339,7 +337,7 @@ check_and_pad(ex, tpp)
If the element is an aggregate, pad() is called recursively. If the element is an aggregate, pad() is called recursively.
*/ */
pad(tp) pad(tp)
struct type *tp; register struct type *tp;
{ {
switch (tp->tp_fund) { switch (tp->tp_fund) {
case ARRAY: case ARRAY:
@ -408,7 +406,7 @@ pad(tp)
*/ */
check_ival(ex, tp) check_ival(ex, tp)
struct expr *ex; struct expr *ex;
struct type *tp; register struct type *tp;
{ {
/* The philosophy here is that ch7cast puts an explicit /* The philosophy here is that ch7cast puts an explicit
conversion node in front of the expression if the types conversion node in front of the expression if the types
@ -506,8 +504,8 @@ ch_array(tpp, ex)
{ {
register struct type *tp = *tpp; register struct type *tp = *tpp;
register arith length; register arith length;
char *s = ex->SG_VALUE; register char *s = ex->SG_VALUE;
arith ntopad; register arith ntopad;
ASSERT(ex->ex_class == String); ASSERT(ex->ex_class == String);
length = ex->SG_LEN; length = ex->SG_LEN;
@ -588,7 +586,7 @@ put_bf(tp, val)
int int
zero_bytes(sd) zero_bytes(sd)
struct sdef *sd; register struct sdef *sd;
{ {
/* fills the space between a selector of a struct /* fills the space between a selector of a struct
and the next selector of that struct with zero-bytes. and the next selector of that struct with zero-bytes.
@ -640,7 +638,7 @@ too_many_initialisers(ex)
} }
aggregate_type(tp) aggregate_type(tp)
struct type *tp; register struct type *tp;
{ {
return tp->tp_fund == ARRAY || tp->tp_fund == STRUCT; return tp->tp_fund == ARRAY || tp->tp_fund == STRUCT;
} }

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* MAIN PROGRAM */ /* MAIN PROGRAM */
#include "nofloat.h"
#include <system.h> #include <system.h>
#include "nopp.h" #include "nopp.h"
#include "target_sizes.h" #include "target_sizes.h"
@ -9,7 +10,6 @@
#include "use_tmp.h" #include "use_tmp.h"
#include "maxincl.h" #include "maxincl.h"
#include "inputtype.h" #include "inputtype.h"
#include "input.h" #include "input.h"
#include "level.h" #include "level.h"
#include "idf.h" #include "idf.h"
@ -84,6 +84,7 @@ main(argc, argv)
#endif OWNALLOC #endif OWNALLOC
init_hmask(); init_hmask();
#ifndef NOPP #ifndef NOPP
init_pp(); /* initialise the preprocessor macros */ init_pp(); /* initialise the preprocessor macros */
#endif NOPP #endif NOPP
@ -289,7 +290,7 @@ init()
} }
init_specials(si) init_specials(si)
struct sp_id *si; register struct sp_id *si;
{ {
while (si->si_identifier) { while (si->si_identifier) {
struct idf *idf = str2idf(si->si_identifier); struct idf *idf = str2idf(si->si_identifier);

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* U S E R O P T I O N - H A N D L I N G */ /* U S E R O P T I O N - H A N D L I N G */
#include "nofloat.h"
#include "nopp.h" #include "nopp.h"
#include "idfsize.h" #include "idfsize.h"
#include "maxincl.h" #include "maxincl.h"
@ -174,7 +175,6 @@ do_option(text)
align = txt2int(&text); align = txt2int(&text);
} }
switch (c) { switch (c) {
case 's': /* short */ case 's': /* short */
if (size != (arith)0) if (size != (arith)0)
short_size = size; short_size = size;
@ -242,11 +242,9 @@ do_option(text)
} }
break; break;
} }
case 'n': case 'n':
options['n'] = 1; /* use no registers */ options['n'] = 1; /* use no registers */
break; break;
case 'w': case 'w':
options['w'] = 1; /* no warnings will be given */ options['w'] = 1; /* no warnings will be given */
break; break;
@ -260,8 +258,7 @@ txt2int(tp)
/* the integer pointed to by *tp is read, while increasing /* the integer pointed to by *tp is read, while increasing
*tp; the resulting value is yielded. *tp; the resulting value is yielded.
*/ */
register int val = 0; register int val = 0, ch;
register int ch;
while (ch = **tp, ch >= '0' && ch <= '9') { while (ch = **tp, ch >= '0' && ch <= '9') {
val = val * 10 + ch - '0'; val = val * 10 + ch - '0';

View file

@ -1,6 +1,8 @@
/* $Header$ */ /* $Header$ */
/* VARIOUS TARGET MACHINE SIZE DESCRIPTORS */ /* VARIOUS TARGET MACHINE SIZE DESCRIPTORS */
#include "nofloat.h"
extern arith extern arith
short_size, word_size, dword_size, int_size, long_size, short_size, word_size, dword_size, int_size, long_size,
#ifndef NOFLOAT #ifndef NOFLOAT

View file

@ -1,14 +1,13 @@
/* $Header$ */ /* $Header$ */
/* S T A C K / U N S T A C K R O U T I N E S */ /* S T A C K / U N S T A C K R O U T I N E S */
#include "nofloat.h"
#include <system.h> #include <system.h>
#include <em.h> #include <em.h>
#include <em_reg.h> #include <em_reg.h>
#include "debug.h" #include "debug.h"
#include "use_tmp.h" #include "use_tmp.h"
#include "botch_free.h" #include "botch_free.h"
#include "alloc.h" #include "alloc.h"
#include "Lpars.h" #include "Lpars.h"
#include "arith.h" #include "arith.h"
@ -42,7 +41,7 @@ int level; /* Always equal to local_level->sl_level. */
stack_level() { stack_level() {
/* A new level is added on top of the identifier stack. /* A new level is added on top of the identifier stack.
*/ */
struct stack_level *stl = new_stack_level(); register struct stack_level *stl = new_stack_level();
clear((char *)stl, sizeof(struct stack_level)); clear((char *)stl, sizeof(struct stack_level));
local_level->sl_next = stl; local_level->sl_next = stl;
@ -55,7 +54,7 @@ stack_level() {
stack_idf(idf, stl) stack_idf(idf, stl)
struct idf *idf; struct idf *idf;
struct stack_level *stl; register struct stack_level *stl;
{ {
/* The identifier idf is inserted in the stack on level stl. /* The identifier idf is inserted in the stack on level stl.
*/ */

View file

@ -49,9 +49,9 @@ int lcm();
*/ */
add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
struct type *stp; /* type of the structure */ register struct type *stp; /* type of the structure */
struct type *tp; /* type of the selector */ struct type *tp; /* type of the selector */
struct idf *idf; /* idf of the selector */ register struct idf *idf; /* idf of the selector */
struct sdef ***sdefpp; /* address of hook to selector definition */ struct sdef ***sdefpp; /* address of hook to selector definition */
arith *szp; /* pointer to struct size upto here */ arith *szp; /* pointer to struct size upto here */
struct field *fd; struct field *fd;
@ -67,8 +67,8 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
extern arith add_field(); extern arith add_field();
#endif NOBITFIELD #endif NOBITFIELD
register struct tag *tg = stp->tp_idf->id_struct; /* or union */ struct tag *tg = stp->tp_idf->id_struct; /* or union */
register struct sdef *sdef = idf->id_sdef; struct sdef *sdef = idf->id_sdef;
register struct sdef *newsdef; register struct sdef *newsdef;
int lvl = tg->tg_level; int lvl = tg->tg_level;
@ -164,7 +164,7 @@ check_selector(idf, stp)
/* checks if idf occurs already as a selector in /* checks if idf occurs already as a selector in
struct or union *stp. struct or union *stp.
*/ */
struct sdef *sdef = stp->tp_sdef; register struct sdef *sdef = stp->tp_sdef;
while (sdef) { while (sdef) {
if (sdef->sd_idf == idf) if (sdef->sd_idf == idf)
@ -174,7 +174,7 @@ check_selector(idf, stp)
} }
declare_struct(fund, idf, tpp) declare_struct(fund, idf, tpp)
struct idf *idf; register struct idf *idf;
struct type **tpp; struct type **tpp;
{ {
/* A struct, union or enum (depending on fund) with tag (!) /* A struct, union or enum (depending on fund) with tag (!)
@ -251,7 +251,7 @@ declare_struct(fund, idf, tpp)
} }
apply_struct(fund, idf, tpp) apply_struct(fund, idf, tpp)
struct idf *idf; register struct idf *idf;
struct type **tpp; struct type **tpp;
{ {
/* The occurrence of a struct, union or enum (depending on /* The occurrence of a struct, union or enum (depending on
@ -271,7 +271,7 @@ apply_struct(fund, idf, tpp)
struct sdef * struct sdef *
idf2sdef(idf, tp) idf2sdef(idf, tp)
struct idf *idf; register struct idf *idf;
struct type *tp; struct type *tp;
{ {
/* The identifier idf is identified as a selector, preferably /* The identifier idf is identified as a selector, preferably
@ -280,7 +280,7 @@ idf2sdef(idf, tp)
If the attempt fails, a selector of type error_type is If the attempt fails, a selector of type error_type is
created. created.
*/ */
struct sdef **sdefp = &idf->id_sdef, *sdef; register struct sdef **sdefp = &idf->id_sdef, *sdef;
/* Follow chain from idf, to meet tp. */ /* Follow chain from idf, to meet tp. */
while ((sdef = *sdefp)) { while ((sdef = *sdefp)) {
@ -316,7 +316,7 @@ idf2sdef(idf, tp)
int int
uniq_selector(idf_sdef) uniq_selector(idf_sdef)
struct sdef *idf_sdef; register struct sdef *idf_sdef;
{ {
/* Returns true if idf_sdef (which is guaranteed to exist) /* Returns true if idf_sdef (which is guaranteed to exist)
is unique for this level, i.e there is no other selector is unique for this level, i.e there is no other selector
@ -326,7 +326,7 @@ uniq_selector(idf_sdef)
case! case!
*/ */
struct sdef *sdef = idf_sdef->next; register struct sdef *sdef = idf_sdef->next;
while (sdef && sdef->sd_level == idf_sdef->sd_level) { while (sdef && sdef->sd_level == idf_sdef->sd_level) {
if ( sdef->sd_type != idf_sdef->sd_type if ( sdef->sd_type != idf_sdef->sd_type
@ -342,11 +342,11 @@ uniq_selector(idf_sdef)
#ifndef NOBITFIELD #ifndef NOBITFIELD
arith arith
add_field(szp, fd, fdtpp, idf, stp) add_field(szp, fd, fdtpp, idf, stp)
arith *szp; /* size of struct upto here */ arith *szp; /* size of struct upto here */
struct field *fd; /* bitfield, containing width */ register struct field *fd; /* bitfield, containing width */
struct type **fdtpp; /* type of selector */ register struct type **fdtpp; /* type of selector */
struct idf *idf; /* name of selector */ struct idf *idf; /* name of selector */
struct type *stp; /* current struct descriptor */ register struct type *stp; /* current struct descriptor */
{ {
/* The address where this selector is put is returned. If the /* The address where this selector is put is returned. If the
selector with specified width does not fit in the word, or selector with specified width does not fit in the word, or
@ -376,7 +376,6 @@ add_field(szp, fd, fdtpp, idf, stp)
} }
switch ((*fdtpp)->tp_fund) { switch ((*fdtpp)->tp_fund) {
case CHAR: case CHAR:
case SHORT: case SHORT:
case INT: case INT:
@ -419,22 +418,19 @@ add_field(szp, fd, fdtpp, idf, stp)
bits_declared = fd->fd_width; bits_declared = fd->fd_width;
} }
else else
if (fd->fd_width == 0) { if (fd->fd_width == 0)
/* next field should be aligned on the next boundary. /* next field should be aligned on the next boundary.
This will take care that no field will fit in the This will take care that no field will fit in the
space allocated upto here. space allocated upto here.
*/ */
bits_declared = bits_in_type + 1; bits_declared = bits_in_type + 1;
} else /* the bitfield fits in the current field */
else { /* the bitfield fits in the current field */
bits_declared += fd->fd_width; bits_declared += fd->fd_width;
}
/* Arrived here, the place where the selector is stored in the /* Arrived here, the place where the selector is stored in the
struct is computed. struct is computed.
Now we need a mask to use its value in expressions. Now we need a mask to use its value in expressions.
*/ */
*fdtpp = construct_type(FIELD, *fdtpp, (arith)0); *fdtpp = construct_type(FIELD, *fdtpp, (arith)0);
(*fdtpp)->tp_field = fd; (*fdtpp)->tp_field = fd;
@ -446,12 +442,10 @@ add_field(szp, fd, fdtpp, idf, stp)
*/ */
fd->fd_mask = (1 << fd->fd_width) - 1; fd->fd_mask = (1 << fd->fd_width) - 1;
if (options['r']) { /* adjust the field at the right */ if (options['r']) /* adjust the field at the right */
fd->fd_shift = bits_declared - fd->fd_width; fd->fd_shift = bits_declared - fd->fd_width;
} else /* adjust the field at the left */
else { /* adjust the field at the left */
fd->fd_shift = bits_in_type - bits_declared; fd->fd_shift = bits_in_type - bits_declared;
}
return field_offset; return field_offset;
} }

View file

@ -1,12 +1,11 @@
/* $Header$ */ /* $Header$ */
/* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */ /* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */
#include "nofloat.h"
#include <em.h> #include <em.h>
#include "debug.h" #include "debug.h"
#include "botch_free.h" #include "botch_free.h"
#include "density.h" #include "density.h"
#include "Lpars.h" #include "Lpars.h"
#include "idf.h" #include "idf.h"
#include "label.h" #include "label.h"

View file

@ -1,6 +1,7 @@
/* $Header$ */ /* $Header$ */
/* T Y P E D E F I N I T I O N M E C H A N I S M */ /* T Y P E D E F I N I T I O N M E C H A N I S M */
#include "nofloat.h"
#include "nobitfield.h" #include "nobitfield.h"
#include "alloc.h" #include "alloc.h"
#include "Lpars.h" #include "Lpars.h"
@ -52,13 +53,13 @@ create_type(fund)
struct type * struct type *
construct_type(fund, tp, count) construct_type(fund, tp, count)
struct type *tp; register struct type *tp;
arith count; /* for fund == ARRAY only */ arith count; /* for fund == ARRAY only */
{ {
/* fund must be a type constructor: FIELD, FUNCTION, POINTER or /* fund must be a type constructor: FIELD, FUNCTION, POINTER or
ARRAY. The pointer to the constructed type is returned. ARRAY. The pointer to the constructed type is returned.
*/ */
struct type *dtp; register struct type *dtp;
switch (fund) { switch (fund) {
#ifndef NOBITFIELD #ifndef NOBITFIELD
@ -97,9 +98,9 @@ construct_type(fund, tp, count)
struct type * struct type *
function_of(tp) function_of(tp)
struct type *tp; register struct type *tp;
{ {
struct type *dtp = tp->tp_function; register struct type *dtp = tp->tp_function;
if (!dtp) { if (!dtp) {
tp->tp_function = dtp = create_type(FUNCTION); tp->tp_function = dtp = create_type(FUNCTION);
@ -112,9 +113,9 @@ function_of(tp)
struct type * struct type *
pointer_to(tp) pointer_to(tp)
struct type *tp; register struct type *tp;
{ {
struct type *dtp = tp->tp_pointer; register struct type *dtp = tp->tp_pointer;
if (!dtp) { if (!dtp) {
tp->tp_pointer = dtp = create_type(POINTER); tp->tp_pointer = dtp = create_type(POINTER);
@ -128,10 +129,10 @@ pointer_to(tp)
struct type * struct type *
array_of(tp, count) array_of(tp, count)
struct type *tp; register struct type *tp;
arith count; arith count;
{ {
struct type *dtp = tp->tp_array; register struct type *dtp = tp->tp_array;
/* look for a type with the right size */ /* look for a type with the right size */
while (dtp && dtp->tp_size != count) while (dtp && dtp->tp_size != count)
@ -151,9 +152,9 @@ array_of(tp, count)
#ifndef NOBITFIELD #ifndef NOBITFIELD
struct type * struct type *
field_of(tp) field_of(tp)
struct type *tp; register struct type *tp;
{ {
struct type *dtp = create_type(FIELD); register struct type *dtp = create_type(FIELD);
dtp->tp_up = tp; dtp->tp_up = tp;
dtp->tp_align = tp->tp_align; dtp->tp_align = tp->tp_align;
@ -177,7 +178,7 @@ size_of_type(tp, nm)
} }
idf2type(idf, tpp) idf2type(idf, tpp)
struct idf *idf; register struct idf *idf;
struct type **tpp; struct type **tpp;
{ {
/* Decoding a typedef-ed identifier: if the size is yet /* Decoding a typedef-ed identifier: if the size is yet

View file

@ -1,7 +1,8 @@
/* $Header$ */ /* $Header$ */
/* TYPE DESCRIPTOR */ /* TYPE DESCRIPTOR */
#include "nobitfield.h" #include "nofloat.h"
#include "nobitfield.h"
struct type { struct type {
struct type *next; /* used only with ARRAY */ struct type *next; /* used only with ARRAY */