diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-07-20 16:46:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-20 16:46:04 (GMT) |
commit | 9c81fc2dbee3ac8a2f30ad24b0876d80628a94ac (patch) | |
tree | 74642722ed13a213cfe9b33701b72fb621c2886d /Modules/_opcode.c | |
parent | 214a25dd81dfe5ee0ab843cf665da2a7473a08db (diff) | |
download | cpython-9c81fc2dbee3ac8a2f30ad24b0876d80628a94ac.zip cpython-9c81fc2dbee3ac8a2f30ad24b0876d80628a94ac.tar.gz cpython-9c81fc2dbee3ac8a2f30ad24b0876d80628a94ac.tar.bz2 |
gh-105481: do not auto-generate pycore_intrinsics.h (#106913)
Diffstat (limited to 'Modules/_opcode.c')
-rw-r--r-- | Modules/_opcode.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Modules/_opcode.c b/Modules/_opcode.c index daabdce..b8d95a0 100644 --- a/Modules/_opcode.c +++ b/Modules/_opcode.c @@ -2,6 +2,7 @@ #include "compile.h" #include "opcode.h" #include "internal/pycore_code.h" +#include "internal/pycore_intrinsics.h" /*[clinic input] module _opcode @@ -220,6 +221,60 @@ _opcode_get_specialization_stats_impl(PyObject *module) #endif } +/*[clinic input] + +_opcode.get_intrinsic1_descs + +Return a list of names of the unary intrinsics. +[clinic start generated code]*/ + +static PyObject * +_opcode_get_intrinsic1_descs_impl(PyObject *module) +/*[clinic end generated code: output=bd1ddb6b4447d18b input=13b51c712618459b]*/ +{ + PyObject *list = PyList_New(MAX_INTRINSIC_1 + 1); + if (list == NULL) { + return NULL; + } + for (int i=0; i <= MAX_INTRINSIC_1; i++) { + PyObject *name = _PyUnstable_GetUnaryIntrinsicName(i); + if (name == NULL) { + Py_DECREF(list); + return NULL; + } + PyList_SET_ITEM(list, i, name); + } + return list; +} + + +/*[clinic input] + +_opcode.get_intrinsic2_descs + +Return a list of names of the binary intrinsics. +[clinic start generated code]*/ + +static PyObject * +_opcode_get_intrinsic2_descs_impl(PyObject *module) +/*[clinic end generated code: output=40e62bc27584c8a0 input=e83068f249f5471b]*/ +{ + PyObject *list = PyList_New(MAX_INTRINSIC_2 + 1); + if (list == NULL) { + return NULL; + } + for (int i=0; i <= MAX_INTRINSIC_2; i++) { + PyObject *name = _PyUnstable_GetBinaryIntrinsicName(i); + if (name == NULL) { + Py_DECREF(list); + return NULL; + } + PyList_SET_ITEM(list, i, name); + } + return list; +} + + static PyMethodDef opcode_functions[] = { _OPCODE_STACK_EFFECT_METHODDEF @@ -232,6 +287,8 @@ opcode_functions[] = { _OPCODE_HAS_LOCAL_METHODDEF _OPCODE_HAS_EXC_METHODDEF _OPCODE_GET_SPECIALIZATION_STATS_METHODDEF + _OPCODE_GET_INTRINSIC1_DESCS_METHODDEF + _OPCODE_GET_INTRINSIC2_DESCS_METHODDEF {NULL, NULL, 0, NULL} }; |