From 43b01a70a0d84a177842c79023702dcb22e2ad60 Mon Sep 17 00:00:00 2001 From: eck Date: Thu, 19 Jul 1990 17:16:36 +0000 Subject: [PATCH] squeezing for MINIX & bug fix in dumpidf --- lang/cem/cemcom.ansi/arith.c | 10 +++++----- lang/cem/cemcom.ansi/atw.h | 6 +++++- lang/cem/cemcom.ansi/dumpidf.c | 2 +- lang/cem/cemcom.ansi/eval.c | 4 ++-- lang/cem/cemcom.ansi/field.c | 6 +++--- lang/cem/cemcom.ansi/label.c | 13 +++++++------ 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 08c146431..b327630a8 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -364,7 +364,7 @@ int2float(expp, tp) converted to the floating type tp. */ register struct expr *exp = *expp; - int uns = (*expp)->ex_type->tp_unsigned; + int uns = exp->ex_type->tp_unsigned; if (is_cp_cst(exp)) { *expp = new_expr(); @@ -596,19 +596,19 @@ field2arith(expp) (*expp)->ex_type = word_type; if (tp->tp_unsigned) { /* don't worry about the sign bit */ - if (fd->fd_width >= 8 * word_size) + if (fd->fd_width >= 8 * (int)word_size) (*expp)->ex_type = uword_type; ch3bin(expp, RIGHT, intexpr((arith)fd->fd_shift, INT)); ch3bin(expp, '&', intexpr(fd->fd_mask, INT)); } else { /* take care of the sign bit: sign extend if needed */ - arith bits_in_type = word_size * 8; + arith other_bits = (int)word_size * 8 - fd->fd_width; ch3bin(expp, LEFT, - intexpr(bits_in_type - fd->fd_width - fd->fd_shift, + intexpr(other_bits - fd->fd_shift, INT) ); - ch3bin(expp, RIGHT, intexpr(bits_in_type - fd->fd_width, INT)); + ch3bin(expp, RIGHT, intexpr(other_bits, INT)); } } #endif NOBITFIELD diff --git a/lang/cem/cemcom.ansi/atw.h b/lang/cem/cemcom.ansi/atw.h index ed2b2dcf4..b63129852 100644 --- a/lang/cem/cemcom.ansi/atw.h +++ b/lang/cem/cemcom.ansi/atw.h @@ -7,4 +7,8 @@ #include "sizes.h" -#define ATW(arg) ((((arg) + word_size - 1) / word_size) * word_size) +#if word_size==2 || word_size==4 +#define ATW(arg) (((arg) + (word_size - 1)) & ~ (word_size - 1)) +#else +#define ATW(arg) ((((arg) + ((int)word_size - 1)) / word_size) * word_size) +#endif diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index fc5ee2249..2b185c1f0 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -326,7 +326,7 @@ dump_type(tp) ops = 0; break; } - if (!ops) tp = tp->tp_up; + if (ops) tp = tp->tp_up; } dumplevel--; } diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 54134b298..e2d775269 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -1019,10 +1019,10 @@ load_val(expr, rlval) load_cst(val, siz) arith val, siz; { - if (siz <= word_size) + if ((int)siz <= (int)word_size) C_loc(val); else - if (siz == dword_size) + if ((int)siz == (int)dword_size) C_ldc(val); else { label datlab; diff --git a/lang/cem/cemcom.ansi/field.c b/lang/cem/cemcom.ansi/field.c index 9cef7b465..2c4edd2c6 100644 --- a/lang/cem/cemcom.ansi/field.c +++ b/lang/cem/cemcom.ansi/field.c @@ -53,7 +53,7 @@ eval_field(expr, code) struct type *tp = leftop->ex_type->tp_up; arith tmpvar = 0; struct type *atype = ( tp->tp_unsigned - && fd->fd_width >= 8 * word_size) + && fd->fd_width >= 8 * (int)word_size) ? uword_type : word_type; @@ -89,7 +89,7 @@ eval_field(expr, code) C_and(word_size); } else { - arith sft = word_size * 8 - fd->fd_width; + arith sft = (int)word_size * 8 - fd->fd_width; C_loc(sft - fd->fd_shift); C_sli(word_size); C_loc(sft); @@ -118,7 +118,7 @@ eval_field(expr, code) retrieval) is on top of stack. */ if (tp->tp_unsigned == 0) { /* sign extension */ - register arith shift = word_size * 8 - fd->fd_width; + register arith shift = (int)word_size * 8 - fd->fd_width; C_loc(shift); C_sli(word_size); diff --git a/lang/cem/cemcom.ansi/label.c b/lang/cem/cemcom.ansi/label.c index 112bd339a..90b6a8928 100644 --- a/lang/cem/cemcom.ansi/label.c +++ b/lang/cem/cemcom.ansi/label.c @@ -23,9 +23,9 @@ enter_label(idf, defining) scope, i.e., on the lowest possible level. If defining, the label comes from a label statement. */ - if (idf->id_def) { - register struct def *def = idf->id_def; - + register struct def *def = idf->id_def; + + if (def) { if (def->df_sc == LABEL) { if (defining && def->df_initialized) error("redeclaration of label %s", @@ -41,11 +41,12 @@ enter_label(idf, defining) } else { add_def(idf, LABEL, label_type, L_LOCAL); + def = idf->id_def; } - if (idf->id_def->df_address == 0) - idf->id_def->df_address = (arith) text_label(); + if (def->df_address == 0) + def->df_address = (arith) text_label(); if (defining) - idf->id_def->df_initialized = 1; + def->df_initialized = 1; } unstack_label(idf)