File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -757,7 +757,7 @@ class TruncFConversion : public OpConversionPattern<arith::TruncFOp> {
757757 return rewriter.notifyMatchFailure (castOp,
758758 " unsupported cast destination type" );
759759
760- if (!castOp. areCastCompatible (operandType, dstType))
760+ if (!emitc::CastOp:: areCastCompatible (operandType, dstType))
761761 return rewriter.notifyMatchFailure (castOp, " cast-incompatible types" );
762762
763763 rewriter.replaceOpWithNewOp <emitc::CastOp>(castOp, dstType,
@@ -787,7 +787,7 @@ class ExtFConversion : public OpConversionPattern<arith::ExtFOp> {
787787 return rewriter.notifyMatchFailure (castOp,
788788 " unsupported cast destination type" );
789789
790- if (!castOp. areCastCompatible (operandType, dstType))
790+ if (!emitc::CastOp:: areCastCompatible (operandType, dstType))
791791 return rewriter.notifyMatchFailure (castOp, " cast-incompatible types" );
792792
793793 rewriter.replaceOpWithNewOp <emitc::CastOp>(castOp, dstType,
Original file line number Diff line number Diff line change @@ -313,6 +313,10 @@ LogicalResult emitc::AssignOp::verify() {
313313bool CastOp::areCastCompatible (TypeRange inputs, TypeRange outputs) {
314314 Type input = inputs.front (), output = outputs.front ();
315315
316+ // Opaque types are always allowed
317+ if (isa<emitc::OpaqueType>(input) || isa<emitc::OpaqueType>(output))
318+ return true ;
319+
316320 // Cast to array is only possible from an array
317321 if (isa<emitc::ArrayType>(input) != isa<emitc::ArrayType>(output))
318322 return false ;
Original file line number Diff line number Diff line change @@ -36,11 +36,15 @@ emitc.func private @extern(i32) attributes {specifiers = ["extern"]}
3636
3737func.func @cast (%arg0: i32 ) {
3838 %1 = emitc.cast %arg0: i32 to f32
39+ %2 = emitc.cast %1: f32 to !emitc.opaque <" some type" >
40+ %3 = emitc.cast %2: !emitc.opaque <" some type" > to !emitc.size_t
3941 return
4042}
4143
4244func.func @cast_array (%arg : !emitc.array <4 xf32 >) {
4345 %1 = emitc.cast %arg: !emitc.array <4 xf32 > to !emitc.array <4 xf32 > ref
46+ %2 = emitc.cast %arg: !emitc.array <4 xf32 > to !emitc.opaque <" some type" >
47+ %3 = emitc.cast %2: !emitc.opaque <" some type" > to !emitc.array <4 xf32 > ref
4448 return
4549}
4650
You can’t perform that action at this time.
0 commit comments