numba-cuda 0.21.1__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. _numba_cuda_redirector.pth +4 -0
  2. _numba_cuda_redirector.py +89 -0
  3. numba_cuda/VERSION +1 -0
  4. numba_cuda/__init__.py +6 -0
  5. numba_cuda/_version.py +11 -0
  6. numba_cuda/numba/cuda/__init__.py +70 -0
  7. numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
  8. numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
  9. numba_cuda/numba/cuda/api.py +577 -0
  10. numba_cuda/numba/cuda/api_util.py +76 -0
  11. numba_cuda/numba/cuda/args.py +72 -0
  12. numba_cuda/numba/cuda/bf16.py +397 -0
  13. numba_cuda/numba/cuda/cache_hints.py +287 -0
  14. numba_cuda/numba/cuda/cext/__init__.py +2 -0
  15. numba_cuda/numba/cuda/cext/_devicearray.cp313-win_amd64.pyd +0 -0
  16. numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
  17. numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
  18. numba_cuda/numba/cuda/cext/_dispatcher.cp313-win_amd64.pyd +0 -0
  19. numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
  20. numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
  21. numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
  22. numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
  23. numba_cuda/numba/cuda/cext/_helperlib.cp313-win_amd64.pyd +0 -0
  24. numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
  25. numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
  26. numba_cuda/numba/cuda/cext/_typeconv.cp313-win_amd64.pyd +0 -0
  27. numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
  28. numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
  29. numba_cuda/numba/cuda/cext/_typeof.h +19 -0
  30. numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
  31. numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
  32. numba_cuda/numba/cuda/cext/mviewbuf.cp313-win_amd64.pyd +0 -0
  33. numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
  34. numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
  35. numba_cuda/numba/cuda/cg.py +67 -0
  36. numba_cuda/numba/cuda/cgutils.py +1294 -0
  37. numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
  38. numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
  39. numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
  40. numba_cuda/numba/cuda/codegen.py +541 -0
  41. numba_cuda/numba/cuda/compiler.py +1396 -0
  42. numba_cuda/numba/cuda/core/analysis.py +758 -0
  43. numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
  44. numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
  45. numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
  46. numba_cuda/numba/cuda/core/base.py +1332 -0
  47. numba_cuda/numba/cuda/core/boxing.py +1411 -0
  48. numba_cuda/numba/cuda/core/bytecode.py +728 -0
  49. numba_cuda/numba/cuda/core/byteflow.py +2346 -0
  50. numba_cuda/numba/cuda/core/caching.py +744 -0
  51. numba_cuda/numba/cuda/core/callconv.py +392 -0
  52. numba_cuda/numba/cuda/core/codegen.py +171 -0
  53. numba_cuda/numba/cuda/core/compiler.py +199 -0
  54. numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
  55. numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
  56. numba_cuda/numba/cuda/core/config.py +650 -0
  57. numba_cuda/numba/cuda/core/consts.py +124 -0
  58. numba_cuda/numba/cuda/core/controlflow.py +989 -0
  59. numba_cuda/numba/cuda/core/entrypoints.py +57 -0
  60. numba_cuda/numba/cuda/core/environment.py +66 -0
  61. numba_cuda/numba/cuda/core/errors.py +917 -0
  62. numba_cuda/numba/cuda/core/event.py +511 -0
  63. numba_cuda/numba/cuda/core/funcdesc.py +330 -0
  64. numba_cuda/numba/cuda/core/generators.py +387 -0
  65. numba_cuda/numba/cuda/core/imputils.py +509 -0
  66. numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
  67. numba_cuda/numba/cuda/core/interpreter.py +3617 -0
  68. numba_cuda/numba/cuda/core/ir.py +1812 -0
  69. numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
  70. numba_cuda/numba/cuda/core/optional.py +129 -0
  71. numba_cuda/numba/cuda/core/options.py +262 -0
  72. numba_cuda/numba/cuda/core/postproc.py +249 -0
  73. numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
  74. numba_cuda/numba/cuda/core/registry.py +46 -0
  75. numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
  76. numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
  77. numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
  78. numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
  79. numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
  80. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
  81. numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
  82. numba_cuda/numba/cuda/core/sigutils.py +68 -0
  83. numba_cuda/numba/cuda/core/ssa.py +498 -0
  84. numba_cuda/numba/cuda/core/targetconfig.py +330 -0
  85. numba_cuda/numba/cuda/core/tracing.py +231 -0
  86. numba_cuda/numba/cuda/core/transforms.py +956 -0
  87. numba_cuda/numba/cuda/core/typed_passes.py +867 -0
  88. numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
  89. numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
  90. numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
  91. numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
  92. numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
  93. numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
  94. numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
  95. numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
  96. numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
  97. numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
  98. numba_cuda/numba/cuda/cpython/iterators.py +167 -0
  99. numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
  100. numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
  101. numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
  102. numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
  103. numba_cuda/numba/cuda/cpython/slicing.py +322 -0
  104. numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
  105. numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
  106. numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
  107. numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
  108. numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
  109. numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
  110. numba_cuda/numba/cuda/cuda_paths.py +691 -0
  111. numba_cuda/numba/cuda/cudadecl.py +556 -0
  112. numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
  113. numba_cuda/numba/cuda/cudadrv/devicearray.py +951 -0
  114. numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
  115. numba_cuda/numba/cuda/cudadrv/driver.py +3222 -0
  116. numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
  117. numba_cuda/numba/cuda/cudadrv/dummyarray.py +558 -0
  118. numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
  119. numba_cuda/numba/cuda/cudadrv/error.py +48 -0
  120. numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
  121. numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
  122. numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
  123. numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
  124. numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
  125. numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
  126. numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
  127. numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
  128. numba_cuda/numba/cuda/cudaimpl.py +995 -0
  129. numba_cuda/numba/cuda/cudamath.py +149 -0
  130. numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
  131. numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
  132. numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
  133. numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
  134. numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
  135. numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
  136. numba_cuda/numba/cuda/datamodel/manager.py +11 -0
  137. numba_cuda/numba/cuda/datamodel/models.py +9 -0
  138. numba_cuda/numba/cuda/datamodel/packer.py +9 -0
  139. numba_cuda/numba/cuda/datamodel/registry.py +11 -0
  140. numba_cuda/numba/cuda/datamodel/testing.py +11 -0
  141. numba_cuda/numba/cuda/debuginfo.py +903 -0
  142. numba_cuda/numba/cuda/decorators.py +294 -0
  143. numba_cuda/numba/cuda/descriptor.py +35 -0
  144. numba_cuda/numba/cuda/device_init.py +158 -0
  145. numba_cuda/numba/cuda/deviceufunc.py +1021 -0
  146. numba_cuda/numba/cuda/dispatcher.py +2463 -0
  147. numba_cuda/numba/cuda/errors.py +72 -0
  148. numba_cuda/numba/cuda/extending.py +697 -0
  149. numba_cuda/numba/cuda/flags.py +178 -0
  150. numba_cuda/numba/cuda/fp16.py +357 -0
  151. numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
  152. numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
  153. numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
  154. numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
  155. numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
  156. numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
  157. numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
  158. numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
  159. numba_cuda/numba/cuda/initialize.py +24 -0
  160. numba_cuda/numba/cuda/intrinsic_wrapper.py +41 -0
  161. numba_cuda/numba/cuda/intrinsics.py +382 -0
  162. numba_cuda/numba/cuda/itanium_mangler.py +214 -0
  163. numba_cuda/numba/cuda/kernels/__init__.py +2 -0
  164. numba_cuda/numba/cuda/kernels/reduction.py +265 -0
  165. numba_cuda/numba/cuda/kernels/transpose.py +65 -0
  166. numba_cuda/numba/cuda/libdevice.py +3386 -0
  167. numba_cuda/numba/cuda/libdevicedecl.py +20 -0
  168. numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
  169. numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
  170. numba_cuda/numba/cuda/locks.py +19 -0
  171. numba_cuda/numba/cuda/lowering.py +1951 -0
  172. numba_cuda/numba/cuda/mathimpl.py +374 -0
  173. numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
  174. numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
  175. numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
  176. numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
  177. numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
  178. numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
  179. numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
  180. numba_cuda/numba/cuda/misc/appdirs.py +594 -0
  181. numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
  182. numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
  183. numba_cuda/numba/cuda/misc/dump_style.py +41 -0
  184. numba_cuda/numba/cuda/misc/findlib.py +75 -0
  185. numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
  186. numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
  187. numba_cuda/numba/cuda/misc/literal.py +28 -0
  188. numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
  189. numba_cuda/numba/cuda/misc/special.py +94 -0
  190. numba_cuda/numba/cuda/models.py +56 -0
  191. numba_cuda/numba/cuda/np/arraymath.py +5130 -0
  192. numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
  193. numba_cuda/numba/cuda/np/extensions.py +11 -0
  194. numba_cuda/numba/cuda/np/linalg.py +3087 -0
  195. numba_cuda/numba/cuda/np/math/__init__.py +0 -0
  196. numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
  197. numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
  198. numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
  199. numba_cuda/numba/cuda/np/npdatetime.py +969 -0
  200. numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
  201. numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
  202. numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
  203. numba_cuda/numba/cuda/np/numpy_support.py +798 -0
  204. numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
  205. numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
  206. numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
  207. numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
  208. numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
  209. numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
  210. numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
  211. numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
  212. numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
  213. numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
  214. numba_cuda/numba/cuda/nvvmutils.py +254 -0
  215. numba_cuda/numba/cuda/printimpl.py +126 -0
  216. numba_cuda/numba/cuda/random.py +308 -0
  217. numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
  218. numba_cuda/numba/cuda/serialize.py +267 -0
  219. numba_cuda/numba/cuda/simulator/__init__.py +63 -0
  220. numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
  221. numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
  222. numba_cuda/numba/cuda/simulator/api.py +179 -0
  223. numba_cuda/numba/cuda/simulator/bf16.py +4 -0
  224. numba_cuda/numba/cuda/simulator/compiler.py +38 -0
  225. numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
  226. numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
  227. numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
  228. numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
  229. numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
  230. numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
  231. numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
  232. numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
  233. numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
  234. numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
  235. numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
  236. numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
  237. numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
  238. numba_cuda/numba/cuda/simulator/kernel.py +320 -0
  239. numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
  240. numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
  241. numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
  242. numba_cuda/numba/cuda/simulator/reduction.py +19 -0
  243. numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
  244. numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
  245. numba_cuda/numba/cuda/simulator_init.py +18 -0
  246. numba_cuda/numba/cuda/stubs.py +635 -0
  247. numba_cuda/numba/cuda/target.py +505 -0
  248. numba_cuda/numba/cuda/testing.py +347 -0
  249. numba_cuda/numba/cuda/tests/__init__.py +62 -0
  250. numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
  251. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
  252. numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
  253. numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
  254. numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
  255. numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
  256. numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
  257. numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
  258. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
  259. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
  260. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
  261. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
  262. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
  263. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +187 -0
  264. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
  265. numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
  266. numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
  267. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +198 -0
  268. numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
  269. numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
  270. numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
  271. numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
  272. numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
  273. numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
  274. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
  275. numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
  276. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
  277. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
  278. numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
  279. numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
  280. numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
  281. numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
  282. numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
  283. numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
  284. numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
  285. numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
  286. numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
  287. numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
  288. numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
  289. numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
  290. numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
  291. numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
  292. numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
  293. numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
  294. numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
  295. numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
  296. numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
  297. numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
  298. numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
  299. numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
  300. numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
  301. numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
  302. numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
  303. numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
  304. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
  305. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
  306. numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
  307. numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
  308. numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
  309. numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
  310. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
  311. numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
  312. numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
  313. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
  314. numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
  315. numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
  316. numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
  317. numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
  318. numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
  319. numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
  320. numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
  321. numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
  322. numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
  323. numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
  324. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +889 -0
  325. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
  326. numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
  327. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
  328. numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
  329. numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
  330. numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
  331. numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
  332. numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
  333. numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
  334. numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
  335. numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
  336. numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
  337. numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
  338. numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
  339. numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
  340. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
  341. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
  342. numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
  343. numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
  344. numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
  345. numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
  346. numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
  347. numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
  348. numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
  349. numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
  350. numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
  351. numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
  352. numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
  353. numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
  354. numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
  355. numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
  356. numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
  357. numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
  358. numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
  359. numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
  360. numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
  361. numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
  362. numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
  363. numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
  364. numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
  365. numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
  366. numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
  367. numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
  368. numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
  369. numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
  370. numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
  371. numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
  372. numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
  373. numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
  374. numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
  375. numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
  376. numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
  377. numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
  378. numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
  379. numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
  380. numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
  381. numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
  382. numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
  383. numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
  384. numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
  385. numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
  386. numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
  387. numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
  388. numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
  389. numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
  390. numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
  391. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
  392. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
  393. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
  394. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
  395. numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
  396. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +331 -0
  397. numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
  398. numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
  399. numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
  400. numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
  401. numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
  402. numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
  403. numba_cuda/numba/cuda/tests/data/error.cu +12 -0
  404. numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
  405. numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
  406. numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
  407. numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
  408. numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
  409. numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
  410. numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
  411. numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
  412. numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
  413. numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
  414. numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
  415. numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
  416. numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
  417. numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
  418. numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
  419. numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
  420. numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
  421. numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
  422. numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
  423. numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
  424. numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
  425. numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
  426. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +391 -0
  427. numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
  428. numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
  429. numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
  430. numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
  431. numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
  432. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
  433. numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
  434. numba_cuda/numba/cuda/tests/support.py +900 -0
  435. numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
  436. numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
  437. numba_cuda/numba/cuda/typeconv/rules.py +63 -0
  438. numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
  439. numba_cuda/numba/cuda/types/__init__.py +233 -0
  440. numba_cuda/numba/cuda/types/__init__.pyi +167 -0
  441. numba_cuda/numba/cuda/types/abstract.py +9 -0
  442. numba_cuda/numba/cuda/types/common.py +9 -0
  443. numba_cuda/numba/cuda/types/containers.py +9 -0
  444. numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
  445. numba_cuda/numba/cuda/types/cuda_common.py +110 -0
  446. numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
  447. numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
  448. numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
  449. numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
  450. numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
  451. numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
  452. numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
  453. numba_cuda/numba/cuda/types/ext_types.py +101 -0
  454. numba_cuda/numba/cuda/types/function_type.py +11 -0
  455. numba_cuda/numba/cuda/types/functions.py +9 -0
  456. numba_cuda/numba/cuda/types/iterators.py +9 -0
  457. numba_cuda/numba/cuda/types/misc.py +9 -0
  458. numba_cuda/numba/cuda/types/npytypes.py +9 -0
  459. numba_cuda/numba/cuda/types/scalars.py +9 -0
  460. numba_cuda/numba/cuda/typing/__init__.py +19 -0
  461. numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
  462. numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
  463. numba_cuda/numba/cuda/typing/bufproto.py +70 -0
  464. numba_cuda/numba/cuda/typing/builtins.py +1209 -0
  465. numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
  466. numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
  467. numba_cuda/numba/cuda/typing/collections.py +138 -0
  468. numba_cuda/numba/cuda/typing/context.py +782 -0
  469. numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
  470. numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
  471. numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
  472. numba_cuda/numba/cuda/typing/listdecl.py +147 -0
  473. numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
  474. numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
  475. numba_cuda/numba/cuda/typing/npydecl.py +749 -0
  476. numba_cuda/numba/cuda/typing/setdecl.py +115 -0
  477. numba_cuda/numba/cuda/typing/templates.py +1446 -0
  478. numba_cuda/numba/cuda/typing/typeof.py +301 -0
  479. numba_cuda/numba/cuda/ufuncs.py +746 -0
  480. numba_cuda/numba/cuda/utils.py +724 -0
  481. numba_cuda/numba/cuda/vector_types.py +214 -0
  482. numba_cuda/numba/cuda/vectorizers.py +260 -0
  483. numba_cuda-0.21.1.dist-info/METADATA +109 -0
  484. numba_cuda-0.21.1.dist-info/RECORD +488 -0
  485. numba_cuda-0.21.1.dist-info/WHEEL +5 -0
  486. numba_cuda-0.21.1.dist-info/licenses/LICENSE +26 -0
  487. numba_cuda-0.21.1.dist-info/licenses/LICENSE.numba +24 -0
  488. numba_cuda-0.21.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,903 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ import abc
5
+ import os
6
+ from contextlib import contextmanager
7
+
8
+ import llvmlite
9
+ from llvmlite import ir
10
+ from numba.cuda import types
11
+ from numba.cuda.core import config
12
+ from numba.cuda import cgutils
13
+ from numba.cuda.datamodel.models import ComplexModel, UnionModel, UniTupleModel
14
+ from numba.cuda.types.ext_types import GridGroup
15
+ from cuda.bindings import runtime
16
+
17
+
18
+ # Check if CUDA Toolkit and llvmlite support polymorphic debug info
19
+ def _get_llvmlite_version():
20
+ """Get llvmlite version as tuple (major, minor)."""
21
+ try:
22
+ version_str = llvmlite.__version__
23
+ # Parse version string like "0.46.0" or "0.46.0dev"
24
+ parts = version_str.split(".")
25
+ if len(parts) < 2:
26
+ return (0, 0)
27
+ major = int(parts[0])
28
+ minor = int(parts[1])
29
+ return (major, minor)
30
+ except (IndexError, AttributeError, ValueError):
31
+ return (0, 0)
32
+
33
+
34
+ def _check_polymorphic_debug_info_support():
35
+ """Check if CTK and llvmlite support polymorphic debug info.
36
+
37
+ Returns:
38
+ tuple: (supported: bool, use_typed_const: bool)
39
+ - supported: Whether feature is supported at all
40
+ - use_typed_const: True for typed constant,
41
+ False for node reference
42
+ """
43
+ # runtime.getLocalRuntimeVersion() returns (cudaError_t, version_int)
44
+ # Example: 13010 = CTK 13.1, 13020 = CTK 13.2
45
+ _, ctk_version_number = runtime.getLocalRuntimeVersion()
46
+ ctk_major = ctk_version_number // 1000
47
+ ctk_minor = (ctk_version_number % 1000) // 10
48
+ ctk_version = (ctk_major, ctk_minor)
49
+
50
+ llvmlite_version = _get_llvmlite_version()
51
+
52
+ # Support not available with CTK 13.1 or older
53
+ if ctk_version <= (13, 1):
54
+ return (False, False)
55
+
56
+ # llvmlite > 0.45: use typed constant
57
+ # llvmlite <= 0.45: use node reference
58
+ use_typed_const = llvmlite_version > (0, 45)
59
+ return (True, use_typed_const)
60
+
61
+
62
+ # Check support and determine mode
63
+ (DEBUG_POLY_SUPPORTED, DEBUG_POLY_USE_TYPED_CONST) = (
64
+ _check_polymorphic_debug_info_support()
65
+ )
66
+
67
+ # Set config based on polymorphic debug info support
68
+ if not hasattr(config, "CUDA_DEBUG_POLY"):
69
+ config.CUDA_DEBUG_POLY = DEBUG_POLY_SUPPORTED
70
+ if not hasattr(config, "CUDA_DEBUG_POLY_USE_TYPED_CONST"):
71
+ config.CUDA_DEBUG_POLY_USE_TYPED_CONST = DEBUG_POLY_USE_TYPED_CONST
72
+
73
+
74
+ @contextmanager
75
+ def suspend_emission(builder):
76
+ """Suspends the emission of debug_metadata for the duration of the context
77
+ managed block."""
78
+ ref = builder.debug_metadata
79
+ builder.debug_metadata = None
80
+ try:
81
+ yield
82
+ finally:
83
+ builder.debug_metadata = ref
84
+
85
+
86
+ class AbstractDIBuilder(metaclass=abc.ABCMeta):
87
+ @abc.abstractmethod
88
+ def mark_variable(
89
+ self,
90
+ builder,
91
+ allocavalue,
92
+ name,
93
+ lltype,
94
+ size,
95
+ line,
96
+ datamodel=None,
97
+ argidx=None,
98
+ ):
99
+ """Emit debug info for the variable."""
100
+ pass
101
+
102
+ @abc.abstractmethod
103
+ def mark_location(self, builder, line):
104
+ """Emit source location information to the given IRBuilder."""
105
+ pass
106
+
107
+ @abc.abstractmethod
108
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
109
+ """Emit source location information for the given function."""
110
+ pass
111
+
112
+ @abc.abstractmethod
113
+ def initialize(self):
114
+ """Initialize the debug info. An opportunity for the debuginfo to
115
+ prepare any necessary data structures.
116
+ """
117
+
118
+ @abc.abstractmethod
119
+ def finalize(self):
120
+ """Finalize the debuginfo by emitting all necessary metadata."""
121
+ pass
122
+
123
+
124
+ class DummyDIBuilder(AbstractDIBuilder):
125
+ def __init__(self, module, filepath, cgctx, directives_only):
126
+ pass
127
+
128
+ def mark_variable(
129
+ self,
130
+ builder,
131
+ allocavalue,
132
+ name,
133
+ lltype,
134
+ size,
135
+ line,
136
+ datamodel=None,
137
+ argidx=None,
138
+ ):
139
+ pass
140
+
141
+ def mark_location(self, builder, line):
142
+ pass
143
+
144
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
145
+ pass
146
+
147
+ def initialize(self):
148
+ pass
149
+
150
+ def finalize(self):
151
+ pass
152
+
153
+
154
+ _BYTE_SIZE = 8
155
+
156
+
157
+ class DIBuilder(AbstractDIBuilder):
158
+ DWARF_VERSION = 4
159
+ DEBUG_INFO_VERSION = 3
160
+ DBG_CU_NAME = "llvm.dbg.cu"
161
+ _DEBUG = False
162
+
163
+ def __init__(self, module, filepath, cgctx, directives_only):
164
+ self.module = module
165
+ self.filepath = os.path.abspath(filepath)
166
+ self.difile = self._di_file()
167
+ self.subprograms = []
168
+ self.cgctx = cgctx
169
+
170
+ if directives_only:
171
+ self.emission_kind = "DebugDirectivesOnly"
172
+ else:
173
+ self.emission_kind = "FullDebug"
174
+
175
+ self.initialize()
176
+
177
+ def initialize(self):
178
+ # Create the compile unit now because it is referenced when
179
+ # constructing subprograms
180
+ self.dicompileunit = self._di_compile_unit()
181
+
182
+ def _var_type(self, lltype, size, datamodel=None):
183
+ if self._DEBUG:
184
+ print(
185
+ "-->",
186
+ lltype,
187
+ size,
188
+ datamodel,
189
+ getattr(datamodel, "fe_type", "NO FE TYPE"),
190
+ )
191
+ m = self.module
192
+ bitsize = _BYTE_SIZE * size
193
+
194
+ int_type = (ir.IntType,)
195
+ real_type = ir.FloatType, ir.DoubleType
196
+ # For simple numeric types, choose the closest encoding.
197
+ # We treat all integers as unsigned when there's no known datamodel.
198
+ if isinstance(lltype, int_type + real_type):
199
+ if datamodel is None:
200
+ # This is probably something like an `i8*` member of a struct
201
+ name = str(lltype)
202
+ if isinstance(lltype, int_type):
203
+ ditok = "DW_ATE_unsigned"
204
+ else:
205
+ ditok = "DW_ATE_float"
206
+ else:
207
+ # This is probably a known int/float scalar type
208
+ name = str(datamodel.fe_type)
209
+ if isinstance(datamodel.fe_type, types.Integer):
210
+ if datamodel.fe_type.signed:
211
+ ditok = "DW_ATE_signed"
212
+ else:
213
+ ditok = "DW_ATE_unsigned"
214
+ else:
215
+ ditok = "DW_ATE_float"
216
+ mdtype = m.add_debug_info(
217
+ "DIBasicType",
218
+ {
219
+ "name": name,
220
+ "size": bitsize,
221
+ "encoding": ir.DIToken(ditok),
222
+ },
223
+ )
224
+ elif isinstance(datamodel, ComplexModel):
225
+ # TODO: Is there a better way of determining "this is a complex
226
+ # number"?
227
+ #
228
+ # NOTE: Commented below is the way to generate the metadata for a
229
+ # C99 complex type that's directly supported by DWARF. Numba however
230
+ # generates a struct with real/imag cf. CPython to give a more
231
+ # pythonic feel to inspection.
232
+ #
233
+ # mdtype = m.add_debug_info('DIBasicType', {
234
+ # 'name': f"{datamodel.fe_type} ({str(lltype)})",
235
+ # 'size': bitsize,
236
+ # 'encoding': ir.DIToken('DW_ATE_complex_float'),
237
+ # })
238
+ meta = []
239
+ offset = 0
240
+ for ix, name in enumerate(("real", "imag")):
241
+ component = lltype.elements[ix]
242
+ component_size = self.cgctx.get_abi_sizeof(component)
243
+ component_basetype = m.add_debug_info(
244
+ "DIBasicType",
245
+ {
246
+ "name": str(component),
247
+ "size": _BYTE_SIZE * component_size, # bits
248
+ "encoding": ir.DIToken("DW_ATE_float"),
249
+ },
250
+ )
251
+ derived_type = m.add_debug_info(
252
+ "DIDerivedType",
253
+ {
254
+ "tag": ir.DIToken("DW_TAG_member"),
255
+ "name": name,
256
+ "baseType": component_basetype,
257
+ "size": _BYTE_SIZE
258
+ * component_size, # DW_TAG_member size is in bits
259
+ "offset": offset,
260
+ },
261
+ )
262
+ meta.append(derived_type)
263
+ offset += _BYTE_SIZE * component_size # offset is in bits
264
+ mdtype = m.add_debug_info(
265
+ "DICompositeType",
266
+ {
267
+ "tag": ir.DIToken("DW_TAG_structure_type"),
268
+ "name": f"{datamodel.fe_type} ({str(lltype)})",
269
+ "identifier": str(lltype),
270
+ "elements": m.add_metadata(meta),
271
+ "size": offset,
272
+ },
273
+ is_distinct=True,
274
+ )
275
+ elif isinstance(datamodel, UniTupleModel):
276
+ element = lltype.element
277
+ el_size = self.cgctx.get_abi_sizeof(element)
278
+ basetype = self._var_type(element, el_size)
279
+ name = f"{datamodel.fe_type} ({str(lltype)})"
280
+ count = size // el_size
281
+ mdrange = m.add_debug_info(
282
+ "DISubrange",
283
+ {
284
+ "count": count,
285
+ },
286
+ )
287
+ mdtype = m.add_debug_info(
288
+ "DICompositeType",
289
+ {
290
+ "tag": ir.DIToken("DW_TAG_array_type"),
291
+ "baseType": basetype,
292
+ "name": name,
293
+ "size": bitsize,
294
+ "identifier": str(lltype),
295
+ "elements": m.add_metadata([mdrange]),
296
+ },
297
+ )
298
+ elif isinstance(lltype, ir.PointerType):
299
+ model = getattr(datamodel, "_pointee_model", None)
300
+ basetype = self._var_type(
301
+ lltype.pointee, self.cgctx.get_abi_sizeof(lltype.pointee), model
302
+ )
303
+ mdtype = m.add_debug_info(
304
+ "DIDerivedType",
305
+ {
306
+ "tag": ir.DIToken("DW_TAG_pointer_type"),
307
+ "baseType": basetype,
308
+ "size": _BYTE_SIZE * self.cgctx.get_abi_sizeof(lltype),
309
+ },
310
+ )
311
+ elif isinstance(lltype, ir.LiteralStructType):
312
+ # Struct type
313
+ meta = []
314
+ offset = 0
315
+ if datamodel is None or not datamodel.inner_models():
316
+ name = f"Anonymous struct ({str(lltype)})"
317
+ for field_id, element in enumerate(lltype.elements):
318
+ size = self.cgctx.get_abi_sizeof(element)
319
+ basetype = self._var_type(element, size)
320
+ derived_type = m.add_debug_info(
321
+ "DIDerivedType",
322
+ {
323
+ "tag": ir.DIToken("DW_TAG_member"),
324
+ "name": f"<field {field_id}>",
325
+ "baseType": basetype,
326
+ "size": _BYTE_SIZE
327
+ * size, # DW_TAG_member size is in bits
328
+ "offset": offset,
329
+ },
330
+ )
331
+ meta.append(derived_type)
332
+ offset += _BYTE_SIZE * size # offset is in bits
333
+ else:
334
+ name = f"{datamodel.fe_type} ({str(lltype)})"
335
+ for element, field, model in zip(
336
+ lltype.elements, datamodel._fields, datamodel.inner_models()
337
+ ):
338
+ size = self.cgctx.get_abi_sizeof(element)
339
+ basetype = self._var_type(element, size, datamodel=model)
340
+ derived_type = m.add_debug_info(
341
+ "DIDerivedType",
342
+ {
343
+ "tag": ir.DIToken("DW_TAG_member"),
344
+ "name": field,
345
+ "baseType": basetype,
346
+ "size": _BYTE_SIZE
347
+ * size, # DW_TAG_member size is in bits
348
+ "offset": offset,
349
+ },
350
+ )
351
+ meta.append(derived_type)
352
+ offset += _BYTE_SIZE * size # offset is in bits
353
+
354
+ mdtype = m.add_debug_info(
355
+ "DICompositeType",
356
+ {
357
+ "tag": ir.DIToken("DW_TAG_structure_type"),
358
+ "name": name,
359
+ "identifier": str(lltype),
360
+ "elements": m.add_metadata(meta),
361
+ "size": offset,
362
+ },
363
+ is_distinct=True,
364
+ )
365
+ elif isinstance(lltype, ir.ArrayType):
366
+ element = lltype.element
367
+ el_size = self.cgctx.get_abi_sizeof(element)
368
+ basetype = self._var_type(element, el_size)
369
+ count = size // el_size
370
+ mdrange = m.add_debug_info(
371
+ "DISubrange",
372
+ {
373
+ "count": count,
374
+ },
375
+ )
376
+ mdtype = m.add_debug_info(
377
+ "DICompositeType",
378
+ {
379
+ "tag": ir.DIToken("DW_TAG_array_type"),
380
+ "baseType": basetype,
381
+ "name": str(lltype),
382
+ "size": bitsize,
383
+ "identifier": str(lltype),
384
+ "elements": m.add_metadata([mdrange]),
385
+ },
386
+ )
387
+ else:
388
+ # For all other types, describe it as sequence of bytes
389
+ count = size
390
+ mdrange = m.add_debug_info(
391
+ "DISubrange",
392
+ {
393
+ "count": count,
394
+ },
395
+ )
396
+ mdbase = m.add_debug_info(
397
+ "DIBasicType",
398
+ {
399
+ "name": "byte",
400
+ "size": _BYTE_SIZE,
401
+ "encoding": ir.DIToken("DW_ATE_unsigned_char"),
402
+ },
403
+ )
404
+ mdtype = m.add_debug_info(
405
+ "DICompositeType",
406
+ {
407
+ "tag": ir.DIToken("DW_TAG_array_type"),
408
+ "baseType": mdbase,
409
+ "name": str(lltype),
410
+ "size": bitsize,
411
+ "identifier": str(lltype),
412
+ "elements": m.add_metadata([mdrange]),
413
+ },
414
+ )
415
+
416
+ return mdtype
417
+
418
+ def mark_variable(
419
+ self,
420
+ builder,
421
+ allocavalue,
422
+ name,
423
+ lltype,
424
+ size,
425
+ line,
426
+ datamodel=None,
427
+ argidx=None,
428
+ ):
429
+ arg_index = 0 if argidx is None else argidx
430
+ m = self.module
431
+ fnty = ir.FunctionType(ir.VoidType(), [ir.MetaDataType()] * 3)
432
+ decl = cgutils.get_or_insert_function(m, fnty, "llvm.dbg.declare")
433
+
434
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
435
+ name = name.replace(".", "$") # for gdb to work correctly
436
+ mdlocalvar = m.add_debug_info(
437
+ "DILocalVariable",
438
+ {
439
+ "name": name,
440
+ "arg": arg_index,
441
+ "scope": self.subprograms[-1],
442
+ "file": self.difile,
443
+ "line": line,
444
+ "type": mdtype,
445
+ },
446
+ )
447
+ mdexpr = m.add_debug_info("DIExpression", {})
448
+
449
+ return builder.call(decl, [allocavalue, mdlocalvar, mdexpr])
450
+
451
+ def mark_location(self, builder, line):
452
+ builder.debug_metadata = self._add_location(line)
453
+
454
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
455
+ name = qualname
456
+ argmap = dict(zip(argnames, argtypes))
457
+ di_subp = self._add_subprogram(
458
+ name=name,
459
+ linkagename=function.name,
460
+ line=line,
461
+ function=function,
462
+ argmap=argmap,
463
+ )
464
+ function.set_metadata("dbg", di_subp)
465
+
466
+ def finalize(self):
467
+ dbgcu = cgutils.get_or_insert_named_metadata(
468
+ self.module, self.DBG_CU_NAME
469
+ )
470
+ dbgcu.add(self.dicompileunit)
471
+ self._set_module_flags()
472
+
473
+ #
474
+ # Internal APIs
475
+ #
476
+
477
+ def _set_module_flags(self):
478
+ """Set the module flags metadata"""
479
+ module = self.module
480
+ mflags = cgutils.get_or_insert_named_metadata(
481
+ module, "llvm.module.flags"
482
+ )
483
+ # Set *require* behavior to warning
484
+ # See http://llvm.org/docs/LangRef.html#module-flags-metadata
485
+ require_warning_behavior = self._const_int(2)
486
+ if self.DWARF_VERSION is not None:
487
+ dwarf_version = module.add_metadata(
488
+ [
489
+ require_warning_behavior,
490
+ "Dwarf Version",
491
+ self._const_int(self.DWARF_VERSION),
492
+ ]
493
+ )
494
+ if dwarf_version not in mflags.operands:
495
+ mflags.add(dwarf_version)
496
+ debuginfo_version = module.add_metadata(
497
+ [
498
+ require_warning_behavior,
499
+ "Debug Info Version",
500
+ self._const_int(self.DEBUG_INFO_VERSION),
501
+ ]
502
+ )
503
+ if debuginfo_version not in mflags.operands:
504
+ mflags.add(debuginfo_version)
505
+
506
+ def _add_subprogram(self, name, linkagename, line, function, argmap):
507
+ """Emit subprogram metadata"""
508
+ subp = self._di_subprogram(name, linkagename, line, function, argmap)
509
+ self.subprograms.append(subp)
510
+ return subp
511
+
512
+ def _add_location(self, line):
513
+ """Emit location metatdaa"""
514
+ loc = self._di_location(line)
515
+ return loc
516
+
517
+ @classmethod
518
+ def _const_int(cls, num, bits=32):
519
+ """Util to create constant int in metadata"""
520
+ return ir.IntType(bits)(num)
521
+
522
+ @classmethod
523
+ def _const_bool(cls, boolean):
524
+ """Util to create constant boolean in metadata"""
525
+ return ir.IntType(1)(boolean)
526
+
527
+ #
528
+ # Helpers to emit the metadata nodes
529
+ #
530
+
531
+ def _di_file(self):
532
+ return self.module.add_debug_info(
533
+ "DIFile",
534
+ {
535
+ "directory": os.path.dirname(self.filepath),
536
+ "filename": os.path.basename(self.filepath),
537
+ },
538
+ )
539
+
540
+ def _di_compile_unit(self):
541
+ return self.module.add_debug_info(
542
+ "DICompileUnit",
543
+ {
544
+ "language": ir.DIToken("DW_LANG_C_plus_plus"),
545
+ "file": self.difile,
546
+ # Numba has to pretend to be clang to ensure the prologue is skipped
547
+ # correctly in gdb. See:
548
+ # https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/amd64-tdep.c;h=e563d369d8cb3eb3c2f732c2fa850ec70ba8d63b;hb=a4b0231e179607e47b1cdf1fe15c5dc25e482fad#l2521
549
+ # Note the "producer_is_llvm" call to specialise the prologue
550
+ # handling, this is defined here:
551
+ # https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/producer.c;h=cdfd80d904c09394febd18749bb90359b2d128cc;hb=a4b0231e179607e47b1cdf1fe15c5dc25e482fad#l124
552
+ # and to get a match for this condition the 'producer' must start
553
+ # with "clang ", hence the following...
554
+ "producer": "clang (Numba)",
555
+ "runtimeVersion": 0,
556
+ "isOptimized": config.OPT != 0,
557
+ "emissionKind": ir.DIToken(self.emission_kind),
558
+ },
559
+ is_distinct=True,
560
+ )
561
+
562
+ def _di_subroutine_type(self, line, function, argmap):
563
+ # The function call conv needs encoding.
564
+ llfunc = function
565
+ md = []
566
+
567
+ for idx, llarg in enumerate(llfunc.args):
568
+ if not llarg.name.startswith("arg."):
569
+ name = llarg.name.replace(".", "$") # for gdb to work correctly
570
+ lltype = llarg.type
571
+ size = self.cgctx.get_abi_sizeof(lltype)
572
+ mdtype = self._var_type(lltype, size, datamodel=None)
573
+ md.append(mdtype)
574
+
575
+ for idx, (name, nbtype) in enumerate(argmap.items()):
576
+ name = name.replace(".", "$") # for gdb to work correctly
577
+ datamodel = self.cgctx.data_model_manager[nbtype]
578
+ lltype = self.cgctx.get_value_type(nbtype)
579
+ size = self.cgctx.get_abi_sizeof(lltype)
580
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
581
+ md.append(mdtype)
582
+
583
+ return self.module.add_debug_info(
584
+ "DISubroutineType",
585
+ {
586
+ "types": self.module.add_metadata(md),
587
+ },
588
+ )
589
+
590
+ def _di_subprogram(self, name, linkagename, line, function, argmap):
591
+ return self.module.add_debug_info(
592
+ "DISubprogram",
593
+ {
594
+ "name": name,
595
+ "linkageName": linkagename,
596
+ "scope": self.difile,
597
+ "file": self.difile,
598
+ "line": line,
599
+ "type": self._di_subroutine_type(line, function, argmap),
600
+ "isLocal": False,
601
+ "isDefinition": True,
602
+ "scopeLine": line,
603
+ "isOptimized": config.OPT != 0,
604
+ "unit": self.dicompileunit,
605
+ },
606
+ is_distinct=True,
607
+ )
608
+
609
+ def _di_location(self, line):
610
+ return self.module.add_debug_info(
611
+ "DILocation",
612
+ {
613
+ "line": line,
614
+ "column": 1,
615
+ "scope": self.subprograms[-1],
616
+ },
617
+ )
618
+
619
+
620
+ class CUDADIBuilder(DIBuilder):
621
+ def __init__(self, module, filepath, cgctx, directives_only):
622
+ super().__init__(module, filepath, cgctx, directives_only)
623
+ # Cache for local variable metadata type and line deduplication
624
+ self._vartypelinemap = {}
625
+
626
+ def _var_type(self, lltype, size, datamodel=None):
627
+ is_bool = False
628
+ is_int_literal = False
629
+ is_grid_group = False
630
+ m = self.module
631
+
632
+ if isinstance(lltype, ir.IntType):
633
+ if datamodel is None:
634
+ if size == 1:
635
+ name = str(lltype)
636
+ is_bool = True
637
+ else:
638
+ name = str(datamodel.fe_type)
639
+ if isinstance(datamodel.fe_type, types.Boolean):
640
+ is_bool = True
641
+ if isinstance(datamodel.fe_type, types.BooleanLiteral):
642
+ name = "bool"
643
+ elif isinstance(datamodel.fe_type, types.Integer):
644
+ if isinstance(datamodel.fe_type, types.IntegerLiteral):
645
+ name = f"int{_BYTE_SIZE * size}"
646
+ is_int_literal = True
647
+ elif isinstance(datamodel.fe_type, GridGroup):
648
+ is_grid_group = True
649
+
650
+ if is_bool or is_int_literal or is_grid_group:
651
+ bitsize = _BYTE_SIZE * size
652
+ # Boolean type workaround until upstream Numba is fixed
653
+ if is_bool:
654
+ ditok = "DW_ATE_boolean"
655
+ elif is_int_literal:
656
+ ditok = "DW_ATE_signed"
657
+ # GridGroup type should use numba.cuda implementation
658
+ elif is_grid_group:
659
+ ditok = "DW_ATE_unsigned"
660
+
661
+ return m.add_debug_info(
662
+ "DIBasicType",
663
+ {
664
+ "name": name,
665
+ "size": bitsize,
666
+ "encoding": ir.DIToken(ditok),
667
+ },
668
+ )
669
+
670
+ if isinstance(datamodel, UnionModel):
671
+ # UnionModel is handled here to represent polymorphic types
672
+ meta = []
673
+ maxwidth = 0
674
+ for field, model in zip(
675
+ datamodel._fields, datamodel.inner_models()
676
+ ):
677
+ # Ignore the "tag" field, focus on the "payload" field which
678
+ # contains the data types in memory
679
+ if field == "payload":
680
+ # Store metadata dictionaries to create members later
681
+ member_metadata_dicts = []
682
+
683
+ for index, mod in enumerate(model.inner_models()):
684
+ dtype = mod.get_value_type()
685
+ membersize = self.cgctx.get_abi_sizeof(dtype)
686
+ basetype = self._var_type(
687
+ dtype, membersize, datamodel=mod
688
+ )
689
+ if isinstance(mod.fe_type, types.Literal):
690
+ typename = str(mod.fe_type.literal_type)
691
+ else:
692
+ typename = str(mod.fe_type)
693
+ # Use a prefix "_" on type names as field names
694
+ membername = "_" + typename
695
+ memberwidth = _BYTE_SIZE * membersize
696
+ # Build the metadata dictionary
697
+ metadata_dict = {
698
+ "tag": ir.DIToken("DW_TAG_member"),
699
+ "name": membername,
700
+ "baseType": basetype,
701
+ # DW_TAG_member size is in bits
702
+ "size": memberwidth,
703
+ }
704
+ if config.CUDA_DEBUG_POLY:
705
+ # Polymorphic debug info with DW_TAG_variant
706
+ # extraData depends on llvmlite version
707
+ if config.CUDA_DEBUG_POLY_USE_TYPED_CONST:
708
+ metadata_dict["extraData"] = ir.IntType(8)(
709
+ index
710
+ )
711
+ else:
712
+ # Use metadata node reference
713
+ metadata_dict["extraData"] = m.add_metadata(
714
+ [ir.IntType(8)(index)]
715
+ )
716
+ # Add offset to each variant member
717
+ # Offset equals the element's own width
718
+ metadata_dict["offset"] = memberwidth
719
+ member_metadata_dicts.append(metadata_dict)
720
+ if memberwidth > maxwidth:
721
+ maxwidth = memberwidth
722
+
723
+ # Create the member DIDerivedTypes
724
+ for metadata_dict in member_metadata_dicts:
725
+ derived_type = m.add_debug_info(
726
+ "DIDerivedType", metadata_dict
727
+ )
728
+ meta.append(derived_type)
729
+
730
+ if config.CUDA_DEBUG_POLY:
731
+ # Polymorphic variable debug info generation
732
+ wrapper_struct_size = 2 * maxwidth
733
+ # Generate unique discriminator name based on composite type
734
+ variant_elements_metadata = m.add_metadata(meta)
735
+ discriminator_unique_id = str(id(variant_elements_metadata))
736
+ discriminator_name = f"discriminator-{discriminator_unique_id}"
737
+ discriminator = m.add_debug_info(
738
+ "DIDerivedType",
739
+ {
740
+ "tag": ir.DIToken("DW_TAG_member"),
741
+ "name": discriminator_name,
742
+ "baseType": m.add_debug_info(
743
+ "DIBasicType",
744
+ {
745
+ "name": "int",
746
+ "size": _BYTE_SIZE,
747
+ "encoding": ir.DIToken("DW_ATE_unsigned"),
748
+ },
749
+ ),
750
+ "size": _BYTE_SIZE,
751
+ "flags": ir.DIToken("DIFlagArtificial"),
752
+ },
753
+ )
754
+ # Create the final variant_part with actual members
755
+ variant_unique_identifier = discriminator_unique_id
756
+ variant_part_type = m.add_debug_info(
757
+ "DICompositeType",
758
+ {
759
+ "file": self.difile,
760
+ "tag": ir.DIToken("DW_TAG_variant_part"),
761
+ "name": "variant_part",
762
+ "identifier": variant_unique_identifier,
763
+ "elements": variant_elements_metadata,
764
+ "size": maxwidth,
765
+ "discriminator": discriminator,
766
+ },
767
+ )
768
+ # Create elements metadata for wrapper struct
769
+ elements_metadata = m.add_metadata(
770
+ [discriminator, variant_part_type]
771
+ )
772
+ unique_identifier = str(id(elements_metadata))
773
+ wrapper_struct = m.add_debug_info(
774
+ "DICompositeType",
775
+ {
776
+ "file": self.difile,
777
+ "tag": ir.DIToken("DW_TAG_structure_type"),
778
+ "name": "variant_wrapper_struct",
779
+ "identifier": unique_identifier,
780
+ "elements": elements_metadata,
781
+ "size": wrapper_struct_size,
782
+ },
783
+ )
784
+ return wrapper_struct
785
+ else:
786
+ fake_union_name = "dbg_poly_union"
787
+ return m.add_debug_info(
788
+ "DICompositeType",
789
+ {
790
+ "file": self.difile,
791
+ "tag": ir.DIToken("DW_TAG_union_type"),
792
+ "name": fake_union_name,
793
+ "identifier": str(lltype),
794
+ "elements": m.add_metadata(meta),
795
+ "size": maxwidth,
796
+ },
797
+ is_distinct=True,
798
+ )
799
+ # For other cases, use upstream Numba implementation
800
+ return super()._var_type(lltype, size, datamodel=datamodel)
801
+
802
+ def _di_subroutine_type(self, line, function, argmap):
803
+ # The function call conv needs encoding.
804
+ llfunc = function
805
+ md = []
806
+
807
+ # Create metadata type for return value
808
+ if len(llfunc.args) > 0:
809
+ lltype = llfunc.args[0].type
810
+ size = self.cgctx.get_abi_sizeof(lltype)
811
+ mdtype = self._var_type(lltype, size, datamodel=None)
812
+ md.append(mdtype)
813
+
814
+ # Create metadata type for arguments
815
+ for idx, (name, nbtype) in enumerate(argmap.items()):
816
+ datamodel = self.cgctx.data_model_manager[nbtype]
817
+ lltype = self.cgctx.get_value_type(nbtype)
818
+ size = self.cgctx.get_abi_sizeof(lltype)
819
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
820
+ md.append(mdtype)
821
+
822
+ return self.module.add_debug_info(
823
+ "DISubroutineType",
824
+ {
825
+ "types": self.module.add_metadata(md),
826
+ },
827
+ )
828
+
829
+ def mark_variable(
830
+ self,
831
+ builder,
832
+ allocavalue,
833
+ name,
834
+ lltype,
835
+ size,
836
+ line,
837
+ datamodel=None,
838
+ argidx=None,
839
+ ):
840
+ if name.startswith("$") or "." in name:
841
+ # Do not emit llvm.dbg.declare on user variable alias
842
+ return
843
+ else:
844
+ int_type = (ir.IntType,)
845
+ real_type = ir.FloatType, ir.DoubleType
846
+ if isinstance(lltype, int_type + real_type):
847
+ # Start with scalar variable, swtiching llvm.dbg.declare
848
+ # to llvm.dbg.value
849
+ return
850
+ else:
851
+ return super().mark_variable(
852
+ builder,
853
+ allocavalue,
854
+ name,
855
+ lltype,
856
+ size,
857
+ line,
858
+ datamodel,
859
+ argidx,
860
+ )
861
+
862
+ def update_variable(
863
+ self,
864
+ builder,
865
+ value,
866
+ name,
867
+ lltype,
868
+ size,
869
+ line,
870
+ datamodel=None,
871
+ argidx=None,
872
+ ):
873
+ m = self.module
874
+ fnty = ir.FunctionType(ir.VoidType(), [ir.MetaDataType()] * 3)
875
+ decl = cgutils.get_or_insert_function(m, fnty, "llvm.dbg.value")
876
+
877
+ mdtype = self._var_type(lltype, size, datamodel)
878
+ index = name.find(".")
879
+ if index >= 0:
880
+ name = name[:index]
881
+ # Merge DILocalVariable nodes with same name and type but different
882
+ # lines. Use the cached [(name, type) -> line] info to deduplicate
883
+ # metadata. Use the lltype as part of key.
884
+ key = (name, lltype)
885
+ if key in self._vartypelinemap:
886
+ line = self._vartypelinemap[key]
887
+ else:
888
+ self._vartypelinemap[key] = line
889
+ arg_index = 0 if argidx is None else argidx
890
+ mdlocalvar = m.add_debug_info(
891
+ "DILocalVariable",
892
+ {
893
+ "name": name,
894
+ "arg": arg_index,
895
+ "scope": self.subprograms[-1],
896
+ "file": self.difile,
897
+ "line": line,
898
+ "type": mdtype,
899
+ },
900
+ )
901
+ mdexpr = m.add_debug_info("DIExpression", {})
902
+
903
+ return builder.call(decl, [value, mdlocalvar, mdexpr])