Port stdarch-gen-loongarch to stdarch-gen-common harness#2178
Conversation
| STDARCH_GEN_MODE: check | ||
| run: | | ||
| cargo run --bin=stdarch-gen-loongarch --release -- crates/stdarch-gen-loongarch/lsx.spec | ||
| cargo run -p stdarch-gen-loongarch --release -- lsx |
There was a problem hiding this comment.
Ultimately, this will still be a bit annoying to replicate in bootstrap, as we have to ensure that we invoke both the right crates, and with the right arguments.
That is not for this PR, but I'd think about merging everything into a single binary that will generate everything, I think that would be easier to work with.
| @@ -1,5 +1,5 @@ | |||
| // This code is automatically generated. DO NOT MODIFY. | |||
| // See crates/stdarch-gen-loongarch/README.md | |||
| // This code is automatically generated. DO NOT MODIFY. | |||
There was a problem hiding this comment.
Since the tests.rs files are not generated using the stdarch-gen-common machinery, let's use a different header for them, to avoid this line moving hack.
By the way, if you regenerate the Loongarch tests.rs files now, are they the same as they committed versions?
There was a problem hiding this comment.
Added a different header . As for regenerating the tests.rs i haven't actually run it. Thank you!
|
cc @heiher |
|
Thanks! LoongArch SIMD intrinsics are being gradually migrated to |
I don't think you can eliminate it entirely. Anyhow this is just a heads-up that we're refactoring it a bit to make it easier to run in |
| let harness_exts: Option<&[&str]> = match args.len() { | ||
| 1 => Some(&["lsx", "lasx"]), | ||
| 2 if args[1] == "lsx" => Some(&["lsx"]), | ||
| 2 if args[1] == "lasx" => Some(&["lasx"]), | ||
| _ => None, | ||
| }; |
There was a problem hiding this comment.
nitpicky but I think this should work
| let harness_exts: Option<&[&str]> = match args.len() { | |
| 1 => Some(&["lsx", "lasx"]), | |
| 2 if args[1] == "lsx" => Some(&["lsx"]), | |
| 2 if args[1] == "lasx" => Some(&["lasx"]), | |
| _ => None, | |
| }; | |
| let harness_exts: Option<&[&str]> = match &args { | |
| [_] => Some(&["lsx", "lasx"]), | |
| [_, "lsx"] => Some(&["lsx"]), | |
| [_, "lasx"] => Some(&["lasx"]), | |
| _ => None, | |
| }; |
| gen_bind(in_file, ext_name) | ||
| return gen_spec(in_file, ext_name).map_err(|e| e.to_string()); | ||
| } | ||
| if args.get(2).is_some() { |
There was a problem hiding this comment.
| if args.get(2).is_some() { | |
| if let [_, _lsx_or_lasx, _some_name_for_what_this_is] = &args { |
I kind of lost what is in args[2] and what it's supposed to indicate.
There was a problem hiding this comment.
args[2] is the literal string "test" it flips this into gen_test mode.
There was a problem hiding this comment.
| if args.get(2).is_some() { | |
| if let [_, _lsx_or_lasx, "test"] = &args { |
is much clearer then.
LoongArch currently generates tests using random input values, with the expected results produced by running them under QEMU. We don't currently fix the random seed, so regenerating the tests produces a different version each time. If maintaining the LoongArch generator is making this work more difficult, another option would be to simply check in the currently generated code and keep them as-is. In any case, most of them are expected to be rewritten eventually. |
This PR ports
stdarch-gen-loongarchtostdarch-gen-commonharness.The change in
maininvokesrun_generatoronce per committed dir when called with no args orlsx/lasx.The CI switches from
-- <spec>to-- lsx/-- lasxwithSTDARCH_GEN_MODE=check.Swapped the first two comment lines of
lsx/tests.rsandlasx/tests.rsso the auto-generated marker moves to line 2 . Sodiscover_ownedonly checks the first line and makes the harness skiptests.rswhich is not produced bystdarch-gen-loongarch.r? @folkertdev