@@ -4249,12 +4249,14 @@ class MLIRGenImpl
42494249 // cast from optional<T> type
42504250 if (auto leftOptType = leftExpressionValue.getType ().dyn_cast_or_null <mlir_ts::OptionalType>())
42514251 {
4252- leftExpressionValue = cast (loc (leftExpression), leftOptType.getElementType (), leftExpressionValue, genContext);
4252+ leftExpressionValue =
4253+ builder.create <mlir_ts::ValueOp>(loc (leftExpression), leftOptType.getElementType (), leftExpressionValue);
42534254 }
42544255
42554256 if (auto rightOptType = rightExpressionValue.getType ().dyn_cast_or_null <mlir_ts::OptionalType>())
42564257 {
4257- rightExpressionValue = cast (loc (rightExpression), rightOptType.getElementType (), rightExpressionValue, genContext);
4258+ rightExpressionValue =
4259+ builder.create <mlir_ts::ValueOp>(loc (rightExpression), rightOptType.getElementType (), rightExpressionValue);
42584260 }
42594261 }
42604262 }
@@ -4265,8 +4267,10 @@ class MLIRGenImpl
42654267 {
42664268 if (auto rightOptType = rightExpressionValue.getType ().dyn_cast_or_null <mlir_ts::OptionalType>())
42674269 {
4268- leftExpressionValue = cast (loc (leftExpression), leftOptType.getElementType (), leftExpressionValue, genContext);
4269- rightExpressionValue = cast (loc (rightExpression), rightOptType.getElementType (), rightExpressionValue, genContext);
4270+ leftExpressionValue =
4271+ builder.create <mlir_ts::ValueOp>(loc (leftExpression), leftOptType.getElementType (), leftExpressionValue);
4272+ rightExpressionValue =
4273+ builder.create <mlir_ts::ValueOp>(loc (rightExpression), rightOptType.getElementType (), rightExpressionValue);
42704274 }
42714275 }
42724276 }
@@ -5029,7 +5033,7 @@ class MLIRGenImpl
50295033
50305034 // value if true
50315035
5032- auto innerFuncRef = cast (location, optFuncRef.getElementType (), funcRefValue, genContext );
5036+ auto innerFuncRef = builder. create <mlir_ts::ValueOp> (location, optFuncRef.getElementType (), funcRefValue);
50335037
50345038 auto hasReturn = false ;
50355039 auto value =
@@ -8681,14 +8685,6 @@ class MLIRGenImpl
86818685 return value;
86828686 }
86838687
8684- if (auto optType = value.getType ().dyn_cast <mlir_ts::OptionalType>())
8685- {
8686- if (optType.getElementType () == type)
8687- {
8688- llvm_unreachable (" for getting value from optional - use ValueOpLowering" );
8689- }
8690- }
8691-
86928688 // class to string
86938689 if (auto stringType = type.dyn_cast_or_null <mlir_ts::StringType>())
86948690 {
0 commit comments