@@ -272,6 +272,12 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
272
272
mlir::Value oper = std::get<1 >(e.value ());
273
273
unsigned index = e.index ();
274
274
llvm::TypeSwitch<mlir::Type>(ty)
275
+ .template Case <mlir::IndexType>([&](mlir::IndexType indexTy) {
276
+ auto newTy = specifics->indexMemoryType (indexTy);
277
+ auto newOper = rewriter->create <mlir::arith::IndexCastOp>(loc, newTy, oper);
278
+ newInTys.push_back (newTy);
279
+ newOpers.push_back (newOper);
280
+ })
275
281
.template Case <fir::BoxCharType>([&](fir::BoxCharType boxTy) {
276
282
bool sret;
277
283
if constexpr (std::is_same_v<std::decay_t <A>, fir::CallOp>) {
@@ -534,6 +540,7 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
534
540
for (auto ty : func.getResults ())
535
541
if ((ty.isa <fir::BoxCharType>() && !noCharacterConversion) ||
536
542
(fir::isa_complex (ty) && !noComplexConversion) ||
543
+ (ty.isa <mlir::IndexType>()) ||
537
544
(ty.isa <mlir::IntegerType>() && hasCCallingConv)) {
538
545
LLVM_DEBUG (llvm::dbgs () << " rewrite " << signature << " for target\n " );
539
546
return false ;
@@ -542,6 +549,7 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
542
549
if (((ty.isa <fir::BoxCharType>() || fir::isCharacterProcedureTuple (ty)) &&
543
550
!noCharacterConversion) ||
544
551
(fir::isa_complex (ty) && !noComplexConversion) ||
552
+ (ty.isa <mlir::IndexType>()) ||
545
553
(ty.isa <mlir::IntegerType>() && hasCCallingConv)) {
546
554
LLVM_DEBUG (llvm::dbgs () << " rewrite " << signature << " for target\n " );
547
555
return false ;
@@ -624,6 +632,9 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
624
632
auto ty = e.value ();
625
633
unsigned index = e.index ();
626
634
llvm::TypeSwitch<mlir::Type>(ty)
635
+ .Case <mlir::IndexType>([&](mlir::IndexType indexTy) {
636
+ newInTys.push_back (specifics->indexMemoryType (indexTy));
637
+ })
627
638
.Case <fir::BoxCharType>([&](fir::BoxCharType boxTy) {
628
639
if (noCharacterConversion) {
629
640
newInTys.push_back (boxTy);
0 commit comments