
A new test added for spirv-friendly builtins for SPV_KHR_bit_instructions unveiled that current mechanism to detect whether SPIRV Backend is in OpenCL environment or Vulkan environment was not good enough. This PR updates how to detect the environment and all the tests accordingly. *UPDATE*: the new approach is having a new member in `SPIRVSubtarget` to represent the environment. It can be either OpenCL, Kernel or Unknown. If the triple is explicit, we can directly set it at the creation of the `SPIRVSubtarget`, otherwise we just leave it unknown until we find other information that can help us set the environment. For now, the only other information we use to set the environment is `hlsl.shader` attribute at `SPIRV::ExecutionModel::ExecutionModel getExecutionModel(const SPIRVSubtarget &STI, const Function &F)`. Going forward we should consider also specific instructions that are Kernel-exclusive or Shader-exclusive. --------- Co-authored-by: marcos.maronas <mmaronas@smtp.igk.intel.com>
22 lines
656 B
LLVM
22 lines
656 B
LLVM
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
|
|
|
|
; CHECK: OpMemoryModel Logical GLSL450
|
|
|
|
define noundef i32 @countbits_i32(i32 noundef %a) {
|
|
entry:
|
|
; CHECK: %[[#]] = OpBitCount %[[#]] %[[#]]
|
|
%elt.bitreverse = call i32 @llvm.ctpop.i32(i32 %a)
|
|
ret i32 %elt.bitreverse
|
|
}
|
|
|
|
define noundef i16 @countbits_i16(i16 noundef %a) {
|
|
entry:
|
|
; CHECK: %[[#]] = OpBitCount %[[#]] %[[#]]
|
|
%elt.ctpop = call i16 @llvm.ctpop.i16(i16 %a)
|
|
ret i16 %elt.ctpop
|
|
}
|
|
|
|
declare i16 @llvm.ctpop.i16(i16)
|
|
declare i32 @llvm.ctpop.i32(i32)
|