Skip to content

Commit 9058b06

Browse files
FractalFirLegNeato
authored andcommitted
Intrinsics will now use fallback bodies if possible.
1 parent 2bf3138 commit 9058b06

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

crates/rustc_codegen_nvvm/src/intrinsic.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,24 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
595595
// We have copied the value to `result` already.
596596
return Ok(());
597597
}
598+
598599
// is this even supported by nvvm? i did not find a definitive answer
599600
_ if name_str.starts_with("simd_") => todo!("simd intrinsics"),
600-
_ => bug!("unknown intrinsic '{}'", name),
601+
// Fall back to a fallback intrinsic implementation, if possible
602+
_ => {
603+
// This piece of code was adapted from `rustc_codegen_cranelift`.
604+
let intrinsic = self.tcx.intrinsic(instance.def_id()).unwrap();
605+
if intrinsic.must_be_overridden {
606+
bug!(
607+
"intrinsic {} must be overridden by codegen_nvvm, but isn't",
608+
intrinsic.name,
609+
);
610+
}
611+
return Err(rustc_middle::ty::Instance::new_raw(
612+
instance.def_id(),
613+
instance.args,
614+
));
615+
}
601616
};
602617
trace!("Finish intrinsic call: `{:?}`", llval);
603618
if !fn_abi.ret.is_ignore() {

0 commit comments

Comments
 (0)