@@ -247,12 +247,19 @@ LogicalResult emitc::AssignOp::verify() {
247247bool CastOp::areCastCompatible (TypeRange inputs, TypeRange outputs) {
248248 Type input = inputs.front (), output = outputs.front ();
249249
250- return ((emitc::isIntegerIndexOrOpaqueType (input) ||
251- emitc::isSupportedFloatType (input) ||
252- isa<emitc::PointerType>(input) || isa<emitc::ArrayType>(input)) &&
253- (emitc::isIntegerIndexOrOpaqueType (output) ||
254- emitc::isSupportedFloatType (output) ||
255- isa<emitc::PointerType>(output)));
250+ if (auto arrayType = dyn_cast<emitc::ArrayType>(input)) {
251+ if (auto pointerType = dyn_cast<emitc::PointerType>(output)) {
252+ return (arrayType.getElementType () == pointerType.getPointee ()) &&
253+ arrayType.getShape ().size () == 1 && arrayType.getShape ()[0 ] >= 1 ;
254+ }
255+ return false ;
256+ }
257+
258+ return (
259+ (emitc::isIntegerIndexOrOpaqueType (input) ||
260+ emitc::isSupportedFloatType (input) || isa<emitc::PointerType>(input)) &&
261+ (emitc::isIntegerIndexOrOpaqueType (output) ||
262+ emitc::isSupportedFloatType (output) || isa<emitc::PointerType>(output)));
256263}
257264
258265// ===----------------------------------------------------------------------===//
@@ -700,9 +707,9 @@ void IfOp::print(OpAsmPrinter &p) {
700707
701708// / Given the region at `index`, or the parent operation if `index` is None,
702709// / return the successor regions. These are the regions that may be selected
703- // / during the flow of control. `operands` is a set of optional attributes that
704- // / correspond to a constant value for each operand, or null if that operand is
705- // / not a constant.
710+ // / during the flow of control. `operands` is a set of optional attributes
711+ // / that correspond to a constant value for each operand, or null if that
712+ // / operand is not a constant.
706713void IfOp::getSuccessorRegions (RegionBranchPoint point,
707714 SmallVectorImpl<RegionSuccessor> ®ions) {
708715 // The `then` and the `else` region branch back to the parent operation.
@@ -1000,8 +1007,8 @@ emitc::ArrayType::cloneWith(std::optional<ArrayRef<int64_t>> shape,
10001007LogicalResult mlir::emitc::LValueType::verify (
10011008 llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
10021009 mlir::Type value) {
1003- // Check that the wrapped type is valid. This especially forbids nested lvalue
1004- // types.
1010+ // Check that the wrapped type is valid. This especially forbids nested
1011+ // lvalue types.
10051012 if (!isSupportedEmitCType (value))
10061013 return emitError ()
10071014 << " !emitc.lvalue must wrap supported emitc type, but got " << value;
0 commit comments