[flang-commits] [flang] [flang][CodeGen] Add initial SystemZ ABI support (PR #208618)
Ulrich Weigand via flang-commits
flang-commits at lists.llvm.org
Mon Jul 27 05:20:42 PDT 2026
================
@@ -1893,6 +1893,111 @@ struct TargetLoongArch64 : public GenericTarget<TargetLoongArch64> {
};
} // namespace
+//===----------------------------------------------------------------------===//
+// SystemZ target specifics.
+//===----------------------------------------------------------------------===//
+
+namespace {
+struct TargetSystemZ : public GenericTarget<TargetSystemZ> {
+ using GenericTarget::GenericTarget;
+
+ static constexpr int defaultWidth = 64;
+
+ auto complexType(mlir::Type eleTy, bool isResult) const {
+ assert(fir::isa_real(eleTy));
+ CodeGenSpecifics::Marshalling marshal;
+ unsigned short align{std::max(
+ static_cast<unsigned short>(getDataLayout().getTypeABIAlignment(eleTy)),
+ static_cast<unsigned short>(8))};
+ marshal.emplace_back(
+ fir::ReferenceType::get(mlir::TupleType::get(
+ eleTy.getContext(), mlir::TypeRange{eleTy, eleTy})),
+ AT{/*align=*/align, /*byval=*/!isResult, /*sret=*/isResult});
+ return marshal;
+ }
+
+ CodeGenSpecifics::Marshalling
+ complexArgumentType(mlir::Location /*loc*/, mlir::Type eleTy) const override {
+ return complexType(eleTy, false);
+ }
+
+ CodeGenSpecifics::Marshalling
+ complexReturnType(mlir::Location /*loc*/, mlir::Type eleTy) const override {
+ return complexType(eleTy, true);
+ }
+
+ CodeGenSpecifics::Marshalling
+ integerArgumentType(mlir::Location loc,
+ mlir::IntegerType argTy) const override {
+ // SystemZ ABI requires all integers < 64 bits to be sign/zero extended.
+ // Handle widths 32 to 63 explicitly; GenericTarget handles widths < 32
+ // including the i1 zero-extension special case.
+ if (argTy.getWidth() >= 32 && argTy.getWidth() < defaultWidth) {
----------------
uweigand wrote:
Probably better to hard-code 64 here as well; it's an external requirement.
https://github.com/llvm/llvm-project/pull/208618
More information about the flang-commits
mailing list