ham@polya.Stanford.EDU (Peter R. Ham) (06/01/89)
The applies to gcc version 1.35 in the target independent portions of the code.
The following code fragment in the function "copy_rtx_if_shared()" in the file
"emit-rtl.c" is not very robustly portable:
bcopy (x, copy, sizeof (int) * (GET_RTX_LENGTH (code) + 1));
Notice how the length in bytes of an rtx is calculated. This
code depends to heavily (and subtly) on the fact that an rtx_def
is exactly 12 bytes (or 3x32 bit words) long. A lot of care in
the definition of rtx_def has attempted to assure this, but the
C compiler available to me doesn't treat bitfields and enums so
well, so things don't work out so nicely.
The function "rtx_alloc()" in the file "rtl.c" accomplishes the
same result in a much more portable way:
/* Allocate an rtx of code CODE. The CODE is stored in the rtx;
all the rest is initialized to zero. */
rtx
rtx_alloc (code)
RTX_CODE code;
{
rtx rt;
register int nelts = GET_RTX_LENGTH (code);
register int length = sizeof (struct rtx_def)
+ (nelts - 1) * sizeof (rtunion);
rt = (rtx) obstack_alloc (rtl_obstack, length);
* (int *) rt = 0;
PUT_CODE (rt, code);
return rt;
}
I propose that the code fragment in emit-rtl.c use the
same code as rtx_alloc. Better yet, the following function
could be defined and used in both cases:
int
rtx_node_length_in_bytes(code)
RTX_CODE code;
{
int nelts = GET_RTX_LENGTH (code);
int length = sizeof (struct rtx_def)
+ (nelts - 1) * sizeof (rtunion);
return ( length );
}
I'd appreciate any feedback on this proposed small change.
I would like to get a feel for what kind of code
improvements are accepted by GNU for gcc.
--
Peter Ham PO Box 3430 (415) 324-4782
MS Computer Science Student Stanford, CA ham@polya.stanford.edu
Stanford University 94309