1
0

j2.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. diff -Nur gcc-7.3.0.orig/gcc/config/sh/sh-protos.h gcc-7.3.0/gcc/config/sh/sh-protos.h
  2. --- gcc-7.3.0.orig/gcc/config/sh/sh-protos.h 2017-01-01 13:07:43.000000000 +0100
  3. +++ gcc-7.3.0/gcc/config/sh/sh-protos.h 2018-06-03 02:20:50.000000000 +0200
  4. @@ -35,6 +35,9 @@
  5. SFUNC_STATIC
  6. };
  7. +#define TARGET_ATOMIC_HARD_CAS \
  8. + (selected_atomic_model ().type == sh_atomic_model::hard_cas)
  9. +
  10. #ifdef RTX_CODE
  11. extern rtx sh_fsca_sf2int (void);
  12. extern rtx sh_fsca_int2sf (void);
  13. diff -Nur gcc-7.3.0.orig/gcc/config/sh/sh.c gcc-7.3.0/gcc/config/sh/sh.c
  14. --- gcc-7.3.0.orig/gcc/config/sh/sh.c 2017-04-04 00:30:56.000000000 +0200
  15. +++ gcc-7.3.0/gcc/config/sh/sh.c 2018-06-03 02:20:50.000000000 +0200
  16. @@ -662,6 +662,7 @@
  17. model_names[sh_atomic_model::hard_llcs] = "hard-llcs";
  18. model_names[sh_atomic_model::soft_tcb] = "soft-tcb";
  19. model_names[sh_atomic_model::soft_imask] = "soft-imask";
  20. + model_names[sh_atomic_model::hard_cas] = "hard-cas";
  21. const char* model_cdef_names[sh_atomic_model::num_models];
  22. model_cdef_names[sh_atomic_model::none] = "NONE";
  23. @@ -669,6 +670,7 @@
  24. model_cdef_names[sh_atomic_model::hard_llcs] = "HARD_LLCS";
  25. model_cdef_names[sh_atomic_model::soft_tcb] = "SOFT_TCB";
  26. model_cdef_names[sh_atomic_model::soft_imask] = "SOFT_IMASK";
  27. + model_cdef_names[sh_atomic_model::hard_cas] = "HARD_CAS";
  28. sh_atomic_model ret;
  29. ret.type = sh_atomic_model::none;
  30. @@ -747,6 +749,9 @@
  31. if (ret.type == sh_atomic_model::soft_imask && TARGET_USERMODE)
  32. err_ret ("cannot use atomic model %s in user mode", ret.name);
  33. + if (ret.type == sh_atomic_model::hard_cas && !TARGET_SHJ2)
  34. + err_ret ("atomic model %s is only available J2 targets", ret.name);
  35. +
  36. return ret;
  37. #undef err_ret
  38. @@ -803,6 +808,8 @@
  39. sh_cpu = PROCESSOR_SH2E;
  40. if (TARGET_SH2A)
  41. sh_cpu = PROCESSOR_SH2A;
  42. + if (TARGET_SHJ2)
  43. + sh_cpu = PROCESSOR_SHJ2;
  44. if (TARGET_SH3)
  45. sh_cpu = PROCESSOR_SH3;
  46. if (TARGET_SH3E)
  47. diff -Nur gcc-7.3.0.orig/gcc/config/sh/sh.h gcc-7.3.0/gcc/config/sh/sh.h
  48. --- gcc-7.3.0.orig/gcc/config/sh/sh.h 2017-01-01 13:07:43.000000000 +0100
  49. +++ gcc-7.3.0/gcc/config/sh/sh.h 2018-06-03 02:20:50.000000000 +0200
  50. @@ -83,6 +83,7 @@
  51. #define SUPPORT_SH4_SINGLE 1
  52. #define SUPPORT_SH2A 1
  53. #define SUPPORT_SH2A_SINGLE 1
  54. +#define SUPPORT_SHJ2 1
  55. #endif
  56. #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
  57. @@ -115,6 +116,7 @@
  58. #define SELECT_SH4A_SINGLE_ONLY (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
  59. #define SELECT_SH4A (MASK_SH4A | SELECT_SH4)
  60. #define SELECT_SH4A_SINGLE (MASK_SH4A | SELECT_SH4_SINGLE)
  61. +#define SELECT_SHJ2 (MASK_SHJ2 | SELECT_SH2)
  62. #if SUPPORT_SH1
  63. #define SUPPORT_SH2 1
  64. @@ -122,6 +124,7 @@
  65. #if SUPPORT_SH2
  66. #define SUPPORT_SH3 1
  67. #define SUPPORT_SH2A_NOFPU 1
  68. +#define SUPPORT_SHJ2 1
  69. #endif
  70. #if SUPPORT_SH3
  71. #define SUPPORT_SH4_NOFPU 1
  72. @@ -154,7 +157,7 @@
  73. #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
  74. | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
  75. | MASK_HARD_SH4 | MASK_FPU_SINGLE \
  76. - | MASK_FPU_SINGLE_ONLY)
  77. + | MASK_FPU_SINGLE_ONLY | MASK_SHJ2)
  78. /* This defaults us to big-endian. */
  79. #ifndef TARGET_ENDIAN_DEFAULT
  80. @@ -229,7 +232,8 @@
  81. %{m2a-single:--isa=sh2a} \
  82. %{m2a-single-only:--isa=sh2a} \
  83. %{m2a-nofpu:--isa=sh2a-nofpu} \
  84. -%{m4al:-dsp}"
  85. +%{m4al:-dsp} \
  86. +%{mj2:-isa=j2}"
  87. #define ASM_SPEC SH_ASM_SPEC
  88. @@ -345,6 +349,7 @@
  89. hard_llcs,
  90. soft_tcb,
  91. soft_imask,
  92. + hard_cas,
  93. num_models
  94. };
  95. @@ -1568,7 +1573,7 @@
  96. /* Nonzero if the target supports dynamic shift instructions
  97. like shad and shld. */
  98. -#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A)
  99. +#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A || TARGET_SHJ2)
  100. /* The cost of using the dynamic shift insns (shad, shld) are the same
  101. if they are available. If they are not available a library function will
  102. @@ -1833,6 +1838,7 @@
  103. PROCESSOR_SH2,
  104. PROCESSOR_SH2E,
  105. PROCESSOR_SH2A,
  106. + PROCESSOR_SHJ2,
  107. PROCESSOR_SH3,
  108. PROCESSOR_SH3E,
  109. PROCESSOR_SH4,
  110. diff -Nur gcc-7.3.0.orig/gcc/config/sh/sh.opt gcc-7.3.0/gcc/config/sh/sh.opt
  111. --- gcc-7.3.0.orig/gcc/config/sh/sh.opt 2017-01-01 13:07:43.000000000 +0100
  112. +++ gcc-7.3.0/gcc/config/sh/sh.opt 2018-06-03 02:20:50.000000000 +0200
  113. @@ -65,6 +65,10 @@
  114. Target RejectNegative Condition(SUPPORT_SH2E)
  115. Generate SH2e code.
  116. +mj2
  117. +Target RejectNegative Mask(SHJ2) Condition(SUPPORT_SHJ2)
  118. +Generate J2 code.
  119. +
  120. m3
  121. Target RejectNegative Mask(SH3) Condition(SUPPORT_SH3)
  122. Generate SH3 code.
  123. diff -Nur gcc-7.3.0.orig/gcc/config/sh/sync.md gcc-7.3.0/gcc/config/sh/sync.md
  124. --- gcc-7.3.0.orig/gcc/config/sh/sync.md 2017-01-01 13:07:43.000000000 +0100
  125. +++ gcc-7.3.0/gcc/config/sh/sync.md 2018-06-03 02:20:50.000000000 +0200
  126. @@ -240,6 +240,9 @@
  127. || (TARGET_SH4A && <MODE>mode == SImode && !TARGET_ATOMIC_STRICT))
  128. atomic_insn = gen_atomic_compare_and_swap<mode>_hard (old_val, mem,
  129. exp_val, new_val);
  130. + else if (TARGET_ATOMIC_HARD_CAS && <MODE>mode == SImode)
  131. + atomic_insn = gen_atomic_compare_and_swap<mode>_cas (old_val, mem,
  132. + exp_val, new_val);
  133. else if (TARGET_ATOMIC_SOFT_GUSA)
  134. atomic_insn = gen_atomic_compare_and_swap<mode>_soft_gusa (old_val, mem,
  135. exp_val, new_val);
  136. @@ -306,6 +309,57 @@
  137. }
  138. [(set_attr "length" "14")])
  139. +(define_expand "atomic_compare_and_swapsi_cas"
  140. + [(set (match_operand:SI 0 "register_operand" "=r")
  141. + (unspec_volatile:SI
  142. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  143. + (match_operand:SI 2 "register_operand" "r")
  144. + (match_operand:SI 3 "register_operand" "r")]
  145. + UNSPECV_CMPXCHG_1))]
  146. + "TARGET_ATOMIC_HARD_CAS"
  147. +{
  148. + rtx mem = gen_rtx_REG (SImode, 0);
  149. + emit_move_insn (mem, force_reg (SImode, XEXP (operands[1], 0)));
  150. + emit_insn (gen_shj2_cas (operands[0], mem, operands[2], operands[3]));
  151. + DONE;
  152. +})
  153. +
  154. +(define_insn "shj2_cas"
  155. + [(set (match_operand:SI 0 "register_operand" "=&r")
  156. + (unspec_volatile:SI
  157. + [(match_operand:SI 1 "register_operand" "=r")
  158. + (match_operand:SI 2 "register_operand" "r")
  159. + (match_operand:SI 3 "register_operand" "0")]
  160. + UNSPECV_CMPXCHG_1))
  161. + (set (reg:SI T_REG)
  162. + (unspec_volatile:SI [(const_int 0)] UNSPECV_CMPXCHG_3))]
  163. + "TARGET_ATOMIC_HARD_CAS"
  164. + "cas.l %2,%0,@%1"
  165. + [(set_attr "length" "2")]
  166. +)
  167. +
  168. +(define_expand "atomic_compare_and_swapqi_cas"
  169. + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
  170. + (unspec_volatile:SI
  171. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  172. + (match_operand:SI 2 "arith_operand" "rI08")
  173. + (match_operand:SI 3 "arith_operand" "rI08")]
  174. + UNSPECV_CMPXCHG_1))]
  175. + "TARGET_ATOMIC_HARD_CAS"
  176. +{FAIL;}
  177. +)
  178. +
  179. +(define_expand "atomic_compare_and_swaphi_cas"
  180. + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
  181. + (unspec_volatile:SI
  182. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  183. + (match_operand:SI 2 "arith_operand" "rI08")
  184. + (match_operand:SI 3 "arith_operand" "rI08")]
  185. + UNSPECV_CMPXCHG_1))]
  186. + "TARGET_ATOMIC_HARD_CAS"
  187. +{FAIL;}
  188. +)
  189. +
  190. ;; The QIHImode llcs patterns modify the address register of the memory
  191. ;; operand. In order to express that, we have to open code the memory
  192. ;; operand. Initially the insn is expanded like every other atomic insn
  193. diff -Nur gcc-7.3.0.orig/gcc/config/sh/t-sh gcc-7.3.0/gcc/config/sh/t-sh
  194. --- gcc-7.3.0.orig/gcc/config/sh/t-sh 2017-01-01 13:07:43.000000000 +0100
  195. +++ gcc-7.3.0/gcc/config/sh/t-sh 2018-06-03 02:20:50.000000000 +0200
  196. @@ -50,7 +50,8 @@
  197. m2e,m3e,m4-single-only,m4-100-single-only,m4-200-single-only,m4-300-single-only,m4a-single-only \
  198. m2a-single,m2a-single-only \
  199. m4-single,m4-100-single,m4-200-single,m4-300-single,m4a-single \
  200. - m4,m4-100,m4-200,m4-300,m4a; do \
  201. + m4,m4-100,m4-200,m4-300,m4a \
  202. + mj2; do \
  203. subst= ; \
  204. for lib in `echo $$abi|tr , ' '` ; do \
  205. if test "`echo $$multilibs|sed s/$$lib//`" != "$$multilibs"; then \
  206. @@ -63,9 +64,9 @@
  207. # SH1 and SH2A support big endian only.
  208. ifeq ($(DEFAULT_ENDIAN),ml)
  209. -MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  210. +MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  211. else
  212. -MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  213. +MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  214. endif
  215. MULTILIB_OSDIRNAMES = \
  216. @@ -87,7 +88,8 @@
  217. m4a-single-only=!m4a-single-only $(OTHER_ENDIAN)/m4a-single-only=!$(OTHER_ENDIAN)/m4a-single-only \
  218. m4a-single=!m4a-single $(OTHER_ENDIAN)/m4a-single=!$(OTHER_ENDIAN)/m4a-single \
  219. m4a=!m4a $(OTHER_ENDIAN)/m4a=!$(OTHER_ENDIAN)/m4a \
  220. - m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al
  221. + m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al \
  222. + mj2=!j2
  223. $(out_object_file): gt-sh.h
  224. gt-sh.h : s-gtype ; @true
  225. diff -Nur gcc-7.3.0.orig/gcc/config.gcc gcc-7.3.0/gcc/config.gcc
  226. --- gcc-7.3.0.orig/gcc/config.gcc 2018-01-08 14:39:11.000000000 +0100
  227. +++ gcc-7.3.0/gcc/config.gcc 2018-06-03 02:20:50.000000000 +0200
  228. @@ -474,7 +474,7 @@
  229. extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
  230. ;;
  231. # Note the 'l'; we need to be able to match e.g. "shle" or "shl".
  232. -sh[123456789lbe]*-*-* | sh-*-*)
  233. +sh[123456789lbej]*-*-* | sh-*-*)
  234. cpu_type=sh
  235. extra_options="${extra_options} fused-madd.opt"
  236. extra_objs="${extra_objs} sh_treg_combine.o sh-mem.o sh_optimize_sett_clrt.o"
  237. @@ -2664,18 +2664,18 @@
  238. extra_options="${extra_options} s390/tpf.opt"
  239. tmake_file="${tmake_file} s390/t-s390"
  240. ;;
  241. -sh-*-elf* | sh[12346l]*-*-elf* | \
  242. - sh-*-linux* | sh[2346lbe]*-*-linux* | \
  243. +sh-*-elf* | sh[12346lj]*-*-elf* | \
  244. + sh-*-linux* | sh[2346lbej]*-*-linux* | \
  245. sh-*-netbsdelf* | shl*-*-netbsdelf*)
  246. tmake_file="${tmake_file} sh/t-sh sh/t-elf"
  247. if test x${with_endian} = x; then
  248. case ${target} in
  249. - sh[1234]*be-*-* | sh[1234]*eb-*-*) with_endian=big ;;
  250. + sh[j1234]*be-*-* | sh[n1234]*eb-*-*) with_endian=big ;;
  251. shbe-*-* | sheb-*-*) with_endian=big,little ;;
  252. sh[1234]l* | sh[34]*-*-linux*) with_endian=little ;;
  253. shl* | sh*-*-linux* | \
  254. sh-superh-elf) with_endian=little,big ;;
  255. - sh[1234]*-*-*) with_endian=big ;;
  256. + sh[j1234]*-*-*) with_endian=big ;;
  257. *) with_endian=big,little ;;
  258. esac
  259. fi
  260. @@ -2742,6 +2742,7 @@
  261. sh2a_nofpu*) sh_cpu_target=sh2a-nofpu ;;
  262. sh2a*) sh_cpu_target=sh2a ;;
  263. sh2e*) sh_cpu_target=sh2e ;;
  264. + shj2*) sh_cpu_target=shj2;;
  265. sh2*) sh_cpu_target=sh2 ;;
  266. *) sh_cpu_target=sh1 ;;
  267. esac
  268. @@ -2763,7 +2764,7 @@
  269. sh2a-single-only | sh2a-single | sh2a-nofpu | sh2a | \
  270. sh4a-single-only | sh4a-single | sh4a-nofpu | sh4a | sh4al | \
  271. sh4-single-only | sh4-single | sh4-nofpu | sh4 | sh4-300 | \
  272. - sh3e | sh3 | sh2e | sh2 | sh1) ;;
  273. + sh3e | sh3 | sh2e | sh2 | sh1 | shj2) ;;
  274. "") sh_cpu_default=${sh_cpu_target} ;;
  275. *) echo "with_cpu=$with_cpu not supported"; exit 1 ;;
  276. esac
  277. @@ -2772,9 +2773,9 @@
  278. case ${target} in
  279. sh[1234]*) sh_multilibs=${sh_cpu_target} ;;
  280. sh-superh-*) sh_multilibs=m4,m4-single,m4-single-only,m4-nofpu ;;
  281. - sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4 ;;
  282. + sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4,mj2 ;;
  283. sh*-*-netbsd*) sh_multilibs=m3,m3e,m4 ;;
  284. - *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single ;;
  285. + *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single,mj2 ;;
  286. esac
  287. if test x$with_fp = xno; then
  288. 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`"
  289. @@ -2789,7 +2790,8 @@
  290. m1 | m2 | m2e | m3 | m3e | \
  291. m4 | m4-single | m4-single-only | m4-nofpu | m4-300 |\
  292. m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al | \
  293. - m2a | m2a-single | m2a-single-only | m2a-nofpu)
  294. + m2a | m2a-single | m2a-single-only | m2a-nofpu | \
  295. + mj2)
  296. # TM_MULTILIB_CONFIG is used by t-sh for the non-endian multilib definition
  297. # It is passed to MULTIILIB_OPTIONS verbatim.
  298. TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG}/${sh_multilib}"
  299. @@ -2806,7 +2808,7 @@
  300. done
  301. TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's:^/::'`
  302. if test x${enable_incomplete_targets} = xyes ; then
  303. - tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1"
  304. + 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"
  305. fi
  306. tm_file="$tm_file ./sysroot-suffix.h"
  307. tmake_file="$tmake_file t-sysroot-suffix"
  308. @@ -4380,6 +4382,8 @@
  309. ;;
  310. m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al)
  311. ;;
  312. + mj2)
  313. + ;;
  314. *)
  315. echo "Unknown CPU used in --with-cpu=$with_cpu, known values:" 1>&2
  316. echo "m1 m2 m2e m3 m3e m4 m4-single m4-single-only m4-nofpu" 1>&2
  317. @@ -4589,7 +4593,7 @@
  318. tmake_file="rs6000/t-rs6000 ${tmake_file}"
  319. ;;
  320. - sh[123456ble]*-*-* | sh-*-*)
  321. + sh[123456blej]*-*-* | sh-*-*)
  322. c_target_objs="${c_target_objs} sh-c.o"
  323. cxx_target_objs="${cxx_target_objs} sh-c.o"
  324. ;;