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]

[patch] Supposrt for stormy16 abi changes


The ABI for stormy16 has changed.  Highlights are that indirect
calls must use registers r8 and r9.  Arguments can no longer be
passed in r8 and r9 -- we will now use r2-r7.  There were several
bugs with trying to return structs in registers.  Revert to returning
structs via hidden pointer for now.  Okay to commit?

Catherine

2001-10-05  Catherine Moore  <clm@redhat.com>

	* config/stormy16/stormy-abi:  Document abi changes.
	* config/stormy16/stormy16.h (REG_ALLOC_ORDER): Redefine.
	(ICALL_REGS): New register class.
	(NUM_ARGUMENT_REGISTERS): Now 6.
	(DEFAULT_PCC_STRUCT_RETURN): Don't try to return structs
	in registers.
	(REG_CLASS_FROM_LETTER): Map 'z' to ICALL_REGS.
	* config/stormy16.md (call_internal, call_value_internal,
	indirect_jump): Use new 'z' constraint.
	

Index: stormy-abi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/stormy16/stormy-abi,v
retrieving revision 1.1
diff -p -r1.1 stormy-abi
*** stormy-abi	2001/08/25 17:14:36	1.1
--- stormy-abi	2001/10/05 17:42:52
*************** The registers are allocated as follows:
*** 24,40 ****
  
  Register	Purpose
  -------------------------------------------------------------------
! r0, r1		Call-volatile.  May be changed during the execution
  		of a call instruction.
- r2 through r9	Argument passing; call-clobbered.
  r10 through r13	Call-saved.
  r14		Program status word.
  r15		Stack pointer.
  
  
! The return value of a procedure is returned in r2-r9 if it fits,
! otherwise a pointer is passed as a `hidden' first argument
! and the return value is placed there.
  
  Arguments are passed in registers starting in r2, then on the stack.
  Arguments of size not a multiple of a word are padded to whole words.
--- 24,40 ----
  
  Register	Purpose
  -------------------------------------------------------------------
! r2 through r7   Argument passing;  call-clobbered.
! r8, r9		Call-volatile.  May be changed during the execution
  		of a call instruction.
  r10 through r13	Call-saved.
  r14		Program status word.
  r15		Stack pointer.
  
  
! Scalar values are returned in register r2-r7 if the value fits.
! Otherwise, a pointer is passed as a 'hidden' first argument and
! the return value is placed there.
  
  Arguments are passed in registers starting in r2, then on the stack.
  Arguments of size not a multiple of a word are padded to whole words.
*************** count += N;
*** 83,102 ****
  
  
  One implementation of this is if a variadic function first
! pushes registers 2 through 9 in sequence at entry, and
  sets 'base' to the address of the first word pushed, 
  producing a stack that appears like:
  
  SP ->
  	[other data]
- 	r9
- 	r8
  	r7
  	r6
  	r5
  	r4
  	r3
! count-> r2
  	Return address (two words)
  	9th procedure parameter word
  	10th procedure parameter word
--- 83,100 ----
  
  
  One implementation of this is if a variadic function first
! pushes registers 2 through 7 in sequence at entry, and
  sets 'base' to the address of the first word pushed, 
  producing a stack that appears like:
  
  SP ->
  	[other data]
  	r7
  	r6
  	r5
  	r4
  	r3
! count->	r2
  	Return address (two words)
  	9th procedure parameter word
  	10th procedure parameter word
Index: stormy16.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/stormy16/stormy16.h,v
retrieving revision 1.9
diff -p -r1.9 stormy16.h
*** stormy16.h	2001/09/21 20:26:44	1.9
--- stormy16.h	2001/10/05 17:42:54
*************** do {									\
*** 1043,1049 ****
     only sequences of consecutive registers.  On such machines, define
     `REG_ALLOC_ORDER' to be an initializer that lists the highest numbered
     allocatable register first.  */
! #define REG_ALLOC_ORDER { 9, 7, 6, 5, 4, 3, 8, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16 }
  
  /* A C statement (sans semicolon) to choose the order in which to allocate hard
     registers for pseudo-registers local to a basic block.
--- 1043,1049 ----
     only sequences of consecutive registers.  On such machines, define
     `REG_ALLOC_ORDER' to be an initializer that lists the highest numbered
     allocatable register first.  */
! #define REG_ALLOC_ORDER { 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 10, 11, 12, 13, 14, 15, 16 }
  
  /* A C statement (sans semicolon) to choose the order in which to allocate hard
     registers for pseudo-registers local to a basic block.
*************** enum reg_class
*** 1204,1209 ****
--- 1204,1210 ----
    R2_REGS,
    EIGHT_REGS,
    R8_REGS,
+   ICALL_REGS,
    GENERAL_REGS,
    CARRY_REGS,
    ALL_REGS,
*************** enum reg_class
*** 1226,1231 ****
--- 1227,1233 ----
    "R2_REGS",					\
    "EIGHT_REGS",					\
    "R8_REGS",					\
+   "ICALL_REGS",					\
    "GENERAL_REGS",				\
    "CARRY_REGS",					\
    "ALL_REGS"					\
*************** enum reg_class
*** 1250,1255 ****
--- 1252,1258 ----
    0x00004,					\
    0x000FF,					\
    0x00100,					\
+   0x00300,					\
    0x6FFFF,					\
    0x10000,					\
    (1 << FIRST_PSEUDO_REGISTER) - 1		\
*************** enum reg_class
*** 1303,1308 ****
--- 1306,1312 ----
    : (CHAR) == 'e' ? EIGHT_REGS			\
    : (CHAR) == 't' ? TWO_REGS			\
    : (CHAR) == 'y' ? CARRY_REGS			\
+   : (CHAR) == 'z' ? ICALL_REGS			\
    : NO_REGS)
  
  /* A C expression which is nonzero if register number NUM is suitable for use
*************** enum reg_class
*** 2007,2013 ****
  
  /* Function Arguments in Registers */
  
! #define NUM_ARGUMENT_REGISTERS 8
  #define FIRST_ARGUMENT_REGISTER 2
  
  #define STORMY16_WORD_SIZE(TYPE, MODE)				\
--- 2011,2017 ----
  
  /* Function Arguments in Registers */
  
! #define NUM_ARGUMENT_REGISTERS 6
  #define FIRST_ARGUMENT_REGISTER 2
  
  #define STORMY16_WORD_SIZE(TYPE, MODE)				\
*************** typedef int CUMULATIVE_ARGS;
*** 2293,2299 ****
     return values are decided by the `RETURN_IN_MEMORY' macro.
  
     If not defined, this defaults to the value 1.  */
! #define DEFAULT_PCC_STRUCT_RETURN 0
  
  /* If the structure value address is passed in a register, then
     `STRUCT_VALUE_REGNUM' should be the number of that register.  */
--- 2297,2303 ----
     return values are decided by the `RETURN_IN_MEMORY' macro.
  
     If not defined, this defaults to the value 1.  */
! /* #define DEFAULT_PCC_STRUCT_RETURN 0 */
  
  /* If the structure value address is passed in a register, then
     `STRUCT_VALUE_REGNUM' should be the number of that register.  */
Index: stormy16.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/stormy16/stormy16.md,v
retrieving revision 1.2
diff -p -r1.2 stormy16.md
*** stormy16.md	2001/08/31 01:56:43	1.2
--- stormy16.md	2001/10/05 17:42:54
***************
*** 822,828 ****
  (define_insn "*call_internal"
    [(call (mem:HI (match_operand:HI 0 "nonmemory_operand" "i,r"))
  	 (match_operand 1 "" ""))
!    (use (match_operand:HI 2 "nonmemory_operand" "X,t"))]
    ""
    "@
     callf %C0
--- 822,828 ----
  (define_insn "*call_internal"
    [(call (mem:HI (match_operand:HI 0 "nonmemory_operand" "i,r"))
  	 (match_operand 1 "" ""))
!    (use (match_operand:HI 2 "nonmemory_operand" "X,z"))]
    ""
    "@
     callf %C0
***************
*** 834,840 ****
    [(set (match_operand 3 "register_operand" "=r,r")
          (call (mem:HI (match_operand:HI 0 "nonmemory_operand" "i,r"))
  	      (match_operand 1 "" "")))
!    (use (match_operand:HI 2 "nonmemory_operand" "X,t"))]
    ""
    "@
     callf %C0
--- 834,840 ----
    [(set (match_operand 3 "register_operand" "=r,r")
          (call (mem:HI (match_operand:HI 0 "nonmemory_operand" "i,r"))
  	      (match_operand 1 "" "")))
!    (use (match_operand:HI 2 "nonmemory_operand" "X,z"))]
    ""
    "@
     callf %C0
***************
*** 882,888 ****
  
  (define_insn ""
    [(set (pc) (match_operand:HI 0 "register_operand" "r"))
!    (use (match_operand:HI 1 "register_operand" "t"))]
    ""
    "jmp %1,%0"
    [(set_attr "length" "4")
--- 882,888 ----
  
  (define_insn ""
    [(set (pc) (match_operand:HI 0 "register_operand" "r"))
!    (use (match_operand:HI 1 "register_operand" "z"))]
    ""
    "jmp %1,%0"
    [(set_attr "length" "4")


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