[flang-commits] [flang] [flang] Added definition of hlfir.cshift operation. (PR #118732)
via flang-commits
flang-commits at lists.llvm.org
Thu Dec 5 01:48:18 PST 2024
================
@@ -1341,6 +1341,91 @@ void hlfir::MatmulTransposeOp::getEffects(
getIntrinsicEffects(getOperation(), effects);
}
+//===----------------------------------------------------------------------===//
+// CShiftOp
+//===----------------------------------------------------------------------===//
+
+llvm::LogicalResult hlfir::CShiftOp::verify() {
+ mlir::Value array = getArray();
+ fir::SequenceType arrayTy = mlir::cast<fir::SequenceType>(
+ hlfir::getFortranElementOrSequenceType(array.getType()));
+ llvm::ArrayRef<int64_t> inShape = arrayTy.getShape();
+ std::size_t arrayRank = inShape.size();
+ mlir::Type eleTy = arrayTy.getEleTy();
+ hlfir::ExprType resultTy = mlir::cast<hlfir::ExprType>(getResult().getType());
+ llvm::ArrayRef<int64_t> resultShape = resultTy.getShape();
+ std::size_t resultRank = resultShape.size();
+ mlir::Type resultEleTy = resultTy.getEleTy();
+ mlir::Value shift = getShift();
+ mlir::Type shiftTy = hlfir::getFortranElementOrSequenceType(shift.getType());
+
+ if (eleTy != resultEleTy)
+ return emitOpError(
----------------
jeanPerier wrote:
I think this should be relaxed for characters where dynamic length vs constant length should be OK. After transformations, the operand could go from a dynamic length to constant length or vice versa without this technically be incorrect.
https://github.com/llvm/llvm-project/pull/118732
More information about the flang-commits
mailing list