summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@xilinx.com>2020-12-03 16:37:39 -0800
committerMark Hatle <mark.hatle@xilinx.com>2020-12-04 16:24:49 -0800
commitb0973557c0938c72bc0045ecacd5aad716c69874 (patch)
tree5a0b4cc90da989fcb85e068d2df022812c80fabd /meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
parentc9bf136ef42d5672a645c3caed23e1f99ac75a20 (diff)
downloadmeta-xilinx-b0973557c0938c72bc0045ecacd5aad716c69874.tar.gz
gcc: update to early gatesgarth version
Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch205
1 files changed, 0 insertions, 205 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch b/meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
deleted file mode 100644
index 1f8decc7..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-10/0018-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
+++ /dev/null
@@ -1,205 +0,0 @@
1From 59273a71f1f180456d87eb4a1a5f95fcc6d17003 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 16:42:44 +0530
4Subject: [PATCH 18/58] [Patch, microblaze]: Reducing Stack space for arguments
5
6Currently in Microblaze target stack space for arguments in register is being
7allocated even if there are no arguments in the function.
8This patch will optimize the extra 24 bytes that are being allocated.
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 :Ajit Agarwal <ajitkum@xilinx.com>
12
13ChangeLog:
142015-04-17 Nagaraju Mekala <nmekala@xilix.com>
15 Ajit Agarwal <ajitkum@xilinx.com>
16
17 *microblaze.c (microblaze_parm_needs_stack, microblaze_function_parms_need_stack): New
18 *microblaze.c (REG_PARM_STACK_SPACE): Modify
19---
20 gcc/config/microblaze/microblaze-protos.h | 1 +
21 gcc/config/microblaze/microblaze.c | 132 +++++++++++++++++++++-
22 gcc/config/microblaze/microblaze.h | 4 +-
23 3 files changed, 134 insertions(+), 3 deletions(-)
24
25diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
26index 982b2abd2d4..96f7bb67f6c 100644
27--- a/gcc/config/microblaze/microblaze-protos.h
28+++ b/gcc/config/microblaze/microblaze-protos.h
29@@ -59,6 +59,7 @@ extern int symbol_mentioned_p (rtx);
30 extern int label_mentioned_p (rtx);
31 extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
32 extern void microblaze_eh_return (rtx op0);
33+int microblaze_reg_parm_stack_space(tree fun);
34 #endif /* RTX_CODE */
35
36 /* Declare functions in microblaze-c.c. */
37diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
38index 9eae5515c60..a4bdf66f045 100644
39--- a/gcc/config/microblaze/microblaze.c
40+++ b/gcc/config/microblaze/microblaze.c
41@@ -2057,6 +2057,136 @@ microblaze_must_save_register (int regno)
42 return 0;
43 }
44
45+static bool
46+microblaze_parm_needs_stack (cumulative_args_t args_so_far, tree type)
47+{
48+ int unsignedp;
49+ rtx entry_parm;
50+
51+ /* Catch errors. */
52+ if (type == NULL || type == error_mark_node)
53+ return true;
54+
55+ if (TREE_CODE (type) == POINTER_TYPE)
56+ return true;
57+
58+ /* Handle types with no storage requirement. */
59+ if (TYPE_MODE (type) == VOIDmode)
60+ return false;
61+
62+ /* Handle complex types. */
63+ if (TREE_CODE (type) == COMPLEX_TYPE)
64+ return (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type))
65+ || microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type)));
66+
67+ /* Handle transparent aggregates. */
68+ if ((TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE)
69+ && TYPE_TRANSPARENT_AGGR (type))
70+ type = TREE_TYPE (first_field (type));
71+
72+ /* See if this arg was passed by invisible reference. */
73+ function_arg_info arg (type, /*named=*/true);
74+ apply_pass_by_reference_rules (get_cumulative_args (args_so_far), arg);
75+
76+ /* Find mode as it is passed by the ABI. */
77+ unsignedp = TYPE_UNSIGNED (type);
78+ arg.mode = promote_mode (arg.type, arg.mode, &unsignedp);
79+
80+ /* If there is no incoming register, we need a stack. */
81+ entry_parm = microblaze_function_arg (args_so_far, arg);
82+ if (entry_parm == NULL)
83+ return true;
84+
85+ /* Likewise if we need to pass both in registers and on the stack. */
86+ if (GET_CODE (entry_parm) == PARALLEL
87+ && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
88+ return true;
89+
90+ /* Also true if we're partially in registers and partially not. */
91+ if (function_arg_partial_bytes (args_so_far, arg) != 0)
92+ return true;
93+
94+ /* Update info on where next arg arrives in registers. */
95+ microblaze_function_arg_advance (args_so_far, arg);
96+ return false;
97+}
98+
99+static bool
100+microblaze_function_parms_need_stack (tree fun, bool incoming)
101+{
102+ tree fntype, result;
103+ CUMULATIVE_ARGS args_so_far_v;
104+ cumulative_args_t args_so_far;
105+ int num_of_args = 0;
106+
107+ /* Must be a libcall, all of which only use reg parms. */
108+ if (!fun)
109+ return true;
110+
111+ fntype = fun;
112+ if (!TYPE_P (fun))
113+ fntype = TREE_TYPE (fun);
114+
115+ /* Varargs functions need the parameter save area. */
116+ if ((!incoming && !prototype_p (fntype)) || stdarg_p (fntype))
117+ return true;
118+
119+ INIT_CUMULATIVE_ARGS(args_so_far_v, fntype, NULL_RTX,0,0);
120+ args_so_far = pack_cumulative_args (&args_so_far_v);
121+
122+ /* When incoming, we will have been passed the function decl.
123+ * It is necessary to use the decl to handle K&R style functions,
124+ * where TYPE_ARG_TYPES may not be available. */
125+ if (incoming)
126+ {
127+ gcc_assert (DECL_P (fun));
128+ result = DECL_RESULT (fun);
129+ }
130+ else
131+ result = TREE_TYPE (fntype);
132+
133+ if (result && aggregate_value_p (result, fntype))
134+ {
135+ if (!TYPE_P (result))
136+ result = build_pointer_type (result);
137+ microblaze_parm_needs_stack (args_so_far, result);
138+ }
139+
140+ if (incoming)
141+ {
142+ tree parm;
143+ for (parm = DECL_ARGUMENTS (fun);
144+ parm && parm != void_list_node;
145+ parm = TREE_CHAIN (parm))
146+ if (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (parm)))
147+ return true;
148+ }
149+ else
150+ {
151+ function_args_iterator args_iter;
152+ tree arg_type;
153+
154+ FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter)
155+ {
156+ num_of_args++;
157+ if (microblaze_parm_needs_stack (args_so_far, arg_type))
158+ return true;
159+ }
160+ }
161+
162+ if (num_of_args > 3) return true;
163+
164+ return false;
165+}
166+
167+int microblaze_reg_parm_stack_space(tree fun)
168+{
169+ if (microblaze_function_parms_need_stack (fun,false))
170+ return MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD;
171+ else
172+ return 0;
173+}
174+
175 /* Return the bytes needed to compute the frame pointer from the current
176 stack pointer.
177
178@@ -3403,7 +3533,7 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
179 emit_insn (gen_indirect_jump (temp2));
180
181 /* Run just enough of rest_of_compilation. This sequence was
182- "borrowed" from rs6000.c. */
183+ "borrowed" from microblaze.c. */
184 insn = get_insns ();
185 shorten_branches (insn);
186 assemble_start_function (thunk_fndecl, fnname);
187diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
188index 8aa3f155790..1e155e4041c 100644
189--- a/gcc/config/microblaze/microblaze.h
190+++ b/gcc/config/microblaze/microblaze.h
191@@ -434,9 +434,9 @@ extern struct microblaze_frame_info current_frame_info;
192
193 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
194
195-#define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
196+#define REG_PARM_STACK_SPACE(FNDECL) microblaze_reg_parm_stack_space(FNDECL)
197
198-#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
199+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
200
201 #define STACK_BOUNDARY 32
202
203--
2042.17.1
205