]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Turn FUNCTION_ARG_OFFSET into a hook
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Sep 2017 14:37:28 +0000 (14:37 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Sep 2017 14:37:28 +0000 (14:37 +0000)
2017-09-13  Richard Sandiford  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* target.def (function_arg_offset): New hook.
* targhooks.h (default_function_arg_offset): Declare.
* targhooks.c (default_function_arg_offset): New function.
* function.c (locate_and_pad_parm): Use
targetm.calls.function_arg_offset instead of FUNCTION_ARG_OFFSET.
* doc/tm.texi.in (FUNCTION_ARG_OFFSET): Replace with...
(TARGET_FUNCTION_ARG_OFFSET): ...this.
* doc/tm.texi: Regenerate.
* config/spu/spu.h (FUNCTION_ARG_OFFSET): Delete.
* config/spu/spu.c (spu_function_arg_offset): New function.
(TARGET_FUNCTION_ARG_OFFSET): Redefine.
* system.h (FUNCTION_ARG_OFFSET): Poison.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252821 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/spu/spu.c
gcc/config/spu/spu.h
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/function.c
gcc/system.h
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h

index 498d6b3bca7c73a9be73c7632f0ff6ece8407a49..509742ac0cca09e3564a93f2d2a62d4799434205 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-15  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * target.def (function_arg_offset): New hook.
+       * targhooks.h (default_function_arg_offset): Declare.
+       * targhooks.c (default_function_arg_offset): New function.
+       * function.c (locate_and_pad_parm): Use
+       targetm.calls.function_arg_offset instead of FUNCTION_ARG_OFFSET.
+       * doc/tm.texi.in (FUNCTION_ARG_OFFSET): Replace with...
+       (TARGET_FUNCTION_ARG_OFFSET): ...this.
+       * doc/tm.texi: Regenerate.
+       * config/spu/spu.h (FUNCTION_ARG_OFFSET): Delete.
+       * config/spu/spu.c (spu_function_arg_offset): New function.
+       (TARGET_FUNCTION_ARG_OFFSET): Redefine.
+       * system.h (FUNCTION_ARG_OFFSET): Poison.
+
 2017-09-15  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayard  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 4ce227b7f9574fb600860d0e43574b09e5e1b613..a35f0b8636b0743156bf8fd897eca32540b7e9da 100644 (file)
@@ -3881,6 +3881,18 @@ spu_function_arg_advance (cumulative_args_t cum_v, machine_mode mode,
           : spu_hard_regno_nregs (FIRST_ARG_REGNUM, mode));
 }
 
+/* Implement TARGET_FUNCTION_ARG_OFFSET.  The SPU ABI wants 32/64-bit
+   types at offset 0 in the quad-word on the stack.  8/16-bit types
+   should be at offsets 3/2 respectively.  */
+
+static HOST_WIDE_INT
+spu_function_arg_offset (machine_mode mode, const_tree type)
+{
+  if (type && INTEGRAL_TYPE_P (type) && GET_MODE_SIZE (mode) < 4)
+    return 4 - GET_MODE_SIZE (mode);
+  return 0;
+}
+
 /* Implement TARGET_FUNCTION_ARG_PADDING.  */
 
 static pad_direction
@@ -7300,6 +7312,9 @@ static const struct attribute_spec spu_attribute_table[] =
 #undef TARGET_FUNCTION_ARG_ADVANCE
 #define TARGET_FUNCTION_ARG_ADVANCE spu_function_arg_advance
 
+#undef TARGET_FUNCTION_ARG_OFFSET
+#define TARGET_FUNCTION_ARG_OFFSET spu_function_arg_offset
+
 #undef TARGET_FUNCTION_ARG_PADDING
 #define TARGET_FUNCTION_ARG_PADDING spu_function_arg_padding
 
index 3e60e1949e1dda326e97e6e6d83b5ce1edad3985..4cf426b7c5b82c3b1c98c91071830d37518752b7 100644 (file)
@@ -309,13 +309,6 @@ targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin;       \
 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \
                ((CUM) = 0)
 
-/* The SPU ABI wants 32/64-bit types at offset 0 in the quad-word on the
-   stack.  8/16-bit types should be at offsets 3/2 respectively.  */
-#define FUNCTION_ARG_OFFSET(MODE, TYPE)                                        \
-(((TYPE) && INTEGRAL_TYPE_P (TYPE) && GET_MODE_SIZE (MODE) < 4)                \
- ? (4 - GET_MODE_SIZE (MODE))                                          \
- : 0)
-
 #define PAD_VARARGS_DOWN 0
 
 #define FUNCTION_ARG_REGNO_P(N) ((N) >= (FIRST_ARG_REGNUM) && (N) <= (LAST_ARG_REGNUM))
index 6277e88b835b699ac10eb78f647ad9e3f2d82a6a..ae65e4f5edf9b4c8336f8b8a5bc0b313a1cd9a25 100644 (file)
@@ -4079,13 +4079,13 @@ on the stack.  The compiler knows how to track the amount of stack space
 used for arguments without any special help.
 @end deftypefn
 
-@defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type})
-If defined, a C expression that is the number of bytes to add to the
-offset of the argument passed in memory.  This is needed for the SPU,
-which passes @code{char} and @code{short} arguments in the preferred
-slot that is in the middle of the quad word instead of starting at the
-top.
-@end defmac
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_FUNCTION_ARG_OFFSET (machine_mode @var{mode}, const_tree @var{type})
+This hook returns the number of bytes to add to the offset of an
+argument of type @var{type} and mode @var{mode} when passed in memory.
+This is needed for the SPU, which passes @code{char} and @code{short}
+arguments in the preferred slot that is in the middle of the quad word
+instead of starting at the top.  The default implementation returns 0.
+@end deftypefn
 
 @deftypefn {Target Hook} pad_direction TARGET_FUNCTION_ARG_PADDING (machine_mode @var{mode}, const_tree @var{type})
 This hook determines whether, and in which direction, to pad out
index c66f8cee51430885aea9c52031778c11739a04ae..733466dbb84985eb7fbfb455bc11be659f3b8f61 100644 (file)
@@ -3281,13 +3281,7 @@ argument @var{libname} exists for symmetry with
 
 @hook TARGET_FUNCTION_ARG_ADVANCE
 
-@defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type})
-If defined, a C expression that is the number of bytes to add to the
-offset of the argument passed in memory.  This is needed for the SPU,
-which passes @code{char} and @code{short} arguments in the preferred
-slot that is in the middle of the quad word instead of starting at the
-top.
-@end defmac
+@hook TARGET_FUNCTION_ARG_OFFSET
 
 @hook TARGET_FUNCTION_ARG_PADDING
 
index 41878a974be0fa8117eb7dba41a75d2f5a29669d..3ae5a3afc0b4d2825d5992fdcf40ef87cddb07e0 100644 (file)
@@ -4249,9 +4249,8 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
       locate->size.constant -= part_size_in_regs;
     }
 
-#ifdef FUNCTION_ARG_OFFSET
-  locate->offset.constant += FUNCTION_ARG_OFFSET (passed_mode, type);
-#endif
+  locate->offset.constant
+    += targetm.calls.function_arg_offset (passed_mode, type);
 }
 
 /* Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY.
index 974d85c4cee6e3db97c80ce4825c01aa93a2aa98..c514cd8b3824966a2c9ce4215f3a6bf7e9a7f42a 100644 (file)
@@ -915,7 +915,7 @@ extern void fancy_abort (const char *, int, const char *)
        MODES_TIEABLE_P FUNCTION_ARG_PADDING SLOW_UNALIGNED_ACCESS      \
        HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE                   \
        SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS                \
-       TRULY_NOOP_TRUNCATION
+       TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET
 
 /* Target macros only used for code built for the target, that have
    moved to libgcc-tm.h or have never been present elsewhere.  */
index 885973be4e23c728da887c463446d71f1148b3a3..f4c35763686ae52c141ac1c6706d18ea6873a3c8 100644 (file)
@@ -4572,6 +4572,16 @@ used for arguments without any special help.",
  (cumulative_args_t ca, machine_mode mode, const_tree type, bool named),
  default_function_arg_advance)
 
+DEFHOOK
+(function_arg_offset,
+ "This hook returns the number of bytes to add to the offset of an\n\
+argument of type @var{type} and mode @var{mode} when passed in memory.\n\
+This is needed for the SPU, which passes @code{char} and @code{short}\n\
+arguments in the preferred slot that is in the middle of the quad word\n\
+instead of starting at the top.  The default implementation returns 0.",
+ HOST_WIDE_INT, (machine_mode mode, const_tree type),
+ default_function_arg_offset)
+
 DEFHOOK
 (function_arg_padding,
  "This hook determines whether, and in which direction, to pad out\n\
index 98e553c0fce799fe531dbf6bdec43e5123f47eef..4bd4833dfdd50876523333e71d5b19d0fbb68d42 100644 (file)
@@ -734,6 +734,14 @@ default_function_arg_advance (cumulative_args_t ca ATTRIBUTE_UNUSED,
   gcc_unreachable ();
 }
 
+/* Default implementation of TARGET_FUNCTION_ARG_OFFSET.  */
+
+HOST_WIDE_INT
+default_function_arg_offset (machine_mode, const_tree)
+{
+  return 0;
+}
+
 /* Default implementation of TARGET_FUNCTION_ARG_PADDING: usually pad
    upward, but pad short args downward on big-endian machines.  */
 
index 3d03215f7b7f226df619827e9f811c18beba9237..6d78508c8a2b0905c5cc640a691f65e15e2ef117 100644 (file)
@@ -132,6 +132,7 @@ extern const char *hook_invalid_arg_for_unprototyped_fn
   (const_tree, const_tree, const_tree);
 extern void default_function_arg_advance
   (cumulative_args_t, machine_mode, const_tree, bool);
+extern HOST_WIDE_INT default_function_arg_offset (machine_mode, const_tree);
 extern pad_direction default_function_arg_padding (machine_mode, const_tree);
 extern rtx default_function_arg
   (cumulative_args_t, machine_mode, const_tree, bool);