
This PR contains changes in virtual register processing aimed to improve correctness of emitted MIR between passes from the perspective of MachineVerifier. This potentially helps to detect previously missed flaws in code emission and harden the test suite. As a measure of correctness and usefulness of this PR we may use a mode with expensive checks set on, and MachineVerifier reports problems in the test suite. In order to satisfy Machine Verifier requirements to MIR correctness not only a rework of usage of virtual registers' types and classes is required, but also corrections into pre-legalizer and instruction selection logics. Namely, the following changes are introduced: * scalar virtual registers have proper bit width, * detect register class by SPIR-V type, * add a superclass for id virtual register classes, * fix Tablegen rules used for instruction selection, * fixes of minor existed issues (missed flag for proper representation of a null constant for OpenCL vs. HLSL, wrong usage of integer virtual registers as a synonym of any non-type virtual register).
55 lines
2.8 KiB
LLVM
55 lines
2.8 KiB
LLVM
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
|
|
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
|
|
;; FIXME: Write tests to ensure invalid usage of image are rejected, such as:
|
|
;; - invalid AS (only global is allowed);
|
|
;; - used in struct, union, array, pointer or return types;
|
|
;; - used with invalid CV-qualifiers (const or volatile in C99).
|
|
;; FIXME: Write further tests to cover _array, _buffer, _depth, ... types.
|
|
|
|
define void @foo(
|
|
target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a,
|
|
target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b,
|
|
target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c,
|
|
i32 addrspace(1)* %d
|
|
) {
|
|
%pixel = call <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a, i32 0)
|
|
call void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b, <2 x i32> zeroinitializer, <4 x i32> %pixel)
|
|
%size = call i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c)
|
|
store i32 %size, i32 addrspace(1)* %d
|
|
ret void
|
|
}
|
|
|
|
declare <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), i32)
|
|
|
|
declare void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32>, <4 x i32>)
|
|
|
|
declare i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2))
|
|
|
|
|
|
;; Capabilities:
|
|
; CHECK-DAG: OpCapability ImageReadWrite
|
|
; CHECK-NOT: DAG-FENCE
|
|
|
|
;; Types, Constants and Variables:
|
|
;; FIXME: The values should be double checked here.
|
|
; CHECK-DAG: %[[#IMG_1D:]] = OpTypeImage %[[#VOID:]] 1D 0 0 0 0 Unknown ReadOnly
|
|
; CHECK-DAG: %[[#IMG_2D:]] = OpTypeImage %[[#VOID]] 2D 0 0 0 0 Unknown WriteOnly
|
|
; CHECK-DAG: %[[#IMG_3D:]] = OpTypeImage %[[#VOID]] 3D 0 0 0 0 Unknown ReadWrite
|
|
; CHECK-DAG: %[[#PTR:]] = OpTypePointer CrossWorkgroup %[[#I32:]]
|
|
; CHECK-DAG: %[[#FN:]] = OpTypeFunction %[[#VOID]] %[[#IMG_1D]] %[[#IMG_2D]] %[[#IMG_3D]] %[[#PTR]]
|
|
|
|
;; Functions:
|
|
; CHECK: OpFunction %[[#VOID]] None %[[#FN]]
|
|
; CHECK: %[[#A:]] = OpFunctionParameter %[[#IMG_1D]]
|
|
; CHECK: %[[#B:]] = OpFunctionParameter %[[#IMG_2D]]
|
|
; CHECK: %[[#C:]] = OpFunctionParameter %[[#IMG_3D]]
|
|
; CHECK: %[[#D:]] = OpFunctionParameter %[[#PTR]]
|
|
; CHECK: %[[#PIXEL:]] = OpImageRead %[[#VEC:]] %[[#A]] %[[#]]
|
|
; CHECK: OpImageWrite %[[#B]] %[[#]] %[[#PIXEL]]
|
|
;; FIXME: It is unclear which of OpImageQuerySize and OpImageQuerySizeLod should be used.
|
|
; CHECK: %[[#SIZE:]] = OpImageQuerySize{{(Lod)?}} %[[#]] %[[#C]]
|