[Test] Add errors test case for HLSCpp dialect

This commit is contained in:
Hanchen Ye 2022-03-23 23:26:08 -05:00
parent 98bf329d1e
commit 75338f35da
2 changed files with 23 additions and 2 deletions

View File

@ -182,7 +182,7 @@ template <typename OpType> static LogicalResult verifyChannelUsers(OpType op) {
return user->emitOpError("unsupported user of a stream channel");
}
if (numWrite > 1)
return op->emitOpError("stream channel is written multiple times");
return op->emitOpError("stream channel is written by multiple ops");
return success();
}
@ -389,7 +389,6 @@ struct SimplifyPrimCastOp : public OpRewritePattern<PrimCastOp> {
defCast.input());
return success();
}
return failure();
}
};

22
test/Dialect/errors.mlir Normal file
View File

@ -0,0 +1,22 @@
// RUN: scalehls-opt %s -verify-diagnostics
func @node0() -> (!hlscpp.stream<i1, 1>) {
// expected-error @+1 {{'hlscpp.stream.channel' op stream channel is written by multiple ops}}
%channel = "hlscpp.stream.channel"() : () -> !hlscpp.stream<i1, 1>
return %channel : !hlscpp.stream<i1, 1>
}
func @node1(%channel : !hlscpp.stream<i1, 1>) {
call @node0() : () -> !hlscpp.stream<i1, 1>
%false = arith.constant false
"hlscpp.stream.write"(%channel, %false) : (!hlscpp.stream<i1, 1>, i1) -> ()
return
}
func @dataflow() {
%channel = call @node0() : () -> !hlscpp.stream<i1, 1>
call @node1(%channel) : (!hlscpp.stream<i1, 1>) -> ()
%false = arith.constant false
"hlscpp.stream.write"(%channel, %false) : (!hlscpp.stream<i1, 1>, i1) -> ()
return
}