This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
va_list: m32r
- To: gcc-patches at gcc dot gnu dot org
- Subject: va_list: m32r
- From: Richard Henderson <rth at cygnus dot com>
- Date: Mon, 26 Jul 1999 22:50:59 -0700
- Cc: Nick Clifton <nickc at cygnus dot com>, Michael Meissner <meissner at cygnus dot com>
Another simple port, with a simulator available.
Also included are 64-bit unfriendliness cleanups so
that a pattern like
(set (reg:SI 101) (const_int -2))
will be recognized on my Alphas.
Ok?
r~
* m32r.c (m32r_setup_incoming_varargs): Use get_varargs_alias_set
for the register spill block.
(m32r_va_arg): New.
* m32r.h (EXPAND_BUILTIN_VA_ARG): New.
(EXPAND_BUILTIN_SAVEREGS): Delete #if 0 code.
* m32r.h (INT8_P): Don't short-cut test with (unsigned).
(INT16_P, CMP_INT16_P, UINT16_P): Likewise.
(UPPER16_P, UINT24_P, INT32_P, UINT5_P): Likewise.
Index: config/m32r/m32r.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/m32r/m32r.c,v
retrieving revision 1.12
diff -c -p -d -r1.12 m32r.c
*** m32r.c 1999/03/24 15:47:29 1.12
--- m32r.c 1999/07/27 05:44:30
*************** m32r_setup_incoming_varargs (cum, int_mo
*** 1338,1348 ****
--- 1338,1411 ----
regblock = gen_rtx (MEM, BLKmode,
plus_constant (arg_pointer_rtx,
FIRST_PARM_OFFSET (0)));
+ MEM_ALIAS_SET (regblock) = get_varargs_alias_set ();
move_block_from_reg (first_reg_offset, regblock,
size, size * UNITS_PER_WORD);
*pretend_size = (size * UNITS_PER_WORD);
}
+ }
+
+ /* Implement `va_arg'. */
+
+ rtx
+ m32r_va_arg (valist, type)
+ tree valist, type;
+ {
+ HOST_WIDE_INT size, rsize;
+ tree t;
+ rtx addr_rtx;
+
+ size = int_size_in_bytes (type);
+ rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD;
+
+ if (size > 8)
+ {
+ tree type_ptr, type_ptr_ptr;
+
+ /* Pass by reference. */
+
+ type_ptr = build_pointer_type (type);
+ type_ptr_ptr = build_pointer_type (type_ptr);
+
+ t = build (POSTINCREMENT_EXPR, va_list_type_node, valist,
+ build_int_2 (UNITS_PER_WORD, 0));
+ TREE_SIDE_EFFECTS (t) = 1;
+ t = build1 (NOP_EXPR, type_ptr_ptr, t);
+ TREE_SIDE_EFFECTS (t) = 1;
+ t = build1 (INDIRECT_REF, type_ptr, t);
+
+ addr_rtx = expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+ }
+ else
+ {
+ /* Pass by value. */
+
+ if (size < UNITS_PER_WORD)
+ {
+ /* Care for bigendian correction on the aligned address. */
+ t = build (PLUS_EXPR, ptr_type_node, valist,
+ build_int_2 (rsize - size, 0));
+ addr_rtx = expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+ addr_rtx = copy_to_reg (addr_rtx);
+
+ /* Increment AP. */
+ t = build (PLUS_EXPR, va_list_type_node, valist,
+ build_int_2 (rsize, 0));
+ t = build (MODIFY_EXPR, va_list_type_node, valist, t);
+ TREE_SIDE_EFFECTS (t) = 1;
+ expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
+ }
+ else
+ {
+ t = build (POSTINCREMENT_EXPR, va_list_type_node, valist,
+ build_int_2 (rsize, 0));
+ TREE_SIDE_EFFECTS (t) = 1;
+ addr_rtx = expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+ }
+ }
+
+ return addr_rtx;
}
/* Cost functions. */
Index: config/m32r/m32r.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/m32r/m32r.h,v
retrieving revision 1.22
diff -c -p -d -r1.22 m32r.h
*** m32r.h 1999/07/26 01:21:56 1.22
--- m32r.h 1999/07/27 05:44:30
*************** extern enum reg_class m32r_regno_reg_cla
*** 597,611 ****
(values in the range -32767 to +32768). */
/* local to this file */
! #define INT8_P(X) ((unsigned) ((X) + 0x80) < 0x100)
! #define INT16_P(X) ((unsigned) ((X) + 0x8000) < 0x10000)
! #define CMP_INT16_P(X) ((unsigned) ((X) - 1 + 0x8000) < 0x10000)
! #define UINT16_P(X) ((unsigned) (X) < 0x10000)
! #define UPPER16_P(X) (((X) & ~0xffff0000) == 0)
! #define UINT24_P(X) ((unsigned) (X) < 0x1000000)
! #define INT32_P(X) ((X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \
! && (X) <= (unsigned HOST_WIDE_INT) 0xffffffff)
! #define UINT5_P(X) ((unsigned) (X) < 32)
#define INVERTED_SIGNED_8BIT(VAL) ((VAL) >= -127 && (VAL) <= 128)
#define CONST_OK_FOR_LETTER_P(VALUE, C) \
--- 597,614 ----
(values in the range -32767 to +32768). */
/* local to this file */
! #define INT8_P(X) ((X) >= -0x80 && (X) <= 0x7f)
! #define INT16_P(X) ((X) >= -0x8000 && (X) <= 0x7fff)
! #define CMP_INT16_P(X) ((X) >= -0x7fff && (X) <= 0x8000)
! #define UINT16_P(X) ((X) >= 0 && (X) <= 0xffff)
! #define UPPER16_P(X) (((X) & 0xffff) == 0 \
! && ((X) >> 16) >= -0x8000 \
! && ((X) >> 16) <= 0x7fff)
! #define UINT24_P(X) ((X) >= 0 && (X) < 0x1000000)
! #define INT32_P(X) (((X) >= -(HOST_WIDE_INT) 0x80000000 \
! && (X) <= (HOST_WIDE_INT) 0x7fffffff) \
! || (unsigned HOST_WIDE_INT) (X) <= 0xffffffff)
! #define UINT5_P(X) ((X) >= 0 && (X) < 32)
#define INVERTED_SIGNED_8BIT(VAL) ((VAL) >= -127 && (VAL) <= 128)
#define CONST_OK_FOR_LETTER_P(VALUE, C) \
*************** M32R_STACK_ALIGN (current_function_outgo
*** 968,989 ****
: 2 * PARM_BOUNDARY)
#endif
- #if 0
- /* If defined, is a C expression that produces the machine-specific
- code for a call to `__builtin_saveregs'. This code will be moved
- to the very beginning of the function, before any parameter access
- are made. The return value of this function should be an RTX that
- contains the value to use as the return of `__builtin_saveregs'.
-
- The argument ARGS is a `tree_list' containing the arguments that
- were passed to `__builtin_saveregs'.
-
- If this macro is not defined, the compiler will output an ordinary
- call to the library function `__builtin_saveregs'. */
- extern struct rtx *m32r_expand_builtin_savergs ();
- #define EXPAND_BUILTIN_SAVEREGS() m32r_expand_builtin_saveregs ()
- #endif
-
/* This macro offers an alternative
to using `__builtin_saveregs' and defining the macro
`EXPAND_BUILTIN_SAVEREGS'. Use it to store the anonymous register
--- 971,976 ----
*************** extern struct rtx *m32r_expand_builtin_s
*** 1013,1018 ****
--- 1000,1009 ----
#define SETUP_INCOMING_VARARGS(ARGS_SO_FAR, MODE, TYPE, PRETEND_SIZE, NO_RTL) \
m32r_setup_incoming_varargs (&ARGS_SO_FAR, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
+
+ /* Implement `va_arg'. */
+ #define EXPAND_BUILTIN_VA_ARG(valist, type) \
+ m32r_va_arg (valist, type)
/* Function results. */
*************** extern int function_arg_partial_nregs
*** 2059,2064 ****
--- 2050,2056 ----
extern void m32r_setup_incoming_varargs PROTO((CUMULATIVE_ARGS *,
int, Tree, int *,
int));
+ extern struct rtx_def *m32r_va_arg PROTO((Tree, Tree));
extern int m32r_address_code PROTO((Rtx));
extern enum m32r_function_type m32r_compute_function_type
PROTO((Tree));