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 darwin cleanup


Hi,

this is a patch which cleans up whitespaces in code and adjusts formatting of comments.

Tested on Darwin.

Ok for mainline?

Thanks,

Andreas

2003-09-18 Andreas Tobler <a.tobler@schweiz.ch>

	* src/powerpc/darwin.S: Cleanup whitespaces,
	comment formatting.
	* src/powerpc/darwin_closure.S: Likewise.
	* src/powerpc/ffi_darwin.c: Likewise.
Index: src/powerpc/darwin.S
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/powerpc/darwin.S,v
retrieving revision 1.5
diff -c -r1.5 darwin.S
*** src/powerpc/darwin.S	22 Jan 2003 18:21:55 -0000	1.5
--- src/powerpc/darwin.S	18 Sep 2003 18:45:46 -0000
***************
*** 1,6 ****
  /* -----------------------------------------------------------------------
     darwin.S - Copyright (c) 2000 John Hornkvist
!    
     PowerPC Assembly glue.
  
     Permission is hereby granted, free of charge, to any person obtaining
--- 1,6 ----
  /* -----------------------------------------------------------------------
     darwin.S - Copyright (c) 2000 John Hornkvist
! 
     PowerPC Assembly glue.
  
     Permission is hereby granted, free of charge, to any person obtaining
***************
*** 23,29 ****
     OTHER DEALINGS IN THE SOFTWARE.
     ----------------------------------------------------------------------- */
  
! #define LIBFFI_ASM	
  #include <ffi.h>
  #define JUMPTARGET(name) name
  #define L(x) x
--- 23,29 ----
     OTHER DEALINGS IN THE SOFTWARE.
     ----------------------------------------------------------------------- */
  
! #define LIBFFI_ASM
  #include <ffi.h>
  #define JUMPTARGET(name) name
  #define L(x) x
***************
*** 37,95 ****
  .text
  	.align 2
  _ffi_call_DARWIN:
! LFB0:	
  	mr      r12,r8		/* We only need r12 until the call,
! 				so it doesn't have to be saved...  */
! LFB1:	
  	/* Save the old stack pointer as AP.  */
  	mr	r8,r1
! LCFI0:	
  	/* Allocate the stack space we need.  */
! 	stwux	r1,r1,r4	
! 	
  	/* Save registers we use.  */
  	mflr	r9
  
! 	stw	r28,-16(r8)	
  	stw	r29,-12(r8)
  	stw	r30, -8(r8)
  	stw	r31, -4(r8)
  
! 	stw	r9,  8(r8)	
  	stw	r2, 20(r1)
! LCFI1:	
  
  	/* Save arguments over call...  */
  	mr	r31,r5	/* flags,  */
  	mr	r30,r6	/* rvalue,  */
  	mr	r29,r7	/* function address,  */
  	mr	r28,r8	/* our AP.  */
! LCFI2:		
  	/* Call ffi_prep_args.  */
  	mr	r4,r1
  	li	r9,0
! 	
  	mtctr	r12 // r12 holds address of _ffi_prep_args
! 	bctrl 
  	lwz     r2,20(r1)
  
! 	/* Now do the call.  */
! 	/* Set up cr1 with bits 4-7 of the flags.  */
  	mtcrf	0x40,r31
  	/* Get the address to call into CTR.  */
  	mtctr	r29
! 	/* Load all those argument registers.  */
!         // We have set up a nice stack frame, just load it into registers.
!         lwz     r3, 20+(1*4)(r1)
!         lwz     r4, 20+(2*4)(r1)
!         lwz     r5, 20+(3*4)(r1)
!         lwz     r6, 20+(4*4)(r1)
!         nop
  	lwz     r7, 20+(5*4)(r1)
!         lwz     r8, 20+(6*4)(r1)
!         lwz     r9, 20+(7*4)(r1)
!         lwz     r10,20+(8*4)(r1)
! 		
  L1:
  	/* Load all the FP registers.  */
  	bf	6,L2 // 2f + 0x18
--- 37,95 ----
  .text
  	.align 2
  _ffi_call_DARWIN:
! LFB0:
  	mr      r12,r8		/* We only need r12 until the call,
! 				   so it doesn't have to be saved...  */
! LFB1:
  	/* Save the old stack pointer as AP.  */
  	mr	r8,r1
! LCFI0:
  	/* Allocate the stack space we need.  */
! 	stwux	r1,r1,r4
! 
  	/* Save registers we use.  */
  	mflr	r9
  
! 	stw	r28,-16(r8)
  	stw	r29,-12(r8)
  	stw	r30, -8(r8)
  	stw	r31, -4(r8)
  
! 	stw	r9,  8(r8)
  	stw	r2, 20(r1)
! LCFI1:
  
  	/* Save arguments over call...  */
  	mr	r31,r5	/* flags,  */
  	mr	r30,r6	/* rvalue,  */
  	mr	r29,r7	/* function address,  */
  	mr	r28,r8	/* our AP.  */
! LCFI2:
  	/* Call ffi_prep_args.  */
  	mr	r4,r1
  	li	r9,0
! 
  	mtctr	r12 // r12 holds address of _ffi_prep_args
! 	bctrl
  	lwz     r2,20(r1)
  
! 	/* Now do the call.
! 	   Set up cr1 with bits 4-7 of the flags.  */
  	mtcrf	0x40,r31
  	/* Get the address to call into CTR.  */
  	mtctr	r29
! 	/* Load all those argument registers.
! 	   We have set up a nice stack frame, just load it into registers.  */
! 	lwz     r3, 20+(1*4)(r1)
! 	lwz     r4, 20+(2*4)(r1)
! 	lwz     r5, 20+(3*4)(r1)
! 	lwz     r6, 20+(4*4)(r1)
! 	nop
  	lwz     r7, 20+(5*4)(r1)
! 	lwz     r8, 20+(6*4)(r1)
! 	lwz     r9, 20+(7*4)(r1)
! 	lwz     r10,20+(8*4)(r1)
! 
  L1:
  	/* Load all the FP registers.  */
  	bf	6,L2 // 2f + 0x18
***************
*** 104,123 ****
  	lfd	f8,-16-(6*8)(r28)
  	nop
  	lfd     f9,-16-(5*8)(r28)
!         lfd     f10,-16-(4*8)(r28)
  	lfd     f11,-16-(3*8)(r28)
  	lfd     f12,-16-(2*8)(r28)
  	nop
  	lfd     f13,-16-(1*8)(r28)
  
! L2:	
! 	mr	r12,r29 // Put the target address in r12 as specified.
  	mtctr  r12
  	nop
  	nop
  	/* Make the call.  */
  	bctrl
!         
  	/* Now, deal with the return value.  */
  	mtcrf	0x01,r31
  
--- 104,123 ----
  	lfd	f8,-16-(6*8)(r28)
  	nop
  	lfd     f9,-16-(5*8)(r28)
! 	lfd     f10,-16-(4*8)(r28)
  	lfd     f11,-16-(3*8)(r28)
  	lfd     f12,-16-(2*8)(r28)
  	nop
  	lfd     f13,-16-(1*8)(r28)
  
! L2:
! 	mr	r12,r29 /* Put the target address in r12 as specified.  */
  	mtctr  r12
  	nop
  	nop
  	/* Make the call.  */
  	bctrl
! 
  	/* Now, deal with the return value.  */
  	mtcrf	0x01,r31
  
***************
*** 147,153 ****
  L(float_return_value):
  	stfs	f1,0(r30)
  	b	L(done_return_value)
! LFE1:	
  /* END(_ffi_call_DARWIN)  */
  
  /* Provide a null definition of _ffi_call_AIX.  */
--- 147,153 ----
  L(float_return_value):
  	stfs	f1,0(r30)
  	b	L(done_return_value)
! LFE1:
  /* END(_ffi_call_DARWIN)  */
  
  /* Provide a null definition of _ffi_call_AIX.  */
***************
*** 193,218 ****
  	.set	L$set$4,LCFI0-LFB1
  	.long	L$set$4
  	.byte	0xd	; DW_CFA_def_cfa_register
! 	.byte	0x08	; uleb128 0x08 
  	.byte	0x4	; DW_CFA_advance_loc4
  	.set	L$set$5,LCFI1-LCFI0
  	.long	L$set$5
  	.byte   0x11    ; DW_CFA_offset_extended_sf
  	.byte	0x41	; uleb128 0x41
  	.byte   0x7e    ; sleb128 -2
! 	.byte	0x9f	; DW_CFA_offset, column 0x1f 
! 	.byte	0x1	; uleb128 0x1 
  	.byte	0x9e	; DW_CFA_offset, column 0x1e
  	.byte	0x2	; uleb128 0x2
! 	.byte	0x9d	; DW_CFA_offset, column 0x1d 
! 	.byte	0x3	; uleb128 0x3 
! 	.byte	0x9c	; DW_CFA_offset, column 0x1c 
  	.byte	0x4	; uleb128 0x4
! 	.byte	0x4	; DW_CFA_advance_loc4 
  	.set	L$set$6,LCFI2-LCFI1
  	.long	L$set$6
! 	.byte	0xd	; DW_CFA_def_cfa_register 
! 	.byte	0x1c	; uleb128 0x1c 
  	.align 2
  LEFDE1:
- 	
--- 193,217 ----
  	.set	L$set$4,LCFI0-LFB1
  	.long	L$set$4
  	.byte	0xd	; DW_CFA_def_cfa_register
! 	.byte	0x08	; uleb128 0x08
  	.byte	0x4	; DW_CFA_advance_loc4
  	.set	L$set$5,LCFI1-LCFI0
  	.long	L$set$5
  	.byte   0x11    ; DW_CFA_offset_extended_sf
  	.byte	0x41	; uleb128 0x41
  	.byte   0x7e    ; sleb128 -2
! 	.byte	0x9f	; DW_CFA_offset, column 0x1f
! 	.byte	0x1	; uleb128 0x1
  	.byte	0x9e	; DW_CFA_offset, column 0x1e
  	.byte	0x2	; uleb128 0x2
! 	.byte	0x9d	; DW_CFA_offset, column 0x1d
! 	.byte	0x3	; uleb128 0x3
! 	.byte	0x9c	; DW_CFA_offset, column 0x1c
  	.byte	0x4	; uleb128 0x4
! 	.byte	0x4	; DW_CFA_advance_loc4
  	.set	L$set$6,LCFI2-LCFI1
  	.long	L$set$6
! 	.byte	0xd	; DW_CFA_def_cfa_register
! 	.byte	0x1c	; uleb128 0x1c
  	.align 2
  LEFDE1:
Index: src/powerpc/darwin_closure.S
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/powerpc/darwin_closure.S,v
retrieving revision 1.5
diff -c -r1.5 darwin_closure.S
*** src/powerpc/darwin_closure.S	18 Sep 2003 18:23:47 -0000	1.5
--- src/powerpc/darwin_closure.S	18 Sep 2003 18:45:46 -0000
***************
*** 1,7 ****
  /* -----------------------------------------------------------------------
!    darwin_closure.S - Copyright (c) 2002 2003 Free Software Foundation, 
     Inc. based on ppc_closure.S
!  
     PowerPC Assembly glue.
  
     Permission is hereby granted, free of charge, to any person obtaining
--- 1,7 ----
  /* -----------------------------------------------------------------------
!    darwin_closure.S - Copyright (c) 2002 2003 Free Software Foundation,
     Inc. based on ppc_closure.S
! 
     PowerPC Assembly glue.
  
     Permission is hereby granted, free of charge, to any person obtaining
***************
*** 29,68 ****
  
  	.file	"darwin_closure.S"
  .text
! 	.align 2	
  .globl _ffi_closure_ASM
  
  .text
  	.align 2
  _ffi_closure_ASM:
! LFB1:		
  	mflr	r0			/* extract return address  */
  	stw	r0, 8(r1)		/* save the return address  */
! LCFI0:	
  	/* 24 Bytes (Linkage Area)
  	   32 Bytes (outgoing parameter area, always reserved)
! 	   104 Bytes (13*8 from FPR)	
  	   8 Bytes (result)
  	   168 Bytes  */
  
  	stwu	r1,-176(r1)	/* skip over caller save area
! 				keep stack aligned to 16  */
! LCFI1:		
! 	/* we want to build up an area for the parameters passed
! 	in registers (both floating point and integer)  */
  
! 	/* we store gpr 3 to gpr 10 (aligned to 4)
! 	in the parents outgoing area  */
  	stw   r3, 200(r1)
  	stw   r4, 204(r1)
! 	stw   r5, 208(r1) 
  	stw   r6, 212(r1)
  	stw   r7, 216(r1)
! 	stw   r8, 220(r1) 
  	stw   r9, 224(r1)
  	stw   r10, 228(r1)
  
! 	/* we save fpr 1 to fpr 13 (aligned to 8) */
  	stfd  f1, 56(r1)
  	stfd  f2, 64(r1)
  	stfd  f3, 72(r1)
--- 29,68 ----
  
  	.file	"darwin_closure.S"
  .text
! 	.align 2
  .globl _ffi_closure_ASM
  
  .text
  	.align 2
  _ffi_closure_ASM:
! LFB1:
  	mflr	r0			/* extract return address  */
  	stw	r0, 8(r1)		/* save the return address  */
! LCFI0:
  	/* 24 Bytes (Linkage Area)
  	   32 Bytes (outgoing parameter area, always reserved)
! 	   104 Bytes (13*8 from FPR)
  	   8 Bytes (result)
  	   168 Bytes  */
  
  	stwu	r1,-176(r1)	/* skip over caller save area
! 				keep stack aligned to 16.  */
! LCFI1:
! 	/* We want to build up an area for the parameters passed
! 	   in registers. (both floating point and integer)  */
  
! 	/* We store gpr 3 to gpr 10 (aligned to 4)
! 	   in the parents outgoing area.  */
  	stw   r3, 200(r1)
  	stw   r4, 204(r1)
! 	stw   r5, 208(r1)
  	stw   r6, 212(r1)
  	stw   r7, 216(r1)
! 	stw   r8, 220(r1)
  	stw   r9, 224(r1)
  	stw   r10, 228(r1)
  
! 	/* We save fpr 1 to fpr 13. (aligned to 8)  */
  	stfd  f1, 56(r1)
  	stfd  f2, 64(r1)
  	stfd  f3, 72(r1)
***************
*** 71,115 ****
  	stfd  f6, 96(r1)
  	stfd  f7, 104(r1)
  	stfd  f8, 112(r1)
! 	stfd  f9, 120(r1) 
! 	stfd  f10, 128(r1) 
! 	stfd  f11, 136(r1) 
! 	stfd  f12, 144(r1) 
! 	stfd  f13, 152(r1) 
  
! 	/* set up registers for the routine that actually does the work */
! 	/* get the context pointer from the trampoline */
  	mr r3,r11
  
! 	/* now load up the pointer to the result storage */
  	addi r4,r1,160
  
! 	/* now load up the pointer to the saved gpr registers  */
  	addi r5,r1,200
  
! 	/* now load up the pointer to the saved fpr registers */
  	addi r6,r1,56
  
! 	/* make the call */
  	bl	Lffi_closure_helper_DARWIN$stub
  
! 	/* now r3 contains the return type */
! 	/* so use it to look up in a table */
! 	/* so we know how to deal with each type */
! 
! 	/* look up the proper starting point in table  */
! 	/* by using return type as offset */
! 	addi  r5,r1,160		  /* get pointer to results area */
! 	bl    Lget_ret_type0_addr /* get pointer to Lret_type0 into LR  */
! 	mflr  r4		  /* move to r4  */
! 	slwi  r3,r3,4		  /* now multiply return type by 16  */
! 	add   r3,r3,r4		  /* add contents of table to table address */
  	mtctr r3
! 	bctr			  /* jump to it  */
  LFE1:
! /* Each of the ret_typeX code fragments has to be exactly 16 bytes long  */
! /* (4 instructions). For cache effectiveness we align to a 16 byte boundary  */
! /* first.  */
  
  	.align 4
  
--- 71,115 ----
  	stfd  f6, 96(r1)
  	stfd  f7, 104(r1)
  	stfd  f8, 112(r1)
! 	stfd  f9, 120(r1)
! 	stfd  f10, 128(r1)
! 	stfd  f11, 136(r1)
! 	stfd  f12, 144(r1)
! 	stfd  f13, 152(r1)
  
! 	/* Set up registers for the routine that actually does the work
! 	   get the context pointer from the trampoline.  */
  	mr r3,r11
  
! 	/* Now load up the pointer to the result storage.  */
  	addi r4,r1,160
  
! 	/* Now load up the pointer to the saved gpr registers.  */
  	addi r5,r1,200
  
! 	/* Now load up the pointer to the saved fpr registers.  */
  	addi r6,r1,56
  
! 	/* Make the call.  */
  	bl	Lffi_closure_helper_DARWIN$stub
  
! 	/* Now r3 contains the return type
! 	   so use it to look up in a table
! 	   so we know how to deal with each type.  */
! 
! 	/* Look up the proper starting point in table
! 	   by using return type as offset.  */
! 	addi  r5,r1,160		  /* Get pointer to results area.  */
! 	bl    Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR.  */
! 	mflr  r4		  /* Move to r4.  */
! 	slwi  r3,r3,4		  /* Now multiply return type by 16.  */
! 	add   r3,r3,r4		  /* Add contents of table to table address.  */
  	mtctr r3
! 	bctr			  /* Jump to it.  */
  LFE1:
! /* Each of the ret_typeX code fragments has to be exactly 16 bytes long
!    (4 instructions). For cache effectiveness we align to a 16 byte boundary
!    first.  */
  
  	.align 4
  
***************
*** 142,162 ****
  
  /* case FFI_TYPE_DOUBLE  */
  Lret_type3:
!         lfd	f1,0(r5)
  	b	Lfinish
  	nop
  	nop
  
  /* case FFI_TYPE_LONGDOUBLE  */
  Lret_type4:
!         lfd	f1,0(r5)
  	b	Lfinish
  	nop
  	nop
  
  /* case FFI_TYPE_UINT8  */
  Lret_type5:
!         lbz	r3,3(r5)
  	b	Lfinish
  	nop
  	nop
--- 142,162 ----
  
  /* case FFI_TYPE_DOUBLE  */
  Lret_type3:
! 	lfd	f1,0(r5)
  	b	Lfinish
  	nop
  	nop
  
  /* case FFI_TYPE_LONGDOUBLE  */
  Lret_type4:
! 	lfd	f1,0(r5)
  	b	Lfinish
  	nop
  	nop
  
  /* case FFI_TYPE_UINT8  */
  Lret_type5:
! 	lbz	r3,3(r5)
  	b	Lfinish
  	nop
  	nop
***************
*** 210,216 ****
  	b	Lfinish
  	nop
  
! /* case FFI_TYPE_STRUCT */
  Lret_type13:
  	b	Lfinish
  	nop
--- 210,216 ----
  	b	Lfinish
  	nop
  
! /* case FFI_TYPE_STRUCT  */
  Lret_type13:
  	b	Lfinish
  	nop
***************
*** 224,237 ****
  	nop
  	nop
  
! /* case done  */	
! Lfinish:	
! 	addi	r1,r1,176		/* restore stack pointer  */
! 	lwz	r0,8(r1)		/* get return address  */
! 	mtlr	r0			/* reset link register  */
  	blr
! 	
! /* END(ffi_closure_ASM)  */	
  
  .data
  .section __TEXT,__eh_frame
--- 224,237 ----
  	nop
  	nop
  
! /* case done  */
! Lfinish:
! 	addi	r1,r1,176		/* Restore stack pointer.  */
! 	lwz	r0,8(r1)		/* Get return address.  */
! 	mtlr	r0			/* Reset link register.  */
  	blr
! 
! /* END(ffi_closure_ASM)  */
  
  .data
  .section __TEXT,__eh_frame
***************
*** 267,273 ****
  	.set	L$set$3,LCFI1-LCFI0
  	.long	L$set$3
  	.byte	0xe	; DW_CFA_def_cfa_offset
!  	.byte	176,1	; uleb128 176
  	.byte	0x4	; DW_CFA_advance_loc4
  	.set	L$set$4,LCFI0-LFB1
  	.long	L$set$4
--- 267,273 ----
  	.set	L$set$3,LCFI1-LCFI0
  	.long	L$set$3
  	.byte	0xe	; DW_CFA_def_cfa_offset
! 	.byte	176,1	; uleb128 176
  	.byte	0x4	; DW_CFA_advance_loc4
  	.set	L$set$4,LCFI0-LFB1
  	.long	L$set$4
***************
*** 281,299 ****
  LDFCM0:
  .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  	.align	2
! Lffi_closure_helper_DARWIN$stub: 
! 	.indirect_symbol _ffi_closure_helper_DARWIN       
! 	mflr	r0         
! 	bcl	20,31,LO$ffi_closure_helper_DARWIN 
  LO$ffi_closure_helper_DARWIN:
! 	mflr	r11                 
  	addis	r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)
! 	mtlr	r0 
! 	lwzu	r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11)         
! 	mtctr	r12                
! 	bctr    
  .data
! .lazy_symbol_pointer 
! L_ffi_closure_helper_DARWIN$lazy_ptr:         
  	.indirect_symbol _ffi_closure_helper_DARWIN
  	.long   dyld_stub_binding_helper
--- 281,299 ----
  LDFCM0:
  .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  	.align	2
! Lffi_closure_helper_DARWIN$stub:
! 	.indirect_symbol _ffi_closure_helper_DARWIN
! 	mflr	r0
! 	bcl	20,31,LO$ffi_closure_helper_DARWIN
  LO$ffi_closure_helper_DARWIN:
! 	mflr	r11
  	addis	r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)
! 	mtlr	r0
! 	lwzu	r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11)
! 	mtctr	r12
! 	bctr
  .data
! .lazy_symbol_pointer
! L_ffi_closure_helper_DARWIN$lazy_ptr:
  	.indirect_symbol _ffi_closure_helper_DARWIN
  	.long   dyld_stub_binding_helper
Index: src/powerpc/ffi_darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/powerpc/ffi_darwin.c,v
retrieving revision 1.8
diff -c -r1.8 ffi_darwin.c
*** src/powerpc/ffi_darwin.c	18 Sep 2003 18:23:47 -0000	1.8
--- src/powerpc/ffi_darwin.c	18 Sep 2003 18:45:46 -0000
***************
*** 1,7 ****
  /* -----------------------------------------------------------------------
     ffi.c - Copyright (c) 1998 Geoffrey Keating
!    
!    PowerPC Foreign Function Interface 
  
     Darwin ABI support (c) 2001 John Hornkvist
     AIX ABI support (c) 2002 Free Software Foundation, Inc.
--- 1,7 ----
  /* -----------------------------------------------------------------------
     ffi.c - Copyright (c) 1998 Geoffrey Keating
! 
!    PowerPC Foreign Function Interface
  
     Darwin ABI support (c) 2001 John Hornkvist
     AIX ABI support (c) 2002 Free Software Foundation, Inc.
***************
*** 34,45 ****
  
  enum {
    /* The assembly depends on these exact flags.  */
!   FLAG_RETURNS_NOTHING  = 1 << (31-30), /* These go in cr7 */
    FLAG_RETURNS_FP       = 1 << (31-29),
    FLAG_RETURNS_64BITS   = 1 << (31-28),
  
    FLAG_ARG_NEEDS_COPY   = 1 << (31- 7),
!   FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI */
    FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
    FLAG_RETVAL_REFERENCE = 1 << (31- 4)
  };
--- 34,45 ----
  
  enum {
    /* The assembly depends on these exact flags.  */
!   FLAG_RETURNS_NOTHING  = 1 << (31-30), /* These go in cr7  */
    FLAG_RETURNS_FP       = 1 << (31-29),
    FLAG_RETURNS_64BITS   = 1 << (31-28),
  
    FLAG_ARG_NEEDS_COPY   = 1 << (31- 7),
!   FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI  */
    FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
    FLAG_RETVAL_REFERENCE = 1 << (31- 4)
  };
***************
*** 58,64 ****
  
     |   Return address from ffi_call_DARWIN      |	higher addresses
     |--------------------------------------------|
!    |   Previous backchain pointer	4	| 	stack pointer here
     |--------------------------------------------|<+ <<<	on entry to
     |   Saved r28-r31			4*4	| |	ffi_call_DARWIN
     |--------------------------------------------| |
--- 58,64 ----
  
     |   Return address from ffi_call_DARWIN      |	higher addresses
     |--------------------------------------------|
!    |   Previous backchain pointer	4	|	stack pointer here
     |--------------------------------------------|<+ <<<	on entry to
     |   Saved r28-r31			4*4	| |	ffi_call_DARWIN
     |--------------------------------------------| |
***************
*** 69,75 ****
     |   Reserved                       2*4       | |	grows	|
     |--------------------------------------------| |	down	V
     |   Space for callee's LR		4	| |
!    |--------------------------------------------| |	lower addresses	
     |   Saved CR                         4       | |
     |--------------------------------------------| |     stack pointer here
     |   Current backchain pointer	4	|-/	during
--- 69,75 ----
     |   Reserved                       2*4       | |	grows	|
     |--------------------------------------------| |	down	V
     |   Space for callee's LR		4	| |
!    |--------------------------------------------| |	lower addresses
     |   Saved CR                         4       | |
     |--------------------------------------------| |     stack pointer here
     |   Current backchain pointer	4	|-/	during
***************
*** 93,99 ****
  
  
    /* 'next_arg' grows up as we put parameters in it.  */
!   unsigned *next_arg = stack + 6; // 6 reserved posistions. 
  
    int i = ecif->cif->nargs;
    double double_tmp;
--- 93,99 ----
  
  
    /* 'next_arg' grows up as we put parameters in it.  */
!   unsigned *next_arg = stack + 6; /* 6 reserved posistions.  */
  
    int i = ecif->cif->nargs;
    double double_tmp;
***************
*** 108,116 ****
    FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
    FFI_ASSERT((bytes & 0xF) == 0);
  
!   /* Deal with return values that are actually pass-by-reference.  */
!   // Rule:
!   // Return values are referenced by r3, so r4 is the first parameter.
    if (flags & FLAG_RETVAL_REFERENCE)
      *next_arg++ = (unsigned)(char *)ecif->rvalue;
  
--- 108,117 ----
    FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
    FFI_ASSERT((bytes & 0xF) == 0);
  
!   /* Deal with return values that are actually pass-by-reference.
!      Rule:
!      Return values are referenced by r3, so r4 is the first parameter.  */
! 
    if (flags & FLAG_RETVAL_REFERENCE)
      *next_arg++ = (unsigned)(char *)ecif->rvalue;
  
***************
*** 127,154 ****
  	case FFI_TYPE_FLOAT:
  	  double_tmp = *(float *)*p_argv;
  	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
!             *(double *)next_arg = double_tmp;
  	  else
!             *fpr_base++ = double_tmp;
!           next_arg++;
  	  fparg_count++;
  	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
  	  break;
  	case FFI_TYPE_DOUBLE:
  	  double_tmp = *(double *)*p_argv;
  	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
!             *(double *)next_arg = double_tmp;
  	  else
!             *fpr_base++ = double_tmp;
!           next_arg += 2;
  	  fparg_count++;
  	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
  	  break;
  
  	case FFI_TYPE_UINT64:
  	case FFI_TYPE_SINT64:
!           *(long long *)next_arg = *(long long *)*p_argv;
!           next_arg+=2;
  	  break;
  	case FFI_TYPE_UINT8:
  	  gprvalue = *(unsigned char *)*p_argv;
--- 128,155 ----
  	case FFI_TYPE_FLOAT:
  	  double_tmp = *(float *)*p_argv;
  	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
! 	    *(double *)next_arg = double_tmp;
  	  else
! 	    *fpr_base++ = double_tmp;
! 	  next_arg++;
  	  fparg_count++;
  	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
  	  break;
  	case FFI_TYPE_DOUBLE:
  	  double_tmp = *(double *)*p_argv;
  	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
! 	    *(double *)next_arg = double_tmp;
  	  else
! 	    *fpr_base++ = double_tmp;
! 	  next_arg += 2;
  	  fparg_count++;
  	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
  	  break;
  
  	case FFI_TYPE_UINT64:
  	case FFI_TYPE_SINT64:
! 	  *(long long *)next_arg = *(long long *)*p_argv;
! 	  next_arg+=2;
  	  break;
  	case FFI_TYPE_UINT8:
  	  gprvalue = *(unsigned char *)*p_argv;
***************
*** 187,193 ****
  	  break;
  
  	case FFI_TYPE_INT:
!    	case FFI_TYPE_UINT32:
  	case FFI_TYPE_SINT32:
  	case FFI_TYPE_POINTER:
  	  gprvalue = *(unsigned *)*p_argv;
--- 188,194 ----
  	  break;
  
  	case FFI_TYPE_INT:
! 	case FFI_TYPE_UINT32:
  	case FFI_TYPE_SINT32:
  	case FFI_TYPE_POINTER:
  	  gprvalue = *(unsigned *)*p_argv;
***************
*** 206,212 ****
    //FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
  }
  
! /* Perform machine dependent cif processing */
  ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
  {
    /* All this is for the DARWIN ABI.  */
--- 207,213 ----
    //FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
  }
  
! /* Perform machine dependent cif processing.  */
  ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
  {
    /* All this is for the DARWIN ABI.  */
***************
*** 220,226 ****
    /* All the machine-independent calculation of cif->bytes will be wrong.
       Redo the calculation for DARWIN.  */
  
!   /* Space for the frame pointer, callee's LR, CR, etc, and for 
       the asm's temp regs.  */
  
    bytes = (6 + ASM_NEEDS_REGISTERS) * sizeof(long);
--- 221,227 ----
    /* All the machine-independent calculation of cif->bytes will be wrong.
       Redo the calculation for DARWIN.  */
  
!   /* Space for the frame pointer, callee's LR, CR, etc, and for
       the asm's temp regs.  */
  
    bytes = (6 + ASM_NEEDS_REGISTERS) * sizeof(long);
***************
*** 343,364 ****
  
  /*@-declundef@*/
  /*@-exportheader@*/
! extern void ffi_call_AIX(/*@out@*/ extended_cif *, 
! 			 unsigned, unsigned, 
! 			 /*@out@*/ unsigned *, 
  			 void (*fn)(),
  			 void (*fn2)());
! extern void ffi_call_DARWIN(/*@out@*/ extended_cif *, 
! 			    unsigned, unsigned, 
! 			    /*@out@*/ unsigned *, 
  			    void (*fn)(),
  			    void (*fn2)());
  /*@=declundef@*/
  /*@=exportheader@*/
  
! void ffi_call(/*@dependent@*/ ffi_cif *cif, 
! 	      void (*fn)(), 
! 	      /*@out@*/ void *rvalue, 
  	      /*@dependent@*/ void **avalue)
  {
    extended_cif ecif;
--- 344,365 ----
  
  /*@-declundef@*/
  /*@-exportheader@*/
! extern void ffi_call_AIX(/*@out@*/ extended_cif *,
! 			 unsigned, unsigned,
! 			 /*@out@*/ unsigned *,
  			 void (*fn)(),
  			 void (*fn2)());
! extern void ffi_call_DARWIN(/*@out@*/ extended_cif *,
! 			    unsigned, unsigned,
! 			    /*@out@*/ unsigned *,
  			    void (*fn)(),
  			    void (*fn2)());
  /*@=declundef@*/
  /*@=exportheader@*/
  
! void ffi_call(/*@dependent@*/ ffi_cif *cif,
! 	      void (*fn)(),
! 	      /*@out@*/ void *rvalue,
  	      /*@dependent@*/ void **avalue)
  {
    extended_cif ecif;
***************
*** 366,375 ****
    ecif.cif = cif;
    ecif.avalue = avalue;
  
!   /* If the return value is a struct and we don't have a return	*/
!   /* value address then we need to make one		        */
  
!   if ((rvalue == NULL) && 
        (cif->rtype->type == FFI_TYPE_STRUCT))
      {
        /*@-sysunrecog@*/
--- 367,376 ----
    ecif.cif = cif;
    ecif.avalue = avalue;
  
!   /* If the return value is a struct and we don't have a return
!      value address then we need to make one.  */
  
!   if ((rvalue == NULL) &&
        (cif->rtype->type == FFI_TYPE_STRUCT))
      {
        /*@-sysunrecog@*/
***************
*** 379,395 ****
    else
      ecif.rvalue = rvalue;
  
!   switch (cif->abi) 
      {
      case FFI_AIX:
        /*@-usedef@*/
!       ffi_call_AIX(&ecif, -cif->bytes, 
  		   cif->flags, ecif.rvalue, fn, ffi_prep_args);
        /*@=usedef@*/
        break;
      case FFI_DARWIN:
        /*@-usedef@*/
!       ffi_call_DARWIN(&ecif, -cif->bytes, 
  		      cif->flags, ecif.rvalue, fn, ffi_prep_args);
        /*@=usedef@*/
        break;
--- 380,396 ----
    else
      ecif.rvalue = rvalue;
  
!   switch (cif->abi)
      {
      case FFI_AIX:
        /*@-usedef@*/
!       ffi_call_AIX(&ecif, -cif->bytes,
  		   cif->flags, ecif.rvalue, fn, ffi_prep_args);
        /*@=usedef@*/
        break;
      case FFI_DARWIN:
        /*@-usedef@*/
!       ffi_call_DARWIN(&ecif, -cif->bytes,
  		      cif->flags, ecif.rvalue, fn, ffi_prep_args);
        /*@=usedef@*/
        break;
***************
*** 402,409 ****
  static void flush_icache(char *);
  static void flush_range(char *, int);
  
! /* The layout of a function descriptor.  A C function pointer really    */
! /* points to one of these.                                              */
  
  typedef struct aix_fd_struct {
      void *code_pointer;
--- 403,410 ----
  static void flush_icache(char *);
  static void flush_range(char *, int);
  
! /* The layout of a function descriptor.  A C function pointer really
!    points to one of these.  */
  
  typedef struct aix_fd_struct {
      void *code_pointer;
***************
*** 411,480 ****
  } aix_fd;
  
  /* here I'd like to add the stack frame layout we use in darwin_closure.S
!  * and aix_clsoure.S
!  *
!  * SP previous -> +---------------------------------------+ <--- child frame
!                   | back chain to caller 4                | 
!                   +---------------------------------------+ 4
!                   | saved CR 4                            | 
!                   +---------------------------------------+ 8 
!                   | saved LR 4                            | 
!                   +---------------------------------------+ 12
!                   | reserved for compilers 4              | 
!                   +---------------------------------------+ 16
!                   | reserved for binders 4                | 
!                   +---------------------------------------+ 20
!                   | saved TOC pointer 4                   | 
!                   +---------------------------------------+ 24
!                   | always reserved 8*4=32 (previous GPRs)| 
!                   | according to the linkage convention   |
!                   | from AIX                              |
!                   +---------------------------------------+ 56
!                   | our FPR area 13*8=104                 |
!                   | f1                                    |
!                   | .                                     |
!                   | f13                                   | 
!                   +---------------------------------------+ 160
!                   | result area 8                         |
!                   +---------------------------------------+ 168
!                   | alignement to the next multiple of 16 |
  SP current -->    +---------------------------------------+ 176 <- parent frame
!                   | back chain to caller 4                | 
!                   +---------------------------------------+ 180
!                   | saved CR 4                            | 
!                   +---------------------------------------+ 184
!                   | saved LR 4                            | 
!                   +---------------------------------------+ 188
!                   | reserved for compilers 4              | 
!                   +---------------------------------------+ 192
!                   | reserved for binders 4                | 
!                   +---------------------------------------+ 196
!                   | saved TOC pointer 4                   | 
!                   +---------------------------------------+ 200
!                   | always reserved 8*4=32  we store our  |
!                   | GPRs here                             |
!                   | r3                                    |
!                   | .                                     |
!                   | r10                                   |
!                   +---------------------------------------+ 232
!                   | overflow part                         | 
!                   +---------------------------------------+ xxx
!                   | ????                                  | 
!                   +---------------------------------------+ xxx
  
  */
  ffi_status
! ffi_prep_closure (ffi_closure* closure,    
!                   ffi_cif* cif,
!                   void (*fun)(ffi_cif*, void*, void**, void*),
!                   void *user_data)
  {
    unsigned int *tramp;
    struct ffi_aix_trampoline_struct *tramp_aix;
    aix_fd *fd;
  
    switch (cif->abi)
!     {  
      case FFI_DARWIN:
  
        FFI_ASSERT (cif->abi == FFI_DARWIN);
--- 412,481 ----
  } aix_fd;
  
  /* here I'd like to add the stack frame layout we use in darwin_closure.S
!    and aix_clsoure.S
! 
!    SP previous -> +---------------------------------------+ <--- child frame
! 		  | back chain to caller 4                |
! 		  +---------------------------------------+ 4
! 		  | saved CR 4                            |
! 		  +---------------------------------------+ 8
! 		  | saved LR 4                            |
! 		  +---------------------------------------+ 12
! 		  | reserved for compilers 4              |
! 		  +---------------------------------------+ 16
! 		  | reserved for binders 4                |
! 		  +---------------------------------------+ 20
! 		  | saved TOC pointer 4                   |
! 		  +---------------------------------------+ 24
! 		  | always reserved 8*4=32 (previous GPRs)|
! 		  | according to the linkage convention   |
! 		  | from AIX                              |
! 		  +---------------------------------------+ 56
! 		  | our FPR area 13*8=104                 |
! 		  | f1                                    |
! 		  | .                                     |
! 		  | f13                                   |
! 		  +---------------------------------------+ 160
! 		  | result area 8                         |
! 		  +---------------------------------------+ 168
! 		  | alignement to the next multiple of 16 |
  SP current -->    +---------------------------------------+ 176 <- parent frame
! 		  | back chain to caller 4                |
! 		  +---------------------------------------+ 180
! 		  | saved CR 4                            |
! 		  +---------------------------------------+ 184
! 		  | saved LR 4                            |
! 		  +---------------------------------------+ 188
! 		  | reserved for compilers 4              |
! 		  +---------------------------------------+ 192
! 		  | reserved for binders 4                |
! 		  +---------------------------------------+ 196
! 		  | saved TOC pointer 4                   |
! 		  +---------------------------------------+ 200
! 		  | always reserved 8*4=32  we store our  |
! 		  | GPRs here                             |
! 		  | r3                                    |
! 		  | .                                     |
! 		  | r10                                   |
! 		  +---------------------------------------+ 232
! 		  | overflow part                         |
! 		  +---------------------------------------+ xxx
! 		  | ????                                  |
! 		  +---------------------------------------+ xxx
  
  */
  ffi_status
! ffi_prep_closure (ffi_closure* closure,
! 		  ffi_cif* cif,
! 		  void (*fun)(ffi_cif*, void*, void**, void*),
! 		  void *user_data)
  {
    unsigned int *tramp;
    struct ffi_aix_trampoline_struct *tramp_aix;
    aix_fd *fd;
  
    switch (cif->abi)
!     {
      case FFI_DARWIN:
  
        FFI_ASSERT (cif->abi == FFI_DARWIN);
***************
*** 527,538 ****
  {
  #ifndef _AIX
    __asm__ volatile (
!                 "dcbf 0,%0;"
!                 "sync;"
!                 "icbi 0,%0;"
!                 "sync;"
!                 "isync;"
!                 : : "r"(addr) : "memory");
  #endif
  }
  
--- 528,539 ----
  {
  #ifndef _AIX
    __asm__ volatile (
! 		"dcbf 0,%0;"
! 		"sync;"
! 		"icbi 0,%0;"
! 		"sync;"
! 		"isync;"
! 		: : "r"(addr) : "memory");
  #endif
  }
  
***************
*** 556,567 ****
  			       unsigned long*, ffi_dblfl*);
  
  /* Basically the trampoline invokes ffi_closure_ASM, and on
!  * entry, r11 holds the address of the closure.
!  * After storing the registers that could possibly contain
!  * parameters to be passed into the stack frame and setting
!  * up space for a return value, ffi_closure_ASM invokes the
!  * following helper function to do most of the work
!  */
  
  int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
  			       unsigned long * pgr, ffi_dblfl * pfr)
--- 557,567 ----
  			       unsigned long*, ffi_dblfl*);
  
  /* Basically the trampoline invokes ffi_closure_ASM, and on
!    entry, r11 holds the address of the closure.
!    After storing the registers that could possibly contain
!    parameters to be passed into the stack frame and setting
!    up space for a return value, ffi_closure_ASM invokes the
!    following helper function to do most of the work.  */
  
  int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
  			       unsigned long * pgr, ffi_dblfl * pfr)
***************
*** 574,581 ****
    void **          avalue;
    ffi_type **      arg_types;
    long             i, avn;
!   long             nf;   /* number of floating registers already used */
!   long             ng;   /* number of general registers already used */
    ffi_cif *        cif;
    double           temp;
    unsigned         size_al;
--- 574,581 ----
    void **          avalue;
    ffi_type **      arg_types;
    long             i, avn;
!   long             nf;   /* number of floating registers already used.  */
!   long             ng;   /* number of general registers already used.  */
    ffi_cif *        cif;
    double           temp;
    unsigned         size_al;
***************
*** 652,661 ****
  	  break;
  
  	case FFI_TYPE_FLOAT:
! 	  /* a float value consumes a GPR
! 	   *
! 	   * here are 13 64bit floating point registers.
! 	   */
  	  if (nf < NUM_FPR_ARG_REGISTERS)
  	    {
  	      temp = pfr->d;
--- 652,659 ----
  	  break;
  
  	case FFI_TYPE_FLOAT:
! 	  /* A float value consumes a GPR.
! 	     There are 13 64bit floating point registers.  */
  	  if (nf < NUM_FPR_ARG_REGISTERS)
  	    {
  	      temp = pfr->d;
***************
*** 673,682 ****
  	  break;
  
  	case FFI_TYPE_DOUBLE:
! 	  /* a double value consumes two GPRs
! 	   *
! 	   * There are 13 64bit floating point registers.
! 	   */
  	  if (nf < NUM_FPR_ARG_REGISTERS)
  	    {
  	      avalue[i] = pfr;
--- 671,678 ----
  	  break;
  
  	case FFI_TYPE_DOUBLE:
! 	  /* A double value consumes two GPRs.
! 	     There are 13 64bit floating point registers.  */
  	  if (nf < NUM_FPR_ARG_REGISTERS)
  	    {
  	      avalue[i] = pfr;
***************
*** 691,699 ****
  	  pgr += 2;
  	  break;
  
!         default:
!           FFI_ASSERT(0);
!         }
        i++;
      }
  
--- 687,695 ----
  	  pgr += 2;
  	  break;
  
! 	default:
! 	  FFI_ASSERT(0);
! 	}
        i++;
      }
  

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