Skip to content

intrinsic-test: use IntoIterator for the add_flags methods #1896

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

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/intrinsic-test/src/arm/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ pub fn build_cpp_compilation(config: &ProcessedCli) -> Option<CppCompilation> {

// -ffp-contract=off emulates Rust's approach of not fusing separate mul-add operations
let mut command = CompilationCommandBuilder::new()
.add_arch_flags(vec!["armv8.6-a", "crypto", "crc", "dotprod", "fp16"])
.add_arch_flags(["armv8.6-a", "crypto", "crc", "dotprod", "fp16"])
.set_compiler(cpp_compiler)
.set_target(&config.target)
.set_opt_level("2")
.set_cxx_toolchain_dir(config.cxx_toolchain_dir.as_deref())
.set_project_root("c_programs")
.add_extra_flags(vec!["-ffp-contract=off", "-Wno-narrowing"]);
.add_extra_flags(["-ffp-contract=off", "-Wno-narrowing"]);

if !config.target.contains("v7") {
command = command.add_arch_flags(vec!["faminmax", "lut", "sha3"]);
command = command.add_arch_flags(["faminmax", "lut", "sha3"]);
}

if !cpp_compiler.contains("clang") {
Expand Down
15 changes: 8 additions & 7 deletions crates/intrinsic-test/src/common/compile_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl CompilationCommandBuilder {
self
}

pub fn add_arch_flags(mut self, flags: Vec<&str>) -> Self {
let mut new_arch_flags = flags.into_iter().map(|v| v.to_string()).collect();
self.arch_flags.append(&mut new_arch_flags);
pub fn add_arch_flags<'a>(mut self, flags: impl IntoIterator<Item = &'a str>) -> Self {
self.arch_flags
.extend(flags.into_iter().map(|s| s.to_owned()));

self
}
Expand All @@ -55,14 +55,15 @@ impl CompilationCommandBuilder {
self
}

pub fn add_extra_flags(mut self, flags: Vec<&str>) -> Self {
let mut flags: Vec<String> = flags.into_iter().map(|f| f.to_string()).collect();
self.extra_flags.append(&mut flags);
pub fn add_extra_flags<'a>(mut self, flags: impl IntoIterator<Item = &'a str>) -> Self {
self.extra_flags
.extend(flags.into_iter().map(|s| s.to_owned()));

self
}

pub fn add_extra_flag(self, flag: &str) -> Self {
self.add_extra_flags(vec![flag])
self.add_extra_flags([flag])
}
}

Expand Down