-
Notifications
You must be signed in to change notification settings - Fork 26
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
LLVM verification #356
base: main
Are you sure you want to change the base?
LLVM verification #356
Conversation
a56b0b1
to
d9b50b2
Compare
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.
I think this is a good start, and is heading in the right direction. Some immediate comments before I look again in the next few days.
Is there anything specific you want feedback on?
Which instructions are you running into issues with so far?
Another overall thought I have is: if this is a test/validation suite, could this be structured using pytest? For instance, you could parse the YAML and the JSON to match up instruction descriptions, and use that to create parameterized fixtures (one instance per matched description) - the advantage of this is that you get all of the niceness of pytest's asserts, and pytest's test suite reports, without having to reimplement all the testcase management. This also makes it easier to split the test code that checks the encoding matches from tests that check the assembly strings match (for example, but we can think of others).
Thanks for your feedback!
Not yet, the point was just some general considerations about the initial approach.
I still didnt find a pattern, but I'll try to fix this soon and if I run into any issue I'm not able to solve by myself, I'll try to bring it up, thanks!
I'll take a look into pytest and see how to port this, thanks for the suggestion! |
current known bugs are:
I'm working on both now. |
Somewhere, a |
ext/auto-inst/parsing.py
Outdated
instr_name = instr_name.lower().strip() | ||
|
||
# Search through all entries in json_data | ||
for key, value in json_data.items(): |
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.
You can use the !instanceof
metadata to only search through things with an encoding, I pointed this out in the comment about the initial approach. This will save you iterating through aliases (and other data like isel patterns)
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.
From what I can see !instanceof
follows this structure, but I'm finding it hard to understand how to use it for the parsing purposes, can you please further explain?
{
"!instanceof": {
"AES_1Arg_Intrinsic": [
"int_arm_neon_aesimc",
"int_arm_neon_aesmc"
],
"AES_2Arg_Intrinsic": [
"int_arm_neon_aesd",
"int_arm_neon_aese"
],
"ALUW_rr": [
"ADDW",
"ADD_UW",
"DIVUW",
"DIVW",
"MULW",
"PACKW",
"REMUW",
"REMW",
"ROLW",
"RORW",
"SH1ADD_UW",
"SH2ADD_UW",
"SH3ADD_UW",
"SLLW",
"SRAW",
"SRLW",
"SUBW"
],
"ALU_ri": [
"ADDI",
"ANDI",
"ORI",
"SLTI",
"SLTIU",
"XORI"
],
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.
So, let's assume you parsed the whole json object, into a python variable called json
.
json["!instanceof"]
is a map, from tablegen classes, to a list of definition names that are instances of that class (or its sub-classes). These definition names appear in the top-level json.
You would use code like the following:
for def_name in json["!instanceof"]["RVInstCommon"]:
def_data = json[def_name]
...
This saves you having to look at all the tablegen data that is not an instruction (so an alias or a pattern or CSR or something).
Note you'll still have to look at isPseudo
and isCodeGenOnly
and potentially exclude items where one or both of those is true.
Unit testing is now working. TODO: |
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
956ad97
to
5992124
Compare
Signed-off-by: Afonso Oliveira <[email protected]>
Can I insert LLVM as a submodule or would this be another licensing problem? |
This is functional. Things missing is how to address LLVM and adding it the test to Rakefile. I will also see how I can optimize code, e.g. what @lenary proposed on one review. |
I highly suggest using environment variables to point to LLVM, and skipping these tests if those environment variables are not set. |
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
Signed-off-by: Afonso Oliveira <[email protected]>
f467578
to
b2748e0
Compare
Signed-off-by: Afonso Oliveira <[email protected]>
@dhower-qc as on out last call was talked, I added LLVM to CI with caching so it doesn't always have to build the table, For local runs, I still kept it optional, it only runs if the user have the file present, is it ok this way? |
Signed-off-by: Afonso Oliveira <[email protected]>
f2d419f
to
40af15d
Compare
Signed-off-by: Afonso Oliveira <[email protected]>
6ca01a7
to
e2a5b73
Compare
Signed-off-by: Afonso Oliveira <[email protected]>
e2a5b73
to
92f9c99
Compare
…he ISA Spec Signed-off-by: Afonso Oliveira <[email protected]>
Sorry for the mess with force pushes, but I had some trouble finding what I was messing up with GH actions caching. However, I believe this PR is ready for merge after #428 is solved and after @dhower-qc and @lenary reviews. |
5eff105
to
af0acae
Compare
Following up on #258.
I've been doing work on what @lenary proposed as a first approach, I think this is an ok first mock-up. Still a WIP since many instructions still have bugs, but if you have any comments or recommendations, please LMK :).
I did not add LLVM as a submodule yet because it may be easier licensing wise to just point at it in the script? Usage is
python3 riscv_parser.py <tablegen_json_file> <arch_inst_directory>")
. I've also used jq to enhance readibility on the output ofllvm-tblgen -I llvm/include -I llvm/lib/Target/RISCV llvm/lib/Target/RISCV/RISCV.td --dump-json -o <path-to-json-output>
.