diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 1994-11-16 21:10:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 1994-11-16 21:10:09 +0000 |
commit | f76b9db2874507ed287d1fe39ca2b1e89ae95207 (patch) | |
tree | 036743ae971e4dddc0469a67fd6d6272b0801af8 | |
parent | 1942e820686abbdd62515895e219476c26429945 (diff) | |
download | gcc-f76b9db2874507ed287d1fe39ca2b1e89ae95207.zip gcc-f76b9db2874507ed287d1fe39ca2b1e89ae95207.tar.gz gcc-f76b9db2874507ed287d1fe39ca2b1e89ae95207.tar.bz2 |
Check target endianness at run time, not compile time
From-SVN: r8470
-rw-r--r-- | gcc/bi-run.h | 31 | ||||
-rw-r--r-- | gcc/bytecode.h | 23 | ||||
-rw-r--r-- | gcc/combine.c | 190 | ||||
-rw-r--r-- | gcc/cse.c | 29 | ||||
-rw-r--r-- | gcc/dbxout.c | 11 | ||||
-rw-r--r-- | gcc/dwarfout.c | 23 | ||||
-rw-r--r-- | gcc/expmed.c | 152 | ||||
-rw-r--r-- | gcc/expr.h | 24 | ||||
-rw-r--r-- | gcc/final.c | 79 | ||||
-rw-r--r-- | gcc/fold-const.c | 23 | ||||
-rw-r--r-- | gcc/function.c | 53 | ||||
-rw-r--r-- | gcc/jump.c | 7 | ||||
-rw-r--r-- | gcc/libgcc2.c | 12 | ||||
-rw-r--r-- | gcc/mips-tfile.c | 2 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 4 | ||||
-rw-r--r-- | gcc/real.c | 955 | ||||
-rw-r--r-- | gcc/real.h | 20 | ||||
-rw-r--r-- | gcc/recog.c | 23 | ||||
-rw-r--r-- | gcc/reload.c | 15 | ||||
-rw-r--r-- | gcc/reload1.c | 43 | ||||
-rw-r--r-- | gcc/sdbout.c | 12 | ||||
-rw-r--r-- | gcc/tree.c | 9 | ||||
-rw-r--r-- | gcc/varasm.c | 135 |
23 files changed, 985 insertions, 890 deletions
diff --git a/gcc/bi-run.h b/gcc/bi-run.h index 669f2ab..d7a547d 100644 --- a/gcc/bi-run.h +++ b/gcc/bi-run.h @@ -124,30 +124,23 @@ struct bytecode DEST offset by OFFSET bits. */ -#if BYTES_BIG_ENDIAN - #define SHIFT_IN_BITS(DEST, SOURCE, OFFSET, NBITS) \ (DEST = ((DEST) << (NBITS)) \ | (LM ((NBITS)) \ - & ((SOURCE) >> (INTERP_BPC - (OFFSET) - (NBITS))))) + & ((SOURCE) \ + >> (BYTES_BIG_ENDIAN \ + ? (INTERP_BPC - (OFFSET) - (NBITS)) \ + : (OFFSET))))) #define OR_IN_BITS(DEST, VALUE, OFFSET, NBITS) \ - (DEST = ((DEST) & ~(LM ((NBITS)) << (INTERP_BPC - (OFFSET) - (NBITS)))) \ - | (((VALUE) & LM ((NBITS))) << (INTERP_BPC - (OFFSET) - (NBITS)))) - -#else - -#define SHIFT_IN_BITS(DEST, SOURCE, OFFSET, NBITS) \ - (DEST = ((DEST) << (NBITS)) \ - | (LM ((NBITS)) \ - & ((SOURCE) >> (OFFSET)))) - -#define OR_IN_BITS(DEST, VALUE, OFFSET, NBITS) \ - (DEST = ((DEST) & ~(LM ((NBITS)) << (OFFSET))) \ - | (((VALUE) & LM ((NBITS))) << (OFFSET))) - -#endif - + (DEST = ((DEST) & ~(LM ((NBITS)) \ + << (BIG_ENDIAN \ + ? (INTERP_BPC - (OFFSET) - (NBITS)) \ + : (OFFSET))) \ + | (((VALUE) & LM ((NBITS))) \ + << (BIG_ENDIAN \ + ? (INTERP_BPC - (OFFSET) - (NBITS)) \ + : (OFFSET))))) /* Procedure call; arguments are a pointer to the function to be called, a pointer to a place to store the return value, a pointer to a vector diff --git a/gcc/bytecode.h b/gcc/bytecode.h index 87030be..e2dc73a 100644 --- a/gcc/bytecode.h +++ b/gcc/bytecode.h @@ -24,28 +24,17 @@ extern int max_stack_depth; /* Emit DI constant according to target machine word ordering */ -#if WORDS_BIG_ENDIAN - #define bc_emit_bytecode_DI_const(CST) \ { int opcode; \ - opcode = TREE_INT_CST_HIGH (CST); \ + opcode = (WORDS_BIG_ENDIAN \ + ? TREE_INT_CST_HIGH (CST) \ + : TREE_INT_CST_LOW (CST)); \ bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ - opcode = TREE_INT_CST_LOW (CST); \ + opcode = (WORDS_BIG_ENDIAN \ + ? TREE_INT_CST_LOW (CST) \ + : TREE_INT_CST_HIGH (CST)); \ bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ } - -#else - -#define bc_emit_bytecode_DI_const(CST) \ -{ int opcode; \ - opcode = TREE_INT_CST_LOW (CST); \ - bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ - opcode = TREE_INT_CST_HIGH (CST); \ - bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ -} - -#endif - extern void bc_expand_expr (); extern void bc_output_data_constructor (); diff --git a/gcc/combine.c b/gcc/combine.c index 8ab1547..bc04c09 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2508,9 +2508,8 @@ find_split_point (loc, insn) enum machine_mode mode = GET_MODE (dest); unsigned HOST_WIDE_INT mask = ((HOST_WIDE_INT) 1 << len) - 1; -#if BITS_BIG_ENDIAN - pos = GET_MODE_BITSIZE (mode) - len - pos; -#endif + if (BITS_BIG_ENDIAN) + pos = GET_MODE_BITSIZE (mode) - len - pos; if (src == mask) SUBST (SET_SRC (x), @@ -2579,9 +2578,8 @@ find_split_point (loc, insn) len = INTVAL (XEXP (SET_SRC (x), 1)); pos = INTVAL (XEXP (SET_SRC (x), 2)); -#if BITS_BIG_ENDIAN - pos = GET_MODE_BITSIZE (GET_MODE (inner)) - len - pos; -#endif + if (BITS_BIG_ENDIAN) + pos = GET_MODE_BITSIZE (GET_MODE (inner)) - len - pos; unsignedp = (code == ZERO_EXTRACT); } break; @@ -3165,12 +3163,14 @@ simplify_rtx (x, op0_mode, last, in_dest) || mode_dependent_address_p (XEXP (inner, 0))) return gen_rtx (CLOBBER, mode, const0_rtx); -#if BYTES_BIG_ENDIAN - if (GET_MODE_SIZE (mode) < UNITS_PER_WORD) - endian_offset += UNITS_PER_WORD - GET_MODE_SIZE (mode); - if (GET_MODE_SIZE (GET_MODE (inner)) < UNITS_PER_WORD) - endian_offset -= UNITS_PER_WORD - GET_MODE_SIZE (GET_MODE (inner)); -#endif + if (BYTES_BIG_ENDIAN) + { + if (GET_MODE_SIZE (mode) < UNITS_PER_WORD) + endian_offset += UNITS_PER_WORD - GET_MODE_SIZE (mode); + if (GET_MODE_SIZE (GET_MODE (inner)) < UNITS_PER_WORD) + endian_offset -= (UNITS_PER_WORD + - GET_MODE_SIZE (GET_MODE (inner))); + } /* Note if the plus_constant doesn't make a valid address then this combination won't be accepted. */ x = gen_rtx (MEM, mode, @@ -3246,10 +3246,8 @@ simplify_rtx (x, op0_mode, last, in_dest) only if the constant's mode fits in one word. */ if (CONSTANT_P (SUBREG_REG (x)) && subreg_lowpart_p (x) && GET_MODE_SIZE (mode) < GET_MODE_SIZE (op0_mode) -#if WORDS_BIG_ENDIAN - && GET_MODE_BITSIZE (op0_mode) <= BITS_PER_WORD -#endif - ) + && (! WORDS_BIG_ENDIAN + || GET_MODE_BITSIZE (op0_mode) <= BITS_PER_WORD)) return gen_lowpart_for_combine (mode, SUBREG_REG (x)); /* A paradoxical SUBREG of a VOIDmode constant is the same constant, @@ -4777,9 +4775,9 @@ expand_compound_operation (x) if (len + pos > GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))) SUBST (XEXP (x, 0), gen_rtx (USE, GET_MODE (x), XEXP (x, 0))); -#if BITS_BIG_ENDIAN - pos = GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0))) - len - pos; -#endif + if (BITS_BIG_ENDIAN) + pos = GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0))) - len - pos; + break; default: @@ -4871,22 +4869,23 @@ expand_field_assignment (x) && INTVAL (pos) + len > GET_MODE_BITSIZE (GET_MODE (inner))) inner = gen_rtx (USE, GET_MODE (SET_DEST (x)), inner); -#if BITS_BIG_ENDIAN - if (GET_CODE (pos) == CONST_INT) - pos = GEN_INT (GET_MODE_BITSIZE (GET_MODE (inner)) - len - - INTVAL (pos)); - else if (GET_CODE (pos) == MINUS - && GET_CODE (XEXP (pos, 1)) == CONST_INT - && (INTVAL (XEXP (pos, 1)) - == GET_MODE_BITSIZE (GET_MODE (inner)) - len)) - /* If position is ADJUST - X, new position is X. */ - pos = XEXP (pos, 0); - else - pos = gen_binary (MINUS, GET_MODE (pos), - GEN_INT (GET_MODE_BITSIZE (GET_MODE (inner)) - - len), - pos); -#endif + if (BITS_BIG_ENDIAN) + { + if (GET_CODE (pos) == CONST_INT) + pos = GEN_INT (GET_MODE_BITSIZE (GET_MODE (inner)) - len + - INTVAL (pos)); + else if (GET_CODE (pos) == MINUS + && GET_CODE (XEXP (pos, 1)) == CONST_INT + && (INTVAL (XEXP (pos, 1)) + == GET_MODE_BITSIZE (GET_MODE (inner)) - len)) + /* If position is ADJUST - X, new position is X. */ + pos = XEXP (pos, 0); + else + pos = gen_binary (MINUS, GET_MODE (pos), + GEN_INT (GET_MODE_BITSIZE (GET_MODE (inner)) + - len), + pos); + } } /* A SUBREG between two modes that occupy the same numbers of words @@ -5169,20 +5168,22 @@ make_extraction (mode, inner, pos, pos_rtx, len, orig_pos = pos; -#if BITS_BIG_ENDIAN - /* If position is constant, compute new position. Otherwise, build - subtraction. */ - if (pos_rtx == 0) - pos = (MAX (GET_MODE_BITSIZE (is_mode), GET_MODE_BITSIZE (wanted_mem_mode)) - - len - pos); - else - pos_rtx - = gen_rtx_combine (MINUS, GET_MODE (pos_rtx), - GEN_INT (MAX (GET_MODE_BITSIZE (is_mode), - GET_MODE_BITSIZE (wanted_mem_mode)) - - len), - pos_rtx); -#endif + if (BITS_BIG_ENDIAN) + { + /* If position is constant, compute new position. Otherwise, + build subtraction. */ + if (pos_rtx == 0) + pos = (MAX (GET_MODE_BITSIZE (is_mode), + GET_MODE_BITSIZE (wanted_mem_mode)) + - len - pos); + else + pos_rtx + = gen_rtx_combine (MINUS, GET_MODE (pos_rtx), + GEN_INT (MAX (GET_MODE_BITSIZE (is_mode), + GET_MODE_BITSIZE (wanted_mem_mode)) + - len), + pos_rtx); + } /* If INNER has a wider mode, make it smaller. If this is a constant extract, try to adjust the byte to point to the byte containing @@ -5202,11 +5203,10 @@ make_extraction (mode, inner, pos, pos_rtx, len, /* If bytes are big endian and we had a paradoxical SUBREG, we must adjust OFFSET to compensate. */ -#if BYTES_BIG_ENDIAN - if (! spans_byte + if (BYTES_BIG_ENDIAN + && ! spans_byte && GET_MODE_SIZE (inner_mode) < GET_MODE_SIZE (is_mode)) offset -= GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (inner_mode); -#endif /* If this is a constant position, we can move to the desired byte. */ if (pos_rtx == 0) @@ -5215,11 +5215,11 @@ make_extraction (mode, inner, pos, pos_rtx, len, pos %= GET_MODE_BITSIZE (wanted_mem_mode); } -#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN - if (! spans_byte && is_mode != wanted_mem_mode) + if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN + && ! spans_byte + && is_mode != wanted_mem_mode) offset = (GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (wanted_mem_mode) - offset); -#endif if (offset != 0 || inner_mode != wanted_mem_mode) { @@ -5701,14 +5701,14 @@ force_to_mode (x, mode, mask, reg, just_select) generating something that won't match. */ return x; -#if ! BITS_BIG_ENDIAN case USE: /* X is a (use (mem ..)) that was made from a bit-field extraction that spanned the boundary of the MEM. If we are now masking so it is within that boundary, we don't need the USE any more. */ - if ((mask & ~ GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + if (! BITS_BIG_ENDIAN + && (mask & ~ GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) return force_to_mode (XEXP (x, 0), mode, mask, reg, next_select); -#endif + break; case SIGN_EXTEND: case ZERO_EXTEND: @@ -7627,16 +7627,17 @@ simplify_shift_const (x, code, result_mode, varop, count) && (tmode = mode_for_size (GET_MODE_BITSIZE (mode) - count, MODE_INT, 1)) != BLKmode) { -#if BYTES_BIG_ENDIAN - new = gen_rtx (MEM, tmode, XEXP (varop, 0)); -#else - new = gen_rtx (MEM, tmode, - plus_constant (XEXP (varop, 0), - count / BITS_PER_UNIT)); - RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (varop); - MEM_VOLATILE_P (new) = MEM_VOLATILE_P (varop); - MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (varop); -#endif + if (BYTES_BIG_ENDIAN) + new = gen_rtx (MEM, tmode, XEXP (varop, 0)); + else + { + new = gen_rtx (MEM, tmode, + plus_constant (XEXP (varop, 0), + count / BITS_PER_UNIT)); + RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (varop); + MEM_VOLATILE_P (new) = MEM_VOLATILE_P (varop); + MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (varop); + } varop = gen_rtx_combine (code == ASHIFTRT ? SIGN_EXTEND : ZERO_EXTEND, mode, new); count = 0; @@ -7654,14 +7655,15 @@ simplify_shift_const (x, code, result_mode, varop, count) MODE_INT, 1)) != BLKmode && tmode == GET_MODE (XEXP (varop, 0))) { -#if BITS_BIG_ENDIAN - new = XEXP (varop, 0); -#else - new = copy_rtx (XEXP (varop, 0)); - SUBST (XEXP (new, 0), - plus_constant (XEXP (new, 0), - count / BITS_PER_UNIT)); -#endif + if (BITS_BIG_ENDIAN) + new = XEXP (varop, 0); + else + { + new = copy_rtx (XEXP (varop, 0)); + SUBST (XEXP (new, 0), + plus_constant (XEXP (new, 0), + count / BITS_PER_UNIT)); + } varop = gen_rtx_combine (code == ASHIFTRT ? SIGN_EXTEND : ZERO_EXTEND, mode, new); @@ -8327,16 +8329,16 @@ gen_lowpart_for_combine (mode, x) if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (mode)) return gen_rtx (SUBREG, mode, x, 0); -#if WORDS_BIG_ENDIAN - offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) - - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); -#endif -#if BYTES_BIG_ENDIAN - /* Adjust the address so that the address-after-the-data - is unchanged. */ - offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); -#endif + if (WORDS_BIG_ENDIAN) + offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) + - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); + if (BYTES_BIG_ENDIAN) + { + /* Adjust the address so that the address-after-the-data is + unchanged. */ + offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); + } new = gen_rtx (MEM, mode, plus_constant (XEXP (x, 0), offset)); RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x); MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x); @@ -8896,15 +8898,20 @@ simplify_comparison (code, pop0, pop1) do this if bit endian and we don't have an extzv since we then can't know what mode to use for the endianness adjustment. */ -#if ! BITS_BIG_ENDIAN || defined (HAVE_extzv) if (GET_CODE (XEXP (op0, 0)) == CONST_INT && XEXP (op0, 1) == const1_rtx && equality_comparison_p && const_op == 0 - && (i = exact_log2 (INTVAL (XEXP (op0, 0)))) >= 0) + && (i = exact_log2 (INTVAL (XEXP (op0, 0)))) >= 0 + && (! BITS_BIG_ENDIAN +#ifdef HAVE_extzv + || HAVE_extzv +#endif + )) { -#if BITS_BIG_ENDIAN - i = (GET_MODE_BITSIZE - (insn_operand_mode[(int) CODE_FOR_extzv][1]) - 1 - i); +#ifdef HAVE_extzv + if (BITS_BIG_ENDIAN) + i = (GET_MODE_BITSIZE + (insn_operand_mode[(int) CODE_FOR_extzv][1]) - 1 - i); #endif op0 = XEXP (op0, 2); @@ -8915,7 +8922,6 @@ simplify_comparison (code, pop0, pop1) code = reverse_condition (code); continue; } -#endif /* ... fall through ... */ @@ -4581,11 +4581,12 @@ simplify_ternary_operation (code, mode, op0_mode, op0, op1, op2) /* Extracting a bit-field from a constant */ HOST_WIDE_INT val = INTVAL (op0); -#if BITS_BIG_ENDIAN - val >>= (GET_MODE_BITSIZE (op0_mode) - INTVAL (op2) - INTVAL (op1)); -#else - val >>= INTVAL (op2); -#endif + if (BITS_BIG_ENDIAN) + val >>= (GET_MODE_BITSIZE (op0_mode) + - INTVAL (op2) - INTVAL (op1)); + else + val >>= INTVAL (op2); + if (HOST_BITS_PER_WIDE_INT != INTVAL (op1)) { /* First zero-extend. */ @@ -5625,16 +5626,14 @@ gen_lowpart_if_possible (mode, x) register int offset = 0; rtx new; -#if WORDS_BIG_ENDIAN - offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) - - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); -#endif -#if BYTES_BIG_ENDIAN - /* Adjust the address so that the address-after-the-data - is unchanged. */ - offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); -#endif + if (WORDS_BIG_ENDIAN) + offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) + - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); + if (BYTES_BIG_ENDIAN) + /* Adjust the address so that the address-after-the-data is + unchanged. */ + offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); new = gen_rtx (MEM, mode, plus_constant (XEXP (x, 0), offset)); if (! memory_address_p (mode, XEXP (new, 0))) return 0; diff --git a/gcc/dbxout.c b/gcc/dbxout.c index f09d52c..ddddd40 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -2136,11 +2136,10 @@ dbxout_parms (parms) with the variable's declared type, and adjust the address if the least significant bytes (which we are using) are not the first ones. */ -#if BYTES_BIG_ENDIAN - if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) + if (BYTES_BIG_ENDIAN + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif if (GET_CODE (DECL_RTL (parms)) == MEM && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS @@ -2348,11 +2347,11 @@ dbxout_reg_parms (parms) /* A parm declared char is really passed as an int, so it occupies the least significant bytes. On a big-endian machine those are not the low-numbered ones. */ -#if BYTES_BIG_ENDIAN - if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) + if (BYTES_BIG_ENDIAN + && offset != -1 + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...} #endif dbxout_symbol_location (parms, TREE_TYPE (parms), diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index ccf436b..4287e10 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -2204,12 +2204,10 @@ location_or_const_value_attribute (decl) if (declared_type == passed_type) rtl = DECL_INCOMING_RTL (decl); -#if (BYTES_BIG_ENDIAN == 0) - else + else if (! BYTES_BIG_ENDIAN) if (TREE_CODE (declared_type) == INTEGER_TYPE) if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type)) rtl = DECL_INCOMING_RTL (decl); -#endif /* (BYTES_BIG_ENDIAN == 0) */ } if (rtl == NULL_RTX) @@ -2519,19 +2517,18 @@ bit_offset_attribute (decl) highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT; highest_order_field_bit_offset = bitpos_int; -#if (BYTES_BIG_ENDIAN == 0) - highest_order_field_bit_offset - += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)); + if (! BYTES_BIG_ENDIAN) + { + highest_order_field_bit_offset + += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)); - highest_order_object_bit_offset += simple_type_size_in_bits (type); -#endif /* (BYTES_BIG_ENDIAN == 0) */ + highest_order_object_bit_offset += simple_type_size_in_bits (type); + } bit_offset = -#if (BYTES_BIG_ENDIAN == 0) - highest_order_object_bit_offset - highest_order_field_bit_offset; -#else /* (BYTES_BIG_ENDIAN != 0) */ - highest_order_field_bit_offset - highest_order_object_bit_offset; -#endif /* (BYTES_BIG_ENDIAN != 0) */ + (! BYTES_BIG_ENDIAN + ? highest_order_object_bit_offset - highest_order_field_bit_offset + : highest_order_field_bit_offset - highest_order_object_bit_offset); ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset); ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset); diff --git a/gcc/expmed.c b/gcc/expmed.c index 6c60f6a..4db9d05 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -221,13 +221,13 @@ store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align, total_size) op0 = SUBREG_REG (op0); } -#if BYTES_BIG_ENDIAN /* If OP0 is a register, BITPOS must count within a word. But as we have it, it counts within whatever size OP0 now has. On a bigendian machine, these are not the same, so convert. */ - if (GET_CODE (op0) != MEM && unit > GET_MODE_BITSIZE (GET_MODE (op0))) + if (BYTES_BIG_ENDIAN + && GET_CODE (op0) != MEM + && unit > GET_MODE_BITSIZE (GET_MODE (op0))) bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0)); -#endif value = protect_from_queue (value, 0); @@ -261,11 +261,7 @@ store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align, total_size) can be done with a movestrict instruction. */ if (GET_CODE (op0) != MEM -#if BYTES_BIG_ENDIAN - && bitpos + bitsize == unit -#else - && bitpos == 0 -#endif + && (BYTES_BIG_ENDIAN ? bitpos + bitsize == unit : bitpos == 0) && bitsize == GET_MODE_BITSIZE (fieldmode) && (GET_MODE (op0) == fieldmode || (movstrict_optab->handlers[(int) fieldmode].insn_code @@ -450,15 +446,14 @@ store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align, total_size) /* On big-endian machines, we count bits from the most significant. If the bit field insn does not, we must invert. */ -#if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN - xbitpos = unit - bitsize - xbitpos; -#endif + if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN) + xbitpos = unit - bitsize - xbitpos; + /* We have been counting XBITPOS within UNIT. Count instead within the size of the register. */ -#if BITS_BIG_ENDIAN - if (GET_CODE (xop0) != MEM) + if (BITS_BIG_ENDIAN && GET_CODE (xop0) != MEM) xbitpos += GET_MODE_BITSIZE (maxmode) - unit; -#endif + unit = GET_MODE_BITSIZE (maxmode); /* Convert VALUE to maxmode (which insv insn wants) in VALUE1. */ @@ -606,13 +601,12 @@ store_fixed_bit_field (op0, offset, bitsize, bitpos, value, struct_align) BITPOS is the starting bit number within OP0. (OP0's mode may actually be narrower than MODE.) */ -#if BYTES_BIG_ENDIAN - /* BITPOS is the distance between our msb - and that of the containing datum. - Convert it to the distance from the lsb. */ + if (BYTES_BIG_ENDIAN) + /* BITPOS is the distance between our msb + and that of the containing datum. + Convert it to the distance from the lsb. */ + bitpos = total_bits - bitsize - bitpos; - bitpos = total_bits - bitsize - bitpos; -#endif /* Now BITPOS is always the distance between our lsb and that of OP0. */ @@ -740,29 +734,33 @@ store_split_bit_field (op0, bitsize, bitpos, value, align) thissize = MIN (bitsize - bitsdone, BITS_PER_WORD); thissize = MIN (thissize, unit - thispos); -#if BYTES_BIG_ENDIAN - /* Fetch successively less significant portions. */ - if (GET_CODE (value) == CONST_INT) - part = GEN_INT (((unsigned HOST_WIDE_INT) (INTVAL (value)) - >> (bitsize - bitsdone - thissize)) - & (((HOST_WIDE_INT) 1 << thissize) - 1)); - else - /* The args are chosen so that the last part includes the lsb. - Give extract_bit_field the value it needs (with endianness - compensation) to fetch the piece we want. */ - part = extract_fixed_bit_field (word_mode, value, 0, thissize, - GET_MODE_BITSIZE (GET_MODE (value)) - - bitsize + bitsdone, - NULL_RTX, 1, align); -#else - /* Fetch successively more significant portions. */ - if (GET_CODE (value) == CONST_INT) - part = GEN_INT (((unsigned HOST_WIDE_INT) (INTVAL (value)) >> bitsdone) - & (((HOST_WIDE_INT) 1 << thissize) - 1)); + if (BYTES_BIG_ENDIAN) + { + /* Fetch successively less significant portions. */ + if (GET_CODE (value) == CONST_INT) + part = GEN_INT (((unsigned HOST_WIDE_INT) (INTVAL (value)) + >> (bitsize - bitsdone - thissize)) + & (((HOST_WIDE_INT) 1 << thissize) - 1)); + else + /* The args are chosen so that the last part includes the + lsb. Give extract_bit_field the value it needs (with + endianness compensation) to fetch the piece we want. */ + part = extract_fixed_bit_field (word_mode, value, 0, thissize, + GET_MODE_BITSIZE (GET_MODE (value)) + - bitsize + bitsdone, + NULL_RTX, 1, align); + } else - part = extract_fixed_bit_field (word_mode, value, 0, thissize, - bitsdone, NULL_RTX, 1, align); -#endif + { + /* Fetch successively more significant portions. */ + if (GET_CODE (value) == CONST_INT) + part = GEN_INT (((unsigned HOST_WIDE_INT) (INTVAL (value)) + >> bitsdone) + & (((HOST_WIDE_INT) 1 << thissize) - 1)); + else + part = extract_fixed_bit_field (word_mode, value, 0, thissize, + bitsdone, NULL_RTX, 1, align); + } /* If OP0 is a register, then handle OFFSET here. @@ -850,13 +848,13 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, op0 = SUBREG_REG (op0); } -#if BYTES_BIG_ENDIAN /* If OP0 is a register, BITPOS must count within a word. But as we have it, it counts within whatever size OP0 now has. On a bigendian machine, these are not the same, so convert. */ - if (GET_CODE (op0) != MEM && unit > GET_MODE_BITSIZE (GET_MODE (op0))) + if (BYTES_BIG_ENDIAN && + GET_CODE (op0) != MEM + && unit > GET_MODE_BITSIZE (GET_MODE (op0))) bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0)); -#endif /* Extracting a full-word or multi-word value from a structure in a register or aligned memory. @@ -872,12 +870,9 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, && ((bitsize >= BITS_PER_WORD && bitsize == GET_MODE_BITSIZE (mode) && bitpos % BITS_PER_WORD == 0) || (mode_for_size (bitsize, GET_MODE_CLASS (tmode), 0) != BLKmode -#if BYTES_BIG_ENDIAN - && bitpos + bitsize == BITS_PER_WORD -#else - && bitpos == 0 -#endif - ))) + && (BYTES_BIG_ENDIAN + ? bitpos + bitsize == BITS_PER_WORD + : bitpos == 0)))) { enum machine_mode mode1 = mode_for_size (bitsize, GET_MODE_CLASS (tmode), 0); @@ -1050,14 +1045,13 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, /* On big-endian machines, we count bits from the most significant. If the bit field insn does not, we must invert. */ -#if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN - xbitpos = unit - bitsize - xbitpos; -#endif + if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN) + xbitpos = unit - bitsize - xbitpos; + /* Now convert from counting within UNIT to counting in MAXMODE. */ -#if BITS_BIG_ENDIAN - if (GET_CODE (xop0) != MEM) + if (BITS_BIG_ENDIAN && GET_CODE (xop0) != MEM) xbitpos += GET_MODE_BITSIZE (maxmode) - unit; -#endif + unit = GET_MODE_BITSIZE (maxmode); if (xtarget == 0 @@ -1185,15 +1179,14 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, /* On big-endian machines, we count bits from the most significant. If the bit field insn does not, we must invert. */ -#if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN - xbitpos = unit - bitsize - xbitpos; -#endif + if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN) + xbitpos = unit - bitsize - xbitpos; + /* XBITPOS counts within a size of UNIT. Adjust to count within a size of MAXMODE. */ -#if BITS_BIG_ENDIAN - if (GET_CODE (xop0) != MEM) + if (BITS_BIG_ENDIAN && GET_CODE (xop0) != MEM) xbitpos += (GET_MODE_BITSIZE (maxmode) - unit); -#endif + unit = GET_MODE_BITSIZE (maxmode); if (xtarget == 0 @@ -1347,12 +1340,14 @@ extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos, mode = GET_MODE (op0); -#if BYTES_BIG_ENDIAN - /* BITPOS is the distance between our msb and that of OP0. - Convert it to the distance from the lsb. */ + if (BYTES_BIG_ENDIAN) + { + /* BITPOS is the distance between our msb and that of OP0. + Convert it to the distance from the lsb. */ + + bitpos = total_bits - bitsize - bitpos; + } - bitpos = total_bits - bitsize - bitpos; -#endif /* Now BITPOS is always the distance between the field's lsb and that of OP0. We have reduced the big-endian case to the little-endian case. */ @@ -1570,15 +1565,18 @@ extract_split_bit_field (op0, bitsize, bitpos, unsignedp, align) bitsdone += thissize; /* Shift this part into place for the result. */ -#if BYTES_BIG_ENDIAN - if (bitsize != bitsdone) - part = expand_shift (LSHIFT_EXPR, word_mode, part, - build_int_2 (bitsize - bitsdone, 0), 0, 1); -#else - if (bitsdone != thissize) - part = expand_shift (LSHIFT_EXPR, word_mode, part, - build_int_2 (bitsdone - thissize, 0), 0, 1); -#endif + if (BYTES_BIG_ENDIAN) + { + if (bitsize != bitsdone) + part = expand_shift (LSHIFT_EXPR, word_mode, part, + build_int_2 (bitsize - bitsdone, 0), 0, 1); + } + else + { + if (bitsdone != thissize) + part = expand_shift (LSHIFT_EXPR, word_mode, part, + build_int_2 (bitsdone - thissize, 0), 0, 1); + } if (first) result = part; @@ -176,16 +176,14 @@ struct args_size enum direction {none, upward, downward}; /* Value has this type. */ #ifndef FUNCTION_ARG_PADDING -#if BYTES_BIG_ENDIAN #define FUNCTION_ARG_PADDING(MODE, TYPE) \ - (((MODE) == BLKmode \ - ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \ - && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT)) \ - : GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY) \ - ? downward : upward) -#else -#define FUNCTION_ARG_PADDING(MODE, TYPE) upward -#endif + (! BYTES_BIG_ENDIAN \ + ? upward \ + : (((MODE) == BLKmode \ + ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \ + && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT)) \ + : GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY) \ + ? downward : upward)) #endif /* Supply a default definition for FUNCTION_ARG_BOUNDARY. Normally, we let @@ -212,12 +210,6 @@ enum direction {none, upward, downward}; /* Value has this type. */ So a value padded in memory at the upper end can't go in a register. For a little-endian machine, the reverse is true. */ -#if BYTES_BIG_ENDIAN -#define MUST_PASS_IN_STACK_BAD_PADDING upward -#else -#define MUST_PASS_IN_STACK_BAD_PADDING downward -#endif - #define MUST_PASS_IN_STACK(MODE,TYPE) \ ((TYPE) != 0 \ && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \ @@ -227,7 +219,7 @@ enum direction {none, upward, downward}; /* Value has this type. */ && 0 == (int_size_in_bytes (TYPE) \ % (PARM_BOUNDARY / BITS_PER_UNIT))) \ && (FUNCTION_ARG_PADDING (MODE, TYPE) \ - == MUST_PASS_IN_STACK_BAD_PADDING)))) + == (BYTES_BIG_ENDIAN ? upward : downward))))) /* Nonzero if type TYPE should be returned in memory. Most machines can use the following default definition. */ diff --git a/gcc/final.c b/gcc/final.c index 61a90a9..b046d78 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2077,10 +2077,9 @@ alter_subreg (x) else if (GET_CODE (y) == MEM) { register int offset = SUBREG_WORD (x) * UNITS_PER_WORD; -#if BYTES_BIG_ENDIAN - offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (y)))); -#endif + if (BYTES_BIG_ENDIAN) + offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (y)))); PUT_CODE (x, MEM); MEM_VOLATILE_P (x) = MEM_VOLATILE_P (y); XEXP (x, 0) = plus_constant (XEXP (y, 0), offset); @@ -2839,23 +2838,29 @@ split_double (value, first, second) is that we regard the value as signed. So sign-extend it. */ rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx); -#if WORDS_BIG_ENDIAN - *first = high; - *second = value; -#else - *first = value; - *second = high; -#endif + if (WORDS_BIG_ENDIAN) + { + *first = high; + *second = value; + } + else + { + *first = value; + *second = high; + } } else if (GET_CODE (value) != CONST_DOUBLE) { -#if WORDS_BIG_ENDIAN - *first = const0_rtx; - *second = value; -#else - *first = value; - *second = const0_rtx; -#endif + if (WORDS_BIG_ENDIAN) + { + *first = const0_rtx; + *second = value; + } + else + { + *first = value; + *second = const0_rtx; + } } else if (GET_MODE (value) == VOIDmode /* This is the old way we did CONST_DOUBLE integers. */ @@ -2863,13 +2868,16 @@ split_double (value, first, second) { /* In an integer, the words are defined as most and least significant. So order them by the target's convention. */ -#if WORDS_BIG_ENDIAN - *first = GEN_INT (CONST_DOUBLE_HIGH (value)); - *second = GEN_INT (CONST_DOUBLE_LOW (value)); -#else - *first = GEN_INT (CONST_DOUBLE_LOW (value)); - *second = GEN_INT (CONST_DOUBLE_HIGH (value)); -#endif + if (WORDS_BIG_ENDIAN) + { + *first = GEN_INT (CONST_DOUBLE_HIGH (value)); + *second = GEN_INT (CONST_DOUBLE_LOW (value)); + } + else + { + *first = GEN_INT (CONST_DOUBLE_LOW (value)); + *second = GEN_INT (CONST_DOUBLE_HIGH (value)); + } } else { @@ -2891,14 +2899,23 @@ split_double (value, first, second) && ! flag_pretend_float) abort (); -#if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN - /* Host and target agree => no need to swap. */ - *first = GEN_INT (CONST_DOUBLE_LOW (value)); - *second = GEN_INT (CONST_DOUBLE_HIGH (value)); + if ( +#ifdef HOST_WORDS_BIG_ENDIAN + WORDS_BIG_ENDIAN #else - *second = GEN_INT (CONST_DOUBLE_LOW (value)); - *first = GEN_INT (CONST_DOUBLE_HIGH (value)); + ! WORDS_BIG_ENDIAN #endif + ) + { + /* Host and target agree => no need to swap. */ + *first = GEN_INT (CONST_DOUBLE_LOW (value)); + *second = GEN_INT (CONST_DOUBLE_HIGH (value)); + } + else + { + *second = GEN_INT (CONST_DOUBLE_LOW (value)); + *first = GEN_INT (CONST_DOUBLE_HIGH (value)); + } #endif /* no REAL_ARITHMETIC */ } } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 54ac733..d286f27 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2267,9 +2267,8 @@ optimize_bit_field_compare (code, compare_type, lhs, rhs) return 0; } -#if BYTES_BIG_ENDIAN - lbitpos = lnbitsize - lbitsize - lbitpos; -#endif + if (BYTES_BIG_ENDIAN) + lbitpos = lnbitsize - lbitsize - lbitpos; /* Make the mask to be used against the extracted field. */ mask = build_int_2 (~0, ~0); @@ -2818,10 +2817,11 @@ fold_truthop (code, truth_type, lhs, rhs) type = type_for_size (lnbitsize, 1); xll_bitpos = ll_bitpos - lnbitpos, xrl_bitpos = rl_bitpos - lnbitpos; -#if BYTES_BIG_ENDIAN - xll_bitpos = lnbitsize - xll_bitpos - ll_bitsize; - xrl_bitpos = lnbitsize - xrl_bitpos - rl_bitsize; -#endif + if (BYTES_BIG_ENDIAN) + { + xll_bitpos = lnbitsize - xll_bitpos - ll_bitsize; + xrl_bitpos = lnbitsize - xrl_bitpos - rl_bitsize; + } ll_mask = const_binop (LSHIFT_EXPR, convert (type, ll_mask), size_int (xll_bitpos), 0); @@ -2870,10 +2870,11 @@ fold_truthop (code, truth_type, lhs, rhs) rnbitpos = first_bit & ~ (rnbitsize - 1); xlr_bitpos = lr_bitpos - rnbitpos, xrr_bitpos = rr_bitpos - rnbitpos; -#if BYTES_BIG_ENDIAN - xlr_bitpos = rnbitsize - xlr_bitpos - lr_bitsize; - xrr_bitpos = rnbitsize - xrr_bitpos - rr_bitsize; -#endif + if (BYTES_BIG_ENDIAN) + { + xlr_bitpos = rnbitsize - xlr_bitpos - lr_bitsize; + xrr_bitpos = rnbitsize - xrr_bitpos - rr_bitsize; + } lr_mask = const_binop (LSHIFT_EXPR, convert (type, lr_mask), size_int (xlr_bitpos), 0); diff --git a/gcc/function.c b/gcc/function.c index 3f482af..3811835 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -682,10 +682,8 @@ assign_stack_local (mode, size, align) /* On a big-endian machine, if we are allocating more space than we will use, use the least significant bytes of those that are allocated. */ -#if BYTES_BIG_ENDIAN - if (mode != BLKmode) + if (BYTES_BIG_ENDIAN && mode != BLKmode) bigend_correction = size - GET_MODE_SIZE (mode); -#endif #ifdef FRAME_GROWS_DOWNWARD frame_offset -= size; @@ -755,10 +753,8 @@ assign_outer_stack_local (mode, size, align, function) /* On a big-endian machine, if we are allocating more space than we will use, use the least significant bytes of those that are allocated. */ -#if BYTES_BIG_ENDIAN - if (mode != BLKmode) + if (BYTES_BIG_ENDIAN && mode != BLKmode) bigend_correction = size - GET_MODE_SIZE (mode); -#endif #ifdef FRAME_GROWS_DOWNWARD function->frame_offset -= size; @@ -1703,10 +1699,9 @@ fixup_var_refs_1 (var, promoted_mode, loc, insn, replacements) /* If the bytes and bits are counted differently, we must adjust the offset. */ -#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN - offset = (GET_MODE_SIZE (is_mode) - - GET_MODE_SIZE (wanted_mode) - offset); -#endif + if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN) + offset = (GET_MODE_SIZE (is_mode) + - GET_MODE_SIZE (wanted_mode) - offset); pos %= GET_MODE_BITSIZE (wanted_mode); @@ -1876,10 +1871,9 @@ fixup_var_refs_1 (var, promoted_mode, loc, insn, replacements) rtx old_pos = XEXP (outerdest, 2); rtx newmem; -#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN - offset = (GET_MODE_SIZE (is_mode) - - GET_MODE_SIZE (wanted_mode) - offset); -#endif + if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN) + offset = (GET_MODE_SIZE (is_mode) + - GET_MODE_SIZE (wanted_mode) - offset); pos %= GET_MODE_BITSIZE (wanted_mode); @@ -2088,10 +2082,9 @@ fixup_memory_subreg (x, insn, uncritical) && ! uncritical) abort (); -#if BYTES_BIG_ENDIAN - offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); -#endif + if (BYTES_BIG_ENDIAN) + offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); addr = plus_constant (addr, offset); if (!flag_force_addr && memory_address_p (mode, addr)) /* Shortcut if no insns need be emitted. */ @@ -2271,21 +2264,20 @@ optimize_bit_field (body, insn, equiv_mem) rtx insns; /* Adjust OFFSET to count bits from low-address byte. */ -#if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN - offset = (GET_MODE_BITSIZE (GET_MODE (XEXP (bitfield, 0))) - - offset - INTVAL (XEXP (bitfield, 1))); -#endif + if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN) + offset = (GET_MODE_BITSIZE (GET_MODE (XEXP (bitfield, 0))) + - offset - INTVAL (XEXP (bitfield, 1))); + /* Adjust OFFSET to count bytes from low-address byte. */ offset /= BITS_PER_UNIT; if (GET_CODE (XEXP (bitfield, 0)) == SUBREG) { offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD; -#if BYTES_BIG_ENDIAN - offset -= (MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0)))) - - MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (memref)))); -#endif + if (BYTES_BIG_ENDIAN) + offset -= (MIN (UNITS_PER_WORD, + GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0)))) + - MIN (UNITS_PER_WORD, + GET_MODE_SIZE (GET_MODE (memref)))); } start_sequence (); @@ -3454,11 +3446,10 @@ assign_parms (fndecl, second_time) { rtx offset_rtx; -#if BYTES_BIG_ENDIAN - if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD) + if (BYTES_BIG_ENDIAN + && GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD) stack_offset.constant += (GET_MODE_SIZE (passed_mode) - GET_MODE_SIZE (nominal_mode)); -#endif offset_rtx = ARGS_SIZE_RTX (stack_offset); if (offset_rtx == const0_rtx) @@ -516,17 +516,16 @@ jump_optimize (f, cross_jump, noop_moves, after_regscan) if (i < 0) delete_insn (insn); } -#if !BYTES_BIG_ENDIAN /* Not worth the hair to detect this - in the big-endian case. */ /* Also delete insns to store bit fields if they are no-ops. */ - else if (GET_CODE (body) == SET + /* Not worth the hair to detect this in the big-endian case. */ + else if (! BYTES_BIG_ENDIAN + && GET_CODE (body) == SET && GET_CODE (SET_DEST (body)) == ZERO_EXTRACT && XEXP (SET_DEST (body), 2) == const0_rtx && XEXP (SET_DEST (body), 0) == SET_SRC (body) && ! (GET_CODE (SET_SRC (body)) == MEM && MEM_VOLATILE_P (SET_SRC (body)))) delete_insn (insn); -#endif /* not BYTES_BIG_ENDIAN */ } insn = next; } diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 63a7114..247b835 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -40,6 +40,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #undef abort #endif +/* Permit the tm.h file to select the endianness to use just for this + file. This is used when the endianness is determined when the + compiler is run. */ + +#ifndef LIBGCC2_WORDS_BIG_ENDIAN +#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN +#endif + /* In the first part of this file, we are interfacing to calls generated by the compiler itself. These calls pass values into these routines which have very specific modes (rather than very specific types), and @@ -90,9 +98,9 @@ typedef int word_type __attribute__ ((mode (DI))); #define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT) /* DIstructs are pairs of SItype values in the order determined by - WORDS_BIG_ENDIAN. */ + LIBGCC2_WORDS_BIG_ENDIAN. */ -#if WORDS_BIG_ENDIAN +#if LIBGCC2_WORDS_BIG_ENDIAN struct DIstruct {SItype high, low;}; #else struct DIstruct {SItype low, high;}; diff --git a/gcc/mips-tfile.c b/gcc/mips-tfile.c index 75336106..1269237 100644 --- a/gcc/mips-tfile.c +++ b/gcc/mips-tfile.c @@ -1159,7 +1159,7 @@ static efdr_t init_file = langC, /* lang: language for this file */ 1, /* fMerge: whether this file can be merged */ 0, /* fReadin: true if read in (not just created) */ -#if BYTES_BIG_ENDIAN +#ifdef HOST_WORDS_BIG_ENDIAN 1, /* fBigendian: if 1, compiled on big endian machine */ #else 0, /* fBigendian: if 1, compiled on big endian machine */ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 4f89d5a..937384d 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2462,11 +2462,9 @@ forwarding_offset (parm) with the variable's declared type, and adjust the address if the least significant bytes (which we are using) are not the first ones. */ -#if BYTES_BIG_ENDIAN - if (TREE_TYPE (parm) != DECL_ARG_TYPE (parm)) + if (BYTES_BIG_ENDIAN && TREE_TYPE (parm) != DECL_ARG_TYPE (parm)) offset_in_bytes += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm))) - GET_MODE_SIZE (GET_MODE (DECL_RTL (parm)))); -#endif return offset_in_bytes; } @@ -58,19 +58,21 @@ transcendental functions can be obtained by ftp from research.att.com: netlib/cephes/ldouble.shar.Z */ /* Type of computer arithmetic. - Only one of DEC, IBM, MIEEE, IBMPC, or UNK should get defined. - - `MIEEE' refers generically to big-endian IEEE floating-point data - structure. This definition should work in SFmode `float' type and - DFmode `double' type on virtually all big-endian IEEE machines. - If LONG_DOUBLE_TYPE_SIZE has been defined to be 96, then MIEEE - also invokes the particular XFmode (`long double' type) data - structure used by the Motorola 680x0 series processors. - - `IBMPC' refers generally to little-endian IEEE machines. In this - case, if LONG_DOUBLE_TYPE_SIZE has been defined to be 96, then - IBMPC also invokes the particular XFmode `long double' data - structure used by the Intel 80x86 series processors. + Only one of DEC, IBM, IEEE, or UNK should get defined. + + `IEEE', when FLOAT_WORDS_BIG_ENDIAN is non-zero, refers generically + to big-endian IEEE floating-point data structure. This definition + should work in SFmode `float' type and DFmode `double' type on + virtually all big-endian IEEE machines. If LONG_DOUBLE_TYPE_SIZE + has been defined to be 96, then IEEE also invokes the particular + XFmode (`long double' type) data structure used by the Motorola + 680x0 series processors. + + `IEEE', when FLOAT_WORDS_BIG_ENDIAN is zero, refers generally to + little-endian IEEE machines. In this case, if LONG_DOUBLE_TYPE_SIZE + has been defined to be 96, then IEEE also invokes the particular + XFmode `long double' data structure used by the Intel 80x86 series + processors. `DEC' refers specifically to the Digital Equipment Corp PDP-11 and VAX floating point data structure. This model currently @@ -119,14 +121,7 @@ research.att.com: netlib/cephes/ldouble.shar.Z */ #define IBM 1 #else /* it's also not an IBM */ #if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT -#if FLOAT_WORDS_BIG_ENDIAN -/* Motorola IEEE, high order words come first (Sun workstation): */ -#define MIEEE 1 -#else /* not big-endian */ -/* Intel IEEE, low order words come first: - */ -#define IBMPC 1 -#endif /* big-endian */ +#define IEEE #else /* it's not IEEE either */ /* UNKnown arithmetic. We don't support this and can't go on. */ unknown arithmetic type @@ -150,11 +145,7 @@ unknown arithmetic type #define IBM 1 #else /* it's also not an IBM */ #if HOST_FLOAT_FORMAT == IEEE_FLOAT_FORMAT -#if HOST_FLOAT_WORDS_BIG_ENDIAN -#define MIEEE 1 -#else /* not big-endian */ -#define IBMPC 1 -#endif /* big-endian */ +#define IEEE #else /* it's not IEEE either */ unknown arithmetic type #define UNK 1 @@ -263,29 +254,35 @@ unknown arithmetic type /* Emulator uses target format internally but host stores it in host endian-ness. */ -#if HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN -#define GET_REAL(r,e) e53toe ((unsigned EMUSHORT*) (r), (e)) -#define PUT_REAL(e,r) etoe53 ((e), (unsigned EMUSHORT *) (r)) - -#else /* endian-ness differs */ -/* emulator uses target endian-ness internally */ -#define GET_REAL(r,e) \ -do { unsigned EMUSHORT w[4]; \ - w[3] = ((EMUSHORT *) r)[0]; \ - w[2] = ((EMUSHORT *) r)[1]; \ - w[1] = ((EMUSHORT *) r)[2]; \ - w[0] = ((EMUSHORT *) r)[3]; \ - e53toe (w, (e)); } while (0) - -#define PUT_REAL(e,r) \ -do { unsigned EMUSHORT w[4]; \ - etoe53 ((e), w); \ - *((EMUSHORT *) r) = w[3]; \ - *((EMUSHORT *) r + 1) = w[2]; \ - *((EMUSHORT *) r + 2) = w[1]; \ - *((EMUSHORT *) r + 3) = w[0]; } while (0) - -#endif /* endian-ness differs */ +#define GET_REAL(r,e) \ +do { \ + if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \ + e53toe ((unsigned EMUSHORT*) (r), (e)); \ + else \ + { \ + unsigned EMUSHORT w[4]; \ + w[3] = ((EMUSHORT *) r)[0]; \ + w[2] = ((EMUSHORT *) r)[1]; \ + w[1] = ((EMUSHORT *) r)[2]; \ + w[0] = ((EMUSHORT *) r)[3]; \ + e53toe (w, (e)); \ + } \ + } while (0) + +#define PUT_REAL(e,r) \ +do { \ + if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \ + etoe53 ((e), (unsigned EMUSHORT *) (r)); \ + else \ + { \ + unsigned EMUSHORT w[4]; \ + etoe53 ((e), w); \ + *((EMUSHORT *) r) = w[3]; \ + *((EMUSHORT *) r + 1) = w[2]; \ + *((EMUSHORT *) r + 2) = w[1]; \ + *((EMUSHORT *) r + 3) = w[0]; \ + } \ + } while (0) #else /* not REAL_ARITHMETIC */ @@ -436,99 +433,99 @@ endian (e, x, mode) { unsigned long th, t; -#if FLOAT_WORDS_BIG_ENDIAN - switch (mode) + if (FLOAT_WORDS_BIG_ENDIAN) { + switch (mode) + { - case TFmode: - /* Swap halfwords in the fourth long. */ - th = (unsigned long) e[6] & 0xffff; - t = (unsigned long) e[7] & 0xffff; - t |= th << 16; - x[3] = (long) t; - - case XFmode: - - /* Swap halfwords in the third long. */ - th = (unsigned long) e[4] & 0xffff; - t = (unsigned long) e[5] & 0xffff; - t |= th << 16; - x[2] = (long) t; - /* fall into the double case */ - - case DFmode: - - /* swap halfwords in the second word */ - th = (unsigned long) e[2] & 0xffff; - t = (unsigned long) e[3] & 0xffff; - t |= th << 16; - x[1] = (long) t; - /* fall into the float case */ - - case HFmode: - case SFmode: - - /* swap halfwords in the first word */ - th = (unsigned long) e[0] & 0xffff; - t = (unsigned long) e[1] & 0xffff; - t |= th << 16; - x[0] = t; - break; + case TFmode: + /* Swap halfwords in the fourth long. */ + th = (unsigned long) e[6] & 0xffff; + t = (unsigned long) e[7] & 0xffff; + t |= th << 16; + x[3] = (long) t; + + case XFmode: + + /* Swap halfwords in the third long. */ + th = (unsigned long) e[4] & 0xffff; + t = (unsigned long) e[5] & 0xffff; + t |= th << 16; + x[2] = (long) t; + /* fall into the double case */ + + case DFmode: + + /* swap halfwords in the second word */ + th = (unsigned long) e[2] & 0xffff; + t = (unsigned long) e[3] & 0xffff; + t |= th << 16; + x[1] = (long) t; + /* fall into the float case */ + + case HFmode: + case SFmode: + + /* swap halfwords in the first word */ + th = (unsigned long) e[0] & 0xffff; + t = (unsigned long) e[1] & 0xffff; + t |= th << 16; + x[0] = t; + break; - default: - abort (); + default: + abort (); + } } - -#else - - /* Pack the output array without swapping. */ - - switch (mode) + else { + /* Pack the output array without swapping. */ - case TFmode: - - /* Pack the fourth long. */ - th = (unsigned long) e[7] & 0xffff; - t = (unsigned long) e[6] & 0xffff; - t |= th << 16; - x[3] = (long) t; - - case XFmode: - - /* Pack the third long. - Each element of the input REAL_VALUE_TYPE array has 16 useful bits - in it. */ - th = (unsigned long) e[5] & 0xffff; - t = (unsigned long) e[4] & 0xffff; - t |= th << 16; - x[2] = (long) t; - /* fall into the double case */ - - case DFmode: - - /* pack the second long */ - th = (unsigned long) e[3] & 0xffff; - t = (unsigned long) e[2] & 0xffff; - t |= th << 16; - x[1] = (long) t; - /* fall into the float case */ - - case HFmode: - case SFmode: + switch (mode) + { - /* pack the first long */ - th = (unsigned long) e[1] & 0xffff; - t = (unsigned long) e[0] & 0xffff; - t |= th << 16; - x[0] = t; - break; + case TFmode: + + /* Pack the fourth long. */ + th = (unsigned long) e[7] & 0xffff; + t = (unsigned long) e[6] & 0xffff; + t |= th << 16; + x[3] = (long) t; + + case XFmode: + + /* Pack the third long. + Each element of the input REAL_VALUE_TYPE array has 16 useful bits + in it. */ + th = (unsigned long) e[5] & 0xffff; + t = (unsigned long) e[4] & 0xffff; + t |= th << 16; + x[2] = (long) t; + /* fall into the double case */ + + case DFmode: + + /* pack the second long */ + th = (unsigned long) e[3] & 0xffff; + t = (unsigned long) e[2] & 0xffff; + t |= th << 16; + x[1] = (long) t; + /* fall into the float case */ + + case HFmode: + case SFmode: + + /* pack the first long */ + th = (unsigned long) e[1] & 0xffff; + t = (unsigned long) e[0] & 0xffff; + t |= th << 16; + x[0] = t; + break; - default: - abort (); + default: + abort (); + } } - -#endif } @@ -1223,6 +1220,8 @@ ereal_isneg (x) Std 754-1985), the symbol IBMPC or MIEEE should be defined. These numbers have 53-bit significands. In this mode, constants are provided as arrays of hexadecimal 16 bit integers. + [This has been changed to instead check the preprocessor macros IEEE + and FLOAT_WORDS_BIG_ENDIAN]. To accommodate other types of computer arithmetic, all constants are also provided in a normal decimal radix @@ -2841,9 +2840,8 @@ e53toe (pe, y) e = pe; denorm = 0; /* flag if denormalized number */ ecleaz (yy); -#ifdef IBMPC - e += 3; -#endif + if (! FLOAT_WORDS_BIG_ENDIAN) + e += 3; r = *e; yy[0] = 0; if (r & 0x8000) @@ -2854,21 +2852,24 @@ e53toe (pe, y) if (r == 0x7ff0) { #ifdef NANS -#ifdef IBMPC - if (((pe[3] & 0xf) != 0) || (pe[2] != 0) - || (pe[1] != 0) || (pe[0] != 0)) + if (! FLOAT_WORDS_BIG_ENDIAN) { - enan (y, yy[0] != 0); - return; + if (((pe[3] & 0xf) != 0) || (pe[2] != 0) + || (pe[1] != 0) || (pe[0] != 0)) + { + enan (y, yy[0] != 0); + return; + } } -#else - if (((pe[0] & 0xf) != 0) || (pe[1] != 0) - || (pe[2] != 0) || (pe[3] != 0)) + else { - enan (y, yy[0] != 0); - return; + if (((pe[0] & 0xf) != 0) || (pe[1] != 0) + || (pe[2] != 0) || (pe[3] != 0)) + { + enan (y, yy[0] != 0); + return; + } } -#endif #endif /* NANS */ eclear (y); einfin (y); @@ -2889,16 +2890,20 @@ e53toe (pe, y) r += EXONE - 01777; yy[E] = r; p = &yy[M + 1]; -#ifdef IBMPC - *p++ = *(--e); - *p++ = *(--e); - *p++ = *(--e); -#endif -#ifdef MIEEE - ++e; - *p++ = *e++; - *p++ = *e++; - *p++ = *e++; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + { + *p++ = *(--e); + *p++ = *(--e); + *p++ = *(--e); + } + else + { + ++e; + *p++ = *e++; + *p++ = *e++; + *p++ = *e++; + } #endif eshift (yy, -5); if (denorm) @@ -2925,10 +2930,6 @@ e64toe (pe, y) p = yy; for (i = 0; i < NE - 5; i++) *p++ = 0; -#ifdef IBMPC - for (i = 0; i < 5; i++) - *p++ = *e++; -#endif /* This precision is not ordinarily supported on DEC or IBM. */ #ifdef DEC for (i = 0; i < 5; i++) @@ -2941,12 +2942,20 @@ e64toe (pe, y) for (i = 0; i < 5; i++) *p-- = *e++; #endif -#ifdef MIEEE - p = &yy[0] + (NE - 1); - *p-- = *e++; - ++e; - for (i = 0; i < 4; i++) - *p-- = *e++; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + { + for (i = 0; i < 5; i++) + *p++ = *e++; + } + else + { + p = &yy[0] + (NE - 1); + *p-- = *e++; + ++e; + for (i = 0; i < 4; i++) + *p-- = *e++; + } #endif p = yy; q = y; @@ -2954,25 +2963,28 @@ e64toe (pe, y) if (*p == 0x7fff) { #ifdef NANS -#ifdef IBMPC - for (i = 0; i < 4; i++) + if (! FLOAT_WORDS_BIG_ENDIAN) { - if (pe[i] != 0) + for (i = 0; i < 4; i++) { - enan (y, (*p & 0x8000) != 0); - return; + if (pe[i] != 0) + { + enan (y, (*p & 0x8000) != 0); + return; + } } } -#else - for (i = 1; i <= 4; i++) + else { - if (pe[i] != 0) + for (i = 1; i <= 4; i++) { - enan (y, (*p & 0x8000) != 0); - return; + if (pe[i] != 0) + { + enan (y, (*p & 0x8000) != 0); + return; + } } } -#endif #endif /* NANS */ eclear (y); einfin (y); @@ -2998,8 +3010,9 @@ e113toe (pe, y) e = pe; denorm = 0; ecleaz (yy); -#ifdef IBMPC - e += 7; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + e += 7; #endif r = *e; yy[0] = 0; @@ -3010,25 +3023,28 @@ e113toe (pe, y) if (r == 0x7fff) { #ifdef NANS -#ifdef IBMPC - for (i = 0; i < 7; i++) + if (! FLOAT_WORDS_BIG_ENDIAN) { - if (pe[i] != 0) + for (i = 0; i < 7; i++) { - enan (y, yy[0] != 0); - return; + if (pe[i] != 0) + { + enan (y, yy[0] != 0); + return; + } } } -#else - for (i = 1; i < 8; i++) + else { - if (pe[i] != 0) + for (i = 1; i < 8; i++) { - enan (y, yy[0] != 0); - return; + if (pe[i] != 0) + { + enan (y, yy[0] != 0); + return; + } } } -#endif #endif /* NANS */ eclear (y); einfin (y); @@ -3039,14 +3055,18 @@ e113toe (pe, y) #endif /* INFINITY */ yy[E] = r; p = &yy[M + 1]; -#ifdef IBMPC - for (i = 0; i < 7; i++) - *p++ = *(--e); -#endif -#ifdef MIEEE - ++e; - for (i = 0; i < 7; i++) - *p++ = *e++; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + { + for (i = 0; i < 7; i++) + *p++ = *(--e); + } + else + { + ++e; + for (i = 0; i < 7; i++) + *p++ = *e++; + } #endif /* If denormal, remove the implied bit; else shift down 1. */ if (r == 0) @@ -3081,8 +3101,9 @@ e24toe (pe, y) e = pe; denorm = 0; /* flag if denormalized number */ ecleaz (yy); -#ifdef IBMPC - e += 1; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + e += 1; #endif #ifdef DEC e += 1; @@ -3097,19 +3118,22 @@ e24toe (pe, y) if (r == 0x7f80) { #ifdef NANS -#ifdef MIEEE - if (((pe[0] & 0x7f) != 0) || (pe[1] != 0)) + if (FLOAT_WORDS_BIG_ENDIAN) { - enan (y, yy[0] != 0); - return; + if (((pe[0] & 0x7f) != 0) || (pe[1] != 0)) + { + enan (y, yy[0] != 0); + return; + } } -#else - if (((pe[1] & 0x7f) != 0) || (pe[0] != 0)) + else { - enan (y, yy[0] != 0); - return; + if (((pe[1] & 0x7f) != 0) || (pe[0] != 0)) + { + enan (y, yy[0] != 0); + return; + } } -#endif #endif /* NANS */ eclear (y); einfin (y); @@ -3129,15 +3153,17 @@ e24toe (pe, y) r += EXONE - 0177; yy[E] = r; p = &yy[M + 1]; -#ifdef IBMPC - *p++ = *(--e); -#endif #ifdef DEC *p++ = *(--e); #endif -#ifdef MIEEE - ++e; - *p++ = *e++; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + *p++ = *(--e); + else + { + ++e; + *p++ = *e++; + } #endif eshift (yy, -8); if (denorm) @@ -3199,11 +3225,10 @@ toe113 (a, b) } #endif p = a; -#ifdef MIEEE - q = b; -#else - q = b + 7; /* point to output exponent */ -#endif + if (FLOAT_WORDS_BIG_ENDIAN) + q = b; + else + q = b + 7; /* point to output exponent */ /* If not denormal, delete the implied bit. */ if (a[E] != 0) @@ -3212,27 +3237,33 @@ toe113 (a, b) } /* combine sign and exponent */ i = *p++; -#ifdef MIEEE - if (i) - *q++ = *p++ | 0x8000; - else - *q++ = *p++; -#else - if (i) - *q-- = *p++ | 0x8000; + if (FLOAT_WORDS_BIG_ENDIAN) + { + if (i) + *q++ = *p++ | 0x8000; + else + *q++ = *p++; + } else - *q-- = *p++; -#endif + { + if (i) + *q-- = *p++ | 0x8000; + else + *q-- = *p++; + } /* skip over guard word */ ++p; /* move the significand */ -#ifdef MIEEE - for (i = 0; i < 7; i++) - *q++ = *p++; -#else - for (i = 0; i < 7; i++) - *q-- = *p++; -#endif + if (FLOAT_WORDS_BIG_ENDIAN) + { + for (i = 0; i < 7; i++) + *q++ = *p++; + } + else + { + for (i = 0; i < 7; i++) + *q-- = *p++; + } } static void @@ -3284,40 +3315,80 @@ toe64 (a, b) } #endif p = a; -#if defined(MIEEE) || defined(IBM) +#ifdef IBM q = b; -#else - q = b + 4; /* point to output exponent */ +#endif +#ifdef DEC + q = b + 4; +#endif +#ifdef IEEE + if (FLOAT_WORDS_BIG_ENDIAN) + q = b; + else + { + q = b + 4; /* point to output exponent */ #if LONG_DOUBLE_TYPE_SIZE == 96 - /* Clear the last two bytes of 12-byte Intel format */ - *(q+1) = 0; + /* Clear the last two bytes of 12-byte Intel format */ + *(q+1) = 0; #endif + } #endif /* combine sign and exponent */ i = *p++; -#if defined(MIEEE) || defined(IBM) +#ifdef IBM if (i) *q++ = *p++ | 0x8000; else *q++ = *p++; *q++ = 0; -#else +#endif +#ifdef DEC if (i) *q-- = *p++ | 0x8000; else *q-- = *p++; #endif +#ifdef IEEE + if (FLOAT_WORDS_BIG_ENDIAN) + { + if (i) + *q++ = *p++ | 0x8000; + else + *q++ = *p++; + *q++ = 0; + } + else + { + if (i) + *q-- = *p++ | 0x8000; + else + *q-- = *p++; + } +#endif /* skip over guard word */ ++p; /* move the significand */ -#if defined(MIEEE) || defined(IBM) +#ifdef IBM for (i = 0; i < 4; i++) *q++ = *p++; -#else +#endif +#ifdef DEC for (i = 0; i < 4; i++) *q-- = *p++; #endif +#ifdef IEEE + if (FLOAT_WORDS_BIG_ENDIAN) + { + for (i = 0; i < 4; i++) + *q++ = *p++; + } + else + { + for (i = 0; i < 4; i++) + *q-- = *p++; + } +#endif } @@ -3405,8 +3476,9 @@ toe53 (x, y) } #endif p = &x[0]; -#ifdef IBMPC - y += 3; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + y += 3; #endif *y = 0; /* output high order */ if (*p++) @@ -3417,30 +3489,34 @@ toe53 (x, y) { /* Saturate at largest number less than infinity. */ #ifdef INFINITY *y |= 0x7ff0; -#ifdef IBMPC - *(--y) = 0; - *(--y) = 0; - *(--y) = 0; -#endif -#ifdef MIEEE - ++y; - *y++ = 0; - *y++ = 0; - *y++ = 0; -#endif + if (! FLOAT_WORDS_BIG_ENDIAN) + { + *(--y) = 0; + *(--y) = 0; + *(--y) = 0; + } + else + { + ++y; + *y++ = 0; + *y++ = 0; + *y++ = 0; + } #else *y |= (unsigned EMUSHORT) 0x7fef; -#ifdef IBMPC - *(--y) = 0xffff; - *(--y) = 0xffff; - *(--y) = 0xffff; -#endif -#ifdef MIEEE - ++y; - *y++ = 0xffff; - *y++ = 0xffff; - *y++ = 0xffff; -#endif + if (! FLOAT_WORDS_BIG_ENDIAN) + { + *(--y) = 0xffff; + *(--y) = 0xffff; + *(--y) = 0xffff; + } + else + { + ++y; + *y++ = 0xffff; + *y++ = 0xffff; + *y++ = 0xffff; + } #endif return; } @@ -3455,17 +3531,19 @@ toe53 (x, y) } i |= *p++ & (unsigned EMUSHORT) 0x0f; /* *p = xi[M] */ *y |= (unsigned EMUSHORT) i; /* high order output already has sign bit set */ -#ifdef IBMPC - *(--y) = *p++; - *(--y) = *p++; - *(--y) = *p; -#endif -#ifdef MIEEE - ++y; - *y++ = *p++; - *y++ = *p++; - *y++ = *p++; -#endif + if (! FLOAT_WORDS_BIG_ENDIAN) + { + *(--y) = *p++; + *(--y) = *p++; + *(--y) = *p; + } + else + { + ++y; + *y++ = *p++; + *y++ = *p++; + *y++ = *p++; + } } #endif /* not IBM */ @@ -3539,8 +3617,9 @@ toe24 (x, y) } #endif p = &x[0]; -#ifdef IBMPC - y += 1; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + y += 1; #endif #ifdef DEC y += 1; @@ -3555,27 +3634,31 @@ toe24 (x, y) { #ifdef INFINITY *y |= (unsigned EMUSHORT) 0x7f80; -#ifdef IBMPC - *(--y) = 0; -#endif #ifdef DEC *(--y) = 0; #endif -#ifdef MIEEE - ++y; - *y = 0; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + *(--y) = 0; + else + { + ++y; + *y = 0; + } #endif #else /* no INFINITY */ *y |= (unsigned EMUSHORT) 0x7f7f; -#ifdef IBMPC - *(--y) = 0xffff; -#endif #ifdef DEC *(--y) = 0xffff; #endif -#ifdef MIEEE - ++y; - *y = 0xffff; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + *(--y) = 0xffff; + else + { + ++y; + *y = 0xffff; + } #endif #ifdef ERANGE errno = ERANGE; @@ -3594,15 +3677,17 @@ toe24 (x, y) } i |= *p++ & (unsigned EMUSHORT) 0x7f; /* *p = xi[M] */ *y |= i; /* high order output already has sign bit set */ -#ifdef IBMPC - *(--y) = *p; -#endif #ifdef DEC *(--y) = *p; #endif -#ifdef MIEEE - ++y; - *y = *p; +#ifdef IEEE + if (! FLOAT_WORDS_BIG_ENDIAN) + *(--y) = *p; + else + { + ++y; + *y = *p; + } #endif } #endif /* not IBM */ @@ -5400,45 +5485,38 @@ toibm (x, y, mode) #ifdef TFMODE_NAN TFMODE_NAN; #else -#ifdef MIEEE -unsigned EMUSHORT TFnan[8] = +#ifdef IEEE +unsigned EMUSHORT TFbignan[8] = {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}; -#endif -#ifdef IBMPC -unsigned EMUSHORT TFnan[8] = {0, 0, 0, 0, 0, 0, 0x8000, 0xffff}; +unsigned EMUSHORT TFlittlenan[8] = {0, 0, 0, 0, 0, 0, 0x8000, 0xffff}; #endif #endif #ifdef XFMODE_NAN XFMODE_NAN; #else -#ifdef MIEEE -unsigned EMUSHORT XFnan[6] = {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}; -#endif -#ifdef IBMPC -unsigned EMUSHORT XFnan[6] = {0, 0, 0, 0xc000, 0xffff, 0}; +#ifdef IEEE +unsigned EMUSHORT XFbignan[6] = + {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}; +unsigned EMUSHORT XFlittlenan[6] = {0, 0, 0, 0xc000, 0xffff, 0}; #endif #endif #ifdef DFMODE_NAN DFMODE_NAN; #else -#ifdef MIEEE -unsigned EMUSHORT DFnan[4] = {0x7fff, 0xffff, 0xffff, 0xffff}; -#endif -#ifdef IBMPC -unsigned EMUSHORT DFnan[4] = {0, 0, 0, 0xfff8}; +#ifdef IEEE +unsigned EMUSHORT DFbignan[4] = {0x7fff, 0xffff, 0xffff, 0xffff}; +unsigned EMUSHORT DFlittlenan[4] = {0, 0, 0, 0xfff8}; #endif #endif #ifdef SFMODE_NAN SFMODE_NAN; #else -#ifdef MIEEE -unsigned EMUSHORT SFnan[2] = {0x7fff, 0xffff}; -#endif -#ifdef IBMPC -unsigned EMUSHORT SFnan[2] = {0, 0xffc0}; +#ifdef IEEE +unsigned EMUSHORT SFbignan[2] = {0x7fff, 0xffff}; +unsigned EMUSHORT SFlittlenan[2] = {0, 0xffc0}; #endif #endif @@ -5459,33 +5537,43 @@ make_nan (nan, sign, mode) #if !defined(DEC) && !defined(IBM) case TFmode: n = 8; - p = TFnan; + if (FLOAT_WORDS_BIG_ENDIAN) + p = TFbignan; + else + p = TFlittlenan; break; case XFmode: n = 6; - p = XFnan; + if (FLOAT_WORDS_BIG_ENDIAN) + p = XFbignan; + else + p = XFlittlenan; break; case DFmode: n = 4; - p = DFnan; + if (FLOAT_WORDS_BIG_ENDIAN) + p = DFbignan; + else + p = DFlittlenan; break; case HFmode: case SFmode: n = 2; - p = SFnan; + if (FLOAT_WORDS_BIG_ENDIAN) + p = SFbignan; + else + p = SFlittlenan; break; #endif default: abort (); } -#ifdef MIEEE - *nan++ = (sign << 15) | *p++; -#endif + if (FLOAT_WORDS_BIG_ENDIAN) + *nan++ = (sign << 15) | *p++; while (--n != 0) *nan++ = *p++; -#ifndef MIEEE - *nan = (sign << 15) | *p; -#endif + if (! FLOAT_WORDS_BIG_ENDIAN) + *nan = (sign << 15) | *p; } /* Convert an SFmode target `float' value to a REAL_VALUE_TYPE. @@ -5502,13 +5590,16 @@ ereal_from_float (f) /* Convert 32 bit integer to array of 16 bit pieces in target machine order. This is the inverse operation to what the function `endian' does. */ -#if FLOAT_WORDS_BIG_ENDIAN - s[0] = (unsigned EMUSHORT) (f >> 16); - s[1] = (unsigned EMUSHORT) f; -#else - s[0] = (unsigned EMUSHORT) f; - s[1] = (unsigned EMUSHORT) (f >> 16); -#endif + if (FLOAT_WORDS_BIG_ENDIAN) + { + s[0] = (unsigned EMUSHORT) (f >> 16); + s[1] = (unsigned EMUSHORT) f; + } + else + { + s[0] = (unsigned EMUSHORT) f; + s[1] = (unsigned EMUSHORT) (f >> 16); + } /* Convert and promote the target float to E-type. */ e24toe (s, e); /* Output E-type to REAL_VALUE_TYPE. */ @@ -5535,30 +5626,34 @@ ereal_from_double (d) unsigned EMUSHORT e[NE]; /* Convert array of HOST_WIDE_INT to equivalent array of 16-bit pieces. */ -#if FLOAT_WORDS_BIG_ENDIAN - s[0] = (unsigned EMUSHORT) (d[0] >> 16); - s[1] = (unsigned EMUSHORT) d[0]; + if (FLOAT_WORDS_BIG_ENDIAN) + { + s[0] = (unsigned EMUSHORT) (d[0] >> 16); + s[1] = (unsigned EMUSHORT) d[0]; #if HOST_BITS_PER_WIDE_INT == 32 - s[2] = (unsigned EMUSHORT) (d[1] >> 16); - s[3] = (unsigned EMUSHORT) d[1]; + s[2] = (unsigned EMUSHORT) (d[1] >> 16); + s[3] = (unsigned EMUSHORT) d[1]; #else - /* In this case the entire target double is contained in the - first array element. The second element of the input is ignored. */ - s[2] = (unsigned EMUSHORT) (d[0] >> 48); - s[3] = (unsigned EMUSHORT) (d[0] >> 32); + /* In this case the entire target double is contained in the + first array element. The second element of the input is + ignored. */ + s[2] = (unsigned EMUSHORT) (d[0] >> 48); + s[3] = (unsigned EMUSHORT) (d[0] >> 32); #endif -#else -/* Target float words are little-endian. */ - s[0] = (unsigned EMUSHORT) d[0]; - s[1] = (unsigned EMUSHORT) (d[0] >> 16); + } + else + { + /* Target float words are little-endian. */ + s[0] = (unsigned EMUSHORT) d[0]; + s[1] = (unsigned EMUSHORT) (d[0] >> 16); #if HOST_BITS_PER_WIDE_INT == 32 - s[2] = (unsigned EMUSHORT) d[1]; - s[3] = (unsigned EMUSHORT) (d[1] >> 16); + s[2] = (unsigned EMUSHORT) d[1]; + s[3] = (unsigned EMUSHORT) (d[1] >> 16); #else - s[2] = (unsigned EMUSHORT) (d[0] >> 32); - s[3] = (unsigned EMUSHORT) (d[0] >> 48); -#endif + s[2] = (unsigned EMUSHORT) (d[0] >> 32); + s[3] = (unsigned EMUSHORT) (d[0] >> 48); #endif + } /* Convert target double to E-type. */ e53toe (s, e); /* Output E-type to REAL_VALUE_TYPE. */ @@ -5580,13 +5675,16 @@ uditoe (di, e) int k; ecleaz (yi); -#if WORDS_BIG_ENDIAN - for (k = M; k < M + 4; k++) - yi[k] = *di++; -#else - for (k = M + 3; k >= M; k--) - yi[k] = *di++; -#endif + if (WORDS_BIG_ENDIAN) + { + for (k = M; k < M + 4; k++) + yi[k] = *di++; + } + else + { + for (k = M + 3; k >= M; k--) + yi[k] = *di++; + } yi[E] = EXONE + 47; /* exponent if normalize shift count were 0 */ if ((k = enormlz (yi)) > NBITS)/* normalize the significand */ ecleaz (yi); /* it was zero */ @@ -5608,13 +5706,16 @@ ditoe (di, e) int k, sign; ecleaz (yi); -#if WORDS_BIG_ENDIAN - for (k = M; k < M + 4; k++) - yi[k] = *di++; -#else - for (k = M + 3; k >= M; k--) - yi[k] = *di++; -#endif + if (WORDS_BIG_ENDIAN) + { + for (k = M; k < M + 4; k++) + yi[k] = *di++; + } + else + { + for (k = M + 3; k >= M; k--) + yi[k] = *di++; + } /* Take absolute value */ sign = 0; if (yi[M] & 0x8000) @@ -5680,21 +5781,21 @@ etoudi (x, i) if (j == 0) j = 16; eshift (xi, j); -#if WORDS_BIG_ENDIAN - *i++ = xi[M]; -#else - i += 3; - *i-- = xi[M]; -#endif + if (WORDS_BIG_ENDIAN) + *i++ = xi[M]; + else + { + i += 3; + *i-- = xi[M]; + } k -= j; do { eshup6 (xi); -#if WORDS_BIG_ENDIAN - *i++ = xi[M]; -#else - *i-- = xi[M]; -#endif + if (WORDS_BIG_ENDIAN) + *i++ = xi[M]; + else + *i-- = xi[M]; } while ((k -= 16) > 0); } @@ -5705,18 +5806,21 @@ etoudi (x, i) noshift: -#if WORDS_BIG_ENDIAN - i += 3; - *i-- = xi[M]; - *i-- = 0; - *i-- = 0; - *i = 0; -#else - *i++ = xi[M]; - *i++ = 0; - *i++ = 0; - *i = 0; -#endif + if (WORDS_BIG_ENDIAN) + { + i += 3; + *i-- = xi[M]; + *i-- = 0; + *i-- = 0; + *i = 0; + } + else + { + *i++ = xi[M]; + *i++ = 0; + *i++ = 0; + *i = 0; + } } } @@ -5759,21 +5863,21 @@ etodi (x, i) if (j == 0) j = 16; eshift (xi, j); -#if WORDS_BIG_ENDIAN - *i++ = xi[M]; -#else - i += 3; - *i-- = xi[M]; -#endif + if (WORDS_BIG_ENDIAN) + *i++ = xi[M]; + else + { + i += 3; + *i-- = xi[M]; + } k -= j; do { eshup6 (xi); -#if WORDS_BIG_ENDIAN - *i++ = xi[M]; -#else - *i-- = xi[M]; -#endif + if (WORDS_BIG_ENDIAN) + *i++ = xi[M]; + else + *i-- = xi[M]; } while ((k -= 16) > 0); } @@ -5782,34 +5886,35 @@ etodi (x, i) /* shift not more than 16 bits */ eshift (xi, k); -#if WORDS_BIG_ENDIAN - i += 3; - *i = xi[M]; - *i-- = 0; - *i-- = 0; - *i = 0; -#else - *i++ = xi[M]; - *i++ = 0; - *i++ = 0; - *i = 0; -#endif + if (WORDS_BIG_ENDIAN) + { + i += 3; + *i = xi[M]; + *i-- = 0; + *i-- = 0; + *i = 0; + } + else + { + *i++ = xi[M]; + *i++ = 0; + *i++ = 0; + *i = 0; + } } /* Negate if negative */ if (xi[0]) { carry = 0; -#if WORDS_BIG_ENDIAN - isave += 3; -#endif + if (WORDS_BIG_ENDIAN) + isave += 3; for (k = 0; k < 4; k++) { acc = (unsigned EMULONG) (~(*isave) & 0xffff) + carry; -#if WORDS_BIG_ENDIAN - *isave-- = acc; -#else - *isave++ = acc; -#endif + if (WORDS_BIG_ENDIAN) + *isave-- = acc; + else + *isave++ = acc; carry = 0; if (acc & 0x10000) carry = 1; @@ -260,19 +260,19 @@ do { float f = (float) (IN); \ values which is its bitwise equivalent, but put the two words into proper word order for the target. */ #ifndef REAL_VALUE_TO_TARGET_DOUBLE -#if HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \ do { REAL_VALUE_TYPE in = (IN); /* Make sure it's not in a register. */\ - (OUT)[0] = ((long *) &in)[0]; \ - (OUT)[1] = ((long *) &in)[1]; \ + if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \ + { \ + (OUT)[0] = ((long *) &in)[0]; \ + (OUT)[1] = ((long *) &in)[1]; \ + } \ + else \ + { \ + (OUT)[1] = ((long *) &in)[0]; \ + (OUT)[0] = ((long *) &in)[1]; \ + } \ } while (0) -#else -#define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \ -do { REAL_VALUE_TYPE in = (IN); /* Make sure it's not in a register. */\ - (OUT)[1] = ((long *) &in)[0]; \ - (OUT)[0] = ((long *) &in)[1]; \ - } while (0) -#endif #endif #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */ diff --git a/gcc/recog.c b/gcc/recog.c index a09a1d9..4177e07 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -423,11 +423,10 @@ validate_replace_rtx_1 (loc, from, to, object) enum machine_mode mode = GET_MODE (x); rtx new; -#if BYTES_BIG_ENDIAN - offset += (MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); -#endif + if (BYTES_BIG_ENDIAN) + offset += (MIN (UNITS_PER_WORD, + GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); new = gen_rtx (MEM, mode, plus_constant (XEXP (to, 0), offset)); MEM_VOLATILE_P (new) = MEM_VOLATILE_P (to); @@ -474,10 +473,9 @@ validate_replace_rtx_1 (loc, from, to, object) /* If the bytes and bits are counted differently, we must adjust the offset. */ -#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN - offset = (GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (wanted_mode) - - offset); -#endif + if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN) + offset = (GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (wanted_mode) + - offset); pos %= GET_MODE_BITSIZE (wanted_mode); @@ -1083,10 +1081,9 @@ indirect_operand (op, mode) register int offset = SUBREG_WORD (op) * UNITS_PER_WORD; rtx inner = SUBREG_REG (op); -#if BYTES_BIG_ENDIAN - offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (op))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (inner)))); -#endif + if (BYTES_BIG_ENDIAN) + offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (op))) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (inner)))); if (mode != VOIDmode && GET_MODE (op) != mode) return 0; diff --git a/gcc/reload.c b/gcc/reload.c index aed06e4..06d7746 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -3934,13 +3934,14 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest) int offset = SUBREG_WORD (x) * UNITS_PER_WORD; rtx addr = (reg_equiv_address[regno] ? reg_equiv_address[regno] : XEXP (reg_equiv_mem[regno], 0)); -#if BYTES_BIG_ENDIAN - int size; - size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))); - offset += MIN (size, UNITS_PER_WORD); - size = GET_MODE_SIZE (GET_MODE (x)); - offset -= MIN (size, UNITS_PER_WORD); -#endif + if (BYTES_BIG_ENDIAN) + { + int size; + size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))); + offset += MIN (size, UNITS_PER_WORD); + size = GET_MODE_SIZE (GET_MODE (x)); + offset -= MIN (size, UNITS_PER_WORD); + } addr = plus_constant (addr, offset); x = gen_rtx (MEM, GET_MODE (x), addr); RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]); diff --git a/gcc/reload1.c b/gcc/reload1.c index 49a1811..2a5db92 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -2328,13 +2328,14 @@ alter_reg (i, from_reg) { /* No known place to spill from => no slot to reuse. */ x = assign_stack_local (GET_MODE (regno_reg_rtx[i]), total_size, -1); -#if BYTES_BIG_ENDIAN - /* Cancel the big-endian correction done in assign_stack_local. - Get the address of the beginning of the slot. - This is so we can do a big-endian correction unconditionally - below. */ - adjust = inherent_size - total_size; -#endif + if (BYTES_BIG_ENDIAN) + { + /* Cancel the big-endian correction done in assign_stack_local. + Get the address of the beginning of the slot. + This is so we can do a big-endian correction unconditionally + below. */ + adjust = inherent_size - total_size; + } } /* Reuse a stack slot if possible. */ else if (spill_stack_slot[from_reg] != 0 @@ -2358,23 +2359,22 @@ alter_reg (i, from_reg) } /* Make a slot with that size. */ x = assign_stack_local (mode, total_size, -1); -#if BYTES_BIG_ENDIAN - /* Cancel the big-endian correction done in assign_stack_local. - Get the address of the beginning of the slot. - This is so we can do a big-endian correction unconditionally - below. */ - adjust = GET_MODE_SIZE (mode) - total_size; -#endif + if (BYTES_BIG_ENDIAN) + { + /* Cancel the big-endian correction done in assign_stack_local. + Get the address of the beginning of the slot. + This is so we can do a big-endian correction unconditionally + below. */ + adjust = GET_MODE_SIZE (mode) - total_size; + } spill_stack_slot[from_reg] = x; spill_stack_slot_width[from_reg] = total_size; } -#if BYTES_BIG_ENDIAN /* On a big endian machine, the "address" of the slot is the address of the low part that fits its inherent mode. */ - if (inherent_size < total_size) + if (BYTES_BIG_ENDIAN && inherent_size < total_size) adjust += (total_size - inherent_size); -#endif /* BYTES_BIG_ENDIAN */ /* If we have any adjustment to make, or if the stack slot is the wrong mode, make a new stack slot. */ @@ -2930,11 +2930,10 @@ eliminate_regs (x, mem_mode, insn) int offset = SUBREG_WORD (x) * UNITS_PER_WORD; enum machine_mode mode = GET_MODE (x); -#if BYTES_BIG_ENDIAN - offset += (MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (new))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); -#endif + if (BYTES_BIG_ENDIAN) + offset += (MIN (UNITS_PER_WORD, + GET_MODE_SIZE (GET_MODE (new))) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); PUT_MODE (new, mode); XEXP (new, 0) = plus_constant (XEXP (new, 0), offset); diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 4426457..e5d643e 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -1252,12 +1252,12 @@ sdbout_parms (parms) the parm with the variable's declared type, and adjust the address if the least significant bytes (which we are using) are not the first ones. */ -#if BYTES_BIG_ENDIAN - if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) + if (BYTES_BIG_ENDIAN + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif + if (GET_CODE (DECL_RTL (parms)) == MEM && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) @@ -1374,11 +1374,11 @@ sdbout_reg_parms (parms) /* A parm declared char is really passed as an int, so it occupies the least significant bytes. On a big-endian machine those are not the low-numbered ones. */ -#if BYTES_BIG_ENDIAN - if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) + if (BYTES_BIG_ENDIAN + && offset != -1 + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...} #endif { @@ -4094,11 +4094,10 @@ get_set_constructor_words (init, buffer, wd_size) { if (bit_buffer[i]) { -#if BITS_BIG_ENDIAN - *wordp |= (1 << (set_word_size - 1 - bit_pos)); -#else - *wordp |= 1 << bit_pos; -#endif + if (BITS_BIG_ENDIAN) + *wordp |= (1 << (set_word_size - 1 - bit_pos)); + else + *wordp |= 1 << bit_pos; } bit_pos++; if (bit_pos >= set_word_size) diff --git a/gcc/varasm.c b/gcc/varasm.c index 1e6a8ae..28165a5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3554,17 +3554,20 @@ bc_assemble_integer (exp, size) } else if (size == 8) { -#if WORDS_BIG_ENDIAN - int i = TREE_INT_CST_HIGH (const_part); - bc_emit ((char *) &i, 4); - i = TREE_INT_CST_LOW (const_part); - bc_emit ((char *) &i, 4); -#else - int i = TREE_INT_CST_LOW (const_part); - bc_emit ((char *) &i, 4); - i = TREE_INT_CST_HIGH (const_part); - bc_emit ((char *) &i, 4); -#endif + if (WORDS_BIG_ENDIAN) + { + int i = TREE_INT_CST_HIGH (const_part); + bc_emit ((char *) &i, 4); + i = TREE_INT_CST_LOW (const_part); + bc_emit ((char *) &i, 4); + } + else + { + int i = TREE_INT_CST_LOW (const_part); + bc_emit ((char *) &i, 4); + i = TREE_INT_CST_HIGH (const_part); + bc_emit ((char *) &i, 4); + } size -= 8; } } @@ -3767,64 +3770,68 @@ output_constructor (exp, size) (all part of the same byte). */ this_time = MIN (end_offset - next_offset, BITS_PER_UNIT - next_bit); -#if BYTES_BIG_ENDIAN - /* On big-endian machine, take the most significant bits - first (of the bits that are significant) - and put them into bytes from the most significant end. */ - shift = end_offset - next_offset - this_time; - /* Don't try to take a bunch of bits that cross - the word boundary in the INTEGER_CST. */ - if (shift < HOST_BITS_PER_WIDE_INT - && shift + this_time > HOST_BITS_PER_WIDE_INT) + if (BYTES_BIG_ENDIAN) { - this_time -= (HOST_BITS_PER_WIDE_INT - shift); - shift = HOST_BITS_PER_WIDE_INT; - } - - /* Now get the bits from the appropriate constant word. */ - if (shift < HOST_BITS_PER_WIDE_INT) - { - value = TREE_INT_CST_LOW (val); - } - else if (shift < 2 * HOST_BITS_PER_WIDE_INT) - { - value = TREE_INT_CST_HIGH (val); - shift -= HOST_BITS_PER_WIDE_INT; + /* On big-endian machine, take the most significant bits + first (of the bits that are significant) + and put them into bytes from the most significant end. */ + shift = end_offset - next_offset - this_time; + /* Don't try to take a bunch of bits that cross + the word boundary in the INTEGER_CST. */ + if (shift < HOST_BITS_PER_WIDE_INT + && shift + this_time > HOST_BITS_PER_WIDE_INT) + { + this_time -= (HOST_BITS_PER_WIDE_INT - shift); + shift = HOST_BITS_PER_WIDE_INT; + } + + /* Now get the bits from the appropriate constant word. */ + if (shift < HOST_BITS_PER_WIDE_INT) + { + value = TREE_INT_CST_LOW (val); + } + else if (shift < 2 * HOST_BITS_PER_WIDE_INT) + { + value = TREE_INT_CST_HIGH (val); + shift -= HOST_BITS_PER_WIDE_INT; + } + else + abort (); + byte |= (((value >> shift) + & (((HOST_WIDE_INT) 1 << this_time) - 1)) + << (BITS_PER_UNIT - this_time - next_bit)); } else - abort (); - byte |= (((value >> shift) - & (((HOST_WIDE_INT) 1 << this_time) - 1)) - << (BITS_PER_UNIT - this_time - next_bit)); -#else - /* On little-endian machines, - take first the least significant bits of the value - and pack them starting at the least significant - bits of the bytes. */ - shift = (next_offset - - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))); - /* Don't try to take a bunch of bits that cross - the word boundary in the INTEGER_CST. */ - if (shift < HOST_BITS_PER_WIDE_INT - && shift + this_time > HOST_BITS_PER_WIDE_INT) { - this_time -= (HOST_BITS_PER_WIDE_INT - shift); - shift = HOST_BITS_PER_WIDE_INT; + /* On little-endian machines, + take first the least significant bits of the value + and pack them starting at the least significant + bits of the bytes. */ + shift = (next_offset + - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))); + /* Don't try to take a bunch of bits that cross + the word boundary in the INTEGER_CST. */ + if (shift < HOST_BITS_PER_WIDE_INT + && shift + this_time > HOST_BITS_PER_WIDE_INT) + { + this_time -= (HOST_BITS_PER_WIDE_INT - shift); + shift = HOST_BITS_PER_WIDE_INT; + } + + /* Now get the bits from the appropriate constant word. */ + if (shift < HOST_BITS_PER_INT) + value = TREE_INT_CST_LOW (val); + else if (shift < 2 * HOST_BITS_PER_WIDE_INT) + { + value = TREE_INT_CST_HIGH (val); + shift -= HOST_BITS_PER_WIDE_INT; + } + else + abort (); + byte |= (((value >> shift) + & (((HOST_WIDE_INT) 1 << this_time) - 1)) + << next_bit); } - - /* Now get the bits from the appropriate constant word. */ - if (shift < HOST_BITS_PER_INT) - value = TREE_INT_CST_LOW (val); - else if (shift < 2 * HOST_BITS_PER_WIDE_INT) - { - value = TREE_INT_CST_HIGH (val); - shift -= HOST_BITS_PER_WIDE_INT; - } - else - abort (); - byte |= ((value >> shift) - & (((HOST_WIDE_INT) 1 << this_time) - 1)) << next_bit; -#endif next_offset += this_time; byte_buffer_in_use = 1; } |