|
| 1 | +; RUN: llvm-as < %s -o %t.bc |
| 2 | +; RUN: llvm-spirv %t.bc -o %t.spv |
| 3 | +; RUN: spirv-val %t.spv |
| 4 | +; RUN: llvm-spirv -to-text %t.spv -o - | FileCheck %s |
| 5 | +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 6 | +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 7 | + |
| 8 | +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" |
| 9 | +target triple = "spir64-unknown-unknown" |
| 10 | + |
| 11 | +%struct.ST = type { i32, i32, i32 } |
| 12 | + |
| 13 | +; CHECK-DAG: Name [[#STRUCT_TYPE_ID:]] "struct.ST" |
| 14 | +; CHECK: TypeInt [[#INT_TYPE:]] 32 0 |
| 15 | +; CHECK: Constant [[#INT_TYPE]] [[#CONST_0:]] 0 |
| 16 | +; CHECK: Constant [[#INT_TYPE]] [[#CONST_1:]] 1 |
| 17 | +; CHECK: Constant [[#INT_TYPE]] [[#CONST_2:]] 2 |
| 18 | +; CHECK: Constant [[#INT_TYPE]] [[#CONST_3:]] 3 |
| 19 | +; CHECK: TypeStruct [[#STRUCT_TYPE_ID]] [[#INT_TYPE]] [[#INT_TYPE]] [[#INT_TYPE]] |
| 20 | +; CHECK: TypePointer [[#PTR_STRUCT_TYPE_ID:]] 7 [[#STRUCT_TYPE_ID]] |
| 21 | +; CHECK: TypePointer [[#PTR_INT_TYPE_ID:]] 7 [[#INT_TYPE]] |
| 22 | + |
| 23 | +; CHECK: Function |
| 24 | +; CHECK: Label |
| 25 | +; CHECK: Variable [[#PTR_STRUCT_TYPE_ID]] [[#ST_VAR_ID:]] |
| 26 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_0]] |
| 27 | +; CHECK: Store |
| 28 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_1]] |
| 29 | +; CHECK: Store |
| 30 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_2]] |
| 31 | +; CHECK: Store |
| 32 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_0]] |
| 33 | +; CHECK: Load [[#INT_TYPE]] [[#A1_LOAD_ID:]] [[#]] |
| 34 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_1]] |
| 35 | +; CHECK: Load [[#INT_TYPE]] [[#B2_LOAD_ID:]] [[#]] |
| 36 | +; CHECK: IAdd [[#INT_TYPE]] [[#ADD_ID:]] [[#A1_LOAD_ID]] [[#B2_LOAD_ID]] |
| 37 | +; CHECK: InBoundsPtrAccessChain [[#PTR_INT_TYPE_ID]] [[#]] [[#ST_VAR_ID]] [[#CONST_0]] [[#CONST_2]] |
| 38 | +; CHECK: Load [[#INT_TYPE]] [[#C3_LOAD_ID:]] [[#]] |
| 39 | +; CHECK: IAdd [[#INT_TYPE]] [[#]] [[#ADD_ID]] [[#C3_LOAD_ID]] |
| 40 | + |
| 41 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 0 |
| 42 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 1 |
| 43 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 2 |
| 44 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 0 |
| 45 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 1 |
| 46 | +; CHECK-LLVM: %{{.*}} = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 2 |
| 47 | + |
| 48 | +define dso_local spir_func i32 @func() { |
| 49 | +entry: |
| 50 | + |
| 51 | + %st = alloca %struct.ST, align 4 |
| 52 | + %a = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 0 |
| 53 | + store i32 1, ptr %a, align 4 |
| 54 | + %b = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 1 |
| 55 | + store i32 2, ptr %b, align 4 |
| 56 | + %c = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 2 |
| 57 | + store i32 3, ptr %c, align 4 |
| 58 | + %a1 = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 0 |
| 59 | + %0 = load i32, ptr %a1, align 4 |
| 60 | + %b2 = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 1 |
| 61 | + %1 = load i32, ptr %b2, align 4 |
| 62 | + %add = add nsw i32 %0, %1 |
| 63 | + %c3 = getelementptr inbounds %struct.ST, ptr %st, i32 0, i32 2 |
| 64 | + %2 = load i32, ptr %c3, align 4 |
| 65 | + %add4 = add nsw i32 %add, %2 |
| 66 | + ret i32 %add4 |
| 67 | +} |
0 commit comments