Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions flang/lib/Optimizer/CodeGen/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,14 +1443,35 @@ struct TargetAMDGPU : public GenericTarget<TargetAMDGPU> {
CodeGenSpecifics::Marshalling
complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override {
CodeGenSpecifics::Marshalling marshal;
TODO(loc, "handle complex argument types");
const auto *sem = &floatToSemantics(kindMap, eleTy);
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider refactoring the common logic used to compute float semantics in both complexArgumentType and complexReturnType to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
if (sem == &llvm::APFloat::IEEEsingle()) {
// Lower COMPLEX(KIND=4) as an array of two element values.
marshal.emplace_back(fir::SequenceType::get({2}, eleTy), AT{});
} else if (sem == &llvm::APFloat::IEEEdouble()) {
// Pass COMPLEX(KIND=8) as two separate arguments.
marshal.emplace_back(eleTy, AT{});
marshal.emplace_back(eleTy, AT{});
} else {
typeTodo(sem, loc, "argument");
}
return marshal;
}

CodeGenSpecifics::Marshalling
complexReturnType(mlir::Location loc, mlir::Type eleTy) const override {
CodeGenSpecifics::Marshalling marshal;
TODO(loc, "handle complex return types");
const auto *sem = &floatToSemantics(kindMap, eleTy);
if (sem == &llvm::APFloat::IEEEsingle()) {
// Return COMPLEX(KIND=4) as an array of two elements.
marshal.emplace_back(fir::SequenceType::get({2}, eleTy), AT{});
} else if (sem == &llvm::APFloat::IEEEdouble()) {
// Return COMPLEX(KIND=8) via an aggregate with two fields.
marshal.emplace_back(mlir::TupleType::get(eleTy.getContext(),
mlir::TypeRange{eleTy, eleTy}),
AT{});
} else {
typeTodo(sem, loc, "return");
}
return marshal;
}
};
Expand Down
Loading