about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFractal Fir(MichaƂ Kostrubiec) <michkos2005@gmail.com>2025-06-03 20:29:37 +0200
committerGitHub <noreply@github.com>2025-06-03 20:29:37 +0200
commite4c9584a55195af88bc2e99b259e33d20e3efbe4 (patch)
tree3b3181a2f8d7be2ad94bb65198e2d430b0842c01
parent6fbac9342b86e095abcfd365f1d1eea17bca0b59 (diff)
downloadrust-e4c9584a55195af88bc2e99b259e33d20e3efbe4.tar.gz
rust-e4c9584a55195af88bc2e99b259e33d20e3efbe4.zip
Apply suggestions from code review
Co-authored-by: antoyo <antoyo@users.noreply.github.com>
-rw-r--r--src/intrinsic/llvm.rs1
-rw-r--r--tools/generate_intrinsics.py12
2 files changed, 7 insertions, 6 deletions
diff --git a/src/intrinsic/llvm.rs b/src/intrinsic/llvm.rs
index 2c44fb23788..25a765f571f 100644
--- a/src/intrinsic/llvm.rs
+++ b/src/intrinsic/llvm.rs
@@ -1555,4 +1555,5 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
     cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
     func
 }
+
 include!("archs.rs");
diff --git a/tools/generate_intrinsics.py b/tools/generate_intrinsics.py
index e24139f9a40..ed0ebf00719 100644
--- a/tools/generate_intrinsics.py
+++ b/tools/generate_intrinsics.py
@@ -168,22 +168,22 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
         os.path.dirname(os.path.abspath(__file__)),
         "../src/intrinsic/archs.rs",
     )
-    # A hashmap of all architectures. This allows us to first match on the architecture, and then on the intrisnics. 
+    # A hashmap of all architectures. This allows us to first match on the architecture, and then on the intrinsics.
     # This speeds up the comparison, and makes our code considerably smaller.
-    # Since all intrinsic names start with ".llvm", we skip that prefix. 
+    # Since all intrinsic names start with "llvm.", we skip that prefix.
     print("Updating content of `{}`...".format(output_file))
     with open(output_file, "w", encoding="utf8") as out:
         out.write("// File generated by `rustc_codegen_gcc/tools/generate_intrinsics.py`\n")
         out.write("// DO NOT EDIT IT!\n")
         out.write("/// Translate a given LLVM intrinsic name to an equivalent GCC one.\n")
         out.write("fn map_arch_intrinsic(name:&str)->&str{\n")
-        out.write('let Some(name) =  name.strip_prefix("llvm.") else {unimplemented!("***** unsupported LLVM intrinsic {}", name)};\n')
-        out.write('let Some((arch, name)) =  name.split_once(\'.\') else {unimplemented!("***** unsupported LLVM intrinsic {}", name)};\n')
+        out.write('let Some(name) = name.strip_prefix("llvm.") else { unimplemented!("***** unsupported LLVM intrinsic {}", name) };\n')
+        out.write('let Some((arch, name)) = name.split_once(\'.\') else { unimplemented!("***** unsupported LLVM intrinsic {}", name) };\n')
         out.write("match arch {\n")
         for arch in archs:
             if len(intrinsics[arch]) == 0:
                 continue
-            out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name:&str)->&str{{ match name{{".format(arch,arch))
+            out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name: &str) -> &str {{ match name {{".format(arch,arch))
             intrinsics[arch].sort(key=lambda x: (x[0], x[2]))
             out.write('    // {}\n'.format(arch))
             for entry in intrinsics[arch]:
@@ -198,7 +198,7 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
                     out.write('    "{}" => "{}",\n'.format(llvm_name, entry[1]))
             out.write('    _ => unimplemented!("***** unsupported LLVM intrinsic {}", name),\n')
             out.write("}} }} {}(name) }}\n,".format(arch))
-        out.write('    _ => unimplemented!("***** unsupported LLVM intrinsic {}", name),\n')
+        out.write('    _ => unimplemented!("***** unsupported LLVM architecture {}", name),\n')
         out.write("}\n}")
     subprocess.call(["rustfmt", output_file])
     print("Done!")