-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add loongarch64 asm! support #101069
Add loongarch64 asm! support #101069
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cjgillot (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
edefffb
to
f3fcaf1
Compare
Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo |
This comment has been minimized.
This comment has been minimized.
As it's related to asm, @Amanieu could you take a look? |
LGTM but this needs tests in src/test/assembly/asm. |
f3fcaf1
to
8dbc47d
Compare
This comment has been minimized.
This comment has been minimized.
src/test/assembly/asm/loongarch-type.rs generates the corresponding assembly file: loongarch-type.s |
It seems that CI is failing due to a check introduced by #77280. cc @petrochenkov: The loongarch target was added in LLVM 15, and is not available on the PR CI which uses the system LLVM. |
I think you might be able to fix this by adding |
8dbc47d
to
419eb1a
Compare
Thanks a lot. |
This comment has been minimized.
This comment has been minimized.
When COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS is set, compiletest expects that all llvm components used by any test are available. This env var is set in CI. In other words you can't use make a test conditional on any llvm component that isn't enabled by default for rust it seems. If loongarch64 is already supported by the llvm version used by rust, you could add it to Line 358 in b32223f
experimental_targets field in config.toml.example ).
|
I think you need to adjust this check: rust/src/tools/compiletest/src/header.rs Line 1037 in b32223f
Move the component detection after the LLVM version checking. |
419eb1a
to
530dedc
Compare
This comment has been minimized.
This comment has been minimized.
530dedc
to
f98a9fd
Compare
I adjusted the check order of llvm version and component in the file |
@@ -0,0 +1,195 @@ | |||
// min-llvm-version: 15.0 | |||
// revisions: loongarch64 |
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.
This line is not needed.
src/tools/compiletest/src/header.rs
Outdated
if let Some(actual_version) = config.llvm_version { | ||
if let Some(rest) = line.strip_prefix("min-llvm-version:").map(str::trim) { | ||
let min_version = extract_llvm_version(rest).unwrap(); | ||
// Ignore if actual version is smaller the minimum required | ||
// version | ||
actual_version < min_version | ||
return actual_version < min_version; |
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.
return actual_version < min_version; | |
if actual_version < min_version { | |
return true; | |
} |
src/tools/compiletest/src/header.rs
Outdated
} else if let Some(rest) = line.strip_prefix("min-system-llvm-version:").map(str::trim) { | ||
let min_version = extract_llvm_version(rest).unwrap(); | ||
// Ignore if using system LLVM and actual version | ||
// is smaller the minimum required version | ||
config.system_llvm && actual_version < min_version | ||
return config.system_llvm && actual_version < min_version; |
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.
Same here.
src/tools/compiletest/src/header.rs
Outdated
@@ -1069,11 +1055,27 @@ fn ignore_llvm(config: &Config, line: &str) -> bool { | |||
panic!("Malformed LLVM version range: max < min") | |||
} | |||
// Ignore if version lies inside of range. | |||
actual_version >= v_min && actual_version <= v_max | |||
return actual_version >= v_min && actual_version <= v_max; |
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.
Same here.
src/tools/compiletest/src/header.rs
Outdated
} else { | ||
false | ||
return false; |
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.
Remove the else
branch: if there's no min-llvm-version
then we should continue on to the next check below.
src/tools/compiletest/src/header.rs
Outdated
return true; | ||
} else { | ||
return false; |
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.
return true; | |
} else { | |
return false; | |
true | |
} else { | |
false |
Use trailing return syntax.
src/tools/compiletest/src/header.rs
Outdated
} | ||
} else { | ||
false | ||
return false; |
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.
return false; | |
false |
f98a9fd
to
ce51141
Compare
I seem to find a problem, when the iter_header function is called in make_test_description, the iter_header function loops to read the configuration information of each line in the xxx-types.rs file, and ignore_llvm is called every time during the loop. make_test_description: I'm not sure if my thinking is correct, my current understanding is: src/tools/compiletest/src/header.rs
|
@bors r+ |
📌 Commit ce51141ae3f5fa8f0ed8d0bdac8956e91e90ddb3 has been approved by It is now in the queue for this repository. |
@Amanieu I recently updated the patch set and noticed that one of the CI tests failed. It appears that the failling test is bound to an older version that does not support LoongArch. I would greatly appreciate it if you could provide me with some guidance on how to resolve this issue. |
It seems we should check the version before checking the components to ignore tests that do not match the |
This check was introduced by rust-lang#77280 to ensure that all tests that are filtered by LLVM component are actually tested in CI. However this causes issues for new targets (e.g. rust-lang#101069) where support is only available on the latest LLVM version. This PR restricts the tests to only CI jobs that use the latest LLVM version.
Should be fixed by #110232. |
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.
Can you also update the documentation in the unstable book for src/doc/unstable-book/src/language-features/asm-experimental-arch.md
.
@@ -44,6 +44,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { | |||
| asm::InlineAsmArch::AArch64 | |||
| asm::InlineAsmArch::RiscV32 | |||
| asm::InlineAsmArch::RiscV64 | |||
| asm::InlineAsmArch::LoongArch64 |
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.
Loongarch asm is not stable, it should not be included in this list.
f57183f
to
8b61821
Compare
☔ The latest upstream changes (presumably #109989) made this pull request unmergeable. Please resolve the merge conflicts. |
8b61821
to
2abcc61
Compare
Allow older LLVM versions to have missing components This check was introduced by #77280 to ensure that all tests that are filtered by LLVM component are actually tested in CI. However this causes issues for new targets (e.g. #101069) where support is only available on the latest LLVM version. This PR restricts the tests to only CI jobs that use the latest LLVM version.
2abcc61
to
5f2fa4c
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (999e6e5): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
cranelift-codegen / keccak are currently noisy, and this PR looks completely unrelated, @rustbot label: +perf-regression-triaged. |
… r=Amanieu Add loongarch64 asm! support
No description provided.