@@ -79,12 +79,12 @@ static const IselTableEntry isel_table[] = {
79
79
80
80
[neg_op ] = {Plain , FirstOp , Same , .fo = {SpvOpSNegate , SpvOpSNegate , SpvOpFNegate }},
81
81
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 }},
88
88
89
89
[not_op ] = {Plain , FirstOp , Same , .fo = {SpvOpNot , SpvOpNot , ISEL_ILLEGAL , SpvOpLogicalNot }},
90
90
@@ -109,7 +109,7 @@ static const IselTableEntry isel_table[] = {
109
109
{ SpvOpBitcast , ISEL_ILLEGAL , SpvOpBitcast , ISEL_ILLEGAL , SpvOpConvertUToPtr },
110
110
{ SpvOpBitcast , SpvOpBitcast , ISEL_IDENTITY , ISEL_ILLEGAL , ISEL_ILLEGAL /* no fp-ptr casts */ },
111
111
{ 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 }
113
113
}},
114
114
115
115
[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
195
195
Nodes results_ts = unwrap_multiple_yield_types (emitter -> arena , instr -> type );
196
196
SpvId result_t = results_ts .count >= 1 ? emit_type (emitter , instr -> type ) : emitter -> void_t ;
197
197
198
- assert (opcode != SpvOpMax );
198
+ if (opcode == SpvOpMax )
199
+ goto custom ;
199
200
200
201
if (entry .extended_set ) {
201
202
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
215
216
216
217
return ;
217
218
}
219
+
220
+ custom :
218
221
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
+ }
219
230
case subgroup_ballot_op : {
220
231
const Type * i32x4 = pack_type (emitter -> arena , (PackType ) { .width = 4 , .element_type = uint32_type (emitter -> arena ) });
221
232
SpvId scope_subgroup = emit_value (emitter , bb_builder , int32_literal (emitter -> arena , SpvScopeSubgroup ));
0 commit comments