@@ -752,41 +752,59 @@ void *tp (void) {
752
752
// WEBASSEMBLY: call {{.*}} @llvm.thread.pointer.p0()
753
753
}
754
754
755
- typedef void (* Fvoid )(void );
756
- typedef float (* Ffloats )(float , double , int );
757
- typedef void (* Fpointers )(Fvoid , Ffloats , void * , int * , int * * * , char [5 ]);
758
- typedef void (* FVarArgs )(int , ...);
759
- typedef __externref_t (* FExternRef )(__externref_t , __externref_t );
760
- typedef __funcref Fpointers (* FFuncRef )(__funcref Fvoid , __funcref Ffloats );
761
755
762
756
void use (int );
763
757
758
+ typedef void (* Fvoid )(void );
764
759
void test_function_pointer_signature_void (Fvoid func ) {
765
760
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison)
766
761
use (__builtin_wasm_test_function_pointer_signature (func ));
767
762
}
768
763
764
+ typedef float (* Ffloats )(float , double , int );
769
765
void test_function_pointer_signature_floats (Ffloats func ) {
770
766
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, float poison, token poison, float poison, double poison, i32 poison)
771
767
use (__builtin_wasm_test_function_pointer_signature (func ));
772
768
}
773
769
770
+ typedef void (* Fpointers )(Fvoid , Ffloats , void * , int * , int * * * , char [5 ]);
774
771
void test_function_pointer_signature_pointers (Fpointers func ) {
775
772
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, ptr poison, ptr poison, ptr poison, ptr poison, ptr poison, ptr poison)
776
773
use (__builtin_wasm_test_function_pointer_signature (func ));
777
774
}
778
775
776
+ typedef void (* FVarArgs )(int , ...);
779
777
void test_function_pointer_signature_varargs (FVarArgs func ) {
780
778
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, i32 poison, ptr poison)
781
779
use (__builtin_wasm_test_function_pointer_signature (func ));
782
780
}
783
781
782
+ typedef __externref_t (* FExternRef )(__externref_t , __externref_t );
784
783
void test_function_pointer_externref (FExternRef func ) {
785
784
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, ptr addrspace(10) poison, token poison, ptr addrspace(10) poison, ptr addrspace(10) poison)
786
785
use (__builtin_wasm_test_function_pointer_signature (func ));
787
786
}
788
787
788
+ typedef __funcref Fpointers (* FFuncRef )(__funcref Fvoid , __funcref Ffloats );
789
789
void test_function_pointer_funcref (FFuncRef func ) {
790
790
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, ptr addrspace(20) poison, token poison, ptr addrspace(20) poison, ptr addrspace(20) poison)
791
791
use (__builtin_wasm_test_function_pointer_signature (func ));
792
792
}
793
+
794
+ // Some tests that we get struct ABIs correct. There is no special code in
795
+ // __builtin_wasm_test_function_pointer_signature for this, it gets handled by
796
+ // the normal type lowering code.
797
+ // Single element structs are unboxed, multi element structs are passed on
798
+ // stack.
799
+ typedef struct {double x ;} (* Fstructs1 )(struct {double x ;}, struct {float x ;}, struct {double x ; float y ;}, union {double x ; float y ;});
800
+ void test_function_pointer_structs1 (Fstructs1 func ) {
801
+ // WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, double poison, token poison, double poison, float poison, ptr poison, ptr poison)
802
+ use (__builtin_wasm_test_function_pointer_signature (func ));
803
+ }
804
+
805
+ // Two element return struct ==> return ptr on stack
806
+ typedef struct {double x ; double y ;} (* Fstructs2 )(void );
807
+ void test_function_pointer_structs2 (Fstructs2 func ) {
808
+ // WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, ptr poison)
809
+ use (__builtin_wasm_test_function_pointer_signature (func ));
810
+ }
0 commit comments