archive: dragora-installer: added parts (MenuMedia)
[dragora.git] / patches / gcc / 0007-j2.patch
blob977437c3260b8e77f2b04485159af38724379619
1 From c9bd49664e3347db0d4aa30f63e41a0fb8729c42 Mon Sep 17 00:00:00 2001
2 From: Szabolcs Nagy <nsz@port70.net>
3 Date: Fri, 26 Jan 2018 20:29:56 +0000
4 Subject: [PATCH 07/12] j2
6 ---
7 gcc/config.gcc | 26 ++++++++++++---------
8 gcc/config/sh/sh.c | 7 ++++++
9 gcc/config/sh/sh.h | 15 +++++++++---
10 gcc/config/sh/sh.opt | 4 ++++
11 gcc/config/sh/sync.md | 54 +++++++++++++++++++++++++++++++++++++++++++
12 gcc/config/sh/t-sh | 10 ++++----
13 6 files changed, 98 insertions(+), 18 deletions(-)
15 diff --git a/gcc/config.gcc b/gcc/config.gcc
16 index 532c33f4c2b..20cdc192b82 100644
17 --- a/gcc/config.gcc
18 +++ b/gcc/config.gcc
19 @@ -505,7 +505,7 @@ s390*-*-*)
20 extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
22 # Note the 'l'; we need to be able to match e.g. "shle" or "shl".
23 -sh[123456789lbe]*-*-* | sh-*-*)
24 +sh[123456789lbej]*-*-* | sh-*-*)
25 cpu_type=sh
26 extra_options="${extra_options} fused-madd.opt"
27 extra_objs="${extra_objs} sh_treg_combine.o sh-mem.o sh_optimize_sett_clrt.o"
28 @@ -2725,18 +2725,18 @@ s390x-ibm-tpf*)
29 extra_options="${extra_options} s390/tpf.opt"
30 tmake_file="${tmake_file} s390/t-s390"
32 -sh-*-elf* | sh[12346l]*-*-elf* | \
33 - sh-*-linux* | sh[2346lbe]*-*-linux* | \
34 +sh-*-elf* | sh[12346lj]*-*-elf* | \
35 + sh-*-linux* | sh[2346lbej]*-*-linux* | \
36 sh-*-netbsdelf* | shl*-*-netbsdelf*)
37 tmake_file="${tmake_file} sh/t-sh sh/t-elf"
38 if test x${with_endian} = x; then
39 case ${target} in
40 - sh[1234]*be-*-* | sh[1234]*eb-*-*) with_endian=big ;;
41 + sh[j1234]*be-*-* | sh[j1234]*eb-*-*) with_endian=big ;;
42 shbe-*-* | sheb-*-*) with_endian=big,little ;;
43 sh[1234]l* | sh[34]*-*-linux*) with_endian=little ;;
44 shl* | sh*-*-linux* | \
45 sh-superh-elf) with_endian=little,big ;;
46 - sh[1234]*-*-*) with_endian=big ;;
47 + sh[j1234]*-*-*) with_endian=big ;;
48 *) with_endian=big,little ;;
49 esac
51 @@ -2803,6 +2803,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
52 sh2a_nofpu*) sh_cpu_target=sh2a-nofpu ;;
53 sh2a*) sh_cpu_target=sh2a ;;
54 sh2e*) sh_cpu_target=sh2e ;;
55 + shj2*) sh_cpu_target=shj2;;
56 sh2*) sh_cpu_target=sh2 ;;
57 *) sh_cpu_target=sh1 ;;
58 esac
59 @@ -2824,7 +2825,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
60 sh2a-single-only | sh2a-single | sh2a-nofpu | sh2a | \
61 sh4a-single-only | sh4a-single | sh4a-nofpu | sh4a | sh4al | \
62 sh4-single-only | sh4-single | sh4-nofpu | sh4 | sh4-300 | \
63 - sh3e | sh3 | sh2e | sh2 | sh1) ;;
64 + sh3e | sh3 | sh2e | sh2 | sh1 | shj2) ;;
65 "") sh_cpu_default=${sh_cpu_target} ;;
66 *) echo "with_cpu=$with_cpu not supported"; exit 1 ;;
67 esac
68 @@ -2833,9 +2834,9 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
69 case ${target} in
70 sh[1234]*) sh_multilibs=${sh_cpu_target} ;;
71 sh-superh-*) sh_multilibs=m4,m4-single,m4-single-only,m4-nofpu ;;
72 - sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4 ;;
73 + sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4,mj2 ;;
74 sh*-*-netbsd*) sh_multilibs=m3,m3e,m4 ;;
75 - *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single ;;
76 + *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single,mj2 ;;
77 esac
78 if test x$with_fp = xno; then
79 sh_multilibs="`echo $sh_multilibs|sed -e s/m4/sh4-nofpu/ -e s/,m4-[^,]*//g -e s/,m[23]e// -e s/m2a,m2a-single/m2a-nofpu/ -e s/m5-..m....,//g`"
80 @@ -2850,7 +2851,8 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
81 m1 | m2 | m2e | m3 | m3e | \
82 m4 | m4-single | m4-single-only | m4-nofpu | m4-300 |\
83 m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al | \
84 - m2a | m2a-single | m2a-single-only | m2a-nofpu)
85 + m2a | m2a-single | m2a-single-only | m2a-nofpu | \
86 + mj2)
87 # TM_MULTILIB_CONFIG is used by t-sh for the non-endian multilib definition
88 # It is passed to MULTIILIB_OPTIONS verbatim.
89 TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG}/${sh_multilib}"
90 @@ -2867,7 +2869,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
91 done
92 TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's:^/::'`
93 if test x${enable_incomplete_targets} = xyes ; then
94 - tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1"
95 + tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1 SUPPORT_SHJ2=1"
97 tm_file="$tm_file ./sysroot-suffix.h"
98 tmake_file="$tmake_file t-sysroot-suffix"
99 @@ -4518,6 +4520,8 @@ case "${target}" in
101 m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al)
103 + mj2)
104 + ;;
106 echo "Unknown CPU used in --with-cpu=$with_cpu, known values:" 1>&2
107 echo "m1 m2 m2e m3 m3e m4 m4-single m4-single-only m4-nofpu" 1>&2
108 @@ -4729,7 +4733,7 @@ case ${target} in
109 tmake_file="${cpu_type}/t-${cpu_type} ${tmake_file}"
112 - sh[123456ble]*-*-* | sh-*-*)
113 + sh[123456blej]*-*-* | sh-*-*)
114 c_target_objs="${c_target_objs} sh-c.o"
115 cxx_target_objs="${cxx_target_objs} sh-c.o"
117 diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
118 index ced66408265..c51b00d8e8b 100644
119 --- a/gcc/config/sh/sh.c
120 +++ b/gcc/config/sh/sh.c
121 @@ -685,6 +685,7 @@ parse_validate_atomic_model_option (const char* str)
122 model_names[sh_atomic_model::hard_llcs] = "hard-llcs";
123 model_names[sh_atomic_model::soft_tcb] = "soft-tcb";
124 model_names[sh_atomic_model::soft_imask] = "soft-imask";
125 + model_names[sh_atomic_model::hard_cas] = "hard-cas";
127 const char* model_cdef_names[sh_atomic_model::num_models];
128 model_cdef_names[sh_atomic_model::none] = "NONE";
129 @@ -692,6 +693,7 @@ parse_validate_atomic_model_option (const char* str)
130 model_cdef_names[sh_atomic_model::hard_llcs] = "HARD_LLCS";
131 model_cdef_names[sh_atomic_model::soft_tcb] = "SOFT_TCB";
132 model_cdef_names[sh_atomic_model::soft_imask] = "SOFT_IMASK";
133 + model_cdef_names[sh_atomic_model::hard_cas] = "HARD_CAS";
135 sh_atomic_model ret;
136 ret.type = sh_atomic_model::none;
137 @@ -770,6 +772,9 @@ got_mode_name:;
138 if (ret.type == sh_atomic_model::soft_imask && TARGET_USERMODE)
139 err_ret ("cannot use atomic model %s in user mode", ret.name);
141 + if (ret.type == sh_atomic_model::hard_cas && !TARGET_SHJ2)
142 + err_ret ("atomic model %s is only available J2 targets", ret.name);
144 return ret;
146 #undef err_ret
147 @@ -826,6 +831,8 @@ sh_option_override (void)
148 sh_cpu = PROCESSOR_SH2E;
149 if (TARGET_SH2A)
150 sh_cpu = PROCESSOR_SH2A;
151 + if (TARGET_SHJ2)
152 + sh_cpu = PROCESSOR_SHJ2;
153 if (TARGET_SH3)
154 sh_cpu = PROCESSOR_SH3;
155 if (TARGET_SH3E)
156 diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
157 index 2f5930bbebd..5a6d113a011 100644
158 --- a/gcc/config/sh/sh.h
159 +++ b/gcc/config/sh/sh.h
160 @@ -83,6 +83,7 @@ extern int code_for_indirect_jump_scratch;
161 #define SUPPORT_SH4_SINGLE 1
162 #define SUPPORT_SH2A 1
163 #define SUPPORT_SH2A_SINGLE 1
164 +#define SUPPORT_SHJ2 1
165 #endif
167 #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
168 @@ -115,6 +116,7 @@ extern int code_for_indirect_jump_scratch;
169 #define SELECT_SH4A_SINGLE_ONLY (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
170 #define SELECT_SH4A (MASK_SH4A | SELECT_SH4)
171 #define SELECT_SH4A_SINGLE (MASK_SH4A | SELECT_SH4_SINGLE)
172 +#define SELECT_SHJ2 (MASK_SHJ2 | SELECT_SH2)
174 #if SUPPORT_SH1
175 #define SUPPORT_SH2 1
176 @@ -122,6 +124,7 @@ extern int code_for_indirect_jump_scratch;
177 #if SUPPORT_SH2
178 #define SUPPORT_SH3 1
179 #define SUPPORT_SH2A_NOFPU 1
180 +#define SUPPORT_SHJ2 1
181 #endif
182 #if SUPPORT_SH3
183 #define SUPPORT_SH4_NOFPU 1
184 @@ -154,7 +157,7 @@ extern int code_for_indirect_jump_scratch;
185 #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
186 | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
187 | MASK_HARD_SH4 | MASK_FPU_SINGLE \
188 - | MASK_FPU_SINGLE_ONLY)
189 + | MASK_FPU_SINGLE_ONLY | MASK_SHJ2)
191 /* This defaults us to big-endian. */
192 #ifndef TARGET_ENDIAN_DEFAULT
193 @@ -229,7 +232,8 @@ extern int code_for_indirect_jump_scratch;
194 %{m2a-single:--isa=sh2a} \
195 %{m2a-single-only:--isa=sh2a} \
196 %{m2a-nofpu:--isa=sh2a-nofpu} \
197 -%{m4al:-dsp}"
198 +%{m4al:-dsp} \
199 +%{mj2:-isa=j2}"
201 #define ASM_SPEC SH_ASM_SPEC
203 @@ -345,6 +349,7 @@ struct sh_atomic_model
204 hard_llcs,
205 soft_tcb,
206 soft_imask,
207 + hard_cas,
209 num_models
211 @@ -388,6 +393,9 @@ extern const sh_atomic_model& selected_atomic_model (void);
212 #define TARGET_ATOMIC_SOFT_IMASK \
213 (selected_atomic_model ().type == sh_atomic_model::soft_imask)
215 +#define TARGET_ATOMIC_HARD_CAS \
216 + (selected_atomic_model ().type == sh_atomic_model::hard_cas)
218 #endif // __cplusplus
220 #define SUBTARGET_OVERRIDE_OPTIONS (void) 0
221 @@ -1521,7 +1529,7 @@ extern bool current_function_interrupt;
223 /* Nonzero if the target supports dynamic shift instructions
224 like shad and shld. */
225 -#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A)
226 +#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A || TARGET_SHJ2)
228 /* The cost of using the dynamic shift insns (shad, shld) are the same
229 if they are available. If they are not available a library function will
230 @@ -1784,6 +1792,7 @@ enum processor_type {
231 PROCESSOR_SH2,
232 PROCESSOR_SH2E,
233 PROCESSOR_SH2A,
234 + PROCESSOR_SHJ2,
235 PROCESSOR_SH3,
236 PROCESSOR_SH3E,
237 PROCESSOR_SH4,
238 diff --git a/gcc/config/sh/sh.opt b/gcc/config/sh/sh.opt
239 index 837d9bfdc23..86b2cd6fc79 100644
240 --- a/gcc/config/sh/sh.opt
241 +++ b/gcc/config/sh/sh.opt
242 @@ -65,6 +65,10 @@ m2e
243 Target RejectNegative Condition(SUPPORT_SH2E)
244 Generate SH2e code.
246 +mj2
247 +Target RejectNegative Mask(SHJ2) Condition(SUPPORT_SHJ2)
248 +Generate J2 code.
251 Target RejectNegative Mask(SH3) Condition(SUPPORT_SH3)
252 Generate SH3 code.
253 diff --git a/gcc/config/sh/sync.md b/gcc/config/sh/sync.md
254 index 9dba513e642..5bc8acabf2f 100644
255 --- a/gcc/config/sh/sync.md
256 +++ b/gcc/config/sh/sync.md
257 @@ -240,6 +240,9 @@
258 || (TARGET_SH4A && <MODE>mode == SImode && !TARGET_ATOMIC_STRICT))
259 atomic_insn = gen_atomic_compare_and_swap<mode>_hard (old_val, mem,
260 exp_val, new_val);
261 + else if (TARGET_ATOMIC_HARD_CAS && <MODE>mode == SImode)
262 + atomic_insn = gen_atomic_compare_and_swap<mode>_cas (old_val, mem,
263 + exp_val, new_val);
264 else if (TARGET_ATOMIC_SOFT_GUSA)
265 atomic_insn = gen_atomic_compare_and_swap<mode>_soft_gusa (old_val, mem,
266 exp_val, new_val);
267 @@ -306,6 +309,57 @@
269 [(set_attr "length" "14")])
271 +(define_expand "atomic_compare_and_swapsi_cas"
272 + [(set (match_operand:SI 0 "register_operand" "=r")
273 + (unspec_volatile:SI
274 + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
275 + (match_operand:SI 2 "register_operand" "r")
276 + (match_operand:SI 3 "register_operand" "r")]
277 + UNSPECV_CMPXCHG_1))]
278 + "TARGET_ATOMIC_HARD_CAS"
280 + rtx mem = gen_rtx_REG (SImode, 0);
281 + emit_move_insn (mem, force_reg (SImode, XEXP (operands[1], 0)));
282 + emit_insn (gen_shj2_cas (operands[0], mem, operands[2], operands[3]));
283 + DONE;
286 +(define_insn "shj2_cas"
287 + [(set (match_operand:SI 0 "register_operand" "=&r")
288 + (unspec_volatile:SI
289 + [(match_operand:SI 1 "register_operand" "=r")
290 + (match_operand:SI 2 "register_operand" "r")
291 + (match_operand:SI 3 "register_operand" "0")]
292 + UNSPECV_CMPXCHG_1))
293 + (set (reg:SI T_REG)
294 + (unspec_volatile:SI [(const_int 0)] UNSPECV_CMPXCHG_3))]
295 + "TARGET_ATOMIC_HARD_CAS"
296 + "cas.l %2,%0,@%1"
297 + [(set_attr "length" "2")]
300 +(define_expand "atomic_compare_and_swapqi_cas"
301 + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
302 + (unspec_volatile:SI
303 + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
304 + (match_operand:SI 2 "arith_operand" "rI08")
305 + (match_operand:SI 3 "arith_operand" "rI08")]
306 + UNSPECV_CMPXCHG_1))]
307 + "TARGET_ATOMIC_HARD_CAS"
308 +{FAIL;}
311 +(define_expand "atomic_compare_and_swaphi_cas"
312 + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
313 + (unspec_volatile:SI
314 + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
315 + (match_operand:SI 2 "arith_operand" "rI08")
316 + (match_operand:SI 3 "arith_operand" "rI08")]
317 + UNSPECV_CMPXCHG_1))]
318 + "TARGET_ATOMIC_HARD_CAS"
319 +{FAIL;}
322 ;; The QIHImode llcs patterns modify the address register of the memory
323 ;; operand. In order to express that, we have to open code the memory
324 ;; operand. Initially the insn is expanded like every other atomic insn
325 diff --git a/gcc/config/sh/t-sh b/gcc/config/sh/t-sh
326 index a78c6a55127..386934dca8a 100644
327 --- a/gcc/config/sh/t-sh
328 +++ b/gcc/config/sh/t-sh
329 @@ -50,7 +50,8 @@ MULTILIB_MATCHES = $(shell \
330 m2e,m3e,m4-single-only,m4-100-single-only,m4-200-single-only,m4-300-single-only,m4a-single-only \
331 m2a-single,m2a-single-only \
332 m4-single,m4-100-single,m4-200-single,m4-300-single,m4a-single \
333 - m4,m4-100,m4-200,m4-300,m4a; do \
334 + m4,m4-100,m4-200,m4-300,m4a \
335 + mj2; do \
336 subst= ; \
337 for lib in `echo $$abi|tr , ' '` ; do \
338 if test "`echo $$multilibs|sed s/$$lib//`" != "$$multilibs"; then \
339 @@ -63,9 +64,9 @@ MULTILIB_MATCHES = $(shell \
341 # SH1 and SH2A support big endian only.
342 ifeq ($(DEFAULT_ENDIAN),ml)
343 -MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
344 +MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
345 else
346 -MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
347 +MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
348 endif
350 MULTILIB_OSDIRNAMES = \
351 @@ -87,7 +88,8 @@ MULTILIB_OSDIRNAMES = \
352 m4a-single-only=!m4a-single-only $(OTHER_ENDIAN)/m4a-single-only=!$(OTHER_ENDIAN)/m4a-single-only \
353 m4a-single=!m4a-single $(OTHER_ENDIAN)/m4a-single=!$(OTHER_ENDIAN)/m4a-single \
354 m4a=!m4a $(OTHER_ENDIAN)/m4a=!$(OTHER_ENDIAN)/m4a \
355 - m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al
356 + m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al \
357 + mj2=!j2
359 $(out_object_file): gt-sh.h
360 gt-sh.h : s-gtype ; @true
362 2.17.1