Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement target constrained venom jump instruction #3687

Merged
merged 41 commits into from
Dec 21, 2023

Conversation

harkal
Copy link
Collaborator

@harkal harkal commented Dec 12, 2023

What I did

This PR augments the venom jump instruction to require the possible jump targets as arguments when it is jumping to a dynamic location. This removes all the workarounds that we had to implement in the normalization pass and the cfg calculations.

How I did it

I passed the jump table data thought the ir_node to the translator. Then the translator can emit the proper venom instruction.

How to verify it

Commit message

this commit adds a new "djmp" instruction which allows jumping to one of
multiple jump targets. it has been added in both the s-expr IR and venom
IR. this removes the workarounds that we had to implement in the
normalization pass and the cfg calculations.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

adopted a shorted name for frequently used methods
Refactored append instructions into a single append_instruction() method
with named arguments for returning or not a variable
Until now log instructions where pass through. Now we have a log instruction
in venom that takes the first argument to be the topic count
(in shape of doing table jmp etc in the future -essentialy have
instructions that require manipulation of operants before emit)
Remove output argument append_instruction() in IRBasicBlock
now the method decides by itself if there is an output value
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (b0ea5b6) 83.98% compared to head (ecb8ee1) 83.94%.
Report is 2 commits behind head on master.

Files Patch % Lines
vyper/venom/venom_to_assembly.py 0.00% 6 Missing and 2 partials ⚠️
vyper/venom/ir_node_to_venom.py 0.00% 5 Missing ⚠️
vyper/compiler/phases.py 77.77% 0 Missing and 4 partials ⚠️
vyper/venom/passes/normalization.py 78.57% 2 Missing and 1 partial ⚠️
vyper/cli/vyper_compile.py 0.00% 1 Missing and 1 partial ⚠️
vyper/compiler/output.py 0.00% 1 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3687      +/-   ##
==========================================
- Coverage   83.98%   83.94%   -0.05%     
==========================================
  Files          92       92              
  Lines       13046    13056      +10     
  Branches     2928     2932       +4     
==========================================
+ Hits        10957    10960       +3     
- Misses       1657     1663       +6     
- Partials      432      433       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@harkal harkal changed the title Feature/jump table feat: Implement target constrained venom jump instruction Dec 13, 2023
@harkal harkal self-assigned this Dec 13, 2023
@harkal harkal added the Feature label Dec 13, 2023
@harkal harkal marked this pull request as ready for review December 13, 2023 11:11
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this will be cleaner if we have a new dedicated instruction for this (in both IRs) as i want to reduce the amount of things we put in passthrough_metadata as opposed to increasing! it could be jump_indirect (a la LLVM), jumptable, jumpv or switch

@harkal harkal marked this pull request as draft December 13, 2023 15:20
vyper/codegen/core.py Fixed Show fixed Hide fixed
vyper/codegen/core.py Fixed Show fixed Hide fixed
charles-cooper and others added 5 commits December 19, 2023 11:45
- remove experimental codegen flag passing
- rewrite a bit of code in module.py
- add the code generator in old IR
@harkal harkal marked this pull request as ready for review December 20, 2023 11:01
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice -- especially with that new djmp instruction! ;)

@charles-cooper charles-cooper enabled auto-merge (squash) December 21, 2023 00:16
@charles-cooper charles-cooper merged commit 3116e88 into vyperlang:master Dec 21, 2023
84 checks passed
@harkal harkal deleted the feature/jump_table branch December 21, 2023 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants