some more squeezing for Minix

This commit is contained in:
ceriel 1989-10-19 19:29:39 +00:00
parent e4857c2446
commit 3d5569183e
7 changed files with 47 additions and 49 deletions

View file

@ -547,18 +547,19 @@ ch3asgn(expp, oper, expr)
int fund = exp->ex_type->tp_fund;
int vol = 0;
struct type *tp;
char *oper_string = symbol2str(oper);
/* We expect an lvalue */
if (!exp->ex_lvalue) {
expr_error(exp, "no lvalue in operand of %s", symbol2str(oper));
expr_error(exp, "no lvalue in operand of %s", oper_string);
} else if (exp->ex_flags & EX_ILVALUE) {
strict("incorrect lvalue in operand of %s", symbol2str(oper));
strict("incorrect lvalue in operand of %s", oper_string);
} else if (exp->ex_flags & EX_READONLY) {
expr_error(exp, "operand of %s is read-only", symbol2str(oper));
expr_error(exp, "operand of %s is read-only", oper_string);
} else if (fund == STRUCT || fund == UNION) {
if (recurconst(exp->ex_type))
expr_error(expr,"operand of %s contains a const-qualified member",
symbol2str(oper));
oper_string);
}
/* Preserve volatile markers across the tree.
@ -596,10 +597,8 @@ ch3asgn(expp, oper, expr)
expr = extmp;
}
#ifndef NOBITFIELD
if (fund == FIELD)
exp = new_oper(exp->ex_type->tp_up, exp, oper, expr);
else
exp = new_oper(exp->ex_type, exp, oper, expr);
exp = new_oper(fund == FIELD ? exp->ex_type->tp_up : exp->ex_type,
exp, oper, expr);
#else NOBITFIELD
exp = new_oper(exp->ex_type, exp, oper, expr);
#endif NOBITFIELD

View file

@ -20,6 +20,7 @@ struct def { /* for ordinary tags */
char df_initialized; /* an initialization has been generated */
char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */
char df_used; /* set if idf is used */
char df_formal_array; /* to warn if sizeof is taken */
char *df_file; /* file containing the definition */
unsigned int df_line; /* line number of the definition */
#ifdef LINT
@ -27,7 +28,6 @@ struct def { /* for ordinary tags */
int df_firstbrace; /* brace number of its first occurrence */
int df_minlevel; /* the lowest level needed for this def */
#endif LINT
char df_formal_array; /* to warn if sizeof is taken */
arith df_address;
};

View file

@ -10,7 +10,7 @@ struct e_stack {
arith s_cnt1, s_cnt2;
struct sdef *s_def;
struct type **s_tpp;
char s_nested;
short s_nested;
};
/* ALLOCDEF "e_stack" 5 */

View file

@ -54,7 +54,7 @@ struct expr {
char *ex_file; /* the file it (probably) comes from */
unsigned int ex_line; /* the line it (probably) comes from */
struct type *ex_type;
char ex_lvalue;
short ex_lvalue;
short ex_flags;
int ex_class;
int ex_depth;

View file

@ -54,10 +54,9 @@ eval_field(expr, code)
struct type *tp = leftop->ex_type->tp_up;
arith tmpvar;
struct type *atype = tp->tp_unsigned ? uword_type : word_type;
arith asize = atype->tp_size;
/* First some assertions to be sure that the rest is legal */
ASSERT(asize == word_size); /* make sure that C_loc() is legal */
ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */
ASSERT(leftop->ex_type->tp_fund == FIELD);
leftop->ex_type = atype; /* this is cheating but it works... */
if (op == '=') {
@ -66,19 +65,19 @@ eval_field(expr, code)
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
conversion(tp, atype);
C_loc(fd->fd_mask);
C_and(asize);
C_and(word_size);
if (code == TRUE)
C_dup(asize);
C_dup(word_size);
C_loc((arith)fd->fd_shift);
if (atype->tp_unsigned)
C_slu(asize);
C_slu(word_size);
else
C_sli(asize);
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[asize]));
C_sli(word_size);
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[(int)word_size]));
if (leftop->ex_depth == 0) { /* simple case */
load_val(leftop, RVAL);
C_and(asize);
C_ior(asize);
C_and(word_size);
C_ior(word_size);
store_val(&(leftop->EX_VALUE), atype);
}
else { /* complex case */
@ -87,11 +86,11 @@ eval_field(expr, code)
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
C_dup(pointer_size);
StoreLocal(tmpvar, pointer_size);
C_loi(asize);
C_and(asize);
C_ior(asize);
C_loi(word_size);
C_and(word_size);
C_ior(word_size);
LoadLocal(tmpvar, pointer_size);
C_sti(asize);
C_sti(word_size);
FreeLocal(tmpvar);
}
}
@ -107,23 +106,23 @@ eval_field(expr, code)
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
C_dup(pointer_size);
StoreLocal(tmpvar, pointer_size);
C_loi(asize);
C_loi(word_size);
}
if (atype->tp_unsigned) {
C_loc((arith)fd->fd_shift);
C_sru(asize);
C_sru(word_size);
C_loc(fd->fd_mask);
C_and(asize);
C_and(word_size);
}
else {
arith bits_in_type = asize * 8;
arith bits_in_type = word_size * 8;
C_loc(bits_in_type - (fd->fd_width + fd->fd_shift));
C_sli(asize);
C_sli(word_size);
C_loc(bits_in_type - fd->fd_width);
C_sri(asize);
C_sri(word_size);
}
if (code == TRUE && (op == POSTINCR || op == POSTDECR))
C_dup(asize);
C_dup(word_size);
conversion(atype, rightop->ex_type);
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
/* the 'op' operation: */
@ -136,28 +135,28 @@ eval_field(expr, code)
assop(rightop->ex_type, op);
conversion(rightop->ex_type, atype);
C_loc(fd->fd_mask);
C_and(asize);
C_and(word_size);
if (code == TRUE && op != POSTINCR && op != POSTDECR)
C_dup(asize);
C_dup(word_size);
C_loc((arith)fd->fd_shift);
if (atype->tp_unsigned)
C_slu(asize);
C_slu(word_size);
else
C_sli(asize);
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[asize]));
C_sli(word_size);
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[(int)word_size]));
if (leftop->ex_depth == 0) {
load_val(leftop, RVAL);
C_and(asize);
C_ior(asize);
C_and(word_size);
C_ior(word_size);
store_val(&(leftop->EX_VALUE), atype);
}
else {
LoadLocal(tmpvar, pointer_size);
C_loi(asize);
C_and(asize);
C_ior(asize);
C_loi(word_size);
C_and(word_size);
C_ior(word_size);
LoadLocal(tmpvar, pointer_size);
C_sti(asize);
C_sti(word_size);
FreeLocal(tmpvar);
}
}
@ -167,12 +166,12 @@ eval_field(expr, code)
retrieval) is on top of stack.
*/
if (atype->tp_unsigned == 0) { /* sign extension */
register arith shift = asize * 8 - fd->fd_width;
register arith shift = word_size * 8 - fd->fd_width;
C_loc(shift);
C_sli(asize);
C_sli(word_size);
C_loc(shift);
C_sri(asize);
C_sri(word_size);
}
conversion(atype, expr->ex_type);
}

View file

@ -58,7 +58,7 @@ promoted_type(tp)
struct type *tp;
{
if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) {
if (tp->tp_unsigned && tp->tp_size == int_size)
if (tp->tp_unsigned && (int) tp->tp_size == (int) int_size)
return uint_type;
else return int_type;
} else if (tp->tp_fund == FLOAT)
@ -127,7 +127,7 @@ construct_type(fund, tp, qual, count, pl)
struct type *
function_of(tp, pl, qual)
register struct type *tp;
register struct proto *pl;
struct proto *pl;
int qual;
{
register struct type *dtp = tp->tp_function;
@ -233,7 +233,7 @@ size_of_type(tp, nm)
if (sz < 0) {
error("size of %s unknown", nm);
return (arith)1;
sz = (arith)1;
}
return sz;
}

View file

@ -10,7 +10,7 @@
struct type {
struct type *next; /* used only with ARRAY */
short tp_fund; /* fundamental type */
char tp_unsigned;
short tp_unsigned;
int tp_align;
int tp_typequal; /* type qualifier */
arith tp_size; /* -1 if declared but not defined */