Skip to content

Commit e4c9584

Browse files
FractalFirantoyo
andauthored
Apply suggestions from code review
Co-authored-by: antoyo <[email protected]>
1 parent 6fbac93 commit e4c9584

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/intrinsic/llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,4 +1555,5 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
15551555
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
15561556
func
15571557
}
1558+
15581559
include!("archs.rs");

tools/generate_intrinsics.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,22 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
168168
os.path.dirname(os.path.abspath(__file__)),
169169
"../src/intrinsic/archs.rs",
170170
)
171-
# A hashmap of all architectures. This allows us to first match on the architecture, and then on the intrisnics.
171+
# A hashmap of all architectures. This allows us to first match on the architecture, and then on the intrinsics.
172172
# This speeds up the comparison, and makes our code considerably smaller.
173-
# Since all intrinsic names start with ".llvm", we skip that prefix.
173+
# Since all intrinsic names start with "llvm.", we skip that prefix.
174174
print("Updating content of `{}`...".format(output_file))
175175
with open(output_file, "w", encoding="utf8") as out:
176176
out.write("// File generated by `rustc_codegen_gcc/tools/generate_intrinsics.py`\n")
177177
out.write("// DO NOT EDIT IT!\n")
178178
out.write("/// Translate a given LLVM intrinsic name to an equivalent GCC one.\n")
179179
out.write("fn map_arch_intrinsic(name:&str)->&str{\n")
180-
out.write('let Some(name) = name.strip_prefix("llvm.") else {unimplemented!("***** unsupported LLVM intrinsic {}", name)};\n')
181-
out.write('let Some((arch, name)) = name.split_once(\'.\') else {unimplemented!("***** unsupported LLVM intrinsic {}", name)};\n')
180+
out.write('let Some(name) = name.strip_prefix("llvm.") else { unimplemented!("***** unsupported LLVM intrinsic {}", name) };\n')
181+
out.write('let Some((arch, name)) = name.split_once(\'.\') else { unimplemented!("***** unsupported LLVM intrinsic {}", name) };\n')
182182
out.write("match arch {\n")
183183
for arch in archs:
184184
if len(intrinsics[arch]) == 0:
185185
continue
186-
out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name:&str)->&str{{ match name{{".format(arch,arch))
186+
out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name: &str) -> &str {{ match name {{".format(arch,arch))
187187
intrinsics[arch].sort(key=lambda x: (x[0], x[2]))
188188
out.write(' // {}\n'.format(arch))
189189
for entry in intrinsics[arch]:
@@ -198,7 +198,7 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
198198
out.write(' "{}" => "{}",\n'.format(llvm_name, entry[1]))
199199
out.write(' _ => unimplemented!("***** unsupported LLVM intrinsic {}", name),\n')
200200
out.write("}} }} {}(name) }}\n,".format(arch))
201-
out.write(' _ => unimplemented!("***** unsupported LLVM intrinsic {}", name),\n')
201+
out.write(' _ => unimplemented!("***** unsupported LLVM architecture {}", name),\n')
202202
out.write("}\n}")
203203
subprocess.call(["rustfmt", output_file])
204204
print("Done!")

0 commit comments

Comments
 (0)