summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2000-02-24 10:07:32 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2000-02-24 10:07:32 +0000
commit3ce66181030ba3ff9867db2237ce96be6d158bdc (patch)
tree962fb4d7ff5222127ff66ea4b5030cebc44cda72
parentca4d26d847c16099c4f7a20a23858cbc49daad75 (diff)
downloadgcc-3ce66181030ba3ff9867db2237ce96be6d158bdc.tar.gz
* machmode.h (get_mode_alignment): Declare.
(GET_MODE_ALIGNMENT): Call it. * stor-layout.c (get_mode_alignment): New function. Make sure alignment is always power of 2. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32134 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/machmode.h6
-rw-r--r--gcc/stor-layout.c17
3 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 71765abe8e0..225b3bcae34 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2000-02-24 Nathan Sidwell <nathan@codesourcery.com>
+
+ * machmode.h (get_mode_alignment): Declare.
+ (GET_MODE_ALIGNMENT): Call it.
+ * stor-layout.c (get_mode_alignment): New function. Make
+ sure alignment is always power of 2.
+
2000-02-23 Zack Weinberg <zack@wolery.cumb.org>
* i386.h: Remove useless definition of "I386" and misleading
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 1f2fb2bbd09..702e20967a6 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -125,9 +125,9 @@ extern enum machine_mode get_best_mode PARAMS ((int, int, unsigned int,
/* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
-#define GET_MODE_ALIGNMENT(MODE) \
- (unsigned int) MIN (BIGGEST_ALIGNMENT, \
- MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)))
+extern unsigned get_mode_alignment PARAMS ((enum machine_mode));
+
+#define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
/* For each class, get the narrowest mode in that class. */
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index be27faeb221..3783a2ff814 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1528,6 +1528,23 @@ get_best_mode (bitsize, bitpos, align, largest_mode, volatilep)
return mode;
}
+/* Return the alignment of MODE. This will be bounded by 1 and
+ BIGGEST_ALIGNMENT. */
+
+unsigned get_mode_alignment (mode)
+ enum machine_mode mode;
+{
+ unsigned alignment = GET_MODE_UNIT_SIZE (mode);
+
+ /* Extract the LSB of the size. */
+ alignment = alignment & -alignment;
+
+ alignment *= BITS_PER_UNIT;
+
+ alignment = MIN (BIGGEST_ALIGNMENT, MAX (1, alignment));
+ return alignment;
+}
+
/* This function is run once to initialize stor-layout.c. */
void