This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for n32/n64 structure returns


Thanks for the review!

Gerald Pfeifer <gerald@pfeifer.com> writes:
> !     <li>The code generated for certain MIPS targets
> ! 	<a href="mips-abi.html">will not be binary compatible</a>
> ! 	with earlier releases.</li>
> 
> How about keeping this sentence (w/o the link) and appending
> 
>    "semicolon the <a href="mips-abi.html">ABI implemented by GCC
>    has changed</a>"
> 
> or adding the word "ABI" in some different way?

How about:

    <li>The implementation of the MIPS ABIs <a href="mips-abi.html">has
	changed</a>.  As a result, the code generated for certain MIPS
	targets will not be binary compatible with earlier releases.</li>

?

> --- gcc-3.4/mips-abi.html	Sat Sep 13 10:15:25 2003
> + <p>GCC 3.4 fixes several cases in which earlier releases would not
> +    follow the MIPS calling conventions.  This document describes
> +    each fix and the kind of code that would be affected by it.
> 
> Would omitting "that would be" and "by it" work?

Changed to "and the kind of code it will affect".

> +     <td>o32, o64, n32 and n64</th>
>                       ^^^
> Perhaps a comma here?

Not sure ;).  I've left it be for now.

Other than that, I fixed the markup errors you pointed out & followed
your other suggestions.  Updated patch below.

Richard


Index: gcc-3.4/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.4/changes.html,v
retrieving revision 1.46
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.46 changes.html
*** gcc-3.4/changes.html	10 Sep 2003 04:54:05 -0000	1.46
--- gcc-3.4/changes.html	21 Sep 2003 11:27:00 -0000
***************
*** 32,40 ****
          in this release</a>.</li>
      <li>GCC now requires an ISO C90 (ANSI C89) C compiler to build.
          K&amp;R C compilers will not work.</li>
!     <li>On some MIPS targets, the code generated by this release
! 	will not be binary compatible with previous releases.
! 	See <a href="#mips_abi">below</a> for details.</li>
    </ul>
  
  <h2>General Optimizer Improvements</h2>
--- 32,40 ----
          in this release</a>.</li>
      <li>GCC now requires an ISO C90 (ANSI C89) C compiler to build.
          K&amp;R C compilers will not work.</li>
!     <li>The implementation of the MIPS ABIs <a href="mips-abi.html">has
! 	changed</a>.  As a result, the code generated for certain MIPS
! 	targets will not be binary compatible with earlier releases.</li>
    </ul>
  
  <h2>General Optimizer Improvements</h2>
***************
*** 293,311 ****
      and should work with any MIPS I (<code>mips-*</code>) or MIPS III
      (<code>mips64-*</code>) configuration.</li>
  
!     <li><a name="mips_abi">n32 and n64 MIPS targets now pass all
!     structures by value.</a>  While this change brings GCC closer
!     to ABI compliance, it will unfortunately break binary compatibility
!     with earlier releases.  A structure used to be passed by reference if:
!     <ul>
!       <li>the target was big-endian;</li>
!       <li>the structure was bigger than 8 bytes;</li>
!       <li>the structure's size was not a multiple of 8 bytes; and</li>
!       <li>the first word of the structure would have been passed in
! 	  a register.</li>
!     </ul>
!     Note that only big-endian n32 & n64 targets (such as IRIX 6) are
!     affected.</li>
    </ul>
  
  <h2><a name="obsolete_systems">Obsolete Systems</a></h2>
--- 293,301 ----
      and should work with any MIPS I (<code>mips-*</code>) or MIPS III
      (<code>mips64-*</code>) configuration.</li>
  
!     <li>Several <a href="mips-abi.html">ABI bugs in the MIPS port</a>
!     have been fixed.  Unfortunately, these changes will break binary
!     compatibility with earlier releases.</li>
    </ul>
  
  <h2><a name="obsolete_systems">Obsolete Systems</a></h2>
*** /dev/null	Tue Jun 17 23:06:41 2003
--- gcc-3.4/mips-abi.html	Sun Sep 21 12:41:14 2003
***************
*** 0 ****
--- 1,346 ----
+ <html>
+ 
+ <head>
+ <title>MIPS ABI Changes in GCC 3.4</title>
+ </head>
+ 
+ <body>
+ 
+ <h1>MIPS ABI Changes in GCC 3.4</h1>
+ 
+ <p>GCC 3.4 fixes several cases in which earlier releases would not
+    follow the MIPS calling conventions.  This document describes
+    each fix and the kind of code it will affect.  In each case,
+    GCC 3.4 will not be binary compatible with earlier releases.</p>
+ 
+ <p>Most of the fixes are related to the handling of structure
+    and union types.  In the summary below, "aggregate" refers
+    to both structures and unions.</p>
+ 
+ <p>Note that IRIX 6 configurations used to work around
+    <a href="#B">B</a> and <a href="#E">E</a> by providing wrappers
+    for certain libc functions.  These wrappers are not needed for 3.4
+    and have been removed.  It should be possible to link code generated
+    by GCC 3.4 directly with code generated by SGI's compilers.</p>
+ 
+ <h2>A. Small aggregate arguments (1)</h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>o32</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>little</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td><ul>
+ 	  <li>An aggregate argument is passed in a register; and</li>
+ 	  <li>that argument is smaller than 4 bytes.</li>
+ 	</ul></td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The register was padded at the least significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>The register is padded at the most significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>struct s { char c[2]; };
+ void f (struct s x);</pre>
+ 
+ 	<p><code>x</code> is passed in argument register <code>$4</code>,
+ 	   which is laid out as follows:</p>
+ 
+ 	<table cellpadding="4">
+ 	  <tr align="center">
+ 	  <th></th> <th>7-0</th> <th>15-8</th> <th>23-16</th> <th>31-24</th>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">Old&nbsp;behavior</td>
+ 	  <td>padding</td> <td>padding</td> <td>c[0]</td> <td>c[1]</td>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">New&nbsp;behavior</td>
+ 	  <td>c[0]</td> <td>c[1]</td> <td>padding</td> <td>padding</td>
+ 	  </tr>
+ 	</table></td>
+   </tr>
+ </table>
+ 
+ <h2><a name="B">B. Small aggregate arguments (2)</a></h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>n32 and n64</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>big</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td><ul>
+ 	  <li>An aggregate argument is passed in a register; and</li>
+ 	  <li>that argument is smaller than 8 bytes.</li>
+ 	</ul></td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The register was padded at the most significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>The register is padded at the least significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>struct s { char c[2]; };
+ void f (struct s x);</pre>
+ 
+ 	<p><code>x</code> is passed in argument register
+ 	   <code>$4</code>, which is laid out as follows:</p>
+ 
+ 	<table cellpadding="4">
+ 	  <tr align="center">
+ 	  <th></th>
+ 	  <th>63-56</th> <th>55-48</th> <th>47-40</th> <th>39-32</th>
+ 	  <th>31-24</th> <th>23-16</th> <th>15-8</th> <th>7-0</th>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">Old&nbsp;behavior</td>
+ 	  <td>padding</td> <td>padding</td> <td>padding</td> <td>padding</td>
+ 	  <td>padding</td> <td>padding</td> <td>c[0]</td> <td>c[1]</td>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">New&nbsp;behavior</td>
+ 	  <td>c[0]</td> <td>c[1]</td> <td>padding</td> <td>padding</td>
+ 	  <td>padding</td> <td>padding</td> <td>padding</td> <td>padding</td>
+ 	  </tr>
+ 	</table></td>
+   </tr>
+ </table>
+ 
+ <h2>C. Large aggregate arguments</h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>n32 and n64</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>either</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td><ul>
+ 	  <li>An aggregate argument is passed to a function;</li>
+ 	  <li>the aggregate's size is not a multiple of 8 bytes; and</li>
+ 	  <li>there are enough argument registers to hold some of
+ 	      the aggregate, but not enough to hold all of it.</li>
+ 	</ul></td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The argument was passed by reference.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>The argument is passed by value.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>struct s { int i[17]; };
+ void f (struct s x);</pre>
+ 
+ 	<p>It would take 9 registers to hold <code>x</code>, but
+ 	   only 8 argument registers are available.  Since <code>x</code>'s
+ 	   size is not a multiple of 8, previous releases passed it by
+ 	   reference (that is, they passed a pointer to <code>x</code>
+ 	   in <code>$4</code>).</p>
+ 
+ 	<p>The new behavior is to pass <code>x</code> by value.
+ 	   The first 8 words are passed in argument registers and
+ 	   the last is passed on the stack.</p></td>
+   </tr>
+ </table>
+ 
+ <h2>D. Single-field structure arguments</h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>o32, o64, n32 and n64</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>either</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td><ul>
+ 	  <li>A structure containing a single field is passed by value;
+ 	      and</li>
+ 	  <li>that field has a floating-point type.</li>
+         </ul></td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The structure was treated like a scalar value of the same
+ 	floating-point type.  For example, a structure containing a
+ 	<code>float</code> field was treated in the same way as a
+ 	scalar <code>float</code> value.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>There is no special treatment for such structures.
+ 	Note however that the usual n32 and n64 rules still hold:
+ 	naturally-aligned fields of type <code>double</code> are
+ 	passed in floating-point registers.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>struct s { float f; };
+ void f (struct s x);</pre>
+ 
+ 	<p>GCC used to pass <code>x</code> in <code>$f12</code>.
+ 	Now it passes it in <code>$4</code>, just like any other
+ 	structure.</p></td>
+   </tr>
+ </table>
+ 
+ <h2><a name="E">E. Structure return values</a></h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>n32 and n64</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>big</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td><ul>
+ 	  <li>An aggregate is returned by value;</li>
+ 	  <li>that aggregate is smaller than 16 bytes;</li>
+ 	  <li>its size is not a multiple of 8 bytes; and</li>
+ 	  <li>if it is a structure, either:
+ 	      <ol>
+ 		<li>it has more than two fields; or</li>
+ 		<li>it has at least one non-floating-point field.</li>
+ 	      </ol></li>
+ 	</ul></td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The return register was padded at the most significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>The return register is padded at the least significant end.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>struct s { char c[3]; };
+ struct s f ();</pre>
+ 
+ 	<p>f() returns its value in <code>$2</code>, which is laid
+ 	   out as follows:</p>
+ 
+ 	<table cellpadding="4">
+ 	  <tr align="center">
+ 	  <th></th>
+ 	  <th>63-56</th> <th>55-48</th> <th>47-40</th> <th>39-32</th>
+ 	  <th>31-24</th> <th>23-16</th> <th>15-8</th> <th>7-0</th>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">Old&nbsp;behavior</td>
+ 	  <td>padding</td> <td>padding</td> <td>padding</td> <td>padding</td>
+ 	  <td>padding</td> <td>c[0]</td> <td>c[1]</td> <td>c[2]</td>
+ 	  </tr>
+ 
+ 	  <tr align="center">
+ 	  <th align="left">New&nbsp;behavior</td>
+ 	  <td>c[0]</td> <td>c[1]</td> <td>c[2]</td> <td>padding</td>
+ 	  <td>padding</td> <td>padding</td> <td>padding</td> <td>padding</td>
+ 	  </tr>
+ 	</table></td>
+   </tr>
+ </table>
+ 
+ <h2>F. Complex return values</h2>
+ 
+ <table cellpadding="4">
+   <tr valign="top">
+     <th align="right">Affected&nbsp;ABIs</th>
+     <td>n32 and n64</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Endianness</th>
+     <td>either</th>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Conditions</th>
+     <td>A function returns a complex <code>float</code> or
+ 	<code>double</code>.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Old&nbsp;behavior</th>
+     <td>The value was returned in <code>$f0</code> and <code>$f1</code>.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">New&nbsp;behavior</th>
+     <td>The value is returned in <code>$f0</code> and <code>$f2</code>.</td>
+   </tr>
+ 
+   <tr valign="top">
+     <th align="right">Example</th>
+     <td><pre>_Complex float f ();</pre></td>
+   </tr>
+ </table>
+ 
+ </body>
+ </html>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]