0004-j2.diff 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. diff --git a/gcc/config.gcc b/gcc/config.gcc
  2. index 0f2dc32..a3d0d45 100644
  3. --- a/gcc/config.gcc
  4. +++ b/gcc/config.gcc
  5. @@ -467,7 +467,7 @@ s390*-*-*)
  6. extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
  7. ;;
  8. # Note the 'l'; we need to be able to match e.g. "shle" or "shl".
  9. -sh[123456789lbe]*-*-* | sh-*-*)
  10. +sh[123456789lbej]*-*-* | sh-*-*)
  11. cpu_type=sh
  12. extra_options="${extra_options} fused-madd.opt"
  13. extra_objs="${extra_objs} sh_treg_combine.o sh-mem.o sh_optimize_sett_clrt.o"
  14. @@ -2601,19 +2601,19 @@ s390x-ibm-tpf*)
  15. extra_options="${extra_options} s390/tpf.opt"
  16. tmake_file="${tmake_file} s390/t-s390"
  17. ;;
  18. -sh-*-elf* | sh[12346l]*-*-elf* | \
  19. - sh-*-linux* | sh[2346lbe]*-*-linux* | \
  20. +sh-*-elf* | sh[12346lj]*-*-elf* | \
  21. + sh-*-linux* | sh[2346lbej]*-*-linux* | \
  22. sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
  23. sh64-*-netbsd* | sh64l*-*-netbsd*)
  24. tmake_file="${tmake_file} sh/t-sh sh/t-elf"
  25. if test x${with_endian} = x; then
  26. case ${target} in
  27. - sh[1234]*be-*-* | sh[1234]*eb-*-*) with_endian=big ;;
  28. + sh[j1234]*be-*-* | sh[j1234]*eb-*-*) with_endian=big ;;
  29. shbe-*-* | sheb-*-*) with_endian=big,little ;;
  30. sh[1234]l* | sh[34]*-*-linux*) with_endian=little ;;
  31. shl* | sh64l* | sh*-*-linux* | \
  32. sh5l* | sh-superh-elf) with_endian=little,big ;;
  33. - sh[1234]*-*-*) with_endian=big ;;
  34. + sh[j1234]*-*-*) with_endian=big ;;
  35. *) with_endian=big,little ;;
  36. esac
  37. fi
  38. @@ -2703,6 +2703,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
  39. sh2a_nofpu*) sh_cpu_target=sh2a-nofpu ;;
  40. sh2a*) sh_cpu_target=sh2a ;;
  41. sh2e*) sh_cpu_target=sh2e ;;
  42. + shj2*) sh_cpu_target=shj2;;
  43. sh2*) sh_cpu_target=sh2 ;;
  44. *) sh_cpu_target=sh1 ;;
  45. esac
  46. @@ -2727,7 +2728,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
  47. sh2a-single-only | sh2a-single | sh2a-nofpu | sh2a | \
  48. sh4a-single-only | sh4a-single | sh4a-nofpu | sh4a | sh4al | \
  49. sh4-single-only | sh4-single | sh4-nofpu | sh4 | sh4-300 | \
  50. - sh3e | sh3 | sh2e | sh2 | sh1) ;;
  51. + sh3e | sh3 | sh2e | sh2 | sh1 | shj2) ;;
  52. "") sh_cpu_default=${sh_cpu_target} ;;
  53. *) echo "with_cpu=$with_cpu not supported"; exit 1 ;;
  54. esac
  55. @@ -2738,9 +2739,9 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
  56. sh[1234]*) sh_multilibs=${sh_cpu_target} ;;
  57. sh64* | sh5*) sh_multilibs=m5-32media,m5-32media-nofpu,m5-compact,m5-compact-nofpu,m5-64media,m5-64media-nofpu ;;
  58. sh-superh-*) sh_multilibs=m4,m4-single,m4-single-only,m4-nofpu ;;
  59. - sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4 ;;
  60. + sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4,mj2 ;;
  61. sh*-*-netbsd*) sh_multilibs=m3,m3e,m4 ;;
  62. - *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single ;;
  63. + *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single,mj2 ;;
  64. esac
  65. if test x$with_fp = xno; then
  66. 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`"
  67. @@ -2758,7 +2759,8 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
  68. m2a | m2a-single | m2a-single-only | m2a-nofpu | \
  69. m5-64media | m5-64media-nofpu | \
  70. m5-32media | m5-32media-nofpu | \
  71. - m5-compact | m5-compact-nofpu)
  72. + m5-compact | m5-compact-nofpu | \
  73. + mj2)
  74. # TM_MULTILIB_CONFIG is used by t-sh for the non-endian multilib definition
  75. # It is passed to MULTIILIB_OPTIONS verbatim.
  76. TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG}/${sh_multilib}"
  77. @@ -2775,7 +2777,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
  78. done
  79. TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's:^/::'`
  80. if test x${enable_incomplete_targets} = xyes ; then
  81. - 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_SH5_32MEDIA=1 SUPPORT_SH5_32MEDIA_NOFPU=1 SUPPORT_SH5_64MEDIA=1 SUPPORT_SH5_64MEDIA_NOFPU=1"
  82. + 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_SH5_32MEDIA=1 SUPPORT_SH5_32MEDIA_NOFPU=1 SUPPORT_SH5_64MEDIA=1 SUPPORT_SH5_64MEDIA_NOFPU=1 SUPPORT_SHJ2=1"
  83. fi
  84. tm_file="$tm_file ./sysroot-suffix.h"
  85. tmake_file="$tmake_file t-sysroot-suffix"
  86. @@ -4106,6 +4109,8 @@
  87. ;;
  88. m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al)
  89. ;;
  90. + mj2)
  91. + ;;
  92. *)
  93. echo "Unknown CPU used in --with-cpu=$with_cpu, known values:" 1>&2
  94. echo "m1 m2 m2e m3 m3e m4 m4-single m4-single-only m4-nofpu" 1>&2
  95. @@ -4456,7 +4458,7 @@ case ${target} in
  96. tmake_file="rs6000/t-rs6000 ${tmake_file}"
  97. ;;
  98. - sh[123456ble]*-*-* | sh-*-*)
  99. + sh[123456blej]*-*-* | sh-*-*)
  100. c_target_objs="${c_target_objs} sh-c.o"
  101. cxx_target_objs="${cxx_target_objs} sh-c.o"
  102. ;;
  103. diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h
  104. index b08120d..63b77fa 100644
  105. --- a/gcc/config/sh/sh-protos.h
  106. +++ b/gcc/config/sh/sh-protos.h
  107. @@ -45,6 +45,7 @@ struct sh_atomic_model
  108. hard_llcs,
  109. soft_tcb,
  110. soft_imask,
  111. + hard_cas,
  112. num_models
  113. };
  114. @@ -88,6 +89,9 @@ extern const sh_atomic_model& selected_atomic_model (void);
  115. #define TARGET_ATOMIC_SOFT_IMASK \
  116. (selected_atomic_model ().type == sh_atomic_model::soft_imask)
  117. +#define TARGET_ATOMIC_HARD_CAS \
  118. + (selected_atomic_model ().type == sh_atomic_model::hard_cas)
  119. +
  120. #ifdef RTX_CODE
  121. extern rtx sh_fsca_sf2int (void);
  122. extern rtx sh_fsca_int2sf (void);
  123. diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
  124. index 0b18ce5..bdf96e2 100644
  125. --- a/gcc/config/sh/sh.c
  126. +++ b/gcc/config/sh/sh.c
  127. @@ -692,6 +692,7 @@ parse_validate_atomic_model_option (const char* str)
  128. model_names[sh_atomic_model::hard_llcs] = "hard-llcs";
  129. model_names[sh_atomic_model::soft_tcb] = "soft-tcb";
  130. model_names[sh_atomic_model::soft_imask] = "soft-imask";
  131. + model_names[sh_atomic_model::hard_cas] = "hard-cas";
  132. const char* model_cdef_names[sh_atomic_model::num_models];
  133. model_cdef_names[sh_atomic_model::none] = "NONE";
  134. @@ -699,6 +700,7 @@ parse_validate_atomic_model_option (const char* str)
  135. model_cdef_names[sh_atomic_model::hard_llcs] = "HARD_LLCS";
  136. model_cdef_names[sh_atomic_model::soft_tcb] = "SOFT_TCB";
  137. model_cdef_names[sh_atomic_model::soft_imask] = "SOFT_IMASK";
  138. + model_cdef_names[sh_atomic_model::hard_cas] = "HARD_CAS";
  139. sh_atomic_model ret;
  140. ret.type = sh_atomic_model::none;
  141. @@ -780,6 +782,9 @@ got_mode_name:;
  142. if (ret.type == sh_atomic_model::soft_imask && TARGET_USERMODE)
  143. err_ret ("cannot use atomic model %s in user mode", ret.name);
  144. + if (ret.type == sh_atomic_model::hard_cas && !TARGET_SHJ2)
  145. + err_ret ("atomic model %s is only available J2 targets", ret.name);
  146. +
  147. return ret;
  148. #undef err_ret
  149. @@ -845,6 +850,8 @@ sh_option_override (void)
  150. sh_cpu = PROCESSOR_SH2E;
  151. if (TARGET_SH2A)
  152. sh_cpu = PROCESSOR_SH2A;
  153. + if (TARGET_SHJ2)
  154. + sh_cpu = PROCESSOR_SHJ2;
  155. if (TARGET_SH3)
  156. sh_cpu = PROCESSOR_SH3;
  157. if (TARGET_SH3E)
  158. diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
  159. index 7187c23..9d0d1d0 100644
  160. --- a/gcc/config/sh/sh.h
  161. +++ b/gcc/config/sh/sh.h
  162. @@ -106,6 +106,7 @@ extern int code_for_indirect_jump_scratch;
  163. #define SUPPORT_SH4_SINGLE 1
  164. #define SUPPORT_SH2A 1
  165. #define SUPPORT_SH2A_SINGLE 1
  166. +#define SUPPORT_SHJ2 1
  167. #endif
  168. #define TARGET_DIVIDE_INV \
  169. @@ -157,6 +158,7 @@ extern int code_for_indirect_jump_scratch;
  170. #define SELECT_SH5_32MEDIA_NOFPU (MASK_SH5 | MASK_SH_E)
  171. #define SELECT_SH5_COMPACT (MASK_SH5 | MASK_SH4 | SELECT_SH3E)
  172. #define SELECT_SH5_COMPACT_NOFPU (MASK_SH5 | SELECT_SH3)
  173. +#define SELECT_SHJ2 (MASK_SHJ2 | SELECT_SH2)
  174. #if SUPPORT_SH1
  175. #define SUPPORT_SH2 1
  176. @@ -164,6 +166,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. @@ -211,7 +214,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 | MASK_SH5 \
  188. - | MASK_FPU_SINGLE_ONLY)
  189. + | MASK_FPU_SINGLE_ONLY | MASK_SHJ2)
  190. /* This defaults us to big-endian. */
  191. #ifndef TARGET_ENDIAN_DEFAULT
  192. @@ -289,8 +292,8 @@ extern int code_for_indirect_jump_scratch;
  193. %{m5-compact*:--isa=SHcompact} \
  194. %{m5-32media*:--isa=SHmedia --abi=32} \
  195. %{m5-64media*:--isa=SHmedia --abi=64} \
  196. -%{m4al:-dsp} %{mcut2-workaround:-cut2-workaround}"
  197. -
  198. +%{m4al:-dsp} %{mcut2-workaround:-cut2-workaround} \
  199. +%{mj2:-isa=j2}"
  200. #define ASM_SPEC SH_ASM_SPEC
  201. #ifndef SUBTARGET_ASM_ENDIAN_SPEC
  202. @@ -1853,7 +1856,7 @@ struct sh_args {
  203. /* Nonzero if the target supports dynamic shift instructions
  204. like shad and shld. */
  205. -#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A)
  206. +#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A || TARGET_SHJ2)
  207. /* The cost of using the dynamic shift insns (shad, shld) are the same
  208. if they are available. If they are not available a library function will
  209. @@ -2185,6 +2188,7 @@ enum processor_type {
  210. PROCESSOR_SH2,
  211. PROCESSOR_SH2E,
  212. PROCESSOR_SH2A,
  213. + PROCESSOR_SHJ2,
  214. PROCESSOR_SH3,
  215. PROCESSOR_SH3E,
  216. PROCESSOR_SH4,
  217. diff --git a/gcc/config/sh/sh.opt b/gcc/config/sh/sh.opt
  218. index 1026c73..bac47ed 100644
  219. --- a/gcc/config/sh/sh.opt
  220. +++ b/gcc/config/sh/sh.opt
  221. @@ -71,6 +71,10 @@ m2e
  222. Target RejectNegative Condition(SUPPORT_SH2E)
  223. Generate SH2e code.
  224. +mj2
  225. +Target RejectNegative Mask(SHJ2) Condition(SUPPORT_SHJ2)
  226. +Generate J2 code.
  227. +
  228. m3
  229. Target RejectNegative Mask(SH3) Condition(SUPPORT_SH3)
  230. Generate SH3 code.
  231. diff --git a/gcc/config/sh/sync.md b/gcc/config/sh/sync.md
  232. index 6f1337b..cff57b8 100644
  233. --- a/gcc/config/sh/sync.md
  234. +++ b/gcc/config/sh/sync.md
  235. @@ -240,6 +240,9 @@
  236. || (TARGET_SH4A && <MODE>mode == SImode && !TARGET_ATOMIC_STRICT))
  237. atomic_insn = gen_atomic_compare_and_swap<mode>_hard (old_val, mem,
  238. exp_val, new_val);
  239. + else if (TARGET_ATOMIC_HARD_CAS && <MODE>mode == SImode)
  240. + atomic_insn = gen_atomic_compare_and_swap<mode>_cas (old_val, mem,
  241. + exp_val, new_val);
  242. else if (TARGET_ATOMIC_SOFT_GUSA)
  243. atomic_insn = gen_atomic_compare_and_swap<mode>_soft_gusa (old_val, mem,
  244. exp_val, new_val);
  245. @@ -306,6 +309,57 @@
  246. }
  247. [(set_attr "length" "14")])
  248. +(define_expand "atomic_compare_and_swapsi_cas"
  249. + [(set (match_operand:SI 0 "register_operand" "=r")
  250. + (unspec_volatile:SI
  251. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  252. + (match_operand:SI 2 "register_operand" "r")
  253. + (match_operand:SI 3 "register_operand" "r")]
  254. + UNSPECV_CMPXCHG_1))]
  255. + "TARGET_ATOMIC_HARD_CAS"
  256. +{
  257. + rtx mem = gen_rtx_REG (SImode, 0);
  258. + emit_move_insn (mem, force_reg (SImode, XEXP (operands[1], 0)));
  259. + emit_insn (gen_shj2_cas (operands[0], mem, operands[2], operands[3]));
  260. + DONE;
  261. +})
  262. +
  263. +(define_insn "shj2_cas"
  264. + [(set (match_operand:SI 0 "register_operand" "=&r")
  265. + (unspec_volatile:SI
  266. + [(match_operand:SI 1 "register_operand" "=r")
  267. + (match_operand:SI 2 "register_operand" "r")
  268. + (match_operand:SI 3 "register_operand" "0")]
  269. + UNSPECV_CMPXCHG_1))
  270. + (set (reg:SI T_REG)
  271. + (unspec_volatile:SI [(const_int 0)] UNSPECV_CMPXCHG_3))]
  272. + "TARGET_ATOMIC_HARD_CAS"
  273. + "cas.l %2,%0,@%1"
  274. + [(set_attr "length" "2")]
  275. +)
  276. +
  277. +(define_expand "atomic_compare_and_swapqi_cas"
  278. + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
  279. + (unspec_volatile:SI
  280. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  281. + (match_operand:SI 2 "arith_operand" "rI08")
  282. + (match_operand:SI 3 "arith_operand" "rI08")]
  283. + UNSPECV_CMPXCHG_1))]
  284. + "TARGET_ATOMIC_HARD_CAS"
  285. +{FAIL;}
  286. +)
  287. +
  288. +(define_expand "atomic_compare_and_swaphi_cas"
  289. + [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
  290. + (unspec_volatile:SI
  291. + [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
  292. + (match_operand:SI 2 "arith_operand" "rI08")
  293. + (match_operand:SI 3 "arith_operand" "rI08")]
  294. + UNSPECV_CMPXCHG_1))]
  295. + "TARGET_ATOMIC_HARD_CAS"
  296. +{FAIL;}
  297. +)
  298. +
  299. ;; The QIHImode llcs patterns modify the address register of the memory
  300. ;; operand. In order to express that, we have to open code the memory
  301. ;; operand. Initially the insn is expanded like every other atomic insn
  302. diff --git a/gcc/config/sh/t-sh b/gcc/config/sh/t-sh
  303. index 348cc0b..8e6bdaf 100644
  304. --- a/gcc/config/sh/t-sh
  305. +++ b/gcc/config/sh/t-sh
  306. @@ -52,7 +52,7 @@ MULTILIB_MATCHES = $(shell \
  307. m4-single,m4-100-single,m4-200-single,m4-300-single,m4a-single \
  308. m4,m4-100,m4-200,m4-300,m4a \
  309. m5-32media,m5-compact,m5-32media \
  310. - m5-32media-nofpu,m5-compact-nofpu,m5-32media-nofpu; do \
  311. + m5-32media-nofpu,m5-compact-nofpu,m5-32media-nofpu,mj2; do \
  312. subst= ; \
  313. for lib in `echo $$abi|tr , ' '` ; do \
  314. if test "`echo $$multilibs|sed s/$$lib//`" != "$$multilibs"; then \
  315. @@ -65,9 +65,9 @@ MULTILIB_MATCHES = $(shell \
  316. # SH1 and SH2A support big endian only.
  317. ifeq ($(DEFAULT_ENDIAN),ml)
  318. -MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  319. +MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  320. else
  321. -MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  322. +MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
  323. endif
  324. MULTILIB_OSDIRNAMES = \
  325. @@ -96,6 +96,7 @@ MULTILIB_OSDIRNAMES = \
  326. m5-compact-nofpu=!m5-compact-nofpu $(OTHER_ENDIAN)/m5-compact-nofpu=!$(OTHER_ENDIAN)/m5-compact-nofpu \
  327. m5-64media=!m5-64media $(OTHER_ENDIAN)/m5-64media=!$(OTHER_ENDIAN)/m5-64media \
  328. m5-64media-nofpu=!m5-64media-nofpu $(OTHER_ENDIAN)/m5-64media-nofpu=!$(OTHER_ENDIAN)/m5-64media-nofpu
  329. + mj2=!j2
  330. $(out_object_file): gt-sh.h
  331. gt-sh.h : s-gtype ; @true