Debian Codegraph @

Modules/clinic/_opcode.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(_opcode_stack_effect__doc__,
12 "stack_effect($module, opcode, oparg=None, /, *, jump=None)\n"
13 "--\n"
14 "\n"
15 "Compute the stack effect of the opcode.");
16
17 #define _OPCODE_STACK_EFFECT_METHODDEF \
18 {"stack_effect", _PyCFunction_CAST(_opcode_stack_effect), METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__},
19
20 static int
21 _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
22 PyObject *jump);
23
24 static PyObject *
25 _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
26 {
27 PyObject *return_value = NULL;
28 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
29
30 #define NUM_KEYWORDS 1
31 static struct {
32 PyGC_Head _this_is_not_used;
33 PyObject_VAR_HEAD
34 PyObject *ob_item[NUM_KEYWORDS];
35 } _kwtuple = {
36 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
37 .ob_item = { &_Py_ID(jump), },
38 };
39 #undef NUM_KEYWORDS
40 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
41
42 #else // !Py_BUILD_CORE
43 # define KWTUPLE NULL
44 #endif // !Py_BUILD_CORE
45
46 static const char * const _keywords[] = {"", "", "jump", NULL};
47 static _PyArg_Parser _parser = {
48 .keywords = _keywords,
49 .fname = "stack_effect",
50 .kwtuple = KWTUPLE,
51 };
52 #undef KWTUPLE
53 PyObject *argsbuf[3];
54 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
55 int opcode;
56 PyObject *oparg = Py_None;
57 PyObject *jump = Py_None;
58 int _return_value;
59
60 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
61 if (!args) {
62 goto exit;
63 }
64 opcode = PyLong_AsInt(args[0]);
65 if (opcode == -1 && PyErr_Occurred()) {
66 goto exit;
67 }
68 if (nargs < 2) {
69 goto skip_optional_posonly;
70 }
71 noptargs--;
72 oparg = args[1];
73 skip_optional_posonly:
74 if (!noptargs) {
75 goto skip_optional_kwonly;
76 }
77 jump = args[2];
78 skip_optional_kwonly:
79 _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump);
80 if ((_return_value == -1) && PyErr_Occurred()) {
81 goto exit;
82 }
83 return_value = PyLong_FromLong((long)_return_value);
84
85 exit:
86 return return_value;
87 }
88
89 PyDoc_STRVAR(_opcode_is_valid__doc__,
90 "is_valid($module, /, opcode)\n"
91 "--\n"
92 "\n"
93 "Return True if opcode is valid, False otherwise.");
94
95 #define _OPCODE_IS_VALID_METHODDEF \
96 {"is_valid", _PyCFunction_CAST(_opcode_is_valid), METH_FASTCALL|METH_KEYWORDS, _opcode_is_valid__doc__},
97
98 static int
99 _opcode_is_valid_impl(PyObject *module, int opcode);
100
101 static PyObject *
102 _opcode_is_valid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
103 {
104 PyObject *return_value = NULL;
105 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
106
107 #define NUM_KEYWORDS 1
108 static struct {
109 PyGC_Head _this_is_not_used;
110 PyObject_VAR_HEAD
111 PyObject *ob_item[NUM_KEYWORDS];
112 } _kwtuple = {
113 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
114 .ob_item = { &_Py_ID(opcode), },
115 };
116 #undef NUM_KEYWORDS
117 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
118
119 #else // !Py_BUILD_CORE
120 # define KWTUPLE NULL
121 #endif // !Py_BUILD_CORE
122
123 static const char * const _keywords[] = {"opcode", NULL};
124 static _PyArg_Parser _parser = {
125 .keywords = _keywords,
126 .fname = "is_valid",
127 .kwtuple = KWTUPLE,
128 };
129 #undef KWTUPLE
130 PyObject *argsbuf[1];
131 int opcode;
132 int _return_value;
133
134 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
135 if (!args) {
136 goto exit;
137 }
138 opcode = PyLong_AsInt(args[0]);
139 if (opcode == -1 && PyErr_Occurred()) {
140 goto exit;
141 }
142 _return_value = _opcode_is_valid_impl(module, opcode);
143 if ((_return_value == -1) && PyErr_Occurred()) {
144 goto exit;
145 }
146 return_value = PyBool_FromLong((long)_return_value);
147
148 exit:
149 return return_value;
150 }
151
152 PyDoc_STRVAR(_opcode_has_arg__doc__,
153 "has_arg($module, /, opcode)\n"
154 "--\n"
155 "\n"
156 "Return True if the opcode uses its oparg, False otherwise.");
157
158 #define _OPCODE_HAS_ARG_METHODDEF \
159 {"has_arg", _PyCFunction_CAST(_opcode_has_arg), METH_FASTCALL|METH_KEYWORDS, _opcode_has_arg__doc__},
160
161 static int
162 _opcode_has_arg_impl(PyObject *module, int opcode);
163
164 static PyObject *
165 _opcode_has_arg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
166 {
167 PyObject *return_value = NULL;
168 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
169
170 #define NUM_KEYWORDS 1
171 static struct {
172 PyGC_Head _this_is_not_used;
173 PyObject_VAR_HEAD
174 PyObject *ob_item[NUM_KEYWORDS];
175 } _kwtuple = {
176 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
177 .ob_item = { &_Py_ID(opcode), },
178 };
179 #undef NUM_KEYWORDS
180 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
181
182 #else // !Py_BUILD_CORE
183 # define KWTUPLE NULL
184 #endif // !Py_BUILD_CORE
185
186 static const char * const _keywords[] = {"opcode", NULL};
187 static _PyArg_Parser _parser = {
188 .keywords = _keywords,
189 .fname = "has_arg",
190 .kwtuple = KWTUPLE,
191 };
192 #undef KWTUPLE
193 PyObject *argsbuf[1];
194 int opcode;
195 int _return_value;
196
197 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
198 if (!args) {
199 goto exit;
200 }
201 opcode = PyLong_AsInt(args[0]);
202 if (opcode == -1 && PyErr_Occurred()) {
203 goto exit;
204 }
205 _return_value = _opcode_has_arg_impl(module, opcode);
206 if ((_return_value == -1) && PyErr_Occurred()) {
207 goto exit;
208 }
209 return_value = PyBool_FromLong((long)_return_value);
210
211 exit:
212 return return_value;
213 }
214
215 PyDoc_STRVAR(_opcode_has_const__doc__,
216 "has_const($module, /, opcode)\n"
217 "--\n"
218 "\n"
219 "Return True if the opcode accesses a constant, False otherwise.");
220
221 #define _OPCODE_HAS_CONST_METHODDEF \
222 {"has_const", _PyCFunction_CAST(_opcode_has_const), METH_FASTCALL|METH_KEYWORDS, _opcode_has_const__doc__},
223
224 static int
225 _opcode_has_const_impl(PyObject *module, int opcode);
226
227 static PyObject *
228 _opcode_has_const(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
229 {
230 PyObject *return_value = NULL;
231 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
232
233 #define NUM_KEYWORDS 1
234 static struct {
235 PyGC_Head _this_is_not_used;
236 PyObject_VAR_HEAD
237 PyObject *ob_item[NUM_KEYWORDS];
238 } _kwtuple = {
239 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
240 .ob_item = { &_Py_ID(opcode), },
241 };
242 #undef NUM_KEYWORDS
243 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
244
245 #else // !Py_BUILD_CORE
246 # define KWTUPLE NULL
247 #endif // !Py_BUILD_CORE
248
249 static const char * const _keywords[] = {"opcode", NULL};
250 static _PyArg_Parser _parser = {
251 .keywords = _keywords,
252 .fname = "has_const",
253 .kwtuple = KWTUPLE,
254 };
255 #undef KWTUPLE
256 PyObject *argsbuf[1];
257 int opcode;
258 int _return_value;
259
260 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
261 if (!args) {
262 goto exit;
263 }
264 opcode = PyLong_AsInt(args[0]);
265 if (opcode == -1 && PyErr_Occurred()) {
266 goto exit;
267 }
268 _return_value = _opcode_has_const_impl(module, opcode);
269 if ((_return_value == -1) && PyErr_Occurred()) {
270 goto exit;
271 }
272 return_value = PyBool_FromLong((long)_return_value);
273
274 exit:
275 return return_value;
276 }
277
278 PyDoc_STRVAR(_opcode_has_name__doc__,
279 "has_name($module, /, opcode)\n"
280 "--\n"
281 "\n"
282 "Return True if the opcode accesses an attribute by name, False otherwise.");
283
284 #define _OPCODE_HAS_NAME_METHODDEF \
285 {"has_name", _PyCFunction_CAST(_opcode_has_name), METH_FASTCALL|METH_KEYWORDS, _opcode_has_name__doc__},
286
287 static int
288 _opcode_has_name_impl(PyObject *module, int opcode);
289
290 static PyObject *
291 _opcode_has_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
292 {
293 PyObject *return_value = NULL;
294 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
295
296 #define NUM_KEYWORDS 1
297 static struct {
298 PyGC_Head _this_is_not_used;
299 PyObject_VAR_HEAD
300 PyObject *ob_item[NUM_KEYWORDS];
301 } _kwtuple = {
302 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
303 .ob_item = { &_Py_ID(opcode), },
304 };
305 #undef NUM_KEYWORDS
306 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
307
308 #else // !Py_BUILD_CORE
309 # define KWTUPLE NULL
310 #endif // !Py_BUILD_CORE
311
312 static const char * const _keywords[] = {"opcode", NULL};
313 static _PyArg_Parser _parser = {
314 .keywords = _keywords,
315 .fname = "has_name",
316 .kwtuple = KWTUPLE,
317 };
318 #undef KWTUPLE
319 PyObject *argsbuf[1];
320 int opcode;
321 int _return_value;
322
323 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
324 if (!args) {
325 goto exit;
326 }
327 opcode = PyLong_AsInt(args[0]);
328 if (opcode == -1 && PyErr_Occurred()) {
329 goto exit;
330 }
331 _return_value = _opcode_has_name_impl(module, opcode);
332 if ((_return_value == -1) && PyErr_Occurred()) {
333 goto exit;
334 }
335 return_value = PyBool_FromLong((long)_return_value);
336
337 exit:
338 return return_value;
339 }
340
341 PyDoc_STRVAR(_opcode_has_jump__doc__,
342 "has_jump($module, /, opcode)\n"
343 "--\n"
344 "\n"
345 "Return True if the opcode has a jump target, False otherwise.");
346
347 #define _OPCODE_HAS_JUMP_METHODDEF \
348 {"has_jump", _PyCFunction_CAST(_opcode_has_jump), METH_FASTCALL|METH_KEYWORDS, _opcode_has_jump__doc__},
349
350 static int
351 _opcode_has_jump_impl(PyObject *module, int opcode);
352
353 static PyObject *
354 _opcode_has_jump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
355 {
356 PyObject *return_value = NULL;
357 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
358
359 #define NUM_KEYWORDS 1
360 static struct {
361 PyGC_Head _this_is_not_used;
362 PyObject_VAR_HEAD
363 PyObject *ob_item[NUM_KEYWORDS];
364 } _kwtuple = {
365 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
366 .ob_item = { &_Py_ID(opcode), },
367 };
368 #undef NUM_KEYWORDS
369 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
370
371 #else // !Py_BUILD_CORE
372 # define KWTUPLE NULL
373 #endif // !Py_BUILD_CORE
374
375 static const char * const _keywords[] = {"opcode", NULL};
376 static _PyArg_Parser _parser = {
377 .keywords = _keywords,
378 .fname = "has_jump",
379 .kwtuple = KWTUPLE,
380 };
381 #undef KWTUPLE
382 PyObject *argsbuf[1];
383 int opcode;
384 int _return_value;
385
386 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
387 if (!args) {
388 goto exit;
389 }
390 opcode = PyLong_AsInt(args[0]);
391 if (opcode == -1 && PyErr_Occurred()) {
392 goto exit;
393 }
394 _return_value = _opcode_has_jump_impl(module, opcode);
395 if ((_return_value == -1) && PyErr_Occurred()) {
396 goto exit;
397 }
398 return_value = PyBool_FromLong((long)_return_value);
399
400 exit:
401 return return_value;
402 }
403
404 PyDoc_STRVAR(_opcode_has_free__doc__,
405 "has_free($module, /, opcode)\n"
406 "--\n"
407 "\n"
408 "Return True if the opcode accesses a free variable, False otherwise.\n"
409 "\n"
410 "Note that \'free\' in this context refers to names in the current scope\n"
411 "that are referenced by inner scopes or names in outer scopes that are\n"
412 "referenced from this scope. It does not include references to global\n"
413 "or builtin scopes.");
414
415 #define _OPCODE_HAS_FREE_METHODDEF \
416 {"has_free", _PyCFunction_CAST(_opcode_has_free), METH_FASTCALL|METH_KEYWORDS, _opcode_has_free__doc__},
417
418 static int
419 _opcode_has_free_impl(PyObject *module, int opcode);
420
421 static PyObject *
422 _opcode_has_free(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
423 {
424 PyObject *return_value = NULL;
425 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
426
427 #define NUM_KEYWORDS 1
428 static struct {
429 PyGC_Head _this_is_not_used;
430 PyObject_VAR_HEAD
431 PyObject *ob_item[NUM_KEYWORDS];
432 } _kwtuple = {
433 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
434 .ob_item = { &_Py_ID(opcode), },
435 };
436 #undef NUM_KEYWORDS
437 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
438
439 #else // !Py_BUILD_CORE
440 # define KWTUPLE NULL
441 #endif // !Py_BUILD_CORE
442
443 static const char * const _keywords[] = {"opcode", NULL};
444 static _PyArg_Parser _parser = {
445 .keywords = _keywords,
446 .fname = "has_free",
447 .kwtuple = KWTUPLE,
448 };
449 #undef KWTUPLE
450 PyObject *argsbuf[1];
451 int opcode;
452 int _return_value;
453
454 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
455 if (!args) {
456 goto exit;
457 }
458 opcode = PyLong_AsInt(args[0]);
459 if (opcode == -1 && PyErr_Occurred()) {
460 goto exit;
461 }
462 _return_value = _opcode_has_free_impl(module, opcode);
463 if ((_return_value == -1) && PyErr_Occurred()) {
464 goto exit;
465 }
466 return_value = PyBool_FromLong((long)_return_value);
467
468 exit:
469 return return_value;
470 }
471
472 PyDoc_STRVAR(_opcode_has_local__doc__,
473 "has_local($module, /, opcode)\n"
474 "--\n"
475 "\n"
476 "Return True if the opcode accesses a local variable, False otherwise.");
477
478 #define _OPCODE_HAS_LOCAL_METHODDEF \
479 {"has_local", _PyCFunction_CAST(_opcode_has_local), METH_FASTCALL|METH_KEYWORDS, _opcode_has_local__doc__},
480
481 static int
482 _opcode_has_local_impl(PyObject *module, int opcode);
483
484 static PyObject *
485 _opcode_has_local(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
486 {
487 PyObject *return_value = NULL;
488 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
489
490 #define NUM_KEYWORDS 1
491 static struct {
492 PyGC_Head _this_is_not_used;
493 PyObject_VAR_HEAD
494 PyObject *ob_item[NUM_KEYWORDS];
495 } _kwtuple = {
496 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
497 .ob_item = { &_Py_ID(opcode), },
498 };
499 #undef NUM_KEYWORDS
500 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
501
502 #else // !Py_BUILD_CORE
503 # define KWTUPLE NULL
504 #endif // !Py_BUILD_CORE
505
506 static const char * const _keywords[] = {"opcode", NULL};
507 static _PyArg_Parser _parser = {
508 .keywords = _keywords,
509 .fname = "has_local",
510 .kwtuple = KWTUPLE,
511 };
512 #undef KWTUPLE
513 PyObject *argsbuf[1];
514 int opcode;
515 int _return_value;
516
517 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
518 if (!args) {
519 goto exit;
520 }
521 opcode = PyLong_AsInt(args[0]);
522 if (opcode == -1 && PyErr_Occurred()) {
523 goto exit;
524 }
525 _return_value = _opcode_has_local_impl(module, opcode);
526 if ((_return_value == -1) && PyErr_Occurred()) {
527 goto exit;
528 }
529 return_value = PyBool_FromLong((long)_return_value);
530
531 exit:
532 return return_value;
533 }
534
535 PyDoc_STRVAR(_opcode_has_exc__doc__,
536 "has_exc($module, /, opcode)\n"
537 "--\n"
538 "\n"
539 "Return True if the opcode sets an exception handler, False otherwise.");
540
541 #define _OPCODE_HAS_EXC_METHODDEF \
542 {"has_exc", _PyCFunction_CAST(_opcode_has_exc), METH_FASTCALL|METH_KEYWORDS, _opcode_has_exc__doc__},
543
544 static int
545 _opcode_has_exc_impl(PyObject *module, int opcode);
546
547 static PyObject *
548 _opcode_has_exc(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
549 {
550 PyObject *return_value = NULL;
551 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
552
553 #define NUM_KEYWORDS 1
554 static struct {
555 PyGC_Head _this_is_not_used;
556 PyObject_VAR_HEAD
557 PyObject *ob_item[NUM_KEYWORDS];
558 } _kwtuple = {
559 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
560 .ob_item = { &_Py_ID(opcode), },
561 };
562 #undef NUM_KEYWORDS
563 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
564
565 #else // !Py_BUILD_CORE
566 # define KWTUPLE NULL
567 #endif // !Py_BUILD_CORE
568
569 static const char * const _keywords[] = {"opcode", NULL};
570 static _PyArg_Parser _parser = {
571 .keywords = _keywords,
572 .fname = "has_exc",
573 .kwtuple = KWTUPLE,
574 };
575 #undef KWTUPLE
576 PyObject *argsbuf[1];
577 int opcode;
578 int _return_value;
579
580 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
581 if (!args) {
582 goto exit;
583 }
584 opcode = PyLong_AsInt(args[0]);
585 if (opcode == -1 && PyErr_Occurred()) {
586 goto exit;
587 }
588 _return_value = _opcode_has_exc_impl(module, opcode);
589 if ((_return_value == -1) && PyErr_Occurred()) {
590 goto exit;
591 }
592 return_value = PyBool_FromLong((long)_return_value);
593
594 exit:
595 return return_value;
596 }
597
598 PyDoc_STRVAR(_opcode_get_specialization_stats__doc__,
599 "get_specialization_stats($module, /)\n"
600 "--\n"
601 "\n"
602 "Return the specialization stats");
603
604 #define _OPCODE_GET_SPECIALIZATION_STATS_METHODDEF \
605 {"get_specialization_stats", (PyCFunction)_opcode_get_specialization_stats, METH_NOARGS, _opcode_get_specialization_stats__doc__},
606
607 static PyObject *
608 _opcode_get_specialization_stats_impl(PyObject *module);
609
610 static PyObject *
611 _opcode_get_specialization_stats(PyObject *module, PyObject *Py_UNUSED(ignored))
612 {
613 return _opcode_get_specialization_stats_impl(module);
614 }
615
616 PyDoc_STRVAR(_opcode_get_nb_ops__doc__,
617 "get_nb_ops($module, /)\n"
618 "--\n"
619 "\n"
620 "Return array of symbols of binary ops.\n"
621 "\n"
622 "Indexed by the BINARY_OP oparg value.");
623
624 #define _OPCODE_GET_NB_OPS_METHODDEF \
625 {"get_nb_ops", (PyCFunction)_opcode_get_nb_ops, METH_NOARGS, _opcode_get_nb_ops__doc__},
626
627 static PyObject *
628 _opcode_get_nb_ops_impl(PyObject *module);
629
630 static PyObject *
631 _opcode_get_nb_ops(PyObject *module, PyObject *Py_UNUSED(ignored))
632 {
633 return _opcode_get_nb_ops_impl(module);
634 }
635
636 PyDoc_STRVAR(_opcode_get_intrinsic1_descs__doc__,
637 "get_intrinsic1_descs($module, /)\n"
638 "--\n"
639 "\n"
640 "Return a list of names of the unary intrinsics.");
641
642 #define _OPCODE_GET_INTRINSIC1_DESCS_METHODDEF \
643 {"get_intrinsic1_descs", (PyCFunction)_opcode_get_intrinsic1_descs, METH_NOARGS, _opcode_get_intrinsic1_descs__doc__},
644
645 static PyObject *
646 _opcode_get_intrinsic1_descs_impl(PyObject *module);
647
648 static PyObject *
649 _opcode_get_intrinsic1_descs(PyObject *module, PyObject *Py_UNUSED(ignored))
650 {
651 return _opcode_get_intrinsic1_descs_impl(module);
652 }
653
654 PyDoc_STRVAR(_opcode_get_intrinsic2_descs__doc__,
655 "get_intrinsic2_descs($module, /)\n"
656 "--\n"
657 "\n"
658 "Return a list of names of the binary intrinsics.");
659
660 #define _OPCODE_GET_INTRINSIC2_DESCS_METHODDEF \
661 {"get_intrinsic2_descs", (PyCFunction)_opcode_get_intrinsic2_descs, METH_NOARGS, _opcode_get_intrinsic2_descs__doc__},
662
663 static PyObject *
664 _opcode_get_intrinsic2_descs_impl(PyObject *module);
665
666 static PyObject *
667 _opcode_get_intrinsic2_descs(PyObject *module, PyObject *Py_UNUSED(ignored))
668 {
669 return _opcode_get_intrinsic2_descs_impl(module);
670 }
671
672 PyDoc_STRVAR(_opcode_get_executor__doc__,
673 "get_executor($module, /, code, offset)\n"
674 "--\n"
675 "\n"
676 "Return the executor object at offset in code if exists, None otherwise.");
677
678 #define _OPCODE_GET_EXECUTOR_METHODDEF \
679 {"get_executor", _PyCFunction_CAST(_opcode_get_executor), METH_FASTCALL|METH_KEYWORDS, _opcode_get_executor__doc__},
680
681 static PyObject *
682 _opcode_get_executor_impl(PyObject *module, PyObject *code, int offset);
683
684 static PyObject *
685 _opcode_get_executor(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
686 {
687 PyObject *return_value = NULL;
688 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
689
690 #define NUM_KEYWORDS 2
691 static struct {
692 PyGC_Head _this_is_not_used;
693 PyObject_VAR_HEAD
694 PyObject *ob_item[NUM_KEYWORDS];
695 } _kwtuple = {
696 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
697 .ob_item = { &_Py_ID(code), &_Py_ID(offset), },
698 };
699 #undef NUM_KEYWORDS
700 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
701
702 #else // !Py_BUILD_CORE
703 # define KWTUPLE NULL
704 #endif // !Py_BUILD_CORE
705
706 static const char * const _keywords[] = {"code", "offset", NULL};
707 static _PyArg_Parser _parser = {
708 .keywords = _keywords,
709 .fname = "get_executor",
710 .kwtuple = KWTUPLE,
711 };
712 #undef KWTUPLE
713 PyObject *argsbuf[2];
714 PyObject *code;
715 int offset;
716
717 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
718 if (!args) {
719 goto exit;
720 }
721 code = args[0];
722 offset = PyLong_AsInt(args[1]);
723 if (offset == -1 && PyErr_Occurred()) {
724 goto exit;
725 }
726 return_value = _opcode_get_executor_impl(module, code, offset);
727
728 exit:
729 return return_value;
730 }
731 /*[clinic end generated code: output=2dbb31b041b49c8f input=a9049054013a1b77]*/