j2.patch 13 KB

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