Browse Source

[spirv] Update the passthru-cs test.

TODO: We need to overhaul the way we recognize which instructions are
rvalues.
Ehsan 6 năm trước cách đây
mục cha
commit
4770e8083b

+ 2 - 0
tools/clang/lib/SPIRV/SpirvBuilder.cpp

@@ -177,6 +177,7 @@ SpirvLoad *SpirvBuilder::createLoad(QualType resultType,
   auto *instruction =
       new (context) SpirvLoad(resultType, /*id*/ 0, loc, pointer);
   instruction->setStorageClass(pointer->getStorageClass());
+  instruction->setRValue();
   insertPoint->addInstruction(instruction);
   return instruction;
 }
@@ -189,6 +190,7 @@ SpirvLoad *SpirvBuilder::createLoad(const SpirvType *resultType,
       new (context) SpirvLoad(/*QualType*/ {}, /*id*/ 0, loc, pointer);
   instruction->setResultType(resultType);
   instruction->setStorageClass(pointer->getStorageClass());
+  instruction->setRValue();
   insertPoint->addInstruction(instruction);
   return instruction;
 }

+ 66 - 66
tools/clang/test/CodeGenSPIRV/passthru-cs.hlsl2spv

@@ -23,79 +23,79 @@ void main( uint3 DTid : SV_DispatchThreadID )
 // ; Generator: Google spiregg; 0
 // ; Bound: 44
 // ; Schema: 0
-// OpCapability Shader
-// OpMemoryModel Logical GLSL450
-// OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
-// OpExecutionMode %main LocalSize 1 1 1
-// OpSource HLSL 600
-// OpName %bb_entry "bb.entry"
-// OpName %type_ByteAddressBuffer "type.ByteAddressBuffer"
-// OpName %Buffer0 "Buffer0"
-// OpName %type_RWByteAddressBuffer "type.RWByteAddressBuffer"
-// OpName %BufferOut "BufferOut"
-// OpName %src_main "src.main"
-// OpName %main "main"
-// OpName %param_var_DTid "param.var.DTid"
-// OpName %DTid "DTid"
-// OpName %word "word"
-// OpDecorate %_runtimearr_uint ArrayStride 4
-// OpDecorate %type_ByteAddressBuffer BufferBlock
-// OpMemberDecorate %type_ByteAddressBuffer 0 Offset 0
-// OpMemberDecorate %type_ByteAddressBuffer 0 NonWritable
-// OpDecorate %type_RWByteAddressBuffer BufferBlock
-// OpMemberDecorate %type_RWByteAddressBuffer 0 Offset 0
-// OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
-// OpDecorate %Buffer0 DescriptorSet 0
-// OpDecorate %Buffer0 Binding 0
-// OpDecorate %BufferOut DescriptorSet 0
-// OpDecorate %BufferOut Binding 1
-// %uint = OpTypeInt 32 0
+//                OpCapability Shader
+//                OpMemoryModel Logical GLSL450
+//                OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
+//                OpExecutionMode %main LocalSize 1 1 1
+//                OpSource HLSL 600
+//                OpName %type_ByteAddressBuffer "type.ByteAddressBuffer"
+//                OpName %Buffer0 "Buffer0"
+//                OpName %type_RWByteAddressBuffer "type.RWByteAddressBuffer"
+//                OpName %BufferOut "BufferOut"
+//                OpName %main "main"
+//                OpName %param_var_DTid "param.var.DTid"
+//                OpName %src_main "src.main"
+//                OpName %DTid "DTid"
+//                OpName %bb_entry "bb.entry"
+//                OpName %word "word"
+//                OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
+//                OpDecorate %Buffer0 DescriptorSet 0
+//                OpDecorate %Buffer0 Binding 0
+//                OpDecorate %BufferOut DescriptorSet 0
+//                OpDecorate %BufferOut Binding 1
+//                OpDecorate %_runtimearr_uint ArrayStride 4
+//                OpMemberDecorate %type_ByteAddressBuffer 0 Offset 0
+//                OpMemberDecorate %type_ByteAddressBuffer 0 NonWritable
+//                OpDecorate %type_ByteAddressBuffer BufferBlock
+//                OpMemberDecorate %type_RWByteAddressBuffer 0 Offset 0
+//                OpDecorate %type_RWByteAddressBuffer BufferBlock
+//         %int = OpTypeInt 32 1
+//        %uint = OpTypeInt 32 0
 // %_runtimearr_uint = OpTypeRuntimeArray %uint
 // %type_ByteAddressBuffer = OpTypeStruct %_runtimearr_uint
 // %_ptr_Uniform_type_ByteAddressBuffer = OpTypePointer Uniform %type_ByteAddressBuffer
 // %type_RWByteAddressBuffer = OpTypeStruct %_runtimearr_uint
 // %_ptr_Uniform_type_RWByteAddressBuffer = OpTypePointer Uniform %type_RWByteAddressBuffer
-// %void = OpTypeVoid
-// %11 = OpTypeFunction %void
-// %v3uint = OpTypeVector %uint 3
-// %_ptr_Function_v3uint = OpTypePointer Function %v3uint
+//      %v3uint = OpTypeVector %uint 3
 // %_ptr_Input_v3uint = OpTypePointer Input %v3uint
-// %21 = OpTypeFunction %void %_ptr_Function_v3uint
+//        %void = OpTypeVoid
+//          %19 = OpTypeFunction %void
+// %_ptr_Function_v3uint = OpTypePointer Function %v3uint
+//          %26 = OpTypeFunction %void %_ptr_Function_v3uint
 // %_ptr_Function_uint = OpTypePointer Function %uint
-// %int = OpTypeInt 32 1
-// %int_0 = OpConstant %int 0
-// %uint_4 = OpConstant %uint 4
-// %uint_2 = OpConstant %uint 2
 // %_ptr_Uniform_uint = OpTypePointer Uniform %uint
-// %uint_0 = OpConstant %uint 0
-// %Buffer0 = OpVariable %_ptr_Uniform_type_ByteAddressBuffer Uniform
-// %BufferOut = OpVariable %_ptr_Uniform_type_RWByteAddressBuffer Uniform
+//       %int_0 = OpConstant %int 0
+//      %uint_4 = OpConstant %uint 4
+//      %uint_2 = OpConstant %uint 2
+//      %uint_0 = OpConstant %uint 0
+//     %Buffer0 = OpVariable %_ptr_Uniform_type_ByteAddressBuffer Uniform
+//   %BufferOut = OpVariable %_ptr_Uniform_type_RWByteAddressBuffer Uniform
 // %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
-// %main = OpFunction %void None %11
-// %13 = OpLabel
+//        %main = OpFunction %void None %19
+//          %20 = OpLabel
 // %param_var_DTid = OpVariable %_ptr_Function_v3uint Function
-// %19 = OpLoad %v3uint %gl_GlobalInvocationID
-// OpStore %param_var_DTid %19
-// %20 = OpFunctionCall %void %src_main %param_var_DTid
-// OpReturn
-// OpFunctionEnd
-// %src_main = OpFunction %void None %21
-// %DTid = OpFunctionParameter %_ptr_Function_v3uint
-// %bb_entry = OpLabel
-// %word = OpVariable %_ptr_Function_uint Function
-// %28 = OpAccessChain %_ptr_Function_uint %DTid %int_0
-// %29 = OpLoad %uint %28
-// %31 = OpIMul %uint %29 %uint_4
-// %33 = OpShiftRightLogical %uint %31 %uint_2
-// %36 = OpAccessChain %_ptr_Uniform_uint %Buffer0 %uint_0 %33
-// %37 = OpLoad %uint %36
-// OpStore %word %37
-// %38 = OpAccessChain %_ptr_Function_uint %DTid %int_0
-// %39 = OpLoad %uint %38
-// %40 = OpIMul %uint %39 %uint_4
-// %41 = OpShiftRightLogical %uint %40 %uint_2
-// %42 = OpLoad %uint %word
-// %43 = OpAccessChain %_ptr_Uniform_uint %BufferOut %uint_0 %41
-// OpStore %43 %42
-// OpReturn
-// OpFunctionEnd
+//          %23 = OpLoad %v3uint %gl_GlobalInvocationID
+//                OpStore %param_var_DTid %23
+//          %24 = OpFunctionCall %void %src_main %param_var_DTid
+//                OpReturn
+//                OpFunctionEnd
+//    %src_main = OpFunction %void None %26
+//        %DTid = OpFunctionParameter %_ptr_Function_v3uint
+//    %bb_entry = OpLabel
+//        %word = OpVariable %_ptr_Function_uint Function
+//          %31 = OpAccessChain %_ptr_Function_uint %DTid %int_0
+//          %32 = OpLoad %uint %31
+//          %33 = OpIMul %uint %32 %uint_4
+//          %34 = OpShiftRightLogical %uint %33 %uint_2
+//          %36 = OpAccessChain %_ptr_Uniform_uint %Buffer0 %uint_0 %34
+//          %37 = OpLoad %uint %36
+//                OpStore %word %37
+//          %38 = OpAccessChain %_ptr_Function_uint %DTid %int_0
+//          %39 = OpLoad %uint %38
+//          %40 = OpIMul %uint %39 %uint_4
+//          %41 = OpShiftRightLogical %uint %40 %uint_2
+//          %42 = OpLoad %uint %word
+//          %43 = OpAccessChain %_ptr_Uniform_uint %BufferOut %uint_0 %41
+//                OpStore %43 %42
+//                OpReturn
+//                OpFunctionEnd