This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
local var alignment on hppa
- To: gcc-patches at gcc dot gnu dot org
- Subject: local var alignment on hppa
- From: Alan Modra <amodra at bigpond dot net dot au>
- Date: Fri, 19 Oct 2001 21:26:44 +0930
- Cc: Jeffrey A Law <law at redhat dot com>, John Marvin <jsm at fc dot hp dot com>
hppa has some nasty alignment requirements for certain data structures.
ldcw, the only parisc atomic operation, needs to have its operand
16 byte aligned. Currently, STACK_BOUNDARY and BIGGEST_ALIGNMENT are
both 64 bits on pa32, so it's not possible to use a local var for a
lock, at least not without doing backflips. This patch increases the
allowed alignment to 16 bytes, and also introduces another target macro
to allow local var alignment to 16 bytes without forcing a similar
alignment on STARTING_FRAME_OFFSET (which would waste stack space).
gcc/ChangeLog
* config/pa/pa.h (PREFERRED_STACK_BOUNDARY): Define.
(BIGGEST_ALIGNMENT): Change from 64 to 128.
(ALIGN_STARTING_FRAME): Define.
* doc/tm.texi (ALIGN_STARTING_FRAME): Document.
* function.c (assign_stack_local_1): Use ALIGN_STARTING_FRAME.
OK to apply?
--
Alan Modra
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.63
diff -u -p -r1.63 tm.texi
--- tm.texi 2001/10/14 17:44:00 1.63
+++ tm.texi 2001/10/19 10:36:10
@@ -2600,6 +2600,13 @@ value @code{STARTING_FRAME_OFFSET}.
@c i'm not sure if the above is still correct.. had to change it to get
@c rid of an overfull. --mew 2feb93
+@findex ALIGN_STARTING_FRAME
+@item ALIGN_STARTING_FRAME
+If defined, local variable stack slots will first have this value added
+to the offset before calculating address alignment padding. This is
+useful when STARTING_FRAME_OFFSET is not a multiple of BIGGEST_ALIGNMENT
+or PREFERRED_STACK_BOUNDARY.
+
@findex STACK_POINTER_OFFSET
@item STACK_POINTER_OFFSET
Offset from the stack pointer register to the first location at which
Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.314
diff -u -p -r1.314 function.c
--- function.c 2001/10/11 03:15:40 1.314
+++ function.c 2001/10/19 10:35:54
@@ -526,6 +526,7 @@ assign_stack_local_1 (mode, size, align,
rtx x, addr;
int bigend_correction = 0;
int alignment;
+ HOST_WIDE_INT offset;
if (align == 0)
{
@@ -552,8 +553,10 @@ assign_stack_local_1 (mode, size, align,
else
alignment = align / BITS_PER_UNIT;
+ offset = function->x_frame_offset;
+
#ifdef FRAME_GROWS_DOWNWARD
- function->x_frame_offset -= size;
+ offset -= size;
#endif
/* Ignore alignment we can't do with expected alignment of the boundary. */
@@ -568,11 +571,17 @@ assign_stack_local_1 (mode, size, align,
division with a negative dividend isn't as well defined as we might
like. So we instead assume that ALIGNMENT is a power of two and
use logical operations which are unambiguous. */
+#ifdef ALIGN_STARTING_FRAME
+ offset += ALIGN_STARTING_FRAME;
+#endif
#ifdef FRAME_GROWS_DOWNWARD
- function->x_frame_offset = FLOOR_ROUND (function->x_frame_offset, alignment);
+ offset = FLOOR_ROUND (offset, alignment);
#else
- function->x_frame_offset = CEIL_ROUND (function->x_frame_offset, alignment);
+ offset = CEIL_ROUND (offset, alignment);
#endif
+#ifdef ALIGN_STARTING_FRAME
+ offset -= ALIGN_STARTING_FRAME;
+#endif
/* 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. */
@@ -583,15 +592,16 @@ assign_stack_local_1 (mode, size, align,
address relative to the frame pointer. */
if (function == cfun && virtuals_instantiated)
addr = plus_constant (frame_pointer_rtx,
- (frame_offset + bigend_correction
- + STARTING_FRAME_OFFSET));
+ offset + bigend_correction + STARTING_FRAME_OFFSET);
else
addr = plus_constant (virtual_stack_vars_rtx,
- function->x_frame_offset + bigend_correction);
+ offset + bigend_correction);
#ifndef FRAME_GROWS_DOWNWARD
- function->x_frame_offset += size;
+ offset += size;
#endif
+
+ function->x_frame_offset = offset;
x = gen_rtx_MEM (mode, addr);
Index: gcc/config/pa/pa.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.126
diff -u -p -r1.126 pa.h
--- pa.h 2001/09/24 16:21:09 1.126
+++ pa.h 2001/10/19 10:35:57
@@ -423,6 +423,8 @@ extern int target_flags;
but that happens late in the compilation process. */
#define STACK_BOUNDARY (TARGET_64BIT ? 128 : 64)
+#define PREFERRED_STACK_BOUNDARY 512
+
/* Allocation boundary (in *bits*) for the code of a function. */
#define FUNCTION_BOUNDARY (TARGET_64BIT ? 64 : 32)
@@ -436,7 +438,7 @@ extern int target_flags;
#define PCC_BITFIELD_TYPE_MATTERS 1
/* No data type wants to be aligned rounder than this. */
-#define BIGGEST_ALIGNMENT 64
+#define BIGGEST_ALIGNMENT 128
/* Get around hp-ux assembler bug, and make strcpy of constants fast. */
#define CONSTANT_ALIGNMENT(CODE, TYPEALIGN) \
@@ -621,6 +623,7 @@ extern struct rtx_def *hppa_pic_save_rtx
first local allocated. Otherwise, it is the offset to the BEGINNING
of the first local allocated. */
#define STARTING_FRAME_OFFSET 8
+#define ALIGN_STARTING_FRAME STARTING_FRAME_OFFSET
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by.