@@ -79,12 +79,12 @@ static const IselTableEntry isel_table[] = {
7979
8080 [neg_op ] = {Plain , FirstOp , Same , .fo = {SpvOpSNegate , SpvOpSNegate , SpvOpFNegate }},
8181
82- [eq_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpIEqual , SpvOpIEqual , SpvOpFOrdEqual , SpvOpLogicalEqual }},
83- [neq_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpINotEqual , SpvOpINotEqual , SpvOpFOrdNotEqual , SpvOpLogicalNotEqual }},
84- [lt_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSLessThan , SpvOpULessThan , SpvOpFOrdLessThan , ISEL_IDENTITY }},
85- [lte_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSLessThanEqual , SpvOpULessThanEqual , SpvOpFOrdLessThanEqual , ISEL_IDENTITY }},
86- [gt_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSGreaterThan , SpvOpUGreaterThan , SpvOpFOrdGreaterThan , ISEL_IDENTITY }},
87- [gte_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSGreaterThanEqual , SpvOpUGreaterThanEqual , SpvOpFOrdGreaterThanEqual , ISEL_IDENTITY }},
82+ [eq_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpIEqual , SpvOpIEqual , SpvOpFOrdEqual , SpvOpLogicalEqual , SpvOpPtrEqual }},
83+ [neq_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpINotEqual , SpvOpINotEqual , SpvOpFOrdNotEqual , SpvOpLogicalNotEqual , SpvOpPtrNotEqual }},
84+ [lt_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSLessThan , SpvOpULessThan , SpvOpFOrdLessThan , ISEL_ILLEGAL , ISEL_ILLEGAL }},
85+ [lte_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSLessThanEqual , SpvOpULessThanEqual , SpvOpFOrdLessThanEqual , ISEL_ILLEGAL , ISEL_ILLEGAL }},
86+ [gt_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSGreaterThan , SpvOpUGreaterThan , SpvOpFOrdGreaterThan , ISEL_ILLEGAL , ISEL_ILLEGAL }},
87+ [gte_op ] = {Plain , FirstOp , Bool , .fo = {SpvOpSGreaterThanEqual , SpvOpUGreaterThanEqual , SpvOpFOrdGreaterThanEqual , ISEL_ILLEGAL , ISEL_ILLEGAL }},
8888
8989 [not_op ] = {Plain , FirstOp , Same , .fo = {SpvOpNot , SpvOpNot , ISEL_ILLEGAL , SpvOpLogicalNot }},
9090
@@ -109,7 +109,7 @@ static const IselTableEntry isel_table[] = {
109109 { SpvOpBitcast , ISEL_ILLEGAL , SpvOpBitcast , ISEL_ILLEGAL , SpvOpConvertUToPtr },
110110 { SpvOpBitcast , SpvOpBitcast , ISEL_IDENTITY , ISEL_ILLEGAL , ISEL_ILLEGAL /* no fp-ptr casts */ },
111111 { ISEL_ILLEGAL , ISEL_ILLEGAL , ISEL_ILLEGAL , ISEL_IDENTITY , ISEL_ILLEGAL /* no bool reinterpret */ },
112- { SpvOpConvertPtrToU , SpvOpConvertPtrToU , ISEL_ILLEGAL , ISEL_ILLEGAL , ISEL_IDENTITY }
112+ { SpvOpConvertPtrToU , SpvOpConvertPtrToU , ISEL_ILLEGAL , ISEL_ILLEGAL , ISEL_CUSTOM }
113113 }},
114114
115115 [sqrt_op ] = { Plain , Monomorphic , Same , .extended_set = "GLSL.std.450" , .op = (SpvOp ) GLSLstd450Sqrt },
@@ -195,7 +195,8 @@ static void emit_primop(Emitter* emitter, FnBuilder fn_builder, BBBuilder bb_bui
195195 Nodes results_ts = unwrap_multiple_yield_types (emitter -> arena , instr -> type );
196196 SpvId result_t = results_ts .count >= 1 ? emit_type (emitter , instr -> type ) : emitter -> void_t ;
197197
198- assert (opcode != SpvOpMax );
198+ if (opcode == SpvOpMax )
199+ goto custom ;
199200
200201 if (entry .extended_set ) {
201202 SpvId set_id = get_extended_instruction_set (emitter , entry .extended_set );
@@ -215,7 +216,17 @@ static void emit_primop(Emitter* emitter, FnBuilder fn_builder, BBBuilder bb_bui
215216
216217 return ;
217218 }
219+
220+ custom :
218221 switch (the_op .op ) {
222+ case reinterpret_op : {
223+ const Type * dst = first (the_op .type_arguments );
224+ const Type * src = get_unqualified_type (first (the_op .operands )-> type );
225+ assert (dst -> tag == PtrType_TAG && src -> tag == PtrType_TAG );
226+ assert (src != dst );
227+ results [0 ] = spvb_op (bb_builder , SpvOpBitcast , emit_type (emitter , dst ), 1 , (SpvId []) {spv_emit_value (emitter , bb_builder , first (the_op .operands )) });
228+ return ;
229+ }
219230 case subgroup_ballot_op : {
220231 const Type * i32x4 = pack_type (emitter -> arena , (PackType ) { .width = 4 , .element_type = uint32_type (emitter -> arena ) });
221232 SpvId scope_subgroup = emit_value (emitter , bb_builder , int32_literal (emitter -> arena , SpvScopeSubgroup ));
0 commit comments