python-whoosh: bump to version 2.7.4
[buildroot-gz.git] / package / gcc / 4.8.5 / 870-xtensa-add-mauto-litpools-option.patch
blobaa1376c44c3b8c2aeba52bb498d03aa8eae9d8bd
1 From 6d852ffb43b111a39162135c95249e749c4e285b Mon Sep 17 00:00:00 2001
2 From: Max Filippov <jcmvbkbc@gmail.com>
3 Date: Thu, 6 Aug 2015 01:16:02 +0300
4 Subject: [PATCH] xtensa: add -mauto-litpools option
6 With support from assembler this option allows compiling huge functions,
7 where single literal pool at the beginning of a function may not be
8 reachable by L32R instructions at its end.
10 Currently assembler --auto-litpools option cannot deal with literals
11 used from multiple locations separated by more than 256 KBytes of code.
12 Don't turn constants into literals, instead use MOVI instruction to load
13 them into registers and let the assembler turn them into literals as
14 necessary.
16 2015-08-12 Max Filippov <jcmvbkbc@gmail.com>
17 gcc/
18 * config/xtensa/constraints.md (define_constraint "Y"): New
19 constraint.
20 * config/xtensa/elf.h (ASM_SPEC): Add m(no-)auto-litpools.
21 * config/xtensa/linux.h (ASM_SPEC): Likewise.
22 * config/xtensa/predicates.md (move_operand): Match constants
23 and symbols in the presence of TARGET_AUTO_LITPOOLS.
24 * config/xtensa/xtensa.c (xtensa_valid_move): Don't allow
25 immediate references to TLS data.
26 (xtensa_emit_move_sequence): Don't force constants to memory in
27 the presence of TARGET_AUTO_LITPOOLS.
28 (print_operand): Add 'y' format, same as default, but capable of
29 printing SF mode constants as well.
30 * config/xtensa/xtensa.md (movsi_internal, movhi_internal)
31 (movsf_internal): Add movi pattern that loads literal.
32 (movsf, movdf): Don't force constants to memory in the presence
33 of TARGET_AUTO_LITPOOLS.
34 (movdf_internal): Add 'Y' constraint.
35 * config/xtensa/xtensa.opt (mauto-litpools): New option.
37 Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
38 ---
39 Backported from: r226828
40 Changes to ChangeLogs and documentation are dropped.
42 gcc/config/xtensa/constraints.md | 5 +++++
43 gcc/config/xtensa/elf.h | 4 +++-
44 gcc/config/xtensa/linux.h | 4 +++-
45 gcc/config/xtensa/predicates.md | 3 ++-
46 gcc/config/xtensa/xtensa.c | 19 ++++++++++++++++++-
47 gcc/config/xtensa/xtensa.md | 35 +++++++++++++++++++----------------
48 gcc/config/xtensa/xtensa.opt | 4 ++++
49 7 files changed, 54 insertions(+), 20 deletions(-)
51 diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
52 index 30f4c1f..773d4f9 100644
53 --- a/gcc/config/xtensa/constraints.md
54 +++ b/gcc/config/xtensa/constraints.md
55 @@ -111,6 +111,11 @@
56 (and (match_code "const_int")
57 (match_test "xtensa_mask_immediate (ival)")))
59 +(define_constraint "Y"
60 + "A constant that can be used in relaxed MOVI instructions."
61 + (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
62 + (match_test "TARGET_AUTO_LITPOOLS")))
64 ;; Memory constraints. Do not use define_memory_constraint here. Doing so
65 ;; causes reload to force some constants into the constant pool, but since
66 ;; the Xtensa constant pool can only be accessed with L32R instructions, it
67 diff --git a/gcc/config/xtensa/elf.h b/gcc/config/xtensa/elf.h
68 index e59bede..12056f7 100644
69 --- a/gcc/config/xtensa/elf.h
70 +++ b/gcc/config/xtensa/elf.h
71 @@ -48,7 +48,9 @@ along with GCC; see the file COPYING3. If not see
72 %{mtarget-align:--target-align} \
73 %{mno-target-align:--no-target-align} \
74 %{mlongcalls:--longcalls} \
75 - %{mno-longcalls:--no-longcalls}"
76 + %{mno-longcalls:--no-longcalls} \
77 + %{mauto-litpools:--auto-litpools} \
78 + %{mno-auto-litpools:--no-auto-litpools}"
80 #undef LIB_SPEC
81 #define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
82 diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
83 index 675aacf..5b0243a 100644
84 --- a/gcc/config/xtensa/linux.h
85 +++ b/gcc/config/xtensa/linux.h
86 @@ -42,7 +42,9 @@ along with GCC; see the file COPYING3. If not see
87 %{mtarget-align:--target-align} \
88 %{mno-target-align:--no-target-align} \
89 %{mlongcalls:--longcalls} \
90 - %{mno-longcalls:--no-longcalls}"
91 + %{mno-longcalls:--no-longcalls} \
92 + %{mauto-litpools:--auto-litpools} \
93 + %{mno-auto-litpools:--no-auto-litpools}"
95 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
97 diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md
98 index e02209e..d7dfa11 100644
99 --- a/gcc/config/xtensa/predicates.md
100 +++ b/gcc/config/xtensa/predicates.md
101 @@ -142,7 +142,8 @@
102 (match_test "GET_MODE_CLASS (mode) == MODE_INT
103 && xtensa_simm12b (INTVAL (op))"))
104 (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
105 - (match_test "TARGET_CONST16 && CONSTANT_P (op)
106 + (match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS)
107 + && CONSTANT_P (op)
108 && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
110 ;; Accept the floating point constant 1 in the appropriate mode.
111 diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
112 index eb039ba..206ff80 100644
113 --- a/gcc/config/xtensa/xtensa.c
114 +++ b/gcc/config/xtensa/xtensa.c
115 @@ -501,6 +501,9 @@ xtensa_valid_move (machine_mode mode, rtx *operands)
117 int dst_regnum = xt_true_regnum (operands[0]);
119 + if (xtensa_tls_referenced_p (operands[1]))
120 + return FALSE;
122 /* The stack pointer can only be assigned with a MOVSP opcode. */
123 if (dst_regnum == STACK_POINTER_REGNUM)
124 return !TARGET_WINDOWED_ABI
125 @@ -1069,7 +1072,7 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode)
126 return 1;
129 - if (! TARGET_CONST16)
130 + if (! TARGET_AUTO_LITPOOLS && ! TARGET_CONST16)
132 src = force_const_mem (SImode, src);
133 operands[1] = src;
134 @@ -2449,6 +2452,20 @@ print_operand (FILE *file, rtx x, int letter)
136 break;
138 + case 'y':
139 + if (GET_CODE (x) == CONST_DOUBLE &&
140 + GET_MODE (x) == SFmode)
142 + REAL_VALUE_TYPE r;
143 + long l;
144 + REAL_VALUE_FROM_CONST_DOUBLE (r, x);
145 + REAL_VALUE_TO_TARGET_SINGLE (r, l);
146 + fprintf (file, "0x%08lx", l);
147 + break;
150 + /* fall through */
152 default:
153 if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG)
154 fprintf (file, "%s", reg_names[xt_true_regnum (x)]);
155 diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
156 index 6d84384..0e673a3 100644
157 --- a/gcc/config/xtensa/xtensa.md
158 +++ b/gcc/config/xtensa/xtensa.md
159 @@ -761,8 +761,8 @@
162 (define_insn "movsi_internal"
163 - [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,W,a,a,U,*a,*A")
164 - (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,i,T,U,r,*A,*r"))]
165 + [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,a,W,a,a,U,*a,*A")
166 + (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,Y,i,T,U,r,*A,*r"))]
167 "xtensa_valid_move (SImode, operands)"
169 movi.n\t%0, %x1
170 @@ -774,15 +774,16 @@
171 mov\t%0, %1
172 movsp\t%0, %1
173 movi\t%0, %x1
174 + movi\t%0, %1
175 const16\t%0, %t1\;const16\t%0, %b1
176 %v1l32r\t%0, %1
177 %v1l32i\t%0, %1
178 %v0s32i\t%1, %0
179 rsr\t%0, ACCLO
180 wsr\t%1, ACCLO"
181 - [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,load,load,store,rsr,wsr")
182 + [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,move,load,load,store,rsr,wsr")
183 (set_attr "mode" "SI")
184 - (set_attr "length" "2,2,2,2,2,2,3,3,3,6,3,3,3,3,3")])
185 + (set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")])
187 ;; 16-bit Integer moves
189 @@ -796,21 +797,22 @@
192 (define_insn "movhi_internal"
193 - [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
194 - (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
195 + [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
196 + (match_operand:HI 1 "move_operand" "M,d,r,I,Y,U,r,*A,*r"))]
197 "xtensa_valid_move (HImode, operands)"
199 movi.n\t%0, %x1
200 mov.n\t%0, %1
201 mov\t%0, %1
202 movi\t%0, %x1
203 + movi\t%0, %1
204 %v1l16ui\t%0, %1
205 %v0s16i\t%1, %0
206 rsr\t%0, ACCLO
207 wsr\t%1, ACCLO"
208 - [(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
209 + [(set_attr "type" "move,move,move,move,move,load,store,rsr,wsr")
210 (set_attr "mode" "HI")
211 - (set_attr "length" "2,2,3,3,3,3,3,3")])
212 + (set_attr "length" "2,2,3,3,3,3,3,3,3")])
214 ;; 8-bit Integer moves
216 @@ -881,7 +883,7 @@
217 (match_operand:SF 1 "general_operand" ""))]
220 - if (!TARGET_CONST16 && CONSTANT_P (operands[1]))
221 + if (!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS && CONSTANT_P (operands[1]))
222 operands[1] = force_const_mem (SFmode, operands[1]);
224 if ((!register_operand (operands[0], SFmode)
225 @@ -896,8 +898,8 @@
228 (define_insn "movsf_internal"
229 - [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,W,a,a,U")
230 - (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,iF,T,U,r"))]
231 + [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,a,W,a,a,U")
232 + (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,Y,iF,T,U,r"))]
233 "((register_operand (operands[0], SFmode)
234 || register_operand (operands[1], SFmode))
235 && !(FP_REG_P (xt_true_regnum (operands[0]))
236 @@ -912,13 +914,14 @@
237 mov\t%0, %1
238 wfr\t%0, %1
239 rfr\t%0, %1
240 + movi\t%0, %y1
241 const16\t%0, %t1\;const16\t%0, %b1
242 %v1l32r\t%0, %1
243 %v1l32i\t%0, %1
244 %v0s32i\t%1, %0"
245 - [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,load,load,store")
246 + [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,move,load,load,store")
247 (set_attr "mode" "SF")
248 - (set_attr "length" "3,3,3,2,2,2,3,3,3,6,3,3,3")])
249 + (set_attr "length" "3,3,3,2,2,2,3,3,3,3,6,3,3,3")])
251 (define_insn "*lsiu"
252 [(set (match_operand:SF 0 "register_operand" "=f")
253 @@ -991,7 +994,7 @@
254 (match_operand:DF 1 "general_operand" ""))]
257 - if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
258 + if (CONSTANT_P (operands[1]) && !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS)
259 operands[1] = force_const_mem (DFmode, operands[1]);
261 if (!register_operand (operands[0], DFmode)
262 @@ -1002,8 +1005,8 @@
265 (define_insn_and_split "movdf_internal"
266 - [(set (match_operand:DF 0 "nonimmed_operand" "=a,W,a,a,U")
267 - (match_operand:DF 1 "move_operand" "r,iF,T,U,r"))]
268 + [(set (match_operand:DF 0 "nonimmed_operand" "=a,a,W,a,a,U")
269 + (match_operand:DF 1 "move_operand" "r,Y,iF,T,U,r"))]
270 "register_operand (operands[0], DFmode)
271 || register_operand (operands[1], DFmode)"
273 diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
274 index 2fd6cee..21c6e96 100644
275 --- a/gcc/config/xtensa/xtensa.opt
276 +++ b/gcc/config/xtensa/xtensa.opt
277 @@ -38,6 +38,10 @@ mtext-section-literals
278 Target
279 Intersperse literal pools with code in the text section
281 +mauto-litpools
282 +Target Report Mask(AUTO_LITPOOLS)
283 +Relax literals in assembler and place them automatically in the text section
285 mserialize-volatile
286 Target Report Mask(SERIALIZE_VOLATILE)
287 -mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions
289 1.8.1.4