https://github.com/Daniel-Hogan updated https://github.com/llvm/llvm-project/pull/237828
>From 7023fb84e3a32008d1b405e078f90512724d7bac Mon Sep 17 00:00:00 2001 From: Daniel-Hogan <[email protected]> Date: Sun, 1 Nov 2026 22:46:30 -0500 Subject: [PATCH] [CIR][SystemZ][NFC] Add SystemZTargetCIRGenInfo Adds SystemZ TargetCIRGenInfo. z/OS uses XPLINK which has its own target info in classic codegen. I assume this is the route we will take for CIR and eventually create seperate target info for z/OS. For now, z/OS uses the SystemZ ELF target info as a placeholder. No Function changes as of now. Next patch I intend on working on the vector ABI module flag. --- clang/include/clang/CIR/MissingFeatures.h | 1 + clang/lib/CIR/CodeGen/CIRGenModule.cpp | 8 ++++ clang/lib/CIR/CodeGen/CMakeLists.txt | 1 + clang/lib/CIR/CodeGen/TargetInfo.h | 3 ++ clang/lib/CIR/CodeGen/Targets/SystemZ.cpp | 47 +++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 clang/lib/CIR/CodeGen/Targets/SystemZ.cpp diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index 8986da21542da7..b3ed21bc3e3a0d 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -281,6 +281,7 @@ struct MissingFeatures { static bool preservedAccessIndexRegion() { return false; } static bool returnValueSlotFeatures() { return false; } static bool runCleanupsScope() { return false; } + static bool s390xVisibleVectorABI() { return false; } static bool sanitizers() { return false; } static bool setDLLStorageClass() { return false; } static bool setNonGC() { return false; } diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 80822f17bec428..1e91ed97a5278b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -400,6 +400,14 @@ const TargetCIRGenInfo &CIRGenModule::getTargetCIRGenInfo() { case llvm::Triple::spirv64: theTargetCIRGenInfo = createCommonSPIRTargetCIRGenInfo(genTypes); return *theTargetCIRGenInfo; + case llvm::Triple::systemz: { + // z/OS XPLINK target info is not implemented yet. + // We just default to SystemZ ELF Target for now. + if (triple.isOSzOS()) + assert(!cir::MissingFeatures::targetCIRGenInfoOS()); + theTargetCIRGenInfo = createSystemZTargetCIRGenInfo(genTypes); + return *theTargetCIRGenInfo; + } } } diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt b/clang/lib/CIR/CodeGen/CMakeLists.txt index 1f4db82585c20e..f40ff409eb4def 100644 --- a/clang/lib/CIR/CodeGen/CMakeLists.txt +++ b/clang/lib/CIR/CodeGen/CMakeLists.txt @@ -60,6 +60,7 @@ add_clang_library(clangCIR Targets/AMDGPU.cpp Targets/NVPTX.cpp Targets/SPIRV.cpp + Targets/SystemZ.cpp DISABLE_PCH_REUSE # PCH contains private headers PRECOMPILE_HEADERS diff --git a/clang/lib/CIR/CodeGen/TargetInfo.h b/clang/lib/CIR/CodeGen/TargetInfo.h index 09f41fcd3cf9b7..62acf0afa80020 100644 --- a/clang/lib/CIR/CodeGen/TargetInfo.h +++ b/clang/lib/CIR/CodeGen/TargetInfo.h @@ -201,6 +201,9 @@ std::unique_ptr<TargetCIRGenInfo> createNVPTXTargetCIRGenInfo(CIRGenTypes &cgt); std::unique_ptr<TargetCIRGenInfo> createCommonSPIRTargetCIRGenInfo(CIRGenTypes &cgt); +std::unique_ptr<TargetCIRGenInfo> +createSystemZTargetCIRGenInfo(CIRGenTypes &cgt); + } // namespace clang::CIRGen #endif // LLVM_CLANG_LIB_CIR_TARGETINFO_H diff --git a/clang/lib/CIR/CodeGen/Targets/SystemZ.cpp b/clang/lib/CIR/CodeGen/Targets/SystemZ.cpp new file mode 100644 index 00000000000000..73389ece694baa --- /dev/null +++ b/clang/lib/CIR/CodeGen/Targets/SystemZ.cpp @@ -0,0 +1,47 @@ +//===---- SystemZ.cpp - SystemZ-specific CIR CodeGen ----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This provides SystemZ-specific CIR CodeGen logic. +// +//===----------------------------------------------------------------------===// + +#include "ABIInfo.h" +#include "CIRGenModule.h" +#include "TargetInfo.h" +#include "clang/AST/Decl.h" +#include "clang/CIR/MissingFeatures.h" + +using namespace clang; +using namespace clang::CIRGen; + +namespace { + +class SystemZABIInfo : public ABIInfo { +public: + SystemZABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {} +}; + +class SystemZTargetCIRGenInfo : public TargetCIRGenInfo { +public: + SystemZTargetCIRGenInfo(CIRGenTypes &cgt) + : TargetCIRGenInfo(std::make_unique<SystemZABIInfo>(cgt)) {} + + void setTargetAttributes(const Decl *d, mlir::Operation *gv, + CIRGenModule &cgm) const override { + if (!d) + return; + assert(!cir::MissingFeatures::s390xVisibleVectorABI()); + } +}; + +} // namespace + +std::unique_ptr<TargetCIRGenInfo> +clang::CIRGen::createSystemZTargetCIRGenInfo(CIRGenTypes &cgt) { + return std::make_unique<SystemZTargetCIRGenInfo>(cgt); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
