aboutsummaryrefslogtreecommitdiff
path: root/parse.py
AgeCommit message (Collapse)AuthorFilesLines
2024-12-20Use argparse for argument parsing (#331)Andrew Waterman1-29/+60
This is more maintainable and scalable and gives better errors and a nice `--help` message. The interface is compatible with the previous version. Co-authored-by: Tim Hutt <timothy.hutt@codasip.com>
2024-12-20Sort JSON output (#315)Tim Hutt1-3/+3
If we're sorting the dictionary anyway we may as well output the JSON sorted. Also since Python 3.6 we can just use `dict()` since the insertion order is preserved.
2024-11-05Enable Pylint in CI and fix its errors (#311)Tim Hutt1-1/+1
* Remove wildcard imports Use explicit imports rather than wildcards. This is more maintainable. * Enable Pylint in CI and fix its errors The main fixes were: * Specify encoding for all file opens. By default it depends on environment variables which is bad. * Use `with` to open files. Otherwise they don't necessarily get closed. There were also a few minor things like using `enumerate`, not using objects as default arguments, etc. In some cases I slightly refactored the code.
2024-10-31Add static type hintsTim Hutt1-9/+14
This makes the code easier to understand and navigate, and also detected a few of bugs: 1. Missing brackets on e.upper. (Fixed) 2. Not strictly related to types, but a lot of the regexes were not raw strings and therefore contained invalid escape sequences. Python prints a warning about these in recent versions. (Fixed) 3. Expression in `process_pseudo_instructions()` that is always false. (Not fixed) 4. Missing definition of `log_and_exit()`. (Fixed) This is validated via pre-commit in CI.
2024-10-31Generate JSON instead of YAMLTim Hutt1-4/+3
Previously this generate a `instr_dict.yaml` file, however there is no need to use YAML here. The only advantages of YAML over JSON are that it is (debatably) easier for humans to write, making it suitable as human-edited input files. This is a machine-generated output file so JSON is better. The main advantages are: 1. It removes the dependency on PyYAML, which is the only external dependency of this project. Python external dependencies are quite a pain - PyYAML is a particularly troublesome one - and having no dependencies is very convenient (no need for venv etc.). 2. It means consumers of the file don't need to depend on PyYAML. Note this could have been done in an 100% backwards compatible way by keeping the file name unchanged (since JSON is valid YAML), however I figured there probably aren't that many users of this file, and since the only thing they need to change is the filename it's probably better to minimise confusion by renaming it. It also makes it clear that it is guaranteed to be JSON.
2024-10-27Minor simplification of Python booleanTim Hutt1-3/+1
2024-10-27optimized the for loop for extensions and targets usageIIITM-Jay1-4/+5
2024-10-27added pseudo flagIIITM-Jay1-2/+11
2024-10-25clean up codes for refactoring parsing logicIIITM-Jay1-107/+54
2024-10-20Pre commit FixesIIITM-Jay1-1/+1
2024-10-20Merge branch 'master' into latex-based-output-refactorJay Dev Jha1-1/+1
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
2024-10-11rectified issues for parsing correctlyJay Dev Jha1-1/+1
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
2024-10-09removed walrus operatorIIITM-Jay1-42/+57
2024-10-09Split hinval.vvma and hinval.gvma from rv_svinval to rv_svinval_hXuan Hu1-1/+1
Because hinval.vvma and hinval.gvma can only be used legally when both Svinval and H extensions are supported, move them out from rv_svinval to rv_svinval_h.
2024-10-05Apply pre-commit fixesTim Hutt1-336/+486
2024-10-01Avoid use of walrus operator for python 3.6 compatibilityAndrew Waterman1-1/+2
2024-09-30Move INSN_FIELD sanitation to appropriate placeAndrew Waterman1-4/+2
The global search-and-replace is a bit worrisome.
2024-09-30Rename _EQU_ to _EQ_ in INSN_FIELD_RS2_EQU_RS1Andrew Waterman1-1/+1
2024-09-30Solve issue #284Afonso Oliveira1-4/+11
2024-09-17Refactored and Optimized Logic:: Parser Logic, Latex Based Output & Shared ↵IIITM-Jay1-1081/+101
Modules
2024-08-31Added Distinction between Instructions and Pseudo-instructions with the same ↵Afonso Oliveira1-4/+7
name. (JAL and JALR case) Signed-off-by: Afonso Oliveira <Afonso.Oliveira@synopsys.com>
2024-08-28Added Pseudo-instructions from F and D. Allow for instructions to have a ↵Afonso Oliveira1-9/+20
special field Signed-off-by: Afonso Oliveira <Afonso.Oliveira@synopsys.com>
2024-07-31Expand nf fields in instr_dict.yamlMilosz Moscicki1-1/+34
parse.py has been edited to expand nf field for segmented vector load store instructions. For backwards compatibility this only applies to instr_dict.yaml.
2024-07-17[Fix] Fix Missing Extensions in Pseudo InstructionsNyembezi Nyirongo1-0/+7
- Added code to extend the extension list of a pseudo instruction in the YAML output - This ensures that all the extensions that a pseudo instruction can belong to are listed - This is in line with what happens for regular and imported instructions - No changes to all other output types
2024-07-15Merge pull request #258 from moscickimilosz/parse_windows_fixAndrew Waterman1-3/+3
Fix python script on windows
2024-07-14Eliminate SyntaxWarning: invalid escape sequence '\s'xyyy14201-2/+2
Signed-off-by: xyyy1420 <xyyy1420@gmail.com>
2024-07-09Fix python script on windowsMilosz Moscicki1-3/+3
Instead of splitting string by '/' to get filename, use os.path.basename
2024-06-27Include rs1 values in Go instruction opcodes. (#254)Joel Sing1-1/+3
Some of the instructions in the V extension encode part of the opcode in the rs1 field. These values are not currently included in the Go instruction opcodes - fix this by adding an rs1 field and populating it with the relevant values.
2024-05-15Fix typos in parse.py (#247)Patrick Yingxi Pan1-3/+3
Signed-off-by: Patrick Yingxi Pan <patrick-yingxi-pan@users.noreply.github.com>
2024-05-01Correctly detect overlapping encodingsAndrew Waterman1-11/+34
A regression introduced a few years ago prevented detecting partially overlapping encodings; instead, we only detected exact matches. Now, we detect the partial cases. We now need to maintain two allowlists (overlapping_extensions and overlapping_instructions) for the cases that extensions and/or instructions overlap by design.
2024-05-01Remove RV128 for nowAndrew Waterman1-3/+1
It is highly speculative at this point, but it adds maintenance burden.
2023-05-02Merge pull request #167 from Lucas-Wye/masterNeel Gala1-2/+28
change decode generation part of chisel
2023-05-01Support for Zvk, Vector Cryptography ExtensionsEric Gouriou1-4/+1
Add encodings for all instructions in the Zvk extensions: - Zvbb, Vector Bit-manipulation instructions used in Cryptography, - Zvbc, Vector Carryless Multiplication - Zvkg, Vector GCM/GMAC instruction for Cryptography, - Zvkned, NIST Suite: Vector AES Encryption & Decryption (Single Round), - Zvknha, Zvknhb, NIST Suite: Vector SHA-2, - Zvksed, ShangMi Suite: SM4 Block Cipher Instructions - Zvkssh, ShangMi Suite: SM3 Hash Function Instructions Add two "shorthand" extensions: - Zvkn: NIST Suite, imports Zvbb, Zvbc, Zvkned, and Zvknh - Zvks: ShangMi Suite, imports Zvbb, Zvbc, Zvksed, and Zvksh Three new fields are listed in constants.py: - 'zimm5', used to encode round constants (Zvkns, Zvksed, Zvksh), and 5-bit shift constant (vwsll.vi in Zvbb) - 'zimm6hi, zimm6lo', used to encode the 6 bits rotate amount in vror.vi. The Zvk instructions – with the exception of Zvbb, Zvbc – reside in the P opcode space. Some encodings conflict with proposed instructions in the P extension (packed SIMD). Zvk and P are exclusive of each other, no implementation will implement both. Conflicting P instructions are marked as pseudo of the Zvk instructions. The encodings match the current documentation of the specification at <https://github.com/riscv/riscv-crypto/tree/master/doc/vector>, at Version v0.9.1, 25 April, 2023 (Freeze Candidate). Co-authored-by: Eric Gouriou <ego@rivosinc.com> Co-authored-by: Stanislaw Kardach <kda@semihalf.com> Co-authored-by: Kornel Duleba <mindal@semihalf.com> Co-authored-by: Raghav Gupta <rgupta@rivosinc.com> Signed-off-by: Eric Gouriou <ego@rivosinc.com>
2023-04-07Fix merging of instructions with the same namedramforever1-6/+8
Fixes generation of 'extension' field for instr_dict.yaml
2023-03-17use val instead of defLucas-Wye1-5/+1
2023-03-10change the generation part of chiselLucas-Wye1-2/+32
2023-01-26Update encoding.h.out's copyright year.Aaron Durbin1-1/+1
It's a new year. Make the copyright clause reflect 2023.
2023-01-14indenting logs for better readabilityNeel Gala1-2/+2
2023-01-14fix regex fpr pseudo op lookup to ensure that we don't hit on substringsNeel Gala1-1/+1
2023-01-12Emit SLLI_RV128 etc. (and SLLI_RV32 etc. while we're at it)Andrew Waterman1-1/+4
2023-01-04Update READMEBabu P S1-2/+2
2022-10-05support import parse.py from other python script.Jiuyang Liu1-14/+16
This PR changes opcodes_dir to the REAL path of parse.py. It helps python scripts which depends on parse.py can be stored in other place, using PYTHONPAT or sys.path to import from riscv-opcodes/parse.
2022-08-28Make path to encoding.h relative to script (#141)Florian Zaruba1-1/+1
That allows for running the script out-of-tree. Signed-off-by: Florian Zaruba <florian@zaruba.email> Signed-off-by: Florian Zaruba <florian@zaruba.email>
2022-08-23Add copyright holder to the generated file (#140)Antonio Borneo1-0/+2
The BSD-3-Clause license mentions a copyright notice that has to be retained while redistributing the source code. Copy the copyright notice from LICENSE file to the script, so it get in the generated file. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-18Change to BSD-3-Clause license, and copyright holder. (#139)Tim Newsome1-1/+1
This removes the language about patents that was added in #133. Change copyright holder to RISC-V International.
2022-08-04fix extension merge and add name and encoding conflict checking (#116)Lehua Ding1-5/+33
* fix extension merge and add name and encoding conflict checking * fix comments * uniform code's indentation
2022-07-22Move the SPDX tag to the first line (#137)Antonio Borneo1-4/+6
Linux kernel coding style requires the SPDX tag to be placed in the very first line of the generated file. See kernel file Documentation/process/license-rules.rst at chapter 'License identifier syntax', '1. Placement:'. Move the SPDX tag in the python script. While there, adjust also the style of the multi-line comment. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-06-10Fix incorrect encoding output in instr_dict.yaml. (#127)Kieran Siek1-1/+1
Making a shallow copy of the list prevents updating the final encoding output when checking for field overlap. Incorrect: encoding: 0000000rs2rs2rs2rs2rs2rs1rs1rs1rs1rs1000rdrdrdrdrd0110011 Correct: encoding: 0000000----------000-----0110011
2022-06-09provide a list of pseudo ops that need to be included in the instruction dictNeel Gala1-4/+10
specifically done to handle encoding.out.h that is being used by spike
2022-06-09improve logging statementsNeel Gala1-3/+3