| 1 |
; RUN: llvm-as %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_bfloat16 -o %t.spv |
| 3 |
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 4 |
|
| 5 |
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 6 |
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM |
| 7 |
|
| 8 |
; RUN: not llvm-spirv %t.bc 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR |
| 9 |
|
| 10 |
; CHECK-ERROR: RequiresExtension: Feature requires the following SPIR-V extension: |
| 11 |
; CHECK-ERROR-NEXT: SPV_KHR_bfloat16 |
| 12 |
; CHECK-ERROR-NEXT: NOTE: LLVM module contains bfloat type, translation of which |
| 13 |
; CHECK-ERROR-SAME: requires this extension |
| 14 |
|
| 15 |
source_filename = "bfloat16.cpp" |
| 16 |
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" |
| 17 |
target triple = "spirv64-unknown-unknown" |
| 18 |
|
| 19 |
; CHECK-SPIRV-DAG: Capability BFloat16TypeKHR |
| 20 |
; CHECK-SPIRV-DAG: Extension "SPV_KHR_bfloat16" |
| 21 |
; CHECK-SPIRV: 4 TypeFloat [[BFLOAT:[0-9]+]] 16 0 |
| 22 |
; CHECK-SPIRV: 4 TypeVector [[#]] [[BFLOAT]] 2 |
| 23 |
|
| 24 |
; CHECK-LLVM: [[ADDR1:]] = alloca bfloat |
| 25 |
; CHECK-LLVM: [[ADDR2:]] = alloca <2 x bfloat> |
| 26 |
; CHECK-LLVM: [[DATA1:]] = load bfloat, ptr [[ADDR1]] |
| 27 |
; CHECK-LLVM: [[DATA2:]] = load <2 x bfloat>, ptr [[ADDR2]] |
| 28 |
|
| 29 |
define spir_kernel void @test() { |
| 30 |
entry: |
| 31 |
%addr1 = alloca bfloat |
| 32 |
%addr2 = alloca <2 x bfloat> |
| 33 |
%data1 = load bfloat, ptr %addr1 |
| 34 |
%data2 = load <2 x bfloat>, ptr %addr2 |
| 35 |
ret void |
| 36 |
} |