-
Notifications
You must be signed in to change notification settings - Fork 300
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
Refactored and Optimized Logic:: Parser Logic, Latex Based Output & Shared Modules #283
base: master
Are you sure you want to change the base?
Conversation
Hi @aswaterman and @rpsene, I have made an attempt to refactor the The test cases are failing as we need to modify the Requesting feedback on the modified code and suggestions on what best we can do to achieve maintainability and scalability. |
Hi @aswaterman, in addition to the written explanation of the parsing logic inside "Flow of Like, we have three main steps with each having sequence of procedures: flowchart TD
A[Start: parse.py] --> B[Create list of all rv* files]
B --> C{File contains regular instructions?}
C -->|Yes| D[Parse file line by line]
D --> E[Perform checks on regular instructions]
E --> F[Check 1: msb > lsb in range assignment]
E --> G[Check 2: Value representable in range]
E --> H[Check 3: No multiple assignments to same bit]
E --> I[Check 4: All bit positions must be accounted for]
F --> J[Pass checks?]
G --> J
H --> J
I --> J
J -->|Yes| K[Create dictionary for regular instruction]
K --> L[Add encoding, extension, mask, match, variable_fields]
L --> M[Add to instr_dict]
M --> N[Process next regular instruction]
N -->|All regular instructions processed| O[End of Regular Instruction Parsing]
|
2. In the second pass, we do the checks for pseudo_instr carrying out similar procedure. 3. In the last step, the output generation, flowchart TD
A[Start Output Generation] --> B[Generate LaTeX tables]
B --> C[Generate encoding.h file]
C --> D[Generate other artifacts]
D --> E[Output files generated]
E --> F[End]
|
@aswaterman and @rpsene , These flowchart creation process are markdown friendly. I think it will also help to give a nutshell view of what we are doing. Let me know the feedback and suggestions, if these will add up to an enhancement for the existing repository. |
@aswaterman and @rpsene , Refactored and Optimized the method used for creating instruction dictionary. P.S. The second point from Needs to be Done header in PR description is ticked(marked as completed) as of now |
The conflicts arises as after the commit w.r.t walrus operator made in @aswaterman, the walrus operator (:=) is compatible with Python 3.8 and later versions, as it was introduced in Python 3.8, and it allows assignment within an expression, making it useful for situations where we want to assign and evaluate a variable in the same line. So, wanted to know, whether we need to keep in mind with older versions compatibility of Python while doing refactorization and optimization. |
I'll try to provide feedback on this PR soon. To answer the immediate question: if we have good reason to start making extensive use of newer Python features, I have no objections to upgrading, but I did not think that a single use of the walrus operator was a sufficient justification for requiring a newer Python version. |
Signed-off-by: Jay Dev Jha <[email protected]>
Yes, I do agree with this. While going through the files in this repository, I found that the |
You've convinced me that other new features are a good enough justification to move to 3.8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very reasonable refactoring. I presume at this point there will be some merge conflicts with respect to other recent changes to the master branch, but feel free to merge once you've resolved them.
This PR intends to refactor the parse.py to achieve maintainability and scalability.
Scopes Covered
Approach Followed
parse.py
file now contains only the main function where it calls respective scripts for generating the output based on extensions selected.shared_utils.py
so that other scripts can re-use them efficiently. These functions are shared between various extension scriptsLatex
is refactored and optimized inlarex_utils.py
parse.py
andshared_utils.py
are refactored, modularized and optimized as wellNeeds to be done
latex
). They require improvements and enhancements. They are just simply taken fromparse.py
to their modules likec_utils.py
for generating c based outputshared_utils.py
, the methodcreate_inst_dict()
is yet to be refactored.