Skip to content

Commit

Permalink
allow libm_intrinsics fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
djdisodo committed Jan 10, 2023
1 parent ebc143b commit 097eacd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
22 changes: 12 additions & 10 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2325,17 +2325,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
.get(&callee_val)
.copied();
if let Some(libm_intrinsic) = libm_intrinsic {
let result = self.call_libm_intrinsic(libm_intrinsic, result_type, args);
if result_type != result.ty {
bug!(
"Mismatched libm result type for {:?}: expected {}, got {}",
libm_intrinsic,
self.debug_type(result_type),
self.debug_type(result.ty),
);
if let Some(result) = self.call_libm_intrinsic(libm_intrinsic, result_type, args) {
if result_type != result.ty {
bug!(
"Mismatched libm result type for {:?}: expected {}, got {}",
libm_intrinsic,
self.debug_type(result_type),
self.debug_type(result.ty),
);
}
return result;
}
result
} else if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()]
}
if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()]
.contains(&Some(callee_val))
{
// HACK(eddyb) redirect builtin panic calls to an abort, to avoid
Expand Down
9 changes: 6 additions & 3 deletions crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl Builder<'_, '_> {
intrinsic: LibmIntrinsic,
result_type: Word,
args: &[SpirvValue],
) -> SpirvValue {
match intrinsic {
) -> Option<SpirvValue> {
Some(match intrinsic {
LibmIntrinsic::GLOp(op) => self.gl_op(op, result_type, args),
LibmIntrinsic::Custom(LibmCustomIntrinsic::SinCos) => {
assert_eq!(args.len(), 1);
Expand Down Expand Up @@ -258,6 +258,7 @@ impl Builder<'_, '_> {
let one = self.constant_float(exp.ty, 1.0);
self.sub(exp, one)
}
/*
LibmIntrinsic::Custom(LibmCustomIntrinsic::Erf) => {
let undef = self.undef(result_type);
self.zombie(undef.def(self), "Erf not supported yet");
Expand Down Expand Up @@ -348,6 +349,8 @@ impl Builder<'_, '_> {
self.zombie(undef.def(self), "Scalbn not supported yet");
undef
}
}
*/
_ => return None
})
}
}

0 comments on commit 097eacd

Please sign in to comment.