Blame view

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