Changed intrinsic generation to include full intrinsic names in panic messages

This commit is contained in:
FractalFir 2025-06-30 00:24:28 +02:00
parent b7091eca6d
commit 88db5895ed

View file

@ -176,14 +176,14 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
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("fn map_arch_intrinsic(full_name:&str)->&'static str{\n")
out.write('let Some(name) = full_name.strip_prefix("llvm.") else { unimplemented!("***** unsupported LLVM intrinsic {}", full_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,full_name:&str) -> &'static 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]:
@ -196,9 +196,9 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
out.write(' // [INVALID CONVERSION]: "{}" => "{}",\n'.format(llvm_name, entry[1]))
else:
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 architecture {}", name),\n')
out.write(' _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"),\n')
out.write("}} }} {}(name,full_name) }}\n,".format(arch))
out.write(' _ => unimplemented!("***** unsupported LLVM architecture {arch}, intrinsic:{full_name}"),\n')
out.write("}\n}")
subprocess.call(["rustfmt", output_file])
print("Done!")