You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jkchandalia thanks! It would be nice for me if this can make it in before the 3.12 feature freeze (May 8), since #103764 relies heavily on intrinsics, so this feature will make the bytecode generated by that PR much easier to understand. If that timeline is too tight for you, I'm happy to have a go at implementing this myself.
I added two lists to opcode.py for the intrinsics names (I added an extra option for not valid, not sure if this is needed)
I use these lists in dis.py to get the argrepr to pass to the Instruction class.
I added tests for args 2, 5, and 6 for CALL_INTRINSIC_1 and updated an existing test for arg 3. I put the three new tests into one test function but can split out if better. I had some trouble getting something to trigger the other codes (0?, 1, 4) and also CALL_INTRINSIC_2 for additional testing.
I updated /Tools/build/generate_opcode_h.py to include the new intrinsic names sections (not sure if this is desired?)
I regenerated opcode.h with the new intrinsics-related sections
I could definitely write the code to generate pycore_intrinsics.h as you suggested but I wasn’t quite sure where to put it? A separate script or another internal file output from /Tools/build/generate_opcode_h.py or something else?
I don't think it's necessary to test every single one of the intrinsics in test_dis.
I would suggest simply expanding generate_opcode_h.py to also generate pycore_intrinsics.h. It already generates multiple files, so it doesn't seem too bad to make it generate another closely related file. We'll add a header to pycore_intrinsics.h to make it clear how it is generated. Perhaps @iritkatriel has a different opinion, though. We definitely shouldn't add the intrinsics to opcode.h, as that's a public header file and we don't want the intrinsics to be part of the public API.
Activity
iritkatriel commentedon Apr 28, 2023
@jkchandalia are you interested in this?
jkchandalia commentedon Apr 28, 2023
@iritkatriel I can work on this.
iritkatriel commentedon Apr 28, 2023
Great. Have a look at /Tools/build/generate_opcode_h.py
(re generating the .h file).
iritkatriel commentedon Apr 28, 2023
Use
make regen-opcodeto run this script.JelleZijlstra commentedon Apr 28, 2023
@jkchandalia thanks! It would be nice for me if this can make it in before the 3.12 feature freeze (May 8), since #103764 relies heavily on intrinsics, so this feature will make the bytecode generated by that PR much easier to understand. If that timeline is too tight for you, I'm happy to have a go at implementing this myself.
jkchandalia commentedon Apr 28, 2023
@JelleZijlstra that timeline is fine for me.
JelleZijlstra commentedon Apr 28, 2023
Great! Let me know if you need any help.
FYI I think these are some of the easiest ways to trigger intrinsics on current main for testing:
jkchandalia commentedon Apr 28, 2023
Absolutely, thank you. And I appreciate the examples.
jkchandalia commentedon Apr 30, 2023
@JelleZijlstra I've pushed my branch (https://github.com/jkchandalia/cpython/tree/display_intrinsics_names) and I wasn't quite sure if it's ready for a PR but can definitely open one if that's easier for feedback/discussion.
opcode.pyfor the intrinsics names (I added an extra option for not valid, not sure if this is needed)dis.pyto get theargreprto pass to theInstructionclass.CALL_INTRINSIC_1and updated an existing test for arg 3. I put the three new tests into one test function but can split out if better. I had some trouble getting something to trigger the other codes (0?, 1, 4) and alsoCALL_INTRINSIC_2for additional testing./Tools/build/generate_opcode_h.pyto include the new intrinsic names sections (not sure if this is desired?)opcode.hwith the new intrinsics-related sectionspycore_intrinsics.has you suggested but I wasn’t quite sure where to put it? A separate script or another internal file output from/Tools/build/generate_opcode_h.pyor something else?JelleZijlstra commentedon Apr 30, 2023
Looks great! Feel free to open a draft PR and we can get it over the finish line.
You can get the CALL_INTRINSIC_2 with
except*(position 38):I don't think it's necessary to test every single one of the intrinsics in test_dis.
I would suggest simply expanding
generate_opcode_h.pyto also generatepycore_intrinsics.h. It already generates multiple files, so it doesn't seem too bad to make it generate another closely related file. We'll add a header topycore_intrinsics.hto make it clear how it is generated. Perhaps @iritkatriel has a different opinion, though. We definitely shouldn't add the intrinsics toopcode.h, as that's a public header file and we don't want the intrinsics to be part of the public API.iritkatriel commentedon Apr 30, 2023
Sounds good.
GH-103963: Make dis display names of args for intrinsics opcodes (#10…
JelleZijlstra commentedon May 3, 2023
Thanks for your contribution @jkchandalia!
pythongh-103963: fix 'make regen-opcode' in out-of-tree builds
gh-103963: fix 'make regen-opcode' in out-of-tree builds (#104177)
Merge branch 'main' into inlinecomp2