IntrinsicsHexagon.td 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. //===- IntrinsicsHexagon.td - Defines Hexagon intrinsics ---*- tablegen -*-===//
  2. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  3. // See https://llvm.org/LICENSE.txt for license information.
  4. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file defines all of the Hexagon-specific intrinsics.
  9. //
  10. //===----------------------------------------------------------------------===//
  11. //===----------------------------------------------------------------------===//
  12. // Definitions for all Hexagon intrinsics.
  13. //
  14. // All Hexagon intrinsics start with "llvm.hexagon.".
  15. let TargetPrefix = "hexagon" in {
  16. /// Hexagon_Intrinsic - Base class for the majority of Hexagon intrinsics.
  17. class Hexagon_Intrinsic<string GCCIntSuffix, list<LLVMType> ret_types,
  18. list<LLVMType> param_types,
  19. list<IntrinsicProperty> properties>
  20. : GCCBuiltin<!strconcat("__builtin_", GCCIntSuffix)>,
  21. Intrinsic<ret_types, param_types, properties>;
  22. /// Hexagon_NonGCC_Intrinsic - Base class for bitcode convertible Hexagon
  23. /// intrinsics.
  24. class Hexagon_NonGCC_Intrinsic<list<LLVMType> ret_types,
  25. list<LLVMType> param_types,
  26. list<IntrinsicProperty> properties>
  27. : Intrinsic<ret_types, param_types, properties>;
  28. }
  29. class Hexagon_mem_memmemsi_Intrinsic<string GCCIntSuffix>
  30. : Hexagon_Intrinsic<GCCIntSuffix,
  31. [llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty,
  32. llvm_i32_ty],
  33. [IntrArgMemOnly]>;
  34. class Hexagon_mem_memsisi_Intrinsic<string GCCIntSuffix>
  35. : Hexagon_Intrinsic<GCCIntSuffix,
  36. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty,
  37. llvm_i32_ty],
  38. [IntrWriteMem]>;
  39. class Hexagon_mem_memdisi_Intrinsic<string GCCIntSuffix>
  40. : Hexagon_Intrinsic<GCCIntSuffix,
  41. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i64_ty,
  42. llvm_i32_ty],
  43. [IntrWriteMem]>;
  44. class Hexagon_mem_memmemsisi_Intrinsic<string GCCIntSuffix>
  45. : Hexagon_Intrinsic<GCCIntSuffix,
  46. [llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty,
  47. llvm_i32_ty, llvm_i32_ty],
  48. [IntrArgMemOnly, ImmArg<ArgIndex<3>>]>;
  49. class Hexagon_mem_memsisisi_Intrinsic<string GCCIntSuffix>
  50. : Hexagon_Intrinsic<GCCIntSuffix,
  51. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty,
  52. llvm_i32_ty, llvm_i32_ty],
  53. [IntrWriteMem, ImmArg<ArgIndex<3>>]>;
  54. class Hexagon_mem_memdisisi_Intrinsic<string GCCIntSuffix>
  55. : Hexagon_Intrinsic<GCCIntSuffix,
  56. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i64_ty,
  57. llvm_i32_ty, llvm_i32_ty],
  58. [IntrWriteMem, ImmArg<ArgIndex<3>>]>;
  59. //
  60. // BUILTIN_INFO_NONCONST(circ_ldd,PTR_ftype_PTRPTRSISI,4)
  61. //
  62. def int_hexagon_circ_ldd :
  63. Hexagon_mem_memmemsisi_Intrinsic<"circ_ldd">;
  64. //
  65. // BUILTIN_INFO_NONCONST(circ_ldw,PTR_ftype_PTRPTRSISI,4)
  66. //
  67. def int_hexagon_circ_ldw :
  68. Hexagon_mem_memmemsisi_Intrinsic<"circ_ldw">;
  69. //
  70. // BUILTIN_INFO_NONCONST(circ_ldh,PTR_ftype_PTRPTRSISI,4)
  71. //
  72. def int_hexagon_circ_ldh :
  73. Hexagon_mem_memmemsisi_Intrinsic<"circ_ldh">;
  74. //
  75. // BUILTIN_INFO_NONCONST(circ_lduh,PTR_ftype_PTRPTRSISI,4)
  76. //
  77. def int_hexagon_circ_lduh :
  78. Hexagon_mem_memmemsisi_Intrinsic<"circ_lduh">;
  79. //
  80. // BUILTIN_INFO_NONCONST(circ_ldb,PTR_ftype_PTRPTRSISI,4)
  81. //
  82. def int_hexagon_circ_ldb :
  83. Hexagon_mem_memmemsisi_Intrinsic<"circ_ldb">;
  84. //
  85. // BUILTIN_INFO_NONCONST(circ_ldub,PTR_ftype_PTRPTRSISI,4)
  86. //
  87. def int_hexagon_circ_ldub :
  88. Hexagon_mem_memmemsisi_Intrinsic<"circ_ldub">;
  89. //
  90. // BUILTIN_INFO_NONCONST(circ_std,PTR_ftype_PTRDISISI,4)
  91. //
  92. def int_hexagon_circ_std :
  93. Hexagon_mem_memdisisi_Intrinsic<"circ_std">;
  94. //
  95. // BUILTIN_INFO_NONCONST(circ_stw,PTR_ftype_PTRSISISI,4)
  96. //
  97. def int_hexagon_circ_stw :
  98. Hexagon_mem_memsisisi_Intrinsic<"circ_stw">;
  99. //
  100. // BUILTIN_INFO_NONCONST(circ_sth,PTR_ftype_PTRSISISI,4)
  101. //
  102. def int_hexagon_circ_sth :
  103. Hexagon_mem_memsisisi_Intrinsic<"circ_sth">;
  104. //
  105. // BUILTIN_INFO_NONCONST(circ_sthhi,PTR_ftype_PTRSISISI,4)
  106. //
  107. def int_hexagon_circ_sthhi :
  108. Hexagon_mem_memsisisi_Intrinsic<"circ_sthhi">;
  109. //
  110. // BUILTIN_INFO_NONCONST(circ_stb,PTR_ftype_PTRSISISI,4)
  111. //
  112. def int_hexagon_circ_stb :
  113. Hexagon_mem_memsisisi_Intrinsic<"circ_stb">;
  114. def int_hexagon_prefetch :
  115. Hexagon_Intrinsic<"HEXAGON_prefetch", [], [llvm_ptr_ty], []>;
  116. def llvm_ptr32_ty : LLVMPointerType<llvm_i32_ty>;
  117. def llvm_ptr64_ty : LLVMPointerType<llvm_i64_ty>;
  118. // Mark locked loads as read/write to prevent any accidental reordering.
  119. def int_hexagon_L2_loadw_locked :
  120. Hexagon_Intrinsic<"HEXAGON_L2_loadw_locked", [llvm_i32_ty], [llvm_ptr32_ty],
  121. [IntrArgMemOnly, NoCapture<ArgIndex<0>>]>;
  122. def int_hexagon_L4_loadd_locked :
  123. Hexagon_Intrinsic<"HEXAGON_L4_loadd_locked", [llvm_i64_ty], [llvm_ptr64_ty],
  124. [IntrArgMemOnly, NoCapture<ArgIndex<0>>]>;
  125. def int_hexagon_S2_storew_locked :
  126. Hexagon_Intrinsic<"HEXAGON_S2_storew_locked", [llvm_i32_ty],
  127. [llvm_ptr32_ty, llvm_i32_ty], [IntrArgMemOnly, NoCapture<ArgIndex<0>>]>;
  128. def int_hexagon_S4_stored_locked :
  129. Hexagon_Intrinsic<"HEXAGON_S4_stored_locked", [llvm_i32_ty],
  130. [llvm_ptr64_ty, llvm_i64_ty], [IntrArgMemOnly, NoCapture<ArgIndex<0>>]>;
  131. def int_hexagon_vmemcpy : Hexagon_Intrinsic<"hexagon_vmemcpy",
  132. [], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
  133. [IntrArgMemOnly, NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>]>;
  134. def int_hexagon_vmemset : Hexagon_Intrinsic<"hexagon_vmemset",
  135. [], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty],
  136. [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>]>;
  137. multiclass Hexagon_custom_circ_ld_Intrinsic<LLVMType ElTy> {
  138. def NAME#_pci : Hexagon_NonGCC_Intrinsic<
  139. [ElTy, llvm_ptr_ty],
  140. [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
  141. [IntrArgMemOnly, NoCapture<ArgIndex<3>>]>;
  142. def NAME#_pcr : Hexagon_NonGCC_Intrinsic<
  143. [ElTy, llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty, llvm_ptr_ty],
  144. [IntrArgMemOnly, NoCapture<ArgIndex<2>>]>;
  145. }
  146. defm int_hexagon_L2_loadrub : Hexagon_custom_circ_ld_Intrinsic<llvm_i32_ty>;
  147. defm int_hexagon_L2_loadrb : Hexagon_custom_circ_ld_Intrinsic<llvm_i32_ty>;
  148. defm int_hexagon_L2_loadruh : Hexagon_custom_circ_ld_Intrinsic<llvm_i32_ty>;
  149. defm int_hexagon_L2_loadrh : Hexagon_custom_circ_ld_Intrinsic<llvm_i32_ty>;
  150. defm int_hexagon_L2_loadri : Hexagon_custom_circ_ld_Intrinsic<llvm_i32_ty>;
  151. defm int_hexagon_L2_loadrd : Hexagon_custom_circ_ld_Intrinsic<llvm_i64_ty>;
  152. multiclass Hexagon_custom_circ_st_Intrinsic<LLVMType ElTy> {
  153. def NAME#_pci : Hexagon_NonGCC_Intrinsic<
  154. [llvm_ptr_ty],
  155. [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty, ElTy, llvm_ptr_ty],
  156. [IntrArgMemOnly, NoCapture<ArgIndex<4>>]>;
  157. def NAME#_pcr : Hexagon_NonGCC_Intrinsic<
  158. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty, ElTy, llvm_ptr_ty],
  159. [IntrArgMemOnly, NoCapture<ArgIndex<3>>]>;
  160. }
  161. defm int_hexagon_S2_storerb : Hexagon_custom_circ_st_Intrinsic<llvm_i32_ty>;
  162. defm int_hexagon_S2_storerh : Hexagon_custom_circ_st_Intrinsic<llvm_i32_ty>;
  163. defm int_hexagon_S2_storerf : Hexagon_custom_circ_st_Intrinsic<llvm_i32_ty>;
  164. defm int_hexagon_S2_storeri : Hexagon_custom_circ_st_Intrinsic<llvm_i32_ty>;
  165. defm int_hexagon_S2_storerd : Hexagon_custom_circ_st_Intrinsic<llvm_i64_ty>;
  166. // The front-end emits the intrinsic call with only two arguments. The third
  167. // argument from the builtin is already used by front-end to write to memory
  168. // by generating a store.
  169. class Hexagon_custom_brev_ld_Intrinsic<LLVMType ElTy>
  170. : Hexagon_NonGCC_Intrinsic<
  171. [ElTy, llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty],
  172. [IntrReadMem]>;
  173. def int_hexagon_L2_loadrub_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i32_ty>;
  174. def int_hexagon_L2_loadrb_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i32_ty>;
  175. def int_hexagon_L2_loadruh_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i32_ty>;
  176. def int_hexagon_L2_loadrh_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i32_ty>;
  177. def int_hexagon_L2_loadri_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i32_ty>;
  178. def int_hexagon_L2_loadrd_pbr : Hexagon_custom_brev_ld_Intrinsic<llvm_i64_ty>;
  179. def int_hexagon_S2_storerb_pbr : Hexagon_mem_memsisi_Intrinsic<"brev_stb">;
  180. def int_hexagon_S2_storerh_pbr : Hexagon_mem_memsisi_Intrinsic<"brev_sth">;
  181. def int_hexagon_S2_storerf_pbr : Hexagon_mem_memsisi_Intrinsic<"brev_sthhi">;
  182. def int_hexagon_S2_storeri_pbr : Hexagon_mem_memsisi_Intrinsic<"brev_stw">;
  183. def int_hexagon_S2_storerd_pbr : Hexagon_mem_memdisi_Intrinsic<"brev_std">;
  184. // tag : V6_vrmpybub_rtt
  185. class Hexagon_v32i32_v16i32i64_rtt_Intrinsic<string GCCIntSuffix>
  186. : Hexagon_Intrinsic<GCCIntSuffix,
  187. [llvm_v32i32_ty], [llvm_v16i32_ty,llvm_i64_ty],
  188. [IntrNoMem]>;
  189. // tag : V6_vrmpybub_rtt_128B
  190. class Hexagon_v64i32_v32i32i64_rtt_Intrinsic<string GCCIntSuffix>
  191. : Hexagon_Intrinsic<GCCIntSuffix,
  192. [llvm_v64i32_ty], [llvm_v32i32_ty,llvm_i64_ty],
  193. [IntrNoMem]>;
  194. // tag : V6_vrmpybub_rtt_acc
  195. class Hexagon_v32i32_v32i32v16i32i64_rtt_Intrinsic<string GCCIntSuffix>
  196. : Hexagon_Intrinsic<GCCIntSuffix,
  197. [llvm_v32i32_ty], [llvm_v32i32_ty,llvm_v16i32_ty,llvm_i64_ty],
  198. [IntrNoMem]>;
  199. // tag : V6_vrmpybub_rtt_acc_128B
  200. class Hexagon_v64i32_v64i32v32i32i64_rtt_Intrinsic<string GCCIntSuffix>
  201. : Hexagon_Intrinsic<GCCIntSuffix,
  202. [llvm_v64i32_ty], [llvm_v64i32_ty,llvm_v32i32_ty,llvm_i64_ty],
  203. [IntrNoMem]>;
  204. def int_hexagon_V6_vrmpybub_rtt :
  205. Hexagon_v32i32_v16i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpybub_rtt">;
  206. def int_hexagon_V6_vrmpybub_rtt_128B :
  207. Hexagon_v64i32_v32i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpybub_rtt_128B">;
  208. def int_hexagon_V6_vrmpybub_rtt_acc :
  209. Hexagon_v32i32_v32i32v16i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpybub_rtt_acc">;
  210. def int_hexagon_V6_vrmpybub_rtt_acc_128B :
  211. Hexagon_v64i32_v64i32v32i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpybub_rtt_acc_128B">;
  212. def int_hexagon_V6_vrmpyub_rtt :
  213. Hexagon_v32i32_v16i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpyub_rtt">;
  214. def int_hexagon_V6_vrmpyub_rtt_128B :
  215. Hexagon_v64i32_v32i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpyub_rtt_128B">;
  216. def int_hexagon_V6_vrmpyub_rtt_acc :
  217. Hexagon_v32i32_v32i32v16i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpyub_rtt_acc">;
  218. def int_hexagon_V6_vrmpyub_rtt_acc_128B :
  219. Hexagon_v64i32_v64i32v32i32i64_rtt_Intrinsic<"HEXAGON_V6_vrmpyub_rtt_acc_128B">;
  220. // HVX Vector predicate casts.
  221. // These intrinsics do not emit (nor do they correspond to) any instructions,
  222. // they are no-ops.
  223. def int_hexagon_V6_pred_typecast :
  224. Hexagon_NonGCC_Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>;
  225. def int_hexagon_V6_pred_typecast_128B :
  226. Hexagon_NonGCC_Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>;
  227. // Masked vector stores
  228. //
  229. class Hexagon_custom_vms_Intrinsic
  230. : Hexagon_NonGCC_Intrinsic<
  231. [], [llvm_v64i1_ty,llvm_ptr_ty,llvm_v16i32_ty], [IntrWriteMem]>;
  232. class Hexagon_custom_vms_Intrinsic_128B
  233. : Hexagon_NonGCC_Intrinsic<
  234. [], [llvm_v128i1_ty,llvm_ptr_ty,llvm_v32i32_ty], [IntrWriteMem]>;
  235. def int_hexagon_V6_vmaskedstoreq: Hexagon_custom_vms_Intrinsic;
  236. def int_hexagon_V6_vmaskedstorenq: Hexagon_custom_vms_Intrinsic;
  237. def int_hexagon_V6_vmaskedstorentq: Hexagon_custom_vms_Intrinsic;
  238. def int_hexagon_V6_vmaskedstorentnq: Hexagon_custom_vms_Intrinsic;
  239. def int_hexagon_V6_vmaskedstoreq_128B: Hexagon_custom_vms_Intrinsic_128B;
  240. def int_hexagon_V6_vmaskedstorenq_128B: Hexagon_custom_vms_Intrinsic_128B;
  241. def int_hexagon_V6_vmaskedstorentq_128B: Hexagon_custom_vms_Intrinsic_128B;
  242. def int_hexagon_V6_vmaskedstorentnq_128B: Hexagon_custom_vms_Intrinsic_128B;
  243. include "llvm/IR/IntrinsicsHexagonDep.td"