Skip to content

Commit ce63b84

Browse files
vmaksimojsji
authored andcommitted
Test access and store operations for cooperative matrix (#2117)
For now, the reverse translation is not resolved properly, so we test only forward translation here. Original commit: KhronosGroup/SPIRV-LLVM-Translator@1677289
1 parent 4132ba4 commit ce63b84

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix -o %t.spv
3+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
4+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5+
6+
; TODO: come up with an approach and implement reverse translation
7+
; R/UN: llvm-spirv -r %t.spv -o %t.rev.bc
8+
; R/UN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
9+
10+
; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 0
11+
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const0:]] 0
12+
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const1:]] 1 {{$}}
13+
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const3:]] 3
14+
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const12:]] 12
15+
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const42:]] 42
16+
17+
; CHECK-SPIRV: TypeCooperativeMatrixKHR [[#TypeMatrix:]] [[#TypeInt]] [[#Const3]] [[#Const12]] [[#Const12]] [[#Const0]]
18+
; CHECK-SPIRV: TypePointer [[#Type:]] 7 [[#TypeInt]]
19+
20+
; CHECK-SPIRV: CompositeConstruct [[#TypeMatrix]] [[#Composite:]] [[#Const0]]
21+
; CHECK-SPIRV: AccessChain [[#Type]] [[#Res:]] [[#Composite]] [[#Const1]]
22+
; CHECK-SPIRV: Store [[#Res]] [[#Const42]]
23+
24+
25+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
26+
target triple = "spir64-unknown-unknown"
27+
28+
; Function Attrs: mustprogress uwtable
29+
define dso_local void @_Z3fooi(i32 noundef %idx) local_unnamed_addr #0 {
30+
entry:
31+
%Obj = tail call spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstruct(i32 noundef 0) #4
32+
%call = call noundef ptr @_Z19__spirv_AccessChainP6Matrixii(target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) %Obj, i32 noundef 1)
33+
call void @_Z13__spirv_StorePii(ptr noundef %call, i32 noundef 42)
34+
ret void
35+
}
36+
37+
declare dso_local spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstruct(i32 noundef) local_unnamed_addr #2
38+
39+
declare noundef ptr @_Z19__spirv_AccessChainP6Matrixii(target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) noundef, i32 noundef) local_unnamed_addr #2
40+
41+
declare void @_Z13__spirv_StorePii(ptr noundef, i32 noundef) local_unnamed_addr #2
42+
43+
attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
44+
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
45+
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
46+
attributes #3 = { nounwind }
47+
48+
!llvm.module.flags = !{!0, !1, !2, !3, !4}
49+
!llvm.ident = !{!5}
50+
51+
!0 = !{i32 7, !"Dwarf Version", i32 4}
52+
!1 = !{i32 1, !"wchar_size", i32 4}
53+
!2 = !{i32 8, !"PIC Level", i32 2}
54+
!3 = !{i32 7, !"PIE Level", i32 2}
55+
!4 = !{i32 7, !"uwtable", i32 2}
56+
!5 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git 08d094a0e457360ad8b94b017d2dc277e697ca76)"}

0 commit comments

Comments
 (0)