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] RETURN_IN_MEMORY for cygwin and mingw32


 --- Zack Weinberg <zack@codesourcery.com> wrote: > Danny Smith
<danny_r_smith_2001@yahoo.co.nz> writes:
> 
> > Hi
> >
> > The default i386 definition of RETURN_IN_MEMORY causes incomapatibility
> with
> > objects produced by native Win32 MSVC compiler and hence the Win32api.
> [...]

==

> The right thing, I believe, would be to put

===snip===

Okay. Here is second attempt. 

The default VECTOR_MODE_P tests still get done if MS_AGGREGATE_RETURN.
Perhaps they are not necessary. 

I have used a runtime test rather than compile time. I don't know how
useful -m[no]ms-aggregate-return target flag would be. 

Does i386-interix.h want to do the same as cygwin.h? 

Does BLKmode include variable-sized aggregates? If not, the value
returned by int_size_in_bytes needs to be cast to 
(unsigned HOST_WIDE_INT) in case it returns -1.

Tested with 
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as
--host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw
--enable-threads --disable-nls --enable-languages=c,c++
--disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
gcc version 3.4 20030205 (experimental)

Danny

ChangeLog

2003-03-07  Danny Smith  <dannysmith@users.sourceforge.net>

	* config/i386/i386.h (MS_AGGREGATE_RETURN): New define.
	* config/i386/cygwin.h (MS_AGGREGATE_RETURN): Override default
	definition.
	* config/i386/i386.h (ix86_return_in_memory): Return aggregate
	types of up to 8 bytes via registers if MS_AGGREGATE_RETURN.

Index: cygwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/cygwin.h,v
retrieving revision 1.76
diff -c -3 -p -r1.76 cygwin.h
*** cygwin.h	19 Dec 2002 22:00:32 -0000	1.76
--- cygwin.h	7 Feb 2003 00:37:02 -0000
*************** extern int i386_pe_dllimport_name_p PARA
*** 409,414 ****
--- 409,419 ----
  /* For Win32 ABI compatibility */
  #undef DEFAULT_PCC_STRUCT_RETURN
  #define DEFAULT_PCC_STRUCT_RETURN 0
+ 
+ /* MSVC returns aggregate types of up to 8 bytes via registers.
+    See i386.c:ix86_return_in_memory.  */
+ #undef MS_AGGREGATE_RETURN
+ #define MS_AGGREGATE_RETURN 1
  
  /* No data type wants to be aligned rounder than this.  */
  #undef	BIGGEST_ALIGNMENT
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.525
diff -c -3 -p -r1.525 i386.c
*** i386.c	4 Feb 2003 18:01:20 -0000	1.525
--- i386.c	7 Feb 2003 00:37:30 -0000
*************** ix86_return_in_memory (type)
*** 2607,2618 ****
      }
    else
      {
!       if (TYPE_MODE (type) == BLKmode
! 	  || (VECTOR_MODE_P (TYPE_MODE (type))
! 	      && int_size_in_bytes (type) == 8)
! 	  || (int_size_in_bytes (type) > 12 && TYPE_MODE (type) != TImode
! 	      && TYPE_MODE (type) != TFmode
! 	      && !VECTOR_MODE_P (TYPE_MODE (type))))
  	return 1;
        return 0;
      }
--- 2607,2624 ----
      }
    else
      {
!       if (TYPE_MODE (type) == BLKmode)
! 	return 1;
!       else if (MS_AGGREGATE_RETURN
! 	       && AGGREGATE_TYPE_P (type)
! 	       && int_size_in_bytes(type) <= 8)
! 	return 0;
!       else if ((VECTOR_MODE_P (TYPE_MODE (type))
! 	        && int_size_in_bytes (type) == 8)
! 	       || (int_size_in_bytes (type) > 12
! 		   && TYPE_MODE (type) != TImode
! 		   && TYPE_MODE (type) != TFmode
! 		   && !VECTOR_MODE_P (TYPE_MODE (type))))
  	return 1;
        return 0;
      }
Index: i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.318
diff -c -3 -p -r1.318 i386.h
*** i386.h	31 Jan 2003 23:34:15 -0000	1.318
--- i386.h	7 Feb 2003 00:37:37 -0000
*************** do {									\
*** 1206,1211 ****
--- 1206,1214 ----
  #define RETURN_IN_MEMORY(TYPE) \
    ix86_return_in_memory (TYPE)
  
+ /* This is overriden by <cygwin.h>.  */
+ #define MS_AGGREGATE_RETURN 0
+ 
  
  /* Define the classes of registers for register constraints in the
     machine description.  Also define ranges of constants.


http://greetings.yahoo.com.au - Yahoo! Greetings
- Send some online love this Valentine's Day.


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