diff options
author | jeanPerier <jperier@nvidia.com> | 2024-10-04 09:57:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-04 09:57:03 +0200 |
commit | 1753de2d9564682cd9034aae50e81691bfd168ec (patch) | |
tree | 6ab132ee43956be354e33fcd7eea9e196335b44a /flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | |
parent | bba3849b81c8fc5343e22e767e4c5ab415b4b1d4 (diff) | |
download | llvm-1753de2d9564682cd9034aae50e81691bfd168ec.zip llvm-1753de2d9564682cd9034aae50e81691bfd168ec.tar.gz llvm-1753de2d9564682cd9034aae50e81691bfd168ec.tar.bz2 |
[flang][FIR] remove fir.complex type and its fir.real element type (#111025)
Final patch of
https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292
Since fir.real was only still used as fir.complex element type, this
patch removes it at the same time.
Diffstat (limited to 'flang/lib/Optimizer/CodeGen/TargetRewrite.cpp')
-rw-r--r-- | flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp index 925b932..fd56fd6 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -351,11 +351,6 @@ public: if (fnTy.getResults().size() == 1) { mlir::Type ty = fnTy.getResult(0); llvm::TypeSwitch<mlir::Type>(ty) - .template Case<fir::ComplexType>([&](fir::ComplexType cmplx) { - wrap = rewriteCallComplexResultType(loc, cmplx, newResTys, - newInTyAndAttrs, newOpers, - savedStackPtr); - }) .template Case<mlir::ComplexType>([&](mlir::ComplexType cmplx) { wrap = rewriteCallComplexResultType(loc, cmplx, newResTys, newInTyAndAttrs, newOpers, @@ -414,10 +409,6 @@ public: } } }) - .template Case<fir::ComplexType>([&](fir::ComplexType cmplx) { - rewriteCallComplexInputType(loc, cmplx, oper, newInTyAndAttrs, - newOpers, savedStackPtr); - }) .template Case<mlir::ComplexType>([&](mlir::ComplexType cmplx) { rewriteCallComplexInputType(loc, cmplx, oper, newInTyAndAttrs, newOpers, savedStackPtr); @@ -538,10 +529,10 @@ public: } } - // Result type fixup for fir::ComplexType and mlir::ComplexType - template <typename A, typename B> + // Result type fixup for ComplexType. + template <typename Ty> void lowerComplexSignatureRes( - mlir::Location loc, A cmplx, B &newResTys, + mlir::Location loc, mlir::ComplexType cmplx, Ty &newResTys, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs) { if (noComplexConversion) { newResTys.push_back(cmplx); @@ -557,10 +548,9 @@ public: } } - // Argument type fixup for fir::ComplexType and mlir::ComplexType - template <typename A> + // Argument type fixup for ComplexType. void lowerComplexSignatureArg( - mlir::Location loc, A cmplx, + mlir::Location loc, mlir::ComplexType cmplx, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs) { if (noComplexConversion) { newInTyAndAttrs.push_back(fir::CodeGenSpecifics::getTypeAndAttr(cmplx)); @@ -602,9 +592,6 @@ public: auto loc = addrOp.getLoc(); for (mlir::Type ty : addrTy.getResults()) { llvm::TypeSwitch<mlir::Type>(ty) - .Case<fir::ComplexType>([&](fir::ComplexType ty) { - lowerComplexSignatureRes(loc, ty, newResTys, newInTyAndAttrs); - }) .Case<mlir::ComplexType>([&](mlir::ComplexType ty) { lowerComplexSignatureRes(loc, ty, newResTys, newInTyAndAttrs); }) @@ -628,9 +615,6 @@ public: } } }) - .Case<fir::ComplexType>([&](fir::ComplexType ty) { - lowerComplexSignatureArg(loc, ty, newInTyAndAttrs); - }) .Case<mlir::ComplexType>([&](mlir::ComplexType ty) { lowerComplexSignatureArg(loc, ty, newInTyAndAttrs); }) @@ -766,12 +750,6 @@ public: // Convert return value(s) for (auto ty : funcTy.getResults()) llvm::TypeSwitch<mlir::Type>(ty) - .Case<fir::ComplexType>([&](fir::ComplexType cmplx) { - if (noComplexConversion) - newResTys.push_back(cmplx); - else - doComplexReturn(func, cmplx, newResTys, newInTyAndAttrs, fixups); - }) .Case<mlir::ComplexType>([&](mlir::ComplexType cmplx) { if (noComplexConversion) newResTys.push_back(cmplx); @@ -835,9 +813,6 @@ public: } } }) - .Case<fir::ComplexType>([&](fir::ComplexType cmplx) { - doComplexArg(func, cmplx, newInTyAndAttrs, fixups); - }) .Case<mlir::ComplexType>([&](mlir::ComplexType cmplx) { doComplexArg(func, cmplx, newInTyAndAttrs, fixups); }) @@ -1090,10 +1065,11 @@ public: /// Convert a complex return value. This can involve converting the return /// value to a "hidden" first argument or packing the complex into a wide /// GPR. - template <typename A, typename B, typename C> - void doComplexReturn(mlir::func::FuncOp func, A cmplx, B &newResTys, + template <typename Ty, typename FIXUPS> + void doComplexReturn(mlir::func::FuncOp func, mlir::ComplexType cmplx, + Ty &newResTys, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs, - C &fixups) { + FIXUPS &fixups) { if (noComplexConversion) { newResTys.push_back(cmplx); return; @@ -1194,10 +1170,10 @@ public: /// Convert a complex argument value. This can involve storing the value to /// a temporary memory location or factoring the value into two distinct /// arguments. - template <typename A, typename B> - void doComplexArg(mlir::func::FuncOp func, A cmplx, + template <typename FIXUPS> + void doComplexArg(mlir::func::FuncOp func, mlir::ComplexType cmplx, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs, - B &fixups) { + FIXUPS &fixups) { if (noComplexConversion) { newInTyAndAttrs.push_back(fir::CodeGenSpecifics::getTypeAndAttr(cmplx)); return; |