@@ -351,11 +351,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
351351 if (fnTy.getResults ().size () == 1 ) {
352352 mlir::Type ty = fnTy.getResult (0 );
353353 llvm::TypeSwitch<mlir::Type>(ty)
354- .template Case <fir::ComplexType>([&](fir::ComplexType cmplx) {
355- wrap = rewriteCallComplexResultType (loc, cmplx, newResTys,
356- newInTyAndAttrs, newOpers,
357- savedStackPtr);
358- })
359354 .template Case <mlir::ComplexType>([&](mlir::ComplexType cmplx) {
360355 wrap = rewriteCallComplexResultType (loc, cmplx, newResTys,
361356 newInTyAndAttrs, newOpers,
@@ -414,10 +409,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
414409 }
415410 }
416411 })
417- .template Case <fir::ComplexType>([&](fir::ComplexType cmplx) {
418- rewriteCallComplexInputType (loc, cmplx, oper, newInTyAndAttrs,
419- newOpers, savedStackPtr);
420- })
421412 .template Case <mlir::ComplexType>([&](mlir::ComplexType cmplx) {
422413 rewriteCallComplexInputType (loc, cmplx, oper, newInTyAndAttrs,
423414 newOpers, savedStackPtr);
@@ -538,10 +529,10 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
538529 }
539530 }
540531
541- // Result type fixup for fir:: ComplexType and mlir::ComplexType
542- template <typename A, typename B >
532+ // Result type fixup for ComplexType.
533+ template <typename Ty >
543534 void lowerComplexSignatureRes (
544- mlir::Location loc, A cmplx, B &newResTys,
535+ mlir::Location loc, mlir::ComplexType cmplx, Ty &newResTys,
545536 fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs) {
546537 if (noComplexConversion) {
547538 newResTys.push_back (cmplx);
@@ -557,10 +548,9 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
557548 }
558549 }
559550
560- // Argument type fixup for fir::ComplexType and mlir::ComplexType
561- template <typename A>
551+ // Argument type fixup for ComplexType.
562552 void lowerComplexSignatureArg (
563- mlir::Location loc, A cmplx,
553+ mlir::Location loc, mlir::ComplexType cmplx,
564554 fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs) {
565555 if (noComplexConversion) {
566556 newInTyAndAttrs.push_back (fir::CodeGenSpecifics::getTypeAndAttr (cmplx));
@@ -602,9 +592,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
602592 auto loc = addrOp.getLoc ();
603593 for (mlir::Type ty : addrTy.getResults ()) {
604594 llvm::TypeSwitch<mlir::Type>(ty)
605- .Case <fir::ComplexType>([&](fir::ComplexType ty) {
606- lowerComplexSignatureRes (loc, ty, newResTys, newInTyAndAttrs);
607- })
608595 .Case <mlir::ComplexType>([&](mlir::ComplexType ty) {
609596 lowerComplexSignatureRes (loc, ty, newResTys, newInTyAndAttrs);
610597 })
@@ -628,9 +615,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
628615 }
629616 }
630617 })
631- .Case <fir::ComplexType>([&](fir::ComplexType ty) {
632- lowerComplexSignatureArg (loc, ty, newInTyAndAttrs);
633- })
634618 .Case <mlir::ComplexType>([&](mlir::ComplexType ty) {
635619 lowerComplexSignatureArg (loc, ty, newInTyAndAttrs);
636620 })
@@ -766,12 +750,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
766750 // Convert return value(s)
767751 for (auto ty : funcTy.getResults ())
768752 llvm::TypeSwitch<mlir::Type>(ty)
769- .Case <fir::ComplexType>([&](fir::ComplexType cmplx) {
770- if (noComplexConversion)
771- newResTys.push_back (cmplx);
772- else
773- doComplexReturn (func, cmplx, newResTys, newInTyAndAttrs, fixups);
774- })
775753 .Case <mlir::ComplexType>([&](mlir::ComplexType cmplx) {
776754 if (noComplexConversion)
777755 newResTys.push_back (cmplx);
@@ -835,9 +813,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
835813 }
836814 }
837815 })
838- .Case <fir::ComplexType>([&](fir::ComplexType cmplx) {
839- doComplexArg (func, cmplx, newInTyAndAttrs, fixups);
840- })
841816 .Case <mlir::ComplexType>([&](mlir::ComplexType cmplx) {
842817 doComplexArg (func, cmplx, newInTyAndAttrs, fixups);
843818 })
@@ -1090,10 +1065,11 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
10901065 // / Convert a complex return value. This can involve converting the return
10911066 // / value to a "hidden" first argument or packing the complex into a wide
10921067 // / GPR.
1093- template <typename A, typename B, typename C>
1094- void doComplexReturn (mlir::func::FuncOp func, A cmplx, B &newResTys,
1068+ template <typename Ty, typename FIXUPS>
1069+ void doComplexReturn (mlir::func::FuncOp func, mlir::ComplexType cmplx,
1070+ Ty &newResTys,
10951071 fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs,
1096- C &fixups) {
1072+ FIXUPS &fixups) {
10971073 if (noComplexConversion) {
10981074 newResTys.push_back (cmplx);
10991075 return ;
@@ -1194,10 +1170,10 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
11941170 // / Convert a complex argument value. This can involve storing the value to
11951171 // / a temporary memory location or factoring the value into two distinct
11961172 // / arguments.
1197- template <typename A, typename B >
1198- void doComplexArg (mlir::func::FuncOp func, A cmplx,
1173+ template <typename FIXUPS >
1174+ void doComplexArg (mlir::func::FuncOp func, mlir::ComplexType cmplx,
11991175 fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs,
1200- B &fixups) {
1176+ FIXUPS &fixups) {
12011177 if (noComplexConversion) {
12021178 newInTyAndAttrs.push_back (fir::CodeGenSpecifics::getTypeAndAttr (cmplx));
12031179 return ;
0 commit comments