]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
m32r.c (m32r_setup_incoming_varargs): Use get_varargs_alias_set for the register...
authorRichard Henderson <rth@cygnus.com>
Mon, 2 Aug 1999 23:08:49 +0000 (16:08 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 2 Aug 1999 23:08:49 +0000 (16:08 -0700)
        * 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.

From-SVN: r28417

gcc/ChangeLog
gcc/config/m32r/m32r.c
gcc/config/m32r/m32r.h

index d557d2539ca71fb1b2a2c8bc51639404307e4512..840602bda913086e4d9c16782ec50210aad23fa7 100644 (file)
@@ -1,3 +1,15 @@
+1999-08-02  Richard Henderson  <rth@cygnus.com>
+
+       * 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.
+
 1999-08-02  Jakub Jelinek  <jj@ultra.linux.cz>
 
        * config/sparc/linux.h: Define WCHAR_TYPE as "int" and undef
index ddc052b365bb3ecb709e0cc3916747c0d89b69e1..6dc5ff43c6a5b0be6e2618d3fa18b34b7c00b5aa 100644 (file)
@@ -1338,12 +1338,75 @@ m32r_setup_incoming_varargs (cum, int_mode, type, pretend_size, no_rtl)
       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;
+}
 \f
 /* Cost functions.  */
 
index b9de985e0c8433ba0e9f25348b7c1b667ebd5c27..d57e50b5957818a54bf251a87318985ffdfd382b 100644 (file)
@@ -597,15 +597,18 @@ extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER];
        (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 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)                                        \
@@ -968,22 +971,6 @@ M32R_STACK_ALIGN (current_function_outgoing_args_size)
  : 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
@@ -1013,6 +1000,10 @@ extern struct rtx *m32r_expand_builtin_savergs ();
 
 #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)
 \f
 /* Function results.  */
 
@@ -2059,6 +2050,7 @@ extern int  function_arg_partial_nregs            PROTO((CUMULATIVE_ARGS *,
 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));