Author: Daniel Hogan Date: 2026-11-16T19:50:48Z New Revision: ce6d6984603084fe2499c9f1ae8d37c397bb1c63
URL: https://github.com/llvm/llvm-project/commit/ce6d6984603084fe2499c9f1ae8d37c397bb1c63 DIFF: https://github.com/llvm/llvm-project/commit/ce6d6984603084fe2499c9f1ae8d37c397bb1c63.diff LOG: [CIR][SystemZ][NFC] Add SystemZTargetCIRGenInfo (#237828) Adds implementation for SystemZ TargetCIRGenInfo (following the structure used in #215424). getTargetCIRGenInfo() had no SystemZ case so it fell through to x86_64 target info. The only hook in SystemZTargetCodeGenInfo in classic code gen that has a CIR equivalent is setTargetAttributes. setTargetAttributes adds the s390x-visible-vector-ABI module flag which CIR doesn't emit yet. This is my intended next PR. For now, I add a MissingFeatures marker. The other classic hook testFPKind has no counterpart in TargetCIRGenInfo yet. z/OS uses XPLINK ABI which has its own target info in classic codegen. For now, z/OS uses the SystemZ ELF target info as a placeholder. I marked it with targetCIRGenInfoOS() for follow up. NFC. This is the first step in my plan I laid out in https://discourse.llvm.org/t/rfc-enable-clangir-build-by-default/91730/114. Assisted-by: Claude Added: clang/lib/CIR/CodeGen/Targets/SystemZ.cpp Modified: clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/CodeGen/CIRGenModule.cpp clang/lib/CIR/CodeGen/CMakeLists.txt clang/lib/CIR/CodeGen/TargetInfo.h Removed: ################################################################################ diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index ea496de95fff6a..998a0c34c7d9ff 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 0b832e140ee6d1..2e72ee06ad6a6f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -414,6 +414,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
