[flang-commits] [flang] [flang][CodeGen] Add initial SystemZ ABI support (PR #208618)

Dominik Steenken via flang-commits flang-commits at lists.llvm.org
Mon Jul 13 01:03:14 PDT 2026


================
@@ -1893,6 +1893,81 @@ 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 {
+    if (argTy.getWidth() == 32) {
----------------
dominik-steenken wrote:

I think so. `GenericTarget::integerArgumentType` will mark all integers shorter than `getCIntTypeWidth()` (32) to be sign/zero extended.

I suppose there is a hole in this for integer types >=32 bits but <64 bits. It sounds like the condition should be
```C++
if ((argTy.getWidth() >= 32) && (argTy.getWidth() < defaultWidth))
```

https://github.com/llvm/llvm-project/pull/208618


More information about the flang-commits mailing list