Skip to content

Commit

Permalink
Improve lit tests: replace hardcoded parameters with more robust and …
Browse files Browse the repository at this point in the history
…reliable values (#1431)
  • Loading branch information
andreytr4intel authored Mar 5, 2022
1 parent d744887 commit 7de9b5b
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 290 deletions.
10 changes: 9 additions & 1 deletion test/complex-constexpr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir64"

; CHECK-SPIRV: TypeInt [[Int_Ty:[0-9]+]] 8 0
; CHECK-SPIRV: TypeVoid [[Void_Ty:[0-9]+]]
; CHECK-SPIRV: TypeFunction [[Func_Ty1:[0-9]+]] [[Void_Ty]]
; CHECK-SPIRV: TypePointer [[Ptr_Ty:[0-9]+]] 8 [[Int_Ty]]
; CHECK-SPIRV: TypeFunction [[Func_Ty2:[0-9]+]] [[Void_Ty]] [[Ptr_Ty]] [[Ptr_Ty]]

@.str.1 = private unnamed_addr addrspace(1) constant [1 x i8] zeroinitializer, align 1

define linkonce_odr hidden spir_func void @foo() {
Expand All @@ -22,7 +28,7 @@ entry:
; CHECK-SPIRV: IEqual {{[0-9]+}} [[IEq:[0-9]+]] [[PtrToU1]] [[PtrToU2]]
; CHECK-SPIRV: ConvertUToPtr {{[0-9]+}} [[UToPtr:[0-9]+]]
; CHECK-SPIRV: Select {{[0-9]+}} [[Sel:[0-9]+]] [[IEq]] [[UToPtr]] [[Gep1]]
; CHECK-SPIRV: FunctionCall 9 31 28 [[Gep]] [[Sel]]
; CHECK-SPIRV: FunctionCall [[Void_Ty]] {{[0-9]+}} [[Func:[0-9]+]] [[Gep]] [[Sel]]
; CHECK-LLVM: %[[Cast:[0-9]+]] = addrspacecast [1 x i8] addrspace(1)* @.str.1 to [1 x i8] addrspace(4)*
; CHECK-LLVM: %[[Gep:[0-9]+]] = getelementptr inbounds [1 x i8], [1 x i8] addrspace(4)* %0, i64 0, i64 0
; CHECK-LLVM: %[[Gep1:[0-9]+]] = getelementptr inbounds [1 x i8], [1 x i8] addrspace(4)* %0, i64 0, i64 0
Expand All @@ -36,6 +42,8 @@ entry:
ret void
}

; CHECK-SPIRV: Function [[Void_Ty]] [[Func]] 0 [[Func_Ty2]]

define linkonce_odr hidden spir_func void @bar(i8 addrspace(4)* %__beg, i8 addrspace(4)* %__end) {
entry:
ret void
Expand Down
7 changes: 4 additions & 3 deletions test/image.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
; RUN: llvm-spirv %t.rev.bc -o %t.rev.spv
; RUN: spirv-val %t.rev.spv

; CHECK-SPIRV-DAG: 10 TypeImage {{[0-9]*}} 6 1 0 0 0 0 0 0
; CHECK-SPIRV-DAG: 10 TypeImage {{[0-9]*}} 6 1 0 0 0 0 0 1
; CHECK-SPIRV-NOT: 10 TypeImage {{[0-9]*}} 6 1 0 0 0 0 0 0
; CHECK-SPIRV: 2 TypeVoid [[VOID_TY:[0-9]+]]
; CHECK-SPIRV-DAG: 10 TypeImage {{[0-9]*}} [[VOID_TY]] 1 0 0 0 0 0 0
; CHECK-SPIRV-DAG: 10 TypeImage {{[0-9]*}} [[VOID_TY]] 1 0 0 0 0 0 1
; CHECK-SPIRV-NOT: 10 TypeImage {{[0-9]*}} [[VOID_TY]] 1 0 0 0 0 0 0
; CHECK-SPIRV: ImageSampleExplicitLod
; CHECK-SPIRV: ImageWrite

Expand Down
2 changes: 1 addition & 1 deletion test/llvm-intrinsics/ceil.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target triple = "spir64-unknown-unknown"

; CHECK: 3 TypeFloat [[var1:[0-9]+]] 32
; CHECK: 3 TypeFloat [[var2:[0-9]+]] 64
; CHECK: 4 TypeVector [[var3:[0-9]+]] 2 4
; CHECK: 4 TypeVector [[var3:[0-9]+]] [[var1]] 4

; CHECK: Function
; CHECK: 6 ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] ceil
Expand Down
551 changes: 276 additions & 275 deletions test/transcoding/OpImageWrite.cl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/transcoding/OpMin.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM

; CHECK-SPIRV: 5 ExtInstImport [[SetInstID:[0-9]+]] "OpenCL.std"
; CHECK-SPIRV: 4 TypeInt [[IntTypeID:[0-9]+]] 32 {{[0-9]+}}
; CHECK-SPIRV: 4 TypeVector [[Int2TypeID:[0-9]+]] [[IntTypeID]] 2
; CHECK-SPIRV: 6 CompositeInsert [[Int2TypeID]] [[CompositeID:[0-9]+]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
; CHECK-SPIRV: 7 VectorShuffle [[Int2TypeID]] [[ShuffleID:[0-9]+]] [[CompositeID]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
; CHECK-SPIRV: 7 ExtInst [[Int2TypeID]] {{[0-9]+}} 1 s_min {{[0-9]+}} [[ShuffleID]]
; CHECK-SPIRV: 7 ExtInst [[Int2TypeID]] {{[0-9]+}} [[SetInstID]] s_min {{[0-9]+}} [[ShuffleID]]

; CHECK-LLVM: call spir_func <2 x i32> @_Z3minDv2_iS_(

Expand Down
3 changes: 2 additions & 1 deletion test/transcoding/OpVariable_Initializer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
; CHECK-LLVM: @test_atomic_fn.L = internal addrspace(3) global [64 x i32] undef, align 4

; CHECK-SPIRV-NOT: undef
; CHECK-SPIRV: 4 Variable 5 6 4
; CHECK-SPIRV: 4 TypePointer [[PtrT:[0-9]+]] 4
; CHECK-SPIRV: 4 Variable [[PtrT]] {{[0-9]+}} 4

target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir-unknown-unknown"
Expand Down
15 changes: 8 additions & 7 deletions test/transcoding/get_image_num_mip_levels.ll
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ target triple = "spir-unknown-unknown"
%opencl.image2d_array_depth_ro_t = type opaque

; CHECK-SPIRV: TypeInt [[INT:[0-9]+]] 32
; CHECK-SPIRV: TypeImage [[IMAGE1D_T:[0-9]+]] 2 0 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_T:[0-9]+]] 2 1 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE3D_T:[0-9]+]] 2 2 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE1D_ARRAY_T:[0-9]+]] 2 0 0 1 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_ARRAY_T:[0-9]+]] 2 1 0 1 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_DEPTH_T:[0-9]+]] 2 1 1 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_ARRAY_DEPTH_T:[0-9]+]] 2 1 1 1 0 0 0 0
; CHECK-SPIRV: TypeVoid [[VOID:[0-9]+]]
; CHECK-SPIRV: TypeImage [[IMAGE1D_T:[0-9]+]] [[VOID]] 0 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_T:[0-9]+]] [[VOID]] 1 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE3D_T:[0-9]+]] [[VOID]] 2 0 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE1D_ARRAY_T:[0-9]+]] [[VOID]] 0 0 1 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_ARRAY_T:[0-9]+]] [[VOID]] 1 0 1 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_DEPTH_T:[0-9]+]] [[VOID]] 1 1 0 0 0 0 0
; CHECK-SPIRV: TypeImage [[IMAGE2D_ARRAY_DEPTH_T:[0-9]+]] [[VOID]] 1 1 1 0 0 0 0

; CHECK-LLVM: %opencl.image1d_ro_t = type opaque
; CHECK-LLVM: %opencl.image2d_ro_t = type opaque
Expand Down
3 changes: 2 additions & 1 deletion test/transcoding/image_with_access_qualifiers.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
; CHECK-SPIRV-DAG: 2 Capability ImageBasic
; CHECK-SPIRV-DAG: 2 Capability ImageReadWrite
; CHECK-SPIRV-DAG: 2 Capability LiteralSampler
; CHECK-SPIRV-DAG: 10 TypeImage [[TyImageID:[0-9]+]] 2 0 0 0 0 0 0 2
; CHECK-SPIRV-DAG: 2 TypeVoid [[TyVoid:[0-9]+]]
; CHECK-SPIRV-DAG: 10 TypeImage [[TyImageID:[0-9]+]] [[TyVoid]] 0 0 0 0 0 0 2
; CHECK-SPIRV-DAG: 3 TypeSampledImage [[TySampledImageID:[0-9]+]] [[TyImageID]]

; CHECK-SPIRV-DAG: 5 SampledImage [[TySampledImageID]] [[ResID:[0-9]+]]
Expand Down

0 comments on commit 7de9b5b

Please sign in to comment.