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]

[RFC] [C++ ABI] support non-standard integer types in mangle.c


The patch below tries to address some limitations in cp/mangle.c when using
non-standard, non-supported or otherwise deprecated size-type options.

This patch enhances but does not change the existing C++ ABI - current gcc versions just abort with an ICE.

Quoting from the patch:

/* Allow for cases where TYPE is not one of the shared
 integer type nodes and write a "vendor extended builtin
 type" with the name __cxa_int16, __cxa_uint16,
 __cxa_int32, __cxa_uint32, __cxa_int64 or
 __cxa_uint64, respectively.

 Siutations like this can happen if you have an
 __attribute__((__mode__(__SI__))) type and use exotic
 switches like '-mint64' on MIPS or '-mint8' on AVR.
 Of course, this is undefined by the C++ ABI (and
 '-mint8' is not even Standard C conforming), but when
  using such special options you're pretty much in nowhere
 land anyway.

 [previous versions of gcc just used to abort with an ICE if
  the precision was not 128]
*/

I'm using this for quite some time on experimental ILP64 and SILP64
gcc versions on AMD64 and PPC64. Comments?

Cheers,
Markus

--
Markus Oberhumer, <markus@oberhumer.com>, http://www.oberhumer.com/

Index: mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.116
diff -c -3 -p -r1.116 mangle.c
*** mangle.c	24 Feb 2005 21:55:15 -0000	1.116
--- mangle.c	2 Mar 2005 21:58:32 -0000
*************** write_builtin_type (tree type)
*** 1757,1772 ****
  	    {
  	      tree t = c_common_type_for_mode (TYPE_MODE (type),
  					       TYPE_UNSIGNED (type));
! 	      if (type == t)
! 		{
! 		  gcc_assert (TYPE_PRECISION (type) == 128);
! 		  write_char (TYPE_UNSIGNED (type) ? 'o' : 'n');
! 		}
! 	      else
  		{
  		  type = t;
  		  goto iagain;
  		}
  	    }
  	}
        break;
--- 1757,1805 ----
  	    {
  	      tree t = c_common_type_for_mode (TYPE_MODE (type),
  					       TYPE_UNSIGNED (type));
! 	      if (type != t)
  		{
  		  type = t;
  		  goto iagain;
  		}
+  
+ 	      /* Allow for cases where TYPE is not one of the shared
+ 	         integer type nodes and write a "vendor extended builtin
+ 	         type" with the name __cxa_int16, __cxa_uint16,
+ 	         __cxa_int32, __cxa_uint32, __cxa_int64 or
+ 	         __cxa_uint64, respectively.
+ 
+ 	         Siutations like this can happen if you have an
+ 	         __attribute__((__mode__(__SI__))) type and use exotic
+ 	         switches like '-mint64' on MIPS or '-mint8' on AVR.
+ 	         Of course, this is undefined by the C++ ABI (and 
+ 	         '-mint8' is not even Standard C conforming), but when
+ 	         using such special options you're pretty much in nowhere
+ 	         land anyway.
+ 	  
+ 	         [previous versions of gcc just used to abort with an ICE if
+ 	          the precision was not 128]
+ 	      */
+ 
+ 	      switch (TYPE_PRECISION (type))
+ 		{
+ 		case 16:
+ 		  write_string (TYPE_UNSIGNED (type) ? "u" "12" "__cxa_uint16" : "u" "11" "__cxa_int16");
+ 		  break;
+ 		case 32:
+ 		  write_string (TYPE_UNSIGNED (type) ? "u" "12" "__cxa_uint32" : "u" "11" "__cxa_int32");
+ 		  break;
+ 		case 64:
+ 		  write_string (TYPE_UNSIGNED (type) ? "u" "12" "__cxa_uint64" : "u" "11" "__cxa_int64");
+ 		  break;
+ 		case 128:
+ 		  write_char (TYPE_UNSIGNED (type) ? 'o' : 'n');
+ 		  break;
+ 		default:
+ 		  /* Couldn't find this type.  */
+ 		  gcc_unreachable ();
+ 		  break;
+ 		}
  	    }
  	}
        break;

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