aboutsummaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1994-02-27 14:46:49 -0800
committerJim Wilson <wilson@gcc.gnu.org>1994-02-27 14:46:49 -0800
commit3bd98790b02cccc5276f6def254c5dfa3e9dba36 (patch)
treea5bc6bfa71ae305b9adfe4f4293f5cacbd8a9bcf /gcc/expmed.c
parenta5f00f07f195bb0012629388da827814fc0a11fc (diff)
downloadgcc-3bd98790b02cccc5276f6def254c5dfa3e9dba36.zip
gcc-3bd98790b02cccc5276f6def254c5dfa3e9dba36.tar.gz
gcc-3bd98790b02cccc5276f6def254c5dfa3e9dba36.tar.bz2
(store_fixed_bit_field): Adjust BITPOS so that it
fits inside MODE before adjusting OFFSET to get an aligned address. From-SVN: r6658
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index b6269c6..5a06dbf 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -569,6 +569,16 @@ store_fixed_bit_field (op0, offset, bitsize, bitpos, value, struct_align)
total_bits = GET_MODE_BITSIZE (mode);
+ /* Make sure bitpos is valid for the chosen mode. Adjust BITPOS to
+ be be in the range 0 to total_bits-1, and put any excess bytes in
+ OFFSET. */
+ if (bitpos >= total_bits)
+ {
+ offset += (bitpos / total_bits) * (total_bits / BITS_PER_UNIT);
+ bitpos -= ((bitpos / total_bits) * (total_bits / BITS_PER_UNIT)
+ * BITS_PER_UNIT);
+ }
+
/* Get ref to an aligned byte, halfword, or word containing the field.
Adjust BITPOS to be position within a word,
and OFFSET to be the offset of that word.