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]

Patch: libffi on IA64 HP-UX


This patch allows me to build libffi on IA64 HP-UX in both 32 and 64 bit
mode.  I have not included the top level configure changes needed to
build libffi on IA64 HP-UX with this patch, I intend to do that
seperately.  But these are all the libffi specific changes that are
required.  I tested these on both HP-UX IA64 and Linux IA64 with no
regressions and no libffi failures on either platform.

The main change needed was to fix an inconsistency between ffi_call_unix
and ffi_closure_unix.  ffi_call_unix extended 8, 16, and 32 bit integer
values to 64 bits before storing them in memory but ffi_closure_unix
simply loaded the 8, 16, or 32 bits from memory without any extending.
This worked on little-endian Linux but not on big-endian HP-UX.  My fix
is to have ffi_closure_unix do a full 64 bit load in all these cases
since that is what ffi_call_unix stored.

OK to check in on the main line?

Steve Ellcey
sje@cup.hp.com


2005-03-18  Steve Ellcey  <sje@cup.hp.com>

	* src/ia64/ffitarget.h (ffi_arg) ADD DI attribute.
	(ffi_sarg) Ditto.
	* src/ia64/unix.S (ffi_closure_unix): Extend gp
	to 64 bits in ILP32 mode.
	Load 64 bits even for short data.

*** gcc.orig/libffi/src/ia64/ffitarget.h	Wed Mar  9 11:25:12 2005
--- gcc/libffi/src/ia64/ffitarget.h	Fri Mar 18 15:32:57 2005
***************
*** 27,34 ****
  #define LIBFFI_TARGET_H
  
  #ifndef LIBFFI_ASM
! typedef unsigned long          ffi_arg;
! typedef signed long            ffi_sarg;
  
  typedef enum ffi_abi {
    FFI_FIRST_ABI = 0,
--- 27,34 ----
  #define LIBFFI_TARGET_H
  
  #ifndef LIBFFI_ASM
! typedef unsigned long          ffi_arg  __attribute__ ((mode (DI)));
! typedef signed long            ffi_sarg __attribute__ ((mode (DI)));
  
  typedef enum ffi_abi {
    FFI_FIRST_ABI = 0,
*** gcc.orig/libffi/src/ia64/unix.S	Wed Mar  9 11:24:59 2005
--- gcc/libffi/src/ia64/unix.S	Fri Mar 18 15:32:42 2005
*************** ffi_closure_unix:
*** 289,294 ****
--- 289,298 ----
  	mov	loc2 = ar.unat
  	.body
  
+ #ifdef _ILP32
+ 	addp4	gp = 0, gp
+ 	;;
+ #endif
  	/* Retrieve closure pointer and real gp.  */
  	mov	out0 = gp
  	add	gp = 16, gp
*************** ffi_closure_unix:
*** 368,398 ****
  	add	sp = FRAME_SIZE, sp
  	br.ret.sptk.many b0
  	;;
! .Lld_int8:
! 	.body
! 	.copy_state 1
! 	ld1	r8 = [r16]
! 	.restore sp
! 	add	sp = FRAME_SIZE, sp
! 	br.ret.sptk.many b0
! 	;;
! .Lld_int16:
! 	.body
! 	.copy_state 1
! 	ld2	r8 = [r16]
! 	.restore sp
! 	add	sp = FRAME_SIZE, sp
! 	br.ret.sptk.many b0
! 	;;
! .Lld_int32:
! 	.body
! 	.copy_state 1
! 	ld4	r8 = [r16]
! 	.restore sp
! 	add	sp = FRAME_SIZE, sp
! 	br.ret.sptk.many b0
! 	;;
! .Lld_int64:
  	.body
  	.copy_state 1
  	ld8	r8 = [r16]
--- 372,378 ----
  	add	sp = FRAME_SIZE, sp
  	br.ret.sptk.many b0
  	;;
! .Lld_int:
  	.body
  	.copy_state 1
  	ld8	r8 = [r16]
*************** ffi_closure_unix:
*** 554,573 ****
  
  .Lld_table:
  	data8	@pcrel(.Lld_void)		// FFI_TYPE_VOID
! 	data8	@pcrel(.Lld_int32)		// FFI_TYPE_INT
  	data8	@pcrel(.Lld_float)		// FFI_TYPE_FLOAT
  	data8	@pcrel(.Lld_double)		// FFI_TYPE_DOUBLE
  	data8	@pcrel(.Lld_ldouble)		// FFI_TYPE_LONGDOUBLE
! 	data8	@pcrel(.Lld_int8)		// FFI_TYPE_UINT8
! 	data8	@pcrel(.Lld_int8)		// FFI_TYPE_SINT8
! 	data8	@pcrel(.Lld_int16)		// FFI_TYPE_UINT16
! 	data8	@pcrel(.Lld_int16)		// FFI_TYPE_SINT16
! 	data8	@pcrel(.Lld_int32)		// FFI_TYPE_UINT32
! 	data8	@pcrel(.Lld_int32)		// FFI_TYPE_SINT32
! 	data8	@pcrel(.Lld_int64)		// FFI_TYPE_UINT64
! 	data8	@pcrel(.Lld_int64)		// FFI_TYPE_SINT64
  	data8	@pcrel(.Lld_void)		// FFI_TYPE_STRUCT
! 	data8	@pcrel(.Lld_int64)		// FFI_TYPE_POINTER
  	data8 	@pcrel(.Lld_small_struct)	// FFI_IA64_TYPE_SMALL_STRUCT
  	data8	@pcrel(.Lld_hfa_float)		// FFI_IA64_TYPE_HFA_FLOAT
  	data8	@pcrel(.Lld_hfa_double)		// FFI_IA64_TYPE_HFA_DOUBLE
--- 534,553 ----
  
  .Lld_table:
  	data8	@pcrel(.Lld_void)		// FFI_TYPE_VOID
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_INT
  	data8	@pcrel(.Lld_float)		// FFI_TYPE_FLOAT
  	data8	@pcrel(.Lld_double)		// FFI_TYPE_DOUBLE
  	data8	@pcrel(.Lld_ldouble)		// FFI_TYPE_LONGDOUBLE
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT8
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT8
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT16
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT16
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT32
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT32
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT64
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT64
  	data8	@pcrel(.Lld_void)		// FFI_TYPE_STRUCT
! 	data8	@pcrel(.Lld_int)		// FFI_TYPE_POINTER
  	data8 	@pcrel(.Lld_small_struct)	// FFI_IA64_TYPE_SMALL_STRUCT
  	data8	@pcrel(.Lld_hfa_float)		// FFI_IA64_TYPE_HFA_FLOAT
  	data8	@pcrel(.Lld_hfa_double)		// FFI_IA64_TYPE_HFA_DOUBLE


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