| 1 |
; Check that we can handle constant expressions correctly. |
| 2 |
; RUN: llvm-as %s -o %t.bc |
| 3 |
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 4 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 5 |
; RUN: spirv-val %t.spv |
| 6 |
; RUN: llvm-spirv -r %t.spv -emit-opaque-pointers -o %t.rev.bc |
| 7 |
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM |
| 8 |
|
| 9 |
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" |
| 10 |
target triple = "spir-unknown-unknown" |
| 11 |
|
| 12 |
; CHECK-SPIRV-DAG: 4 TypeInt [[U8:[0-9]+]] 8 0 |
| 13 |
; CHECK-SPIRV-DAG: 4 TypeInt [[U32:[0-9]+]] 32 0 |
| 14 |
; CHECK-SPIRV-DAG: 4 TypeInt [[U64:[0-9]+]] 64 0 |
| 15 |
; CHECK-SPIRV-DAG: 4 Constant [[U32]] [[I320:[0-9]+]] 0 |
| 16 |
; CHECK-SPIRV-DAG: 4 Constant [[U32]] [[I323:[0-9]+]] 3 |
| 17 |
; CHECK-SPIRV: 4 TypePointer [[AS2:[0-9]+]] 0 [[U8]] |
| 18 |
; CHECK-SPIRV: 4 TypePointer [[AS1:[0-9]+]] 5 [[U8]] |
| 19 |
; CHECK-SPIRV-DAG: 4 TypeStruct [[STRUCTTY:[0-9]+]] |
| 20 |
; CHECK-SPIRV-DAG: 4 TypeArray [[ARRAYTY:[0-9]+]] [[AS1]] [[I323]] |
| 21 |
|
| 22 |
@astr = internal addrspace(2) constant [7 x i8] c"string\00", align 4 |
| 23 |
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[ASTR:[0-9]+]] 0 |
| 24 |
|
| 25 |
@i64arr = addrspace(1) constant [3 x i64] [i64 0, i64 1, i64 2] |
| 26 |
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[I64ARR:[0-9]+]] 5 |
| 27 |
|
| 28 |
@struct = addrspace(1) global {ptr addrspace(2), ptr addrspace(1)} { ptr addrspace(2) @astr, ptr addrspace(1) @i64arr } |
| 29 |
|
| 30 |
; CHECK-SPIRV: 7 SpecConstantOp [[AS2]] [[ASTRC:[0-9]+]] 70 [[ASTR]] [[I320]] [[I320]] |
| 31 |
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[I64ARRC:[0-9]+]] 124 [[I64ARR]] |
| 32 |
; CHECK-SPIRV: 5 ConstantComposite [[STRUCTTY]] [[STRUCT_INIT:[0-9]+]] [[ASTRC]] [[I64ARRC]] |
| 33 |
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[STRUCT:[0-9]+]] 5 [[STRUCT_INIT]] |
| 34 |
|
| 35 |
@array = addrspace(1) global [3 x ptr addrspace(1)] [ptr addrspace(1) @i64arr, ptr addrspace(1) @struct, ptr addrspace(1) getelementptr ([3 x i64], ptr addrspace(1) @i64arr, i64 0, i64 1) ] |
| 36 |
|
| 37 |
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[I64ARRC2:[0-9]+]] 124 [[I64ARR]] |
| 38 |
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[STRUCTC:[0-9]+]] 124 [[STRUCT]] |
| 39 |
; CHECK-SPIRV: 7 SpecConstantOp {{[0-9]+}} [[GEP:[0-9]+]] 70 [[I64ARR]] |
| 40 |
; CHECK-SPIRV: 6 ConstantComposite [[ARRAYTY]] [[ARRAY_INIT:[0-9]+]] [[I64ARRC2]] [[STRUCTC]] [[GEP]] |
| 41 |
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[ARRAY:[0-9]+]] 5 [[ARRAY_INIT]] |
| 42 |
|
| 43 |
; CHECK-LLVM: %structtype = type { ptr addrspace(2), ptr addrspace(1) } |
| 44 |
; CHECK-LLVM: @astr = internal unnamed_addr addrspace(2) constant [7 x i8] c"string\00", align 4 |
| 45 |
; CHECK-LLVM: @i64arr = addrspace(1) constant [3 x i64] [i64 0, i64 1, i64 2] |
| 46 |
; CHECK-LLVM: @struct = addrspace(1) global %structtype { ptr addrspace(2) @astr, ptr addrspace(1) @i64arr } |
| 47 |
; CHECK-LLVM: @array = addrspace(1) global [3 x ptr addrspace(1)] [ptr addrspace(1) @i64arr, ptr addrspace(1) @struct, ptr addrspace(1) getelementptr inbounds ([3 x i64], ptr addrspace(1) @i64arr, i64 0, i64 1)] |
| 48 |
|
| 49 |
define spir_kernel void @foo() { |
| 50 |
%val = load i32, ptr addrspace(2) @astr, align 4 |
| 51 |
ret void |
| 52 |
} |