File tree 2 files changed +20
-5
lines changed
lib/Conversion/FuncToEmitC
test/Conversion/FuncToEmitC
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,14 @@ class CallOpConversion final : public OpConversionPattern<func::CallOp> {
31
31
LogicalResult
32
32
matchAndRewrite (func::CallOp callOp, OpAdaptor adaptor,
33
33
ConversionPatternRewriter &rewriter) const override {
34
- // Multiple results func was not converted to `emitc.func`.
34
+ // Multiple results func cannot be converted to `emitc.func`.
35
35
if (callOp.getNumResults () > 1 )
36
36
return rewriter.notifyMatchFailure (
37
37
callOp, " only functions with zero or one result can be converted" );
38
38
39
- rewriter.replaceOpWithNewOp <emitc::CallOp>(
40
- callOp,
41
- callOp.getNumResults () ? callOp.getResult (0 ).getType () : nullptr ,
42
- adaptor.getOperands (), callOp->getAttrs ());
39
+ rewriter.replaceOpWithNewOp <emitc::CallOp>(callOp, callOp.getResultTypes (),
40
+ adaptor.getOperands (),
41
+ callOp->getAttrs ());
43
42
44
43
return success ();
45
44
}
Original file line number Diff line number Diff line change @@ -58,3 +58,19 @@ func.func @call(%arg0: i32) -> i32 {
58
58
59
59
// CHECK-LABEL: emitc.func private @return_i32(i32) -> i32 attributes {specifiers = ["extern"]}
60
60
func.func private @return_i32 (%arg0: i32 ) -> i32
61
+
62
+ // -----
63
+
64
+ // CHECK-LABEL: emitc.func private @return_void() attributes {specifiers = ["static"]}
65
+ // CHECK-NEXT: emitc.return
66
+ func.func private @return_void () {
67
+ return
68
+ }
69
+
70
+ // CHECK-LABEL: emitc.func @call()
71
+ // CHECK-NEXT: emitc.call @return_void() : () -> ()
72
+ // CHECK-NEXT: emitc.return
73
+ func.func @call () {
74
+ call @return_void () : () -> ()
75
+ return
76
+ }
You can’t perform that action at this time.
0 commit comments