tpy-lang 0.3.0.dev0__py3-none-any.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 (333) hide show
  1. tpy_lang-0.3.0.dev0.dist-info/METADATA +151 -0
  2. tpy_lang-0.3.0.dev0.dist-info/RECORD +333 -0
  3. tpy_lang-0.3.0.dev0.dist-info/WHEEL +4 -0
  4. tpy_lang-0.3.0.dev0.dist-info/entry_points.txt +3 -0
  5. tpyc/__init__.py +104 -0
  6. tpyc/__main__.py +6 -0
  7. tpyc/_buildinfo.py +1 -0
  8. tpyc/_data/docs/LANGUAGE_FEATURES.md +6278 -0
  9. tpyc/_data/docs/STDLIB_ROADMAP.md +1258 -0
  10. tpyc/_data/docs/TPY_FOR_AGENTS.md +556 -0
  11. tpyc/_data/lib/tpy/_bindings/__init__.py +6 -0
  12. tpyc/_data/lib/tpy/_bindings/pcre2.py +173 -0
  13. tpyc/_data/lib/tpy/_bindings/posix_socket.py +161 -0
  14. tpyc/_data/lib/tpy/_functools_macros.py +80 -0
  15. tpyc/_data/lib/tpy/_macro_helpers.py +161 -0
  16. tpyc/_data/lib/tpy/argparse.py +2062 -0
  17. tpyc/_data/lib/tpy/asyncio/__init__.py +744 -0
  18. tpyc/_data/lib/tpy/asyncio/_executor.py +515 -0
  19. tpyc/_data/lib/tpy/base64.py +410 -0
  20. tpyc/_data/lib/tpy/bisect.py +39 -0
  21. tpyc/_data/lib/tpy/builtins.py +38 -0
  22. tpyc/_data/lib/tpy/dataclasses.py +354 -0
  23. tpyc/_data/lib/tpy/enum.py +23 -0
  24. tpyc/_data/lib/tpy/functools.py +33 -0
  25. tpyc/_data/lib/tpy/hashlib.py +206 -0
  26. tpyc/_data/lib/tpy/heapq.py +118 -0
  27. tpyc/_data/lib/tpy/io.py +395 -0
  28. tpyc/_data/lib/tpy/json.py +221 -0
  29. tpyc/_data/lib/tpy/math.py +406 -0
  30. tpyc/_data/lib/tpy/random.py +597 -0
  31. tpyc/_data/lib/tpy/re.py +467 -0
  32. tpyc/_data/lib/tpy/socket.py +379 -0
  33. tpyc/_data/lib/tpy/struct.py +178 -0
  34. tpyc/_data/lib/tpy/sys.py +40 -0
  35. tpyc/_data/lib/tpy/time.py +39 -0
  36. tpyc/_data/lib/tpy/tpy/__init__.py +78 -0
  37. tpyc/_data/lib/tpy/tpy/_bootstrap/__init__.py +10 -0
  38. tpyc/_data/lib/tpy/tpy/_bootstrap/_decorators.py +37 -0
  39. tpyc/_data/lib/tpy/tpy/_bootstrap/_extern.py +64 -0
  40. tpyc/_data/lib/tpy/tpy/_builtins/__init__.py +11 -0
  41. tpyc/_data/lib/tpy/tpy/_builtins/_bytes.py +378 -0
  42. tpyc/_data/lib/tpy/tpy/_builtins/_dict.py +151 -0
  43. tpyc/_data/lib/tpy/tpy/_builtins/_exceptions.py +125 -0
  44. tpyc/_data/lib/tpy/tpy/_builtins/_funcs.py +681 -0
  45. tpyc/_data/lib/tpy/tpy/_builtins/_io.py +97 -0
  46. tpyc/_data/lib/tpy/tpy/_builtins/_list.py +127 -0
  47. tpyc/_data/lib/tpy/tpy/_builtins/_range.py +52 -0
  48. tpyc/_data/lib/tpy/tpy/_builtins/_set.py +139 -0
  49. tpyc/_data/lib/tpy/tpy/_builtins/_super.py +11 -0
  50. tpyc/_data/lib/tpy/tpy/_builtins/_types.py +661 -0
  51. tpyc/_data/lib/tpy/tpy/_core/__init__.py +23 -0
  52. tpyc/_data/lib/tpy/tpy/_core/_bytes_view.py +129 -0
  53. tpyc/_data/lib/tpy/tpy/_core/_containers.py +137 -0
  54. tpyc/_data/lib/tpy/tpy/_core/_functions.py +40 -0
  55. tpyc/_data/lib/tpy/tpy/_core/_types.py +2061 -0
  56. tpyc/_data/lib/tpy/tpy/_typing/__init__.py +77 -0
  57. tpyc/_data/lib/tpy/tpy/_version.py +29 -0
  58. tpyc/_data/lib/tpy/tpy/bits.py +28 -0
  59. tpyc/_data/lib/tpy/tpy/coro/__init__.py +127 -0
  60. tpyc/_data/lib/tpy/tpy/extern.py +8 -0
  61. tpyc/_data/lib/tpy/tpy/mem.py +49 -0
  62. tpyc/_data/lib/tpy/tpy/unsafe.py +195 -0
  63. tpyc/_data/lib/tpy/tpy/version.py +21 -0
  64. tpyc/_data/lib/tpy/typing.py +13 -0
  65. tpyc/_data/runtime/cpp/include/tpy/any.hpp +461 -0
  66. tpyc/_data/runtime/cpp/include/tpy/as_ostream.hpp +117 -0
  67. tpyc/_data/runtime/cpp/include/tpy/async.hpp +76 -0
  68. tpyc/_data/runtime/cpp/include/tpy/bigint.hpp +1343 -0
  69. tpyc/_data/runtime/cpp/include/tpy/builtins.hpp +400 -0
  70. tpyc/_data/runtime/cpp/include/tpy/bytes_ops.hpp +469 -0
  71. tpyc/_data/runtime/cpp/include/tpy/container_ops.hpp +487 -0
  72. tpyc/_data/runtime/cpp/include/tpy/copy_iter.hpp +82 -0
  73. tpyc/_data/runtime/cpp/include/tpy/core.hpp +558 -0
  74. tpyc/_data/runtime/cpp/include/tpy/dict_ops.hpp +289 -0
  75. tpyc/_data/runtime/cpp/include/tpy/dunder.hpp +750 -0
  76. tpyc/_data/runtime/cpp/include/tpy/dynamic.hpp +44 -0
  77. tpyc/_data/runtime/cpp/include/tpy/enum.hpp +40 -0
  78. tpyc/_data/runtime/cpp/include/tpy/file.hpp +245 -0
  79. tpyc/_data/runtime/cpp/include/tpy/fixed_int.hpp +317 -0
  80. tpyc/_data/runtime/cpp/include/tpy/format.hpp +954 -0
  81. tpyc/_data/runtime/cpp/include/tpy/frame_slot.hpp +120 -0
  82. tpyc/_data/runtime/cpp/include/tpy/generator.hpp +47 -0
  83. tpyc/_data/runtime/cpp/include/tpy/iterable_ops.hpp +122 -0
  84. tpyc/_data/runtime/cpp/include/tpy/itertools.hpp +749 -0
  85. tpyc/_data/runtime/cpp/include/tpy/next_iter.hpp +82 -0
  86. tpyc/_data/runtime/cpp/include/tpy/ordered_map.hpp +518 -0
  87. tpyc/_data/runtime/cpp/include/tpy/ordered_set.hpp +337 -0
  88. tpyc/_data/runtime/cpp/include/tpy/own_iter.hpp +54 -0
  89. tpyc/_data/runtime/cpp/include/tpy/pascal_graph_sdl.hpp +192 -0
  90. tpyc/_data/runtime/cpp/include/tpy/printing.hpp +302 -0
  91. tpyc/_data/runtime/cpp/include/tpy/protocols.hpp +61 -0
  92. tpyc/_data/runtime/cpp/include/tpy/range.hpp +115 -0
  93. tpyc/_data/runtime/cpp/include/tpy/ranges.hpp +212 -0
  94. tpyc/_data/runtime/cpp/include/tpy/set_ops.hpp +265 -0
  95. tpyc/_data/runtime/cpp/include/tpy/slice.hpp +47 -0
  96. tpyc/_data/runtime/cpp/include/tpy/span_iter.hpp +42 -0
  97. tpyc/_data/runtime/cpp/include/tpy/stdlib/math.hpp +41 -0
  98. tpyc/_data/runtime/cpp/include/tpy/stdlib/pcre2_h.hpp +96 -0
  99. tpyc/_data/runtime/cpp/include/tpy/stdlib/random.hpp +25 -0
  100. tpyc/_data/runtime/cpp/include/tpy/stdlib/socket_h.hpp +145 -0
  101. tpyc/_data/runtime/cpp/include/tpy/stdlib/time.hpp +62 -0
  102. tpyc/_data/runtime/cpp/include/tpy/system.hpp +121 -0
  103. tpyc/_data/runtime/cpp/include/tpy/throwable.hpp +55 -0
  104. tpyc/_data/runtime/cpp/include/tpy/tpy.hpp +156 -0
  105. tpyc/_data/runtime/cpp/include/tpy/type_name.hpp +77 -0
  106. tpyc/_data/runtime/cpp/include/tpy/type_traits.hpp +240 -0
  107. tpyc/_data/runtime/cpp/include/tpy/uninit_array_storage.hpp +250 -0
  108. tpyc/_data/runtime/cpp/include/tpy/uninit_heap_storage.hpp +277 -0
  109. tpyc/_data/runtime/cpp/include/tpy/varargs.hpp +174 -0
  110. tpyc/_data/runtime/cpp/include/tpy/variant_ref.hpp +118 -0
  111. tpyc/_data/runtime/cpp/src/stdlib/socket_impl.cpp +104 -0
  112. tpyc/_data/runtime/cpp/third_party/README.md +58 -0
  113. tpyc/_data/runtime/cpp/third_party/pcre2/AUTHORS +36 -0
  114. tpyc/_data/runtime/cpp/third_party/pcre2/CMakeLists.txt +1233 -0
  115. tpyc/_data/runtime/cpp/third_party/pcre2/COPYING +5 -0
  116. tpyc/_data/runtime/cpp/third_party/pcre2/ChangeLog +3097 -0
  117. tpyc/_data/runtime/cpp/third_party/pcre2/HACKING +853 -0
  118. tpyc/_data/runtime/cpp/third_party/pcre2/INSTALL +368 -0
  119. tpyc/_data/runtime/cpp/third_party/pcre2/LICENCE +94 -0
  120. tpyc/_data/runtime/cpp/third_party/pcre2/NEWS +492 -0
  121. tpyc/_data/runtime/cpp/third_party/pcre2/NON-AUTOTOOLS-BUILD +430 -0
  122. tpyc/_data/runtime/cpp/third_party/pcre2/README +956 -0
  123. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  124. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindEditline.cmake +16 -0
  125. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  126. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindReadline.cmake +29 -0
  127. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/pcre2-config-version.cmake.in +15 -0
  128. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/pcre2-config.cmake.in +148 -0
  129. tpyc/_data/runtime/cpp/third_party/pcre2/config-cmake.h.in +56 -0
  130. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-16.pc.in +13 -0
  131. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-32.pc.in +13 -0
  132. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-8.pc.in +13 -0
  133. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-posix.pc.in +13 -0
  134. tpyc/_data/runtime/cpp/third_party/pcre2/pcre2-config.in +121 -0
  135. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h +483 -0
  136. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h.generic +483 -0
  137. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h.in +460 -0
  138. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h +1010 -0
  139. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h.generic +1010 -0
  140. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h.in +1010 -0
  141. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_auto_possess.c +1371 -0
  142. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chartables.c +196 -0
  143. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chartables.c.dist +196 -0
  144. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chkdint.c +96 -0
  145. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_compile.c +11001 -0
  146. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_config.c +252 -0
  147. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_context.c +510 -0
  148. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_convert.c +1189 -0
  149. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_dfa_match.c +4119 -0
  150. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_dftables.c +297 -0
  151. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_error.c +345 -0
  152. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_extuni.c +162 -0
  153. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_find_bracket.c +219 -0
  154. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_fuzzsupport.c +792 -0
  155. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_internal.h +2084 -0
  156. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_intmodedep.h +940 -0
  157. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_compile.c +14972 -0
  158. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_match.c +200 -0
  159. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_misc.c +234 -0
  160. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_neon_inc.h +354 -0
  161. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_simd_inc.h +2355 -0
  162. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_test.c +2528 -0
  163. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_maketables.c +165 -0
  164. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_match.c +7777 -0
  165. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_match_data.c +185 -0
  166. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_newline.c +243 -0
  167. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ord2utf.c +120 -0
  168. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_pattern_info.c +432 -0
  169. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_printint.c +886 -0
  170. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_script_run.c +344 -0
  171. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_serialize.c +286 -0
  172. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_string_utils.c +237 -0
  173. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_study.c +1915 -0
  174. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_substitute.c +1009 -0
  175. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_substring.c +550 -0
  176. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_tables.c +234 -0
  177. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucd.c +5460 -0
  178. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucp.h +396 -0
  179. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucptables.c +1533 -0
  180. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_valid_utf.c +398 -0
  181. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_xclass.c +308 -0
  182. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2demo.c +497 -0
  183. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2grep.c +4606 -0
  184. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix.c +425 -0
  185. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix.h +187 -0
  186. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix_test.c +209 -0
  187. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2test.c +9708 -0
  188. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorApple.c +137 -0
  189. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorCore.c +327 -0
  190. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorFreeBSD.c +89 -0
  191. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorPosix.c +62 -0
  192. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorWindows.c +40 -0
  193. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitProtExecAllocatorNetBSD.c +72 -0
  194. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitProtExecAllocatorPosix.c +172 -0
  195. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitWXExecAllocatorPosix.c +141 -0
  196. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitWXExecAllocatorWindows.c +102 -0
  197. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfig.h +142 -0
  198. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfigCPU.h +188 -0
  199. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfigInternal.h +907 -0
  200. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitLir.c +3561 -0
  201. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitLir.h +2466 -0
  202. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_32.c +4636 -0
  203. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_64.c +3491 -0
  204. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_T2_32.c +4302 -0
  205. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeLOONGARCH_64.c +3765 -0
  206. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_32.c +472 -0
  207. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_64.c +387 -0
  208. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_common.c +4259 -0
  209. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_32.c +485 -0
  210. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_64.c +719 -0
  211. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_common.c +3161 -0
  212. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_32.c +142 -0
  213. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_64.c +222 -0
  214. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_common.c +3121 -0
  215. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeS390X.c +4526 -0
  216. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_32.c +1685 -0
  217. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_64.c +1398 -0
  218. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_common.c +5001 -0
  219. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitSerialize.c +516 -0
  220. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitUtils.c +344 -0
  221. tpyc/_data/runtime/cpp/third_party/pcre2.sources.txt +54 -0
  222. tpyc/_data/runtime/cpp/third_party/pcre2.vendor.json +7 -0
  223. tpyc/build/__init__.py +7 -0
  224. tpyc/build/pcre2.py +122 -0
  225. tpyc/build/third_party.py +413 -0
  226. tpyc/cli.py +822 -0
  227. tpyc/codegen_cpp/__init__.py +18 -0
  228. tpyc/codegen_cpp/builtins.py +484 -0
  229. tpyc/codegen_cpp/context.py +2064 -0
  230. tpyc/codegen_cpp/expressions.py +5940 -0
  231. tpyc/codegen_cpp/functions.py +1913 -0
  232. tpyc/codegen_cpp/gen_async.py +3258 -0
  233. tpyc/codegen_cpp/gen_generators.py +657 -0
  234. tpyc/codegen_cpp/generator.py +2258 -0
  235. tpyc/codegen_cpp/match.py +1997 -0
  236. tpyc/codegen_cpp/param_const.py +172 -0
  237. tpyc/codegen_cpp/protocols.py +907 -0
  238. tpyc/codegen_cpp/records.py +1654 -0
  239. tpyc/codegen_cpp/resumable_cfg.py +1651 -0
  240. tpyc/codegen_cpp/statements.py +4963 -0
  241. tpyc/codegen_cpp/string_dispatch.py +76 -0
  242. tpyc/codegen_cpp/test_context.py +46 -0
  243. tpyc/codegen_cpp/test_param_const.py +113 -0
  244. tpyc/codegen_cpp/test_resumable_cfg.py +182 -0
  245. tpyc/codegen_cpp/type_resolution.py +53 -0
  246. tpyc/codegen_cpp/types.py +436 -0
  247. tpyc/codegen_cpp/variant_access.py +135 -0
  248. tpyc/coercions.py +749 -0
  249. tpyc/compilation_context.py +57 -0
  250. tpyc/compiler.py +3945 -0
  251. tpyc/cycle_detection.py +358 -0
  252. tpyc/diagnostics.py +135 -0
  253. tpyc/dump_types.py +353 -0
  254. tpyc/frontend_diagnostics.py +47 -0
  255. tpyc/frontend_ir/__init__.py +140 -0
  256. tpyc/frontend_ir/lower.py +1098 -0
  257. tpyc/frontend_ir/nodes.py +718 -0
  258. tpyc/frontend_ir/resolver_adapter.py +151 -0
  259. tpyc/frontend_plugin.py +209 -0
  260. tpyc/install_docs.py +81 -0
  261. tpyc/liveness.py +756 -0
  262. tpyc/macro_api.py +1724 -0
  263. tpyc/macro_loader.py +497 -0
  264. tpyc/module_names.py +64 -0
  265. tpyc/modules/__init__.py +31 -0
  266. tpyc/modules/defs.py +89 -0
  267. tpyc/modules/registry.py +36 -0
  268. tpyc/modules/resolver.py +192 -0
  269. tpyc/modules/type_resolution.py +629 -0
  270. tpyc/namespace.py +172 -0
  271. tpyc/parse/__init__.py +84 -0
  272. tpyc/parse/imports.py +490 -0
  273. tpyc/parse/nodes.py +1732 -0
  274. tpyc/parse/parser.py +4043 -0
  275. tpyc/parse/resolve_refs.py +466 -0
  276. tpyc/parse/type_resolver.py +1060 -0
  277. tpyc/prescan.py +254 -0
  278. tpyc/qnames.py +149 -0
  279. tpyc/repl.py +529 -0
  280. tpyc/repl_backends.py +848 -0
  281. tpyc/sema/__init__.py +21 -0
  282. tpyc/sema/analyzer.py +3625 -0
  283. tpyc/sema/bound_check.py +72 -0
  284. tpyc/sema/builder_trace.py +684 -0
  285. tpyc/sema/calls.py +5406 -0
  286. tpyc/sema/compatibility.py +2107 -0
  287. tpyc/sema/context.py +1243 -0
  288. tpyc/sema/expressions.py +3737 -0
  289. tpyc/sema/flow_facts.py +199 -0
  290. tpyc/sema/init_tracker.py +150 -0
  291. tpyc/sema/list_literals.py +69 -0
  292. tpyc/sema/literal_utils.py +27 -0
  293. tpyc/sema/local_deduction.py +1088 -0
  294. tpyc/sema/macros.py +179 -0
  295. tpyc/sema/match.py +1177 -0
  296. tpyc/sema/method_expansion.py +347 -0
  297. tpyc/sema/methods.py +2197 -0
  298. tpyc/sema/mutation_propagation.py +268 -0
  299. tpyc/sema/narrowing.py +857 -0
  300. tpyc/sema/numeric_lattice.py +160 -0
  301. tpyc/sema/operators.py +402 -0
  302. tpyc/sema/overloads.py +841 -0
  303. tpyc/sema/protocols.py +1209 -0
  304. tpyc/sema/reach_analysis.py +202 -0
  305. tpyc/sema/registration.py +3156 -0
  306. tpyc/sema/scope_tracker.py +193 -0
  307. tpyc/sema/statements.py +4426 -0
  308. tpyc/sema/type_ops.py +1879 -0
  309. tpyc/sema/value_range.py +181 -0
  310. tpyc/symbol_binding.py +259 -0
  311. tpyc/test_c3_mro.py +208 -0
  312. tpyc/test_cli_argv.py +52 -0
  313. tpyc/test_compiler.py +559 -0
  314. tpyc/test_contains_type_param.py +101 -0
  315. tpyc/test_cycle_detection.py +221 -0
  316. tpyc/test_dump_types.py +225 -0
  317. tpyc/test_install_docs.py +65 -0
  318. tpyc/test_local_cpp_form.py +135 -0
  319. tpyc/test_macro_loader.py +76 -0
  320. tpyc/test_method_expansion.py +254 -0
  321. tpyc/test_nominal_identity.py +182 -0
  322. tpyc/test_overloads.py +410 -0
  323. tpyc/test_parse.py +303 -0
  324. tpyc/test_parse_type_ref.py +506 -0
  325. tpyc/test_parse_version_info.py +58 -0
  326. tpyc/test_reach_analysis.py +72 -0
  327. tpyc/test_ref_type.py +216 -0
  328. tpyc/test_send_sync_substitution.py +276 -0
  329. tpyc/test_tuple_mutation_propagation.py +206 -0
  330. tpyc/test_type_def_registry.py +1729 -0
  331. tpyc/test_union_types.py +195 -0
  332. tpyc/type_def_registry.py +975 -0
  333. tpyc/typesys.py +5104 -0
@@ -0,0 +1,907 @@
1
+ /*
2
+ * Stack-less Just-In-Time compiler
3
+ *
4
+ * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without modification, are
7
+ * permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
10
+ * conditions and the following disclaimer.
11
+ *
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
+ * of conditions and the following disclaimer in the documentation and/or other materials
14
+ * provided with the distribution.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19
+ * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ #ifndef SLJIT_CONFIG_INTERNAL_H_
28
+ #define SLJIT_CONFIG_INTERNAL_H_
29
+
30
+ #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
31
+ || (defined SLJIT_DEBUG && SLJIT_DEBUG && (!defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE)))
32
+ #include <stdio.h>
33
+ #endif
34
+
35
+ #if (defined SLJIT_DEBUG && SLJIT_DEBUG \
36
+ && (!defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE) || !defined(SLJIT_HALT_PROCESS)))
37
+ #include <stdlib.h>
38
+ #endif
39
+
40
+ #ifdef __cplusplus
41
+ extern "C" {
42
+ #endif
43
+
44
+ /*
45
+ SLJIT defines the following architecture dependent types and macros:
46
+
47
+ Types:
48
+ sljit_s8, sljit_u8 : signed and unsigned 8 bit integer type
49
+ sljit_s16, sljit_u16 : signed and unsigned 16 bit integer type
50
+ sljit_s32, sljit_u32 : signed and unsigned 32 bit integer type
51
+ sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
52
+ sljit_sp, sljit_up : signed and unsigned pointer value (usually the same as
53
+ sljit_uw, but some 64 bit ABIs may use 32 bit pointers)
54
+ sljit_f32 : 32 bit single precision floating point value
55
+ sljit_f64 : 64 bit double precision floating point value
56
+
57
+ Macros for feature detection (boolean):
58
+ SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
59
+ SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
60
+ SLJIT_LITTLE_ENDIAN : little endian architecture
61
+ SLJIT_BIG_ENDIAN : big endian architecture
62
+ SLJIT_UNALIGNED : unaligned memory accesses for non-fpu operations are supported
63
+ SLJIT_FPU_UNALIGNED : unaligned memory accesses for fpu operations are supported
64
+ SLJIT_MASKED_SHIFT : all word shifts are always masked
65
+ SLJIT_MASKED_SHIFT32 : all 32 bit shifts are always masked
66
+ SLJIT_INDIRECT_CALL : see SLJIT_FUNC_ADDR() for more information
67
+
68
+ Constants:
69
+ SLJIT_NUMBER_OF_REGISTERS : number of available registers
70
+ SLJIT_NUMBER_OF_SCRATCH_REGISTERS : number of available scratch registers
71
+ SLJIT_NUMBER_OF_SAVED_REGISTERS : number of available saved registers
72
+ SLJIT_NUMBER_OF_FLOAT_REGISTERS : number of available floating point registers
73
+ SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS : number of available floating point scratch registers
74
+ SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS : number of available floating point saved registers
75
+ SLJIT_NUMBER_OF_TEMPORARY_REGISTERS : number of available temporary registers
76
+ SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS : number of available temporary floating point registers
77
+ SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
78
+ SLJIT_F32_SHIFT : the shift required to apply when accessing
79
+ a single precision floating point array by index
80
+ SLJIT_F64_SHIFT : the shift required to apply when accessing
81
+ a double precision floating point array by index
82
+ SLJIT_PREF_SHIFT_REG : x86 systems prefers ecx for shifting by register
83
+ the scratch register index of ecx is stored in this variable
84
+ SLJIT_LOCALS_OFFSET : local space starting offset (SLJIT_SP + SLJIT_LOCALS_OFFSET)
85
+ SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
86
+ SLJIT_CONV_MAX_FLOAT : result when a floating point value is converted to integer
87
+ and the floating point value is higher than the maximum integer value
88
+ (possible values: SLJIT_CONV_RESULT_MAX_INT or SLJIT_CONV_RESULT_MIN_INT)
89
+ SLJIT_CONV_MIN_FLOAT : result when a floating point value is converted to integer
90
+ and the floating point value is lower than the minimum integer value
91
+ (possible values: SLJIT_CONV_RESULT_MAX_INT or SLJIT_CONV_RESULT_MIN_INT)
92
+ SLJIT_CONV_NAN_FLOAT : result when a NaN floating point value is converted to integer
93
+ (possible values: SLJIT_CONV_RESULT_MAX_INT, SLJIT_CONV_RESULT_MIN_INT,
94
+ or SLJIT_CONV_RESULT_ZERO)
95
+
96
+ Other macros:
97
+ SLJIT_TMP_R0 .. R9 : accessing temporary registers
98
+ SLJIT_TMP_R(i) : accessing temporary registers
99
+ SLJIT_TMP_FR0 .. FR9 : accessing temporary floating point registers
100
+ SLJIT_TMP_FR(i) : accessing temporary floating point registers
101
+ SLJIT_TMP_DEST_REG : a temporary register for results
102
+ SLJIT_TMP_MEM_REG : a temporary base register for accessing memory
103
+ (can be the same as SLJIT_TMP_DEST_REG)
104
+ SLJIT_TMP_DEST_FREG : a temporary register for float results
105
+ SLJIT_FUNC : calling convention attribute for both calling JIT from C and C calling back from JIT
106
+ SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (platform independent helper)
107
+ SLJIT_F64_SECOND(reg) : provides the register index of the second 32 bit part of a 64 bit
108
+ floating point register when SLJIT_HAS_F64_AS_F32_PAIR returns non-zero
109
+ */
110
+
111
+ /***********************************************************/
112
+ /* Intel Control-flow Enforcement Technology (CET) spport. */
113
+ /***********************************************************/
114
+
115
+ #ifdef SLJIT_CONFIG_X86
116
+
117
+ #if defined(__CET__) && !(defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
118
+ #define SLJIT_CONFIG_X86_CET 1
119
+ #endif
120
+
121
+ #if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined(__GNUC__)
122
+ #include <x86intrin.h>
123
+ #endif
124
+
125
+ #endif /* SLJIT_CONFIG_X86 */
126
+
127
+ /**********************************/
128
+ /* External function definitions. */
129
+ /**********************************/
130
+
131
+ /* General macros:
132
+ Note: SLJIT is designed to be independent from them as possible.
133
+
134
+ In release mode (SLJIT_DEBUG is not defined) only the following
135
+ external functions are needed:
136
+ */
137
+
138
+ #ifndef SLJIT_MALLOC
139
+ #define SLJIT_MALLOC(size, allocator_data) (malloc(size))
140
+ #endif
141
+
142
+ #ifndef SLJIT_FREE
143
+ #define SLJIT_FREE(ptr, allocator_data) (free(ptr))
144
+ #endif
145
+
146
+ #ifndef SLJIT_MEMCPY
147
+ #define SLJIT_MEMCPY(dest, src, len) (memcpy(dest, src, len))
148
+ #endif
149
+
150
+ #ifndef SLJIT_MEMMOVE
151
+ #define SLJIT_MEMMOVE(dest, src, len) (memmove(dest, src, len))
152
+ #endif
153
+
154
+ #ifndef SLJIT_ZEROMEM
155
+ #define SLJIT_ZEROMEM(dest, len) (memset(dest, 0, len))
156
+ #endif
157
+
158
+ /***************************/
159
+ /* Compiler helper macros. */
160
+ /***************************/
161
+
162
+ #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
163
+
164
+ #if defined(__GNUC__) && (__GNUC__ >= 3)
165
+ #define SLJIT_LIKELY(x) __builtin_expect((x), 1)
166
+ #define SLJIT_UNLIKELY(x) __builtin_expect((x), 0)
167
+ #else
168
+ #define SLJIT_LIKELY(x) (x)
169
+ #define SLJIT_UNLIKELY(x) (x)
170
+ #endif
171
+
172
+ #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
173
+
174
+ #ifndef SLJIT_INLINE
175
+ /* Inline functions. Some old compilers do not support them. */
176
+ #ifdef __SUNPRO_C
177
+ #if __SUNPRO_C < 0x560
178
+ #define SLJIT_INLINE
179
+ #else
180
+ #define SLJIT_INLINE inline
181
+ #endif /* __SUNPRO_C */
182
+ #else
183
+ #define SLJIT_INLINE __inline
184
+ #endif
185
+ #endif /* !SLJIT_INLINE */
186
+
187
+ #ifndef SLJIT_NOINLINE
188
+ /* Not inline functions. */
189
+ #if defined(__GNUC__)
190
+ #define SLJIT_NOINLINE __attribute__ ((noinline))
191
+ #else
192
+ #define SLJIT_NOINLINE
193
+ #endif
194
+ #endif /* !SLJIT_INLINE */
195
+
196
+ #ifndef SLJIT_UNUSED_ARG
197
+ /* Unused arguments. */
198
+ #define SLJIT_UNUSED_ARG(arg) (void)arg
199
+ #endif
200
+
201
+ /*********************************/
202
+ /* Type of public API functions. */
203
+ /*********************************/
204
+
205
+ #ifndef SLJIT_API_FUNC_ATTRIBUTE
206
+ #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
207
+ /* Static ABI functions. For all-in-one programs. */
208
+
209
+ #if defined(__GNUC__)
210
+ /* Disable unused warnings in gcc. */
211
+ #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
212
+ #else
213
+ #define SLJIT_API_FUNC_ATTRIBUTE static
214
+ #endif
215
+
216
+ #else
217
+ #define SLJIT_API_FUNC_ATTRIBUTE
218
+ #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
219
+ #endif /* defined SLJIT_API_FUNC_ATTRIBUTE */
220
+
221
+ /****************************/
222
+ /* Instruction cache flush. */
223
+ /****************************/
224
+
225
+ #ifdef __APPLE__
226
+ #include <AvailabilityMacros.h>
227
+ #endif
228
+
229
+ /*
230
+ * TODO:
231
+ *
232
+ * clang >= 15 could be safe to enable below
233
+ * older versions are known to abort in some targets
234
+ * https://github.com/PhilipHazel/pcre2/issues/92
235
+ *
236
+ * beware some vendors (ex: Microsoft, Apple) are known to have
237
+ * removed the code to support this builtin even if the call for
238
+ * __has_builtin reports it is available.
239
+ *
240
+ * make sure linking doesn't fail because __clear_cache() is
241
+ * missing before changing it or add an exception so that the
242
+ * system provided method that should be defined below is used
243
+ * instead.
244
+ */
245
+ #if (!defined SLJIT_CACHE_FLUSH && defined __has_builtin)
246
+ #if __has_builtin(__builtin___clear_cache) && !defined(__clang__)
247
+
248
+ /*
249
+ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=91248
250
+ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=93811
251
+ * gcc's clear_cache builtin for power is broken
252
+ */
253
+ #if !defined(SLJIT_CONFIG_PPC)
254
+ #define SLJIT_CACHE_FLUSH(from, to) \
255
+ __builtin___clear_cache((char*)(from), (char*)(to))
256
+ #endif
257
+
258
+ #endif /* gcc >= 10 */
259
+ #endif /* (!defined SLJIT_CACHE_FLUSH && defined __has_builtin) */
260
+
261
+ #ifndef SLJIT_CACHE_FLUSH
262
+
263
+ #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
264
+ || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
265
+
266
+ /* Not required to implement on archs with unified caches. */
267
+ #define SLJIT_CACHE_FLUSH(from, to)
268
+
269
+ #elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
270
+
271
+ /* Supported by all macs since Mac OS 10.5.
272
+ However, it does not work on non-jailbroken iOS devices,
273
+ although the compilation is successful. */
274
+ #include <libkern/OSCacheControl.h>
275
+ #define SLJIT_CACHE_FLUSH(from, to) \
276
+ sys_icache_invalidate((void*)(from), (size_t)((char*)(to) - (char*)(from)))
277
+
278
+ #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
279
+
280
+ /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
281
+ #define SLJIT_CACHE_FLUSH(from, to) \
282
+ ppc_cache_flush((from), (to))
283
+ #define SLJIT_CACHE_FLUSH_OWN_IMPL 1
284
+
285
+ #elif defined(_WIN32)
286
+
287
+ #define SLJIT_CACHE_FLUSH(from, to) \
288
+ FlushInstructionCache(GetCurrentProcess(), (void*)(from), (char*)(to) - (char*)(from))
289
+
290
+ #elif (defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || defined(__clang__)
291
+
292
+ #define SLJIT_CACHE_FLUSH(from, to) \
293
+ __builtin___clear_cache((char*)(from), (char*)(to))
294
+
295
+ #elif defined __ANDROID__
296
+
297
+ /* Android ARMv7 with gcc lacks __clear_cache; use cacheflush instead. */
298
+ #include <sys/cachectl.h>
299
+ #define SLJIT_CACHE_FLUSH(from, to) \
300
+ cacheflush((long)(from), (long)(to), 0)
301
+
302
+ #else
303
+
304
+ /* Call __ARM_NR_cacheflush on ARM-Linux or the corresponding MIPS syscall. */
305
+ #define SLJIT_CACHE_FLUSH(from, to) \
306
+ __clear_cache((char*)(from), (char*)(to))
307
+
308
+ #endif
309
+
310
+ #endif /* !SLJIT_CACHE_FLUSH */
311
+
312
+ /******************************************************/
313
+ /* Integer and floating point type definitions. */
314
+ /******************************************************/
315
+
316
+ /* 8 bit byte type. */
317
+ typedef unsigned char sljit_u8;
318
+ typedef signed char sljit_s8;
319
+
320
+ /* 16 bit half-word type. */
321
+ typedef unsigned short int sljit_u16;
322
+ typedef signed short int sljit_s16;
323
+
324
+ /* 32 bit integer type. */
325
+ typedef unsigned int sljit_u32;
326
+ typedef signed int sljit_s32;
327
+
328
+ /* Machine word type. Enough for storing a pointer.
329
+ 32 bit for 32 bit machines.
330
+ 64 bit for 64 bit machines. */
331
+ #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
332
+ /* Just to have something. */
333
+ #define SLJIT_WORD_SHIFT 0
334
+ typedef unsigned int sljit_uw;
335
+ typedef int sljit_sw;
336
+ #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
337
+ && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
338
+ && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
339
+ && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
340
+ && !(defined SLJIT_CONFIG_RISCV_64 && SLJIT_CONFIG_RISCV_64) \
341
+ && !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
342
+ && !(defined SLJIT_CONFIG_LOONGARCH_64 && SLJIT_CONFIG_LOONGARCH_64)
343
+ #define SLJIT_32BIT_ARCHITECTURE 1
344
+ #define SLJIT_WORD_SHIFT 2
345
+ typedef unsigned int sljit_uw;
346
+ typedef int sljit_sw;
347
+ #else
348
+ #define SLJIT_64BIT_ARCHITECTURE 1
349
+ #define SLJIT_WORD_SHIFT 3
350
+ #ifdef _WIN32
351
+ #ifdef __GNUC__
352
+ /* These types do not require windows.h */
353
+ typedef unsigned long long sljit_uw;
354
+ typedef long long sljit_sw;
355
+ #else
356
+ typedef unsigned __int64 sljit_uw;
357
+ typedef __int64 sljit_sw;
358
+ #endif
359
+ #else /* !_WIN32 */
360
+ typedef unsigned long int sljit_uw;
361
+ typedef long int sljit_sw;
362
+ #endif /* _WIN32 */
363
+ #endif
364
+
365
+ typedef sljit_sw sljit_sp;
366
+ typedef sljit_uw sljit_up;
367
+
368
+ /* Floating point types. */
369
+ typedef float sljit_f32;
370
+ typedef double sljit_f64;
371
+
372
+ /* Shift for pointer sized data. */
373
+ #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
374
+
375
+ /* Shift for double precision sized data. */
376
+ #define SLJIT_F32_SHIFT 2
377
+ #define SLJIT_F64_SHIFT 3
378
+
379
+ #define SLJIT_CONV_RESULT_MAX_INT 0
380
+ #define SLJIT_CONV_RESULT_MIN_INT 1
381
+ #define SLJIT_CONV_RESULT_ZERO 2
382
+
383
+ #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
384
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MIN_INT
385
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
386
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MIN_INT
387
+ #elif (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
388
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
389
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
390
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_ZERO
391
+ #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
392
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
393
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MAX_INT
394
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MAX_INT
395
+ #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
396
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
397
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
398
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MIN_INT
399
+ #elif (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV)
400
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
401
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
402
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MAX_INT
403
+ #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
404
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
405
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
406
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MIN_INT
407
+ #elif (defined SLJIT_CONFIG_LOONGARCH && SLJIT_CONFIG_LOONGARCH)
408
+ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT
409
+ #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT
410
+ #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_ZERO
411
+ #else
412
+ #error "Result for float to integer conversion is not defined"
413
+ #endif
414
+
415
+ #ifndef SLJIT_W
416
+
417
+ /* Defining long constants. */
418
+ #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
419
+ #ifdef _WIN64
420
+ #define SLJIT_W(w) (w##ll)
421
+ #else /* !windows */
422
+ #define SLJIT_W(w) (w##l)
423
+ #endif /* windows */
424
+ #else /* 32 bit */
425
+ #define SLJIT_W(w) (w)
426
+ #endif /* unknown */
427
+
428
+ #endif /* !SLJIT_W */
429
+
430
+ /*************************/
431
+ /* Endianness detection. */
432
+ /*************************/
433
+
434
+ #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
435
+
436
+ /* These macros are mostly useful for the applications. */
437
+ #if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
438
+
439
+ #ifdef __LITTLE_ENDIAN__
440
+ #define SLJIT_LITTLE_ENDIAN 1
441
+ #else
442
+ #define SLJIT_BIG_ENDIAN 1
443
+ #endif
444
+
445
+ #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
446
+
447
+ #ifdef __MIPSEL__
448
+ #define SLJIT_LITTLE_ENDIAN 1
449
+ #else
450
+ #define SLJIT_BIG_ENDIAN 1
451
+ #endif
452
+
453
+ #ifndef SLJIT_MIPS_REV
454
+
455
+ /* Auto detecting mips revision. */
456
+ #if (defined __mips_isa_rev) && (__mips_isa_rev >= 6)
457
+ #define SLJIT_MIPS_REV 6
458
+ #elif defined(__mips_isa_rev) && __mips_isa_rev >= 1
459
+ #define SLJIT_MIPS_REV __mips_isa_rev
460
+ #elif defined(__clang__) \
461
+ && (defined(_MIPS_ARCH_OCTEON) || defined(_MIPS_ARCH_P5600))
462
+ /* clang either forgets to define (clang-7) __mips_isa_rev at all
463
+ * or sets it to zero (clang-8,-9) for -march=octeon (MIPS64 R2+)
464
+ * and -march=p5600 (MIPS32 R5).
465
+ * It also sets the __mips macro to 64 or 32 for -mipsN when N <= 5
466
+ * (should be set to N exactly) so we cannot rely on this too.
467
+ */
468
+ #define SLJIT_MIPS_REV 1
469
+ #endif
470
+
471
+ #endif /* !SLJIT_MIPS_REV */
472
+
473
+ #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
474
+
475
+ #define SLJIT_BIG_ENDIAN 1
476
+
477
+ #else
478
+ #define SLJIT_LITTLE_ENDIAN 1
479
+ #endif
480
+
481
+ #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
482
+
483
+ /* Sanity check. */
484
+ #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
485
+ #error "Exactly one endianness must be selected"
486
+ #endif
487
+
488
+ #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
489
+ #error "Exactly one endianness must be selected"
490
+ #endif
491
+
492
+ #ifndef SLJIT_UNALIGNED
493
+
494
+ #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
495
+ || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
496
+ || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
497
+ || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
498
+ || (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
499
+ || (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV) \
500
+ || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
501
+ || (defined SLJIT_CONFIG_LOONGARCH && SLJIT_CONFIG_LOONGARCH)
502
+ #define SLJIT_UNALIGNED 1
503
+ #endif
504
+
505
+ #endif /* !SLJIT_UNALIGNED */
506
+
507
+ #ifndef SLJIT_FPU_UNALIGNED
508
+
509
+ #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
510
+ || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
511
+ || (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
512
+ || (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV) \
513
+ || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
514
+ || (defined SLJIT_CONFIG_LOONGARCH && SLJIT_CONFIG_LOONGARCH)
515
+ #define SLJIT_FPU_UNALIGNED 1
516
+ #endif
517
+
518
+ #endif /* !SLJIT_FPU_UNALIGNED */
519
+
520
+ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
521
+ /* Auto detect SSE2 support using CPUID.
522
+ On 64 bit x86 cpus, sse2 must be present. */
523
+ #define SLJIT_DETECT_SSE2 1
524
+ #endif
525
+
526
+ /*****************************************************************************************/
527
+ /* Calling convention of functions generated by SLJIT or called from the generated code. */
528
+ /*****************************************************************************************/
529
+
530
+ #ifndef SLJIT_FUNC
531
+ #define SLJIT_FUNC
532
+ #endif /* !SLJIT_FUNC */
533
+
534
+ #ifndef SLJIT_INDIRECT_CALL
535
+ #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (!defined _CALL_ELF || _CALL_ELF == 1)) \
536
+ || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
537
+ /* It seems certain ppc compilers use an indirect addressing for functions
538
+ which makes things complicated. */
539
+ #define SLJIT_INDIRECT_CALL 1
540
+ #endif
541
+ #endif /* SLJIT_INDIRECT_CALL */
542
+
543
+ /* The offset which needs to be subtracted from the return address to
544
+ determine the next executed instruction after return. */
545
+ #ifndef SLJIT_RETURN_ADDRESS_OFFSET
546
+ #define SLJIT_RETURN_ADDRESS_OFFSET 0
547
+ #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
548
+
549
+ /***************************************************/
550
+ /* Functions of the built-in executable allocator. */
551
+ /***************************************************/
552
+
553
+ #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
554
+ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
555
+ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
556
+ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
557
+ #define SLJIT_BUILTIN_MALLOC_EXEC(size, exec_allocator_data) sljit_malloc_exec(size)
558
+ #define SLJIT_BUILTIN_FREE_EXEC(ptr, exec_allocator_data) sljit_free_exec(ptr)
559
+
560
+ #ifndef SLJIT_MALLOC_EXEC
561
+ #define SLJIT_MALLOC_EXEC(size, exec_allocator_data) SLJIT_BUILTIN_MALLOC_EXEC((size), (exec_allocator_data))
562
+ #endif /* SLJIT_MALLOC_EXEC */
563
+
564
+ #ifndef SLJIT_FREE_EXEC
565
+ #define SLJIT_FREE_EXEC(ptr, exec_allocator_data) SLJIT_BUILTIN_FREE_EXEC((ptr), (exec_allocator_data))
566
+ #endif /* SLJIT_FREE_EXEC */
567
+
568
+ #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
569
+ SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void *code);
570
+ #define SLJIT_EXEC_OFFSET(code) sljit_exec_offset(code)
571
+ #endif /* SLJIT_PROT_EXECUTABLE_ALLOCATOR */
572
+
573
+ #endif /* SLJIT_EXECUTABLE_ALLOCATOR */
574
+
575
+ #ifndef SLJIT_EXEC_OFFSET
576
+ #define SLJIT_EXEC_OFFSET(ptr) 0
577
+ #endif
578
+
579
+ /**********************************************/
580
+ /* Registers and locals offset determination. */
581
+ /**********************************************/
582
+
583
+ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
584
+
585
+ #define SLJIT_NUMBER_OF_REGISTERS 12
586
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
587
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 1
588
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 7
589
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
590
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 1
591
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R0
592
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R0
593
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
594
+ #define SLJIT_LOCALS_OFFSET_BASE (8 * SSIZE_OF(sw))
595
+ #define SLJIT_PREF_SHIFT_REG SLJIT_R2
596
+ #define SLJIT_MASKED_SHIFT 1
597
+ #define SLJIT_MASKED_SHIFT32 1
598
+
599
+ #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
600
+
601
+ #define SLJIT_NUMBER_OF_REGISTERS 13
602
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 2
603
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 15
604
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 1
605
+ #ifndef _WIN64
606
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
607
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
608
+ #define SLJIT_LOCALS_OFFSET_BASE 0
609
+ #else /* _WIN64 */
610
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
611
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 10
612
+ #define SLJIT_LOCALS_OFFSET_BASE (4 * SSIZE_OF(sw))
613
+ #endif /* !_WIN64 */
614
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R0
615
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R0
616
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
617
+ #define SLJIT_PREF_SHIFT_REG SLJIT_R3
618
+ #define SLJIT_MASKED_SHIFT 1
619
+ #define SLJIT_MASKED_SHIFT32 1
620
+
621
+ #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32)
622
+
623
+ #define SLJIT_NUMBER_OF_REGISTERS 12
624
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
625
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 2
626
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 14
627
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 8
628
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 2
629
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R1
630
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R1
631
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
632
+ #define SLJIT_LOCALS_OFFSET_BASE 0
633
+
634
+ #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
635
+
636
+ #define SLJIT_NUMBER_OF_REGISTERS 26
637
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
638
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 3
639
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 30
640
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 8
641
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 2
642
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R0
643
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R0
644
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
645
+ #define SLJIT_LOCALS_OFFSET_BASE (2 * (sljit_s32)sizeof(sljit_sw))
646
+ #define SLJIT_MASKED_SHIFT 1
647
+ #define SLJIT_MASKED_SHIFT32 1
648
+
649
+ #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
650
+
651
+ #define SLJIT_NUMBER_OF_REGISTERS 23
652
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
653
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 3
654
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 30
655
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 18
656
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 2
657
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R1
658
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R1
659
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
660
+ #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined _AIX)
661
+ #define SLJIT_LOCALS_OFFSET_BASE ((6 + 8) * (sljit_s32)sizeof(sljit_sw))
662
+ #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
663
+ /* Add +1 for double alignment. */
664
+ #define SLJIT_LOCALS_OFFSET_BASE ((3 + 1) * (sljit_s32)sizeof(sljit_sw))
665
+ #else
666
+ #define SLJIT_LOCALS_OFFSET_BASE (3 * (sljit_s32)sizeof(sljit_sw))
667
+ #endif /* SLJIT_CONFIG_PPC_64 || _AIX */
668
+
669
+ #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
670
+
671
+ #define SLJIT_NUMBER_OF_REGISTERS 21
672
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
673
+ #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
674
+ #define SLJIT_LOCALS_OFFSET_BASE (4 * (sljit_s32)sizeof(sljit_sw))
675
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 13
676
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 6
677
+ #else
678
+ #define SLJIT_LOCALS_OFFSET_BASE 0
679
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 29
680
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 8
681
+ #endif
682
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 5
683
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 3
684
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R1
685
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R1
686
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
687
+ #define SLJIT_MASKED_SHIFT 1
688
+ #define SLJIT_MASKED_SHIFT32 1
689
+
690
+ #elif (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV)
691
+
692
+ #define SLJIT_NUMBER_OF_REGISTERS 23
693
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 12
694
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 5
695
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 30
696
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 12
697
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 2
698
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R1
699
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R1
700
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
701
+ #define SLJIT_LOCALS_OFFSET_BASE 0
702
+ #define SLJIT_MASKED_SHIFT 1
703
+ #define SLJIT_MASKED_SHIFT32 1
704
+
705
+ #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
706
+
707
+ /*
708
+ * https://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_zSeries.html#STACKFRAME
709
+ *
710
+ * 160
711
+ * .. FR6
712
+ * .. FR4
713
+ * .. FR2
714
+ * 128 FR0
715
+ * 120 R15 (used for SP)
716
+ * 112 R14
717
+ * 104 R13
718
+ * 96 R12
719
+ * ..
720
+ * 48 R6
721
+ * ..
722
+ * 16 R2
723
+ * 8 RESERVED
724
+ * 0 SP
725
+ */
726
+ #define SLJIT_S390X_DEFAULT_STACK_FRAME_SIZE 160
727
+
728
+ #define SLJIT_NUMBER_OF_REGISTERS 12
729
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
730
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 3
731
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 15
732
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 8
733
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 1
734
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R0
735
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R2
736
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
737
+ #define SLJIT_LOCALS_OFFSET_BASE SLJIT_S390X_DEFAULT_STACK_FRAME_SIZE
738
+ #define SLJIT_MASKED_SHIFT 1
739
+
740
+ #elif (defined SLJIT_CONFIG_LOONGARCH && SLJIT_CONFIG_LOONGARCH)
741
+
742
+ #define SLJIT_NUMBER_OF_REGISTERS 23
743
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
744
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 5
745
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 30
746
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 12
747
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 2
748
+ #define SLJIT_TMP_DEST_REG SLJIT_TMP_R1
749
+ #define SLJIT_TMP_MEM_REG SLJIT_TMP_R1
750
+ #define SLJIT_TMP_DEST_FREG SLJIT_TMP_FR0
751
+ #define SLJIT_LOCALS_OFFSET_BASE 0
752
+ #define SLJIT_MASKED_SHIFT 1
753
+ #define SLJIT_MASKED_SHIFT32 1
754
+
755
+ #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
756
+
757
+ /* Just to have something. */
758
+ #define SLJIT_NUMBER_OF_REGISTERS 0
759
+ #define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
760
+ #define SLJIT_NUMBER_OF_TEMPORARY_REGISTERS 0
761
+ #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 0
762
+ #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
763
+ #define SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS 0
764
+ #define SLJIT_TMP_DEST_REG 0
765
+ #define SLJIT_TMP_MEM_REG 0
766
+ #define SLJIT_TMP_DEST_FREG 0
767
+ #define SLJIT_LOCALS_OFFSET_BASE 0
768
+
769
+ #endif
770
+
771
+ #define SLJIT_LOCALS_OFFSET (SLJIT_LOCALS_OFFSET_BASE)
772
+
773
+ #define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
774
+ (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
775
+
776
+ #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
777
+ (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
778
+
779
+ /**********************************/
780
+ /* Temporary register management. */
781
+ /**********************************/
782
+
783
+ #define SLJIT_TMP_REGISTER_BASE (SLJIT_NUMBER_OF_REGISTERS + 2)
784
+ #define SLJIT_TMP_FREGISTER_BASE (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
785
+
786
+ /* WARNING: Accessing temporary registers is not recommended, because they
787
+ are also used by the JIT compiler for various computations. Using them
788
+ might have any side effects including incorrect operations and crashes,
789
+ so use them at your own risk. The machine registers themselves might have
790
+ limitations, e.g. the r0 register on s390x / ppc cannot be used as
791
+ base address for memory operations. */
792
+
793
+ /* Temporary registers */
794
+ #define SLJIT_TMP_R0 (SLJIT_TMP_REGISTER_BASE + 0)
795
+ #define SLJIT_TMP_R1 (SLJIT_TMP_REGISTER_BASE + 1)
796
+ #define SLJIT_TMP_R2 (SLJIT_TMP_REGISTER_BASE + 2)
797
+ #define SLJIT_TMP_R3 (SLJIT_TMP_REGISTER_BASE + 3)
798
+ #define SLJIT_TMP_R4 (SLJIT_TMP_REGISTER_BASE + 4)
799
+ #define SLJIT_TMP_R5 (SLJIT_TMP_REGISTER_BASE + 5)
800
+ #define SLJIT_TMP_R6 (SLJIT_TMP_REGISTER_BASE + 6)
801
+ #define SLJIT_TMP_R7 (SLJIT_TMP_REGISTER_BASE + 7)
802
+ #define SLJIT_TMP_R8 (SLJIT_TMP_REGISTER_BASE + 8)
803
+ #define SLJIT_TMP_R9 (SLJIT_TMP_REGISTER_BASE + 9)
804
+ #define SLJIT_TMP_R(i) (SLJIT_TMP_REGISTER_BASE + (i))
805
+
806
+ #define SLJIT_TMP_FR0 (SLJIT_TMP_FREGISTER_BASE + 0)
807
+ #define SLJIT_TMP_FR1 (SLJIT_TMP_FREGISTER_BASE + 1)
808
+ #define SLJIT_TMP_FR2 (SLJIT_TMP_FREGISTER_BASE + 2)
809
+ #define SLJIT_TMP_FR3 (SLJIT_TMP_FREGISTER_BASE + 3)
810
+ #define SLJIT_TMP_FR4 (SLJIT_TMP_FREGISTER_BASE + 4)
811
+ #define SLJIT_TMP_FR5 (SLJIT_TMP_FREGISTER_BASE + 5)
812
+ #define SLJIT_TMP_FR6 (SLJIT_TMP_FREGISTER_BASE + 6)
813
+ #define SLJIT_TMP_FR7 (SLJIT_TMP_FREGISTER_BASE + 7)
814
+ #define SLJIT_TMP_FR8 (SLJIT_TMP_FREGISTER_BASE + 8)
815
+ #define SLJIT_TMP_FR9 (SLJIT_TMP_FREGISTER_BASE + 9)
816
+ #define SLJIT_TMP_FR(i) (SLJIT_TMP_FREGISTER_BASE + (i))
817
+
818
+ /********************************/
819
+ /* CPU status flags management. */
820
+ /********************************/
821
+
822
+ #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM) \
823
+ || (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
824
+ || (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) \
825
+ || (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV) \
826
+ || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
827
+ || (defined SLJIT_CONFIG_LOONGARCH && SLJIT_CONFIG_LOONGARCH)
828
+ #define SLJIT_HAS_STATUS_FLAGS_STATE 1
829
+ #endif
830
+
831
+ /***************************************/
832
+ /* Floating point register management. */
833
+ /***************************************/
834
+
835
+ #if (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) \
836
+ || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
837
+ #define SLJIT_F64_SECOND(reg) \
838
+ ((reg) + SLJIT_FS0 + SLJIT_NUMBER_OF_TEMPORARY_FLOAT_REGISTERS)
839
+ #else /* !SLJIT_CONFIG_ARM_32 && !SLJIT_CONFIG_MIPS_32 */
840
+ #define SLJIT_F64_SECOND(reg) \
841
+ (reg)
842
+ #endif /* SLJIT_CONFIG_ARM_32 || SLJIT_CONFIG_MIPS_32 */
843
+
844
+ /*************************************/
845
+ /* Debug and verbose related macros. */
846
+ /*************************************/
847
+
848
+ #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
849
+
850
+ #if !defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE)
851
+
852
+ /* SLJIT_HALT_PROCESS must halt the process. */
853
+ #ifndef SLJIT_HALT_PROCESS
854
+ #define SLJIT_HALT_PROCESS() \
855
+ abort();
856
+ #endif /* !SLJIT_HALT_PROCESS */
857
+
858
+ #endif /* !SLJIT_ASSERT || !SLJIT_UNREACHABLE */
859
+
860
+ /* Feel free to redefine these two macros. */
861
+ #ifndef SLJIT_ASSERT
862
+
863
+ #define SLJIT_ASSERT(x) \
864
+ do { \
865
+ if (SLJIT_UNLIKELY(!(x))) { \
866
+ printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
867
+ SLJIT_HALT_PROCESS(); \
868
+ } \
869
+ } while (0)
870
+
871
+ #endif /* !SLJIT_ASSERT */
872
+
873
+ #ifndef SLJIT_UNREACHABLE
874
+
875
+ #define SLJIT_UNREACHABLE() \
876
+ do { \
877
+ printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
878
+ SLJIT_HALT_PROCESS(); \
879
+ } while (0)
880
+
881
+ #endif /* !SLJIT_UNREACHABLE */
882
+
883
+ #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
884
+
885
+ /* Forcing empty, but valid statements. */
886
+ #undef SLJIT_ASSERT
887
+ #undef SLJIT_UNREACHABLE
888
+
889
+ #define SLJIT_ASSERT(x) \
890
+ do { } while (0)
891
+ #define SLJIT_UNREACHABLE() \
892
+ do { } while (0)
893
+
894
+ #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
895
+
896
+ #ifndef SLJIT_COMPILE_ASSERT
897
+
898
+ #define SLJIT_COMPILE_ASSERT(x, description) \
899
+ switch(0) { case 0: case ((x) ? 1 : 0): break; }
900
+
901
+ #endif /* !SLJIT_COMPILE_ASSERT */
902
+
903
+ #ifdef __cplusplus
904
+ } /* extern "C" */
905
+ #endif
906
+
907
+ #endif /* SLJIT_CONFIG_INTERNAL_H_ */