[patch] Re: ARM: testsuite gcc.c-torture/execute/20020307-2.c failure

jeroen dobbelaere jeroen.dobbelaere@acunia.com
Wed Nov 13 05:43:00 GMT 2002


Richard Earnshaw wrote:
[..]

> 
> 
> I really don't think it's worth spending a lot of time on this problem, 
> and I really don't want to start significantly messing up the ARM back end 
> in order to support it when there's no evidence of it being in regular use 
> -- try and write a non-variadic function that uses this feature and yet 
> still has a prototype if want to see what a mess it causes.  Passing 
> arguments of this type by reference would solve the problem with minimal 
> invasion into the ARM back-end (we simply define FUNCTION_ARG_PASS_BY_REFER
> ENCE in the same way as ia64 has done and we are finished).
> 
> R.
> 

I agree, as this is a gcc specific extension...
I have implemented this (similar to ia64) and I'm doing a regression test right
now (c only). First indication is that 20020307-2.c does not fail any more...

2002-11-13  Jeroen Dobbelaere  <jeroen.dobbelaere@acunia.com>

	* config/arm/arm.h (EXPAND_BUILTIN_VA_ARG,
	FUNCTION_ARG_PASS_BY_REFERENCE): Add.
	* config/arm/arm.c (arm_va_arg,
	arm_function_arg_pass_by_reference): Add.
	* config/arm/arm-protos.h: Add prototypes.

diff -ur gcc-3.2.1-20021111/gcc/config/arm-orig/arm-protos.h gcc-3.2.1-20021111/gcc/config/arm/arm-protos.h
--- gcc-3.2.1-20021111/gcc/config/arm-orig/arm-protos.h	Wed Nov 13 14:27:31 2002
+++ gcc-3.2.1-20021111/gcc/config/arm/arm-protos.h	Wed Nov 13 13:12:18 2002
@@ -136,6 +136,11 @@
  						enum machine_mode, tree, int));
  extern void   arm_init_cumulative_args	PARAMS ((CUMULATIVE_ARGS *, tree, rtx,
  						int));
+extern rtx    arm_va_arg                PARAMS ((tree, tree));
+extern int    arm_function_arg_pass_by_reference PARAMS ((CUMULATIVE_ARGS *,
+						         enum machine_mode,
+						         tree, int));
+
  #endif

  #if defined AOF_ASSEMBLER
diff -ur gcc-3.2.1-20021111/gcc/config/arm-orig/arm.c gcc-3.2.1-20021111/gcc/config/arm/arm.c
--- gcc-3.2.1-20021111/gcc/config/arm-orig/arm.c	Wed Nov 13 14:27:31 2002
+++ gcc-3.2.1-20021111/gcc/config/arm/arm.c	Wed Nov 13 14:22:30 2002
@@ -1899,6 +1899,35 @@

    return gen_rtx_REG (mode, pcum->nregs);
  }
+
+/* Variable sized types are passed by reference.  */
+/* ??? At present this is a GCC extension to the ARM ABI.  */
+
+int
+arm_function_arg_pass_by_reference (cum, mode, type, named)
+     CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED;
+     enum machine_mode mode ATTRIBUTE_UNUSED;
+     tree type;
+     int named ATTRIBUTE_UNUSED;
+{
+  return type && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST;
+}
+
+/* Implement va_arg.  */
+
+rtx
+arm_va_arg (valist, type)
+     tree valist, type;
+{
+  /* Variable sized types are passed by reference.  */
+  if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
+    {
+      rtx addr = std_expand_builtin_va_arg (valist, build_pointer_type (type));
+      return gen_rtx_MEM (ptr_mode, force_reg (Pmode, addr));
+    }
+
+  return std_expand_builtin_va_arg (valist, type);
+}

  /* Encode the current state of the #pragma [no_]long_calls.  */
  typedef enum
diff -ur gcc-3.2.1-20021111/gcc/config/arm-orig/arm.h gcc-3.2.1-20021111/gcc/config/arm/arm.h
--- gcc-3.2.1-20021111/gcc/config/arm-orig/arm.h	Wed Nov 13 14:27:31 2002
+++ gcc-3.2.1-20021111/gcc/config/arm/arm.h	Wed Nov 13 13:10:08 2002
@@ -1506,6 +1506,16 @@
     && (NUM_ARG_REGS < ((CUM).nregs + NUM_REGS2 (MODE, TYPE)))	\
     ?   NUM_ARG_REGS - (CUM).nregs : 0)

+/* A C expression that indicates when an argument must be passed by reference.
+   If nonzero for an argument, a copy of that argument is made in memory and a
+   pointer to the argument is passed instead of the argument itself.  The
+   pointer is passed in whatever way is appropriate for passing a pointer to
+   that type.  */
+
+#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
+  arm_function_arg_pass_by_reference (&CUM, MODE, TYPE, NAMED)
+
+
  /* Initialize a variable CUM of type CUMULATIVE_ARGS
     for a call to a function whose data type is FNTYPE.
     For a library call, FNTYPE is 0.
@@ -1523,6 +1533,9 @@
     On the ARM, r0-r3 are used to pass args.  */
  #define FUNCTION_ARG_REGNO_P(REGNO)	(IN_RANGE ((REGNO), 0, 3))

+/* Implement `va_arg'.  */
+#define EXPAND_BUILTIN_VA_ARG(valist, type) \
+  arm_va_arg (valist, type)

  /* Tail calling.  */



Greetings,
-- 
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com/aes




More information about the Gcc mailing list