@@ -633,8 +633,12 @@ callback()
633
633
634
634
println (" done (took " , time () - before_time, " seconds)" )
635
635
636
+ # ############################################################################################
636
637
# Test overdubbing of a call overload invoke
637
638
639
+ print (" running CtxCallOverload test..." )
640
+ before_time = time ()
641
+
638
642
using LinearAlgebra
639
643
640
644
struct Dense{F,S,T}
@@ -663,3 +667,38 @@ let d = Dense(3,3)
663
667
data = rand (3 )
664
668
Cassette. overdub (CtxCallOverload (), d, data)
665
669
end
670
+
671
+ println (" done (took " , time () - before_time, " seconds)" )
672
+
673
+ # ############################################################################################
674
+
675
+ print (" running LLVMCallCtx test..." )
676
+ before_time = time ()
677
+ using Cassette
678
+ Cassette. @context LLVMCallCtx
679
+
680
+ # This overdub does nothing
681
+ @noinline function Cassette. overdub (ctx:: LLVMCallCtx , f, args... )
682
+ if Cassette. canrecurse (ctx, f, args... )
683
+ Cassette. recurse (ctx, f, args... )
684
+ else
685
+ Cassette. fallback (ctx, f, args... )
686
+ end
687
+ end
688
+
689
+ import Core. Intrinsics
690
+ function llvm_sin (x:: Float64 )
691
+ # Needs fix for Core.Intrinsics.llvmcall
692
+ Intrinsics. llvmcall (
693
+ (
694
+ """ declare double @llvm.sin.f64(double)""" ,
695
+ """ %2 = call double @llvm.sin.f64(double %0)
696
+ ret double %2"""
697
+ ),
698
+ Float64, Tuple{Float64}, x
699
+ )
700
+ end
701
+
702
+ Cassette. @overdub LLVMCallCtx () llvm_sin (4.0 )
703
+
704
+ println (" done (took " , time () - before_time, " seconds)" )
0 commit comments