OpSpecConstantOp for OpPtrCastToGeneric or OpGenericCastToPtr
sjfricke opened this issue · comments
It is not possible to have OpSpecConstantOp
for OpPtrCastToGeneric
or OpGenericCastToPtr
currently
Both OpPtrCastToGeneric
or OpGenericCastToPtr
must appear in a block so the following is invalid
%void = OpTypeVoid
%func = OpTypeFunction %void
%f32 = OpTypeFloat 32
%f32ptr_gen = OpTypePointer Generic %f32
%f32ptr_wg = OpTypePointer Workgroup %f32
%var_wg = OpVariable %f32ptr_wg Workgroup
// spirv-val error: PtrCastToGeneric must appear in a block
%ptr_gen = OpPtrCastToGeneric %f32ptr_gen %var_wg
%ptr_wg = OpGenericCastToPtr %f32ptr_wg %ptr_gen
%main = OpFunction %void None %func
%main_entry = OpLabel
OpReturn
OpFunctionEnd
but at the same time SpecConstantOp
cant appear in a function declaration so the following is also invalid
%void = OpTypeVoid
%func = OpTypeFunction %void
%f32 = OpTypeFloat 32
%f32ptr_gen = OpTypePointer Generic %f32
%f32ptr_wg = OpTypePointer Workgroup %f32
%var_wg = OpVariable %f32ptr_wg Workgroup
%main = OpFunction %void None %func
%main_entry = OpLabel
// spirv-val error: SpecConstantOp cannot appear in a function declaration
%ptr_gen = OpSpecConstantOp %f32ptr_gen PtrCastToGeneric %var_wg
%ptr_wg = OpSpecConstantOp %f32ptr_wg GenericCastToPtr %ptr_gen
OpReturn
OpFunctionEnd
So I am not sure when it is possible to use something such asOpSpecConstantOp %_ PtrCastToGeneric
%ptr_gen = OpSpecConstantOp %f32ptr_gen PtrCastToGeneric %var_wg
This line should appear outside the function definition. You use PtrCastToGeneric as an operand to OpSpecConstantOp which is defined outside of the the function.
Closing per discussion in SPIR WG - please reopen if needed