From: Richard Kenner Date: Sun, 15 Sep 1996 00:42:46 +0000 (-0400) Subject: (store_field): If storing a record on big endian targets, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef19912d09dff11b4a52d4e1ea52acb86c5c85c8;p=gcc.git (store_field): If storing a record on big endian targets, set up so we store the high-order bits. (expand_expr, case COMPONENT_REF): Likewise for loads. From-SVN: r12714 --- diff --git a/gcc/expr.c b/gcc/expr.c index e1b178779f5..5713d6d2eac 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4105,6 +4105,18 @@ store_field (target, bitsize, bitpos, mode, exp, value_mode, { rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0); + /* If BITSIZE is narrower than the size of the type of EXP + we will be narrowing TEMP. Normally, what's wanted are the + low-order bits. However, if EXP's type is a record and this is + big-endian machine, we want the upper BITSIZE bits. */ + if (BYTES_BIG_ENDIAN && GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT + && bitsize < GET_MODE_BITSIZE (GET_MODE (temp)) + && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) + temp = expand_shift (RSHIFT_EXPR, GET_MODE (temp), temp, + size_int (GET_MODE_BITSIZE (GET_MODE (temp)) + - bitsize), + temp, 1); + /* Unless MODE is VOIDmode or BLKmode, convert TEMP to MODE. */ if (mode != VOIDmode && mode != BLKmode @@ -5595,6 +5607,18 @@ expand_expr (exp, target, tmode, modifier) unsignedp, target, ext_mode, ext_mode, alignment, int_size_in_bytes (TREE_TYPE (tem))); + + /* If the result is a record type and BITSIZE is narrower than + the mode of OP0, an integral mode, and this is a big endian + machine, we must put the field into the high-order bits. */ + if (TREE_CODE (type) == RECORD_TYPE && BYTES_BIG_ENDIAN + && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT + && bitsize < GET_MODE_BITSIZE (GET_MODE (op0))) + op0 = expand_shift (LSHIFT_EXPR, GET_MODE (op0), op0, + size_int (GET_MODE_BITSIZE (GET_MODE (op0)) + - bitsize), + op0, 1); + if (mode == BLKmode) { rtx new = assign_stack_temp (ext_mode,