- Redefines `DXILAttribute` to denote a function attribute, compatible to how it was define in DXC/LLVM 3.7 - Fix how `DXILAttribute` is emitted to be a struct of set attributes instead of an "or" of the enums - Implement the lowering of `DXILAttribute` to LLVM function attributes in `DXILOpBuilder.cpp`. A custom mapping is defined. - Audit all current ops to specify the correct attributes consistent with DXC. This is done here to allow for testing. - Update testcases in `llvm/test/CodeGen/DirectX` of all ops with attributes to match that attributes are set - Update testcases of ops that had previously incorrectly set attributes to check there is no attributes set - Defines `DXILProperty` to denote the other type of attributes from DXC used to query properties. - Emit `DXILProperty` as a struct of set attributes. - Updates `DXIL.td` to specify applicable `DXILProperty`s on ops Note: `DXILProperty` was referred to as 'queryable attributes' in design discussion. Changed to property to allow for better expression in `DXIL.td` Resolves #114461 Resolves #115912
117 lines
5.7 KiB
LLVM
117 lines
5.7 KiB
LLVM
; RUN: opt -S -dxil-op-lower %s | FileCheck %s
|
|
|
|
target triple = "dxil-pc-shadermodel6.6-compute"
|
|
|
|
define void @storefloat(<4 x float> %data, i32 %index) {
|
|
|
|
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
|
|
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
|
|
%buffer = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
|
|
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0(
|
|
i32 0, i32 0, i32 1, i32 0, i1 false)
|
|
|
|
; The temporary casts should all have been cleaned up
|
|
; CHECK-NOT: %dx.resource.casthandle
|
|
|
|
; CHECK: [[DATA0_0:%.*]] = extractelement <4 x float> %data, i32 0
|
|
; CHECK: [[DATA0_1:%.*]] = extractelement <4 x float> %data, i32 1
|
|
; CHECK: [[DATA0_2:%.*]] = extractelement <4 x float> %data, i32 2
|
|
; CHECK: [[DATA0_3:%.*]] = extractelement <4 x float> %data, i32 3
|
|
; CHECK: call void @dx.op.bufferStore.f32(i32 69, %dx.types.Handle [[HANDLE]], i32 %index, i32 undef, float [[DATA0_0]], float [[DATA0_1]], float [[DATA0_2]], float [[DATA0_3]], i8 15){{$}}
|
|
call void @llvm.dx.resource.store.typedbuffer(
|
|
target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer,
|
|
i32 %index, <4 x float> %data)
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @storeint(<4 x i32> %data, i32 %index) {
|
|
|
|
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
|
|
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
|
|
%buffer = call target("dx.TypedBuffer", <4 x i32>, 1, 0, 0)
|
|
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4i32_1_0_0(
|
|
i32 0, i32 0, i32 1, i32 0, i1 false)
|
|
|
|
; CHECK: [[DATA0_0:%.*]] = extractelement <4 x i32> %data, i32 0
|
|
; CHECK: [[DATA0_1:%.*]] = extractelement <4 x i32> %data, i32 1
|
|
; CHECK: [[DATA0_2:%.*]] = extractelement <4 x i32> %data, i32 2
|
|
; CHECK: [[DATA0_3:%.*]] = extractelement <4 x i32> %data, i32 3
|
|
; CHECK: call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle [[HANDLE]], i32 %index, i32 undef, i32 [[DATA0_0]], i32 [[DATA0_1]], i32 [[DATA0_2]], i32 [[DATA0_3]], i8 15){{$}}
|
|
call void @llvm.dx.resource.store.typedbuffer(
|
|
target("dx.TypedBuffer", <4 x i32>, 1, 0, 0) %buffer,
|
|
i32 %index, <4 x i32> %data)
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @storehalf(<4 x half> %data, i32 %index) {
|
|
|
|
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
|
|
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
|
|
%buffer = call target("dx.TypedBuffer", <4 x half>, 1, 0, 0)
|
|
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f16_1_0_0(
|
|
i32 0, i32 0, i32 1, i32 0, i1 false)
|
|
|
|
; The temporary casts should all have been cleaned up
|
|
; CHECK-NOT: %dx.resource.casthandle
|
|
|
|
; CHECK: [[DATA0_0:%.*]] = extractelement <4 x half> %data, i32 0
|
|
; CHECK: [[DATA0_1:%.*]] = extractelement <4 x half> %data, i32 1
|
|
; CHECK: [[DATA0_2:%.*]] = extractelement <4 x half> %data, i32 2
|
|
; CHECK: [[DATA0_3:%.*]] = extractelement <4 x half> %data, i32 3
|
|
; CHECK: call void @dx.op.bufferStore.f16(i32 69, %dx.types.Handle [[HANDLE]], i32 %index, i32 undef, half [[DATA0_0]], half [[DATA0_1]], half [[DATA0_2]], half [[DATA0_3]], i8 15){{$}}
|
|
call void @llvm.dx.resource.store.typedbuffer(
|
|
target("dx.TypedBuffer", <4 x half>, 1, 0, 0) %buffer,
|
|
i32 %index, <4 x half> %data)
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @storei16(<4 x i16> %data, i32 %index) {
|
|
|
|
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
|
|
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
|
|
%buffer = call target("dx.TypedBuffer", <4 x i16>, 1, 0, 0)
|
|
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4i16_1_0_0(
|
|
i32 0, i32 0, i32 1, i32 0, i1 false)
|
|
|
|
; The temporary casts should all have been cleaned up
|
|
; CHECK-NOT: %dx.resource.casthandle
|
|
|
|
; CHECK: [[DATA0_0:%.*]] = extractelement <4 x i16> %data, i32 0
|
|
; CHECK: [[DATA0_1:%.*]] = extractelement <4 x i16> %data, i32 1
|
|
; CHECK: [[DATA0_2:%.*]] = extractelement <4 x i16> %data, i32 2
|
|
; CHECK: [[DATA0_3:%.*]] = extractelement <4 x i16> %data, i32 3
|
|
; CHECK: call void @dx.op.bufferStore.i16(i32 69, %dx.types.Handle [[HANDLE]], i32 %index, i32 undef, i16 [[DATA0_0]], i16 [[DATA0_1]], i16 [[DATA0_2]], i16 [[DATA0_3]], i8 15){{$}}
|
|
call void @llvm.dx.resource.store.typedbuffer(
|
|
target("dx.TypedBuffer", <4 x i16>, 1, 0, 0) %buffer,
|
|
i32 %index, <4 x i16> %data)
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @store_scalarized_floats(float %data0, float %data1, float %data2, float %data3, i32 %index) {
|
|
|
|
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
|
|
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
|
|
%buffer = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
|
|
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0(
|
|
i32 0, i32 0, i32 1, i32 0, i1 false)
|
|
|
|
; We shouldn't end up with any inserts/extracts.
|
|
; CHECK-NOT: insertelement
|
|
; CHECK-NOT: extractelement
|
|
|
|
; CHECK: call void @dx.op.bufferStore.f32(i32 69, %dx.types.Handle [[HANDLE]], i32 %index, i32 undef, float %data0, float %data1, float %data2, float %data3, i8 15)
|
|
%vec.upto0 = insertelement <4 x float> poison, float %data0, i64 0
|
|
%vec.upto1 = insertelement <4 x float> %vec.upto0, float %data1, i64 1
|
|
%vec.upto2 = insertelement <4 x float> %vec.upto1, float %data2, i64 2
|
|
%vec = insertelement <4 x float> %vec.upto2, float %data3, i64 3
|
|
call void @llvm.dx.resource.store.typedbuffer(
|
|
target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer,
|
|
i32 %index, <4 x float> %vec)
|
|
|
|
ret void
|
|
}
|