@@ -815,3 +815,107 @@ func.func @exp2_invalid_type(%arg0 : i32) -> () {
815815 %0 = spirv.GL.Exp2 %arg0 : i32
816816 return
817817}
818+
819+ // -----
820+
821+ //===----------------------------------------------------------------------===//
822+ // spirv.GL.PackHalf2x16
823+ //===----------------------------------------------------------------------===//
824+
825+ func.func @pack_half_2x16 (%arg0 : vector <2 xf32 >) -> () {
826+ // CHECK: spirv.GL.PackHalf2x16 {{%.*}} : vector<2xf32> -> i32
827+ %0 = spirv.GL.PackHalf2x16 %arg0 : vector <2 xf32 > -> i32
828+ return
829+ }
830+
831+ // -----
832+
833+ func.func @pack_half_2x16_i16_output (%arg0 : vector <2 xf32 >) -> () {
834+ // expected-error @+1 {{op result #0 must be Int32, but got 'i16'}}
835+ %0 = spirv.GL.PackHalf2x16 %arg0 : vector <2 xf32 > -> i16
836+ return
837+ }
838+
839+ // -----
840+
841+ func.func @pack_half_2x16_wrong_vec_size (%arg0 : vector <3 xf32 >) -> () {
842+ // expected-error @+1 {{op operand #0 must be vector of Float32 values of length 2, but got 'vector<3xf32>'}}
843+ %0 = spirv.GL.PackHalf2x16 %arg0 : vector <3 xf32 > -> i32
844+ return
845+ }
846+
847+ // -----
848+
849+ func.func @pack_half_2x16_wrong_vec_type (%arg0 : vector <2 xi32 >) -> () {
850+ // expected-error @+1 {{op operand #0 must be vector of Float32 values of length 2, but got 'vector<2xi32>'}}
851+ %0 = spirv.GL.PackHalf2x16 %arg0 : vector <2 xi32 > -> i32
852+ return
853+ }
854+
855+ // -----
856+
857+ func.func @pack_half_2x16_scalar_in (%arg0 : f32 ) -> () {
858+ // expected-error @+1 {{invalid kind of type specified: expected builtin.vector, but found 'f32'}}
859+ %0 = spirv.GL.PackHalf2x16 %arg0 : f32 -> i32
860+ return
861+ }
862+
863+ // -----
864+
865+ func.func @unpack_half_2x16_vector_out (%arg0 : vector <2 xf32 >) -> () {
866+ // expected-error @+1 {{invalid kind of type specified: expected builtin.integer, but found 'vector<2xf32>'}}
867+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : vector <2 xf32 > -> vector <2 xi32 >
868+ return
869+ }
870+
871+ // -----
872+
873+ //===----------------------------------------------------------------------===//
874+ // spirv.GL.UnpackHalf2x16
875+ //===----------------------------------------------------------------------===//
876+
877+ func.func @unpack_half_2x16 (%arg0 : i32 ) -> () {
878+ // CHECK: spirv.GL.UnpackHalf2x16 {{%.*}} : i32 -> vector<2xf32>
879+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector <2 xf32 >
880+ return
881+ }
882+
883+ // -----
884+
885+ func.func @unpack_half_2x16_i16_input (%arg0 : i16 ) -> () {
886+ // expected-error @+1 {{op operand #0 must be Int32, but got 'i16'}}
887+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : i16 -> vector <2 xf32 >
888+ return
889+ }
890+
891+ // -----
892+
893+ func.func @unpack_half_2x16_wrong_vec_size (%arg0 : i32 ) -> () {
894+ // expected-error @+1 {{op result #0 must be vector of Float32 values of length 2, but got 'vector<3xf32>'}}
895+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector <3 xf32 >
896+ return
897+ }
898+
899+ // -----
900+
901+ func.func @unpack_half_2x16_wrong_vec_type (%arg0 : i32 ) -> () {
902+ // expected-error @+1 {{op result #0 must be vector of Float32 values of length 2, but got 'vector<2xi32>'}}
903+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector <2 xi32 >
904+ return
905+ }
906+
907+ // -----
908+
909+ func.func @unpack_half_2x16_vec_in (%arg0 : vector <2 xf32 >) -> () {
910+ // expected-error @+1 {{invalid kind of type specified: expected builtin.integer, but found 'vector<2xf32>'}}
911+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : vector <2 xf32 > -> vector <2 xf32 >
912+ return
913+ }
914+
915+ // -----
916+
917+ func.func @unpack_half_2x16_scalar_out (%arg0 : i32 ) -> () {
918+ // expected-error @+1 {{invalid kind of type specified: expected builtin.vector, but found 'f32'}}
919+ %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> f32
920+ return
921+ }
0 commit comments