https://github.com/ayokunle321 updated https://github.com/llvm/llvm-project/pull/182645
>From fd8662a0613e8165b221aacf69535741f0ab0adc Mon Sep 17 00:00:00 2001 From: Ayokunle Amodu <[email protected]> Date: Fri, 20 Feb 2026 19:35:27 -0700 Subject: [PATCH 1/2] add skeleton for nvptx target lowering --- .gitignore | 1 + clang/include/clang/CIR/MissingFeatures.h | 36 +++++++++ .../Transforms/TargetLowering/ABIInfo.cpp | 21 +++++ .../Transforms/TargetLowering/ABIInfo.h | 39 ++++++++++ .../TargetLowering/CIRLowerContext.cpp | 62 +++++++++++++++ .../TargetLowering/CIRLowerContext.h | 77 +++++++++++++++++++ .../Transforms/TargetLowering/CMakeLists.txt | 4 + .../Transforms/TargetLowering/LowerModule.cpp | 18 ++++- .../Transforms/TargetLowering/LowerModule.h | 11 ++- .../Transforms/TargetLowering/LowerTypes.cpp | 24 ++++++ .../Transforms/TargetLowering/LowerTypes.h | 55 +++++++++++++ .../Transforms/TargetLowering/TargetInfo.h | 27 +++++++ .../TargetLowering/TargetLoweringInfo.cpp | 3 + .../TargetLowering/TargetLoweringInfo.h | 7 ++ .../TargetLowering/Targets/NVPTX.cpp | 39 ++++++++++ 15 files changed, 419 insertions(+), 5 deletions(-) create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.cpp create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.h create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.h create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.h create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetInfo.h create mode 100644 clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp diff --git a/.gitignore b/.gitignore index fa133b2d09834..f24f1599ed0f6 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ # Nested build directory /build* +/llvm/build-release* #==============================================================================# # Explicit files to ignore (only matches one). diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index 97c76df0bb0b9..388bfb81d53fb 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -15,6 +15,40 @@ #ifndef CLANG_CIR_MISSINGFEATURES_H #define CLANG_CIR_MISSINGFEATURES_H +constexpr bool cirCConvAssertionMode = + true; // Change to `false` to use llvm_unreachable + +#define CIR_CCONV_NOTE \ + " Target lowering is now required. To workaround use " \ + "-fno-clangir-call-conv-lowering. This flag is going to be removed at some" \ + " point." + +// Special assertion to be used in the target lowering library. +#define cir_cconv_assert(cond) \ + do { \ + if (!(cond)) \ + llvm::errs() << CIR_CCONV_NOTE << "\n"; \ + assert((cond)); \ + } while (0) + +// Special version of llvm_unreachable to give more info to the user on how +// to temporarily disable target lowering. +#define cir_cconv_unreachable(msg) \ + do { \ + llvm_unreachable(msg CIR_CCONV_NOTE); \ + } while (0) + +// Some assertions knowingly generate incorrect code. This macro allows us to +// switch between using `assert` and `llvm_unreachable` for these cases. +#define cir_cconv_assert_or_abort(cond, msg) \ + do { \ + if (cirCConvAssertionMode) { \ + assert((cond) && msg CIR_CCONV_NOTE); \ + } else { \ + llvm_unreachable(msg CIR_CCONV_NOTE); \ + } \ + } while (0) + namespace cir { // As a way to track features that haven't yet been implemented this class @@ -189,6 +223,8 @@ struct MissingFeatures { static bool lowerModuleCodeGenOpts() { return false; } static bool lowerModuleLangOpts() { return false; } static bool targetLoweringInfo() { return false; } + static bool extParamInfo() { return false; } + static bool qualifiedTypes() { return false; } // Extra checks for lowerGetMethod in ItaniumCXXABI static bool emitCFICheck() { return false; } diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.cpp new file mode 100644 index 0000000000000..75f0c33410cee --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.cpp @@ -0,0 +1,21 @@ +//===- ABIInfo.cpp --------------------------------------------------------===// +// +// 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 file partially mimics clang/lib/CodeGen/ABIInfo.cpp. The queries are +// adapted to operate on the CIR dialect, however. +// +//===----------------------------------------------------------------------===// + +#include "ABIInfo.h" + +namespace cir { + +// Pin the vtable to this file. +ABIInfo::~ABIInfo() = default; + +} // namespace cir \ No newline at end of file diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.h new file mode 100644 index 0000000000000..3b0a40a0c80e4 --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.h @@ -0,0 +1,39 @@ +//===----- ABIInfo.h - CIR's ABI information --------------------*- C++ -*-===// +// +// 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 file partially mimics the CodeGen/ABIInfo.h class. The main difference +// is that this is adapted to operate on the CIR dialect. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFO_H +#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFO_H + +#include "llvm/IR/CallingConv.h" + +namespace cir { + +// Forward declarations. +class LowerTypes; + +/// Target specific hooks for defining how a type should be passed or returned +/// from functions. +/// FIXME(cir): this needs to be merged with clang/lib/CIR/CodeGen/ABIInfo.h +class ABIInfo { +protected: + LowerTypes < + llvm::CallingConv::ID RuntimeCC; + +public: + ABIInfo(LowerTypes <) : lt(lt), RuntimeCC(llvm::CallingConv::C) {} + virtual ~ABIInfo(); +}; + +} // namespace cir + +#endif // LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFO_H \ No newline at end of file diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp new file mode 100644 index 0000000000000..c711c1c07aca0 --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp @@ -0,0 +1,62 @@ +//===- CIRLowerContext.cpp ------------------------------------------------===// +// +// 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 file partially mimics clang/lib/AST/ASTContext.cpp. The queries are +// adapted to operate on the CIR dialect, however. +// +//===----------------------------------------------------------------------===// + +#include "CIRLowerContext.h" +#include "mlir/IR/BuiltinOps.h" +#include "clang/AST/ASTContext.h" +#include "clang/CIR/Dialect/IR/CIRTypes.h" +#include "clang/CIR/MissingFeatures.h" +#include "llvm/Support/ErrorHandling.h" + +namespace cir { + +CIRLowerContext::CIRLowerContext(mlir::ModuleOp module, + clang::LangOptions langOpts, + clang::CodeGenOptions codeGenOpts) + : mlirContext(module.getContext()), langOpts(std::move(langOpts)), + codeGenOpts(std::move(codeGenOpts)) {} + +CIRLowerContext::~CIRLowerContext() {} + +mlir::Type CIRLowerContext::initBuiltinType(clang::BuiltinType::Kind builtinKind) { + mlir::Type ty; + + // NOTE(cir): Clang does more stuff here. Not sure if we need to do the same. + cir_cconv_assert(!cir::MissingFeatures::qualifiedTypes()); + switch (builtinKind) { + case clang::BuiltinType::Char_S: + ty = IntType::get(getMLIRContext(), 8, true); + break; + default: + cir_cconv_unreachable("NYI"); + } + + types.push_back(ty); + return ty; +} + +void CIRLowerContext::initBuiltinTypes(const clang::TargetInfo &target, + const clang::TargetInfo *auxTarget) { + cir_cconv_assert((!this->target || this->target == &target) && + "incorrect target reinitialization"); + this->target = ⌖ + this->auxTarget = auxTarget; + + // C99 6.2.5p3. + if (langOpts.CharIsSigned) + charTy = initBuiltinType(clang::BuiltinType::Char_S); + else + cir_cconv_unreachable("NYI"); +} + +} // namespace cir \ No newline at end of file diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.h new file mode 100644 index 0000000000000..9ef0e617eaa08 --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.h @@ -0,0 +1,77 @@ +//===- CIRLowerContext.h - Context to lower CIR -----------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// Partially mimics AST/ASTContext.h. The main difference is that this is +// adapted to operate on the CIR dialect. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRLowerContext_H +#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRLowerContext_H + +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/Types.h" +#include "mlir/Interfaces/DataLayoutInterfaces.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Type.h" +#include "clang/Basic/TargetInfo.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" + +namespace cir { + +// FIXME(cir): Most of this is type-related information that should already be +// embedded into CIR. Maybe we can move this to an MLIR interface. +class CIRLowerContext : public llvm::RefCountedBase<CIRLowerContext> { + +private: + mutable llvm::SmallVector<mlir::Type, 0> types; + + const clang::TargetInfo *target = nullptr; + const clang::TargetInfo *auxTarget = nullptr; + + /// MLIR context to be used when creating types. + mlir::MLIRContext *mlirContext; + + /// The language options used to create the AST associated with + /// this ASTContext object. + clang::LangOptions langOpts; + + /// Options for code generation. + clang::CodeGenOptions codeGenOpts; + + //===--------------------------------------------------------------------===// + // Built-in Types + //===--------------------------------------------------------------------===// + + mlir::Type charTy; + +public: + CIRLowerContext(mlir::ModuleOp module, clang::LangOptions langOpts, + clang::CodeGenOptions codeGenOpts); + ~CIRLowerContext(); + + /// Initialize built-in types. + /// + /// This routine may only be invoked once for a given ASTContext object. + /// It is normally invoked after ASTContext construction. + /// + /// \param Target The target + void initBuiltinTypes(const clang::TargetInfo &target, + const clang::TargetInfo *auxTarget = nullptr); + +private: + mlir::Type initBuiltinType(clang::BuiltinType::Kind builtinKind); + +public: + mlir::MLIRContext *getMLIRContext() const { return mlirContext; } + +}; + +} // namespace cir + +#endif // LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRLowerContext_H \ No newline at end of file diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt index 92148127424e9..7c94815ce3f26 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt @@ -1,8 +1,12 @@ add_clang_library(MLIRCIRTargetLowering + ABIInfo.cpp CIRCXXABI.cpp + CIRLowerContext.cpp LowerModule.cpp + LowerTypes.cpp LowerItaniumCXXABI.cpp TargetLoweringInfo.cpp + Targets/NVPTX.cpp DEPENDS clangBasic diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp index f2398e3105578..674440102acb3 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp @@ -13,6 +13,7 @@ #include "LowerModule.h" #include "CIRCXXABI.h" +#include "TargetInfo.h" #include "mlir/IR/BuiltinAttributes.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/TargetInfo.h" @@ -45,15 +46,26 @@ static std::unique_ptr<CIRCXXABI> createCXXABI(LowerModule &lm) { static std::unique_ptr<TargetLoweringInfo> createTargetLoweringInfo(LowerModule &lm) { - assert(!cir::MissingFeatures::targetLoweringInfo()); - return std::make_unique<TargetLoweringInfo>(); + const clang::TargetInfo &target = lm.getTarget(); + const llvm::Triple &triple = target.getTriple(); + + switch (triple.getArch()) { + case llvm::Triple::nvptx: + case llvm::Triple::nvptx64: + return createNVPTXTargetLoweringInfo(lm); + + default: + cir_cconv_unreachable("ABI NYI"); + } } LowerModule::LowerModule(clang::LangOptions langOpts, clang::CodeGenOptions codeGenOpts, mlir::ModuleOp &module, std::unique_ptr<clang::TargetInfo> target) - : module(module), target(std::move(target)), abi(createCXXABI(*this)) {} + : context(module, std::move(langOpts), std::move(codeGenOpts)), module(module), target(std::move(target)), abi(createCXXABI(*this)), types(*this) { + context.initBuiltinTypes(*target); + } const TargetLoweringInfo &LowerModule::getTargetLoweringInfo() { if (!targetLoweringInfo) diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.h index ab3a648683279..f61f397f0bb9a 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.h @@ -15,6 +15,7 @@ #define CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERMODULE_H #include "CIRCXXABI.h" +#include "LowerTypes.h" #include "TargetLoweringInfo.h" #include "mlir/IR/BuiltinOps.h" #include "clang/Basic/CodeGenOptions.h" @@ -27,11 +28,14 @@ namespace cir { class LowerModule { + CIRLowerContext context; mlir::ModuleOp module; const std::unique_ptr<clang::TargetInfo> target; std::unique_ptr<TargetLoweringInfo> targetLoweringInfo; std::unique_ptr<CIRCXXABI> abi; + LowerTypes types; + public: LowerModule(clang::LangOptions langOpts, clang::CodeGenOptions codeGenOpts, mlir::ModuleOp &module, @@ -43,9 +47,12 @@ class LowerModule { return target->getCXXABI().getKind(); } - CIRCXXABI &getCXXABI() const { return *abi; } - const clang::TargetInfo &getTarget() const { return *target; } + CIRLowerContext &getContext() { return context; } mlir::MLIRContext *getMLIRContext() { return module.getContext(); } + mlir::ModuleOp &getModule() { return module; } + const clang::TargetInfo &getTarget() const { return *target; } + CIRCXXABI &getCXXABI() const { return *abi; } + LowerTypes &getTypes() { return types; } const TargetLoweringInfo &getTargetLoweringInfo(); }; diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp new file mode 100644 index 0000000000000..62382f4e647ef --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp @@ -0,0 +1,24 @@ +//===--- LowerTypes.cpp - Type translation to target-specific types -------===// +// +// 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 file partially mimics clang/lib/CodeGen/CodeGenTypes.cpp. The queries +// are adapted to operate on the CIR dialect, however. +// +//===----------------------------------------------------------------------===// + +#include "LowerTypes.h" +#include "LowerModule.h" +#include "mlir/Support/LLVM.h" + +using namespace cir; + +LowerTypes::LowerTypes(LowerModule &lm) + : lm(lm), context(lm.getContext()), target(lm.getTarget()), + CXXABI(lm.getCXXABI()), + theABIInfo(lm.getTargetLoweringInfo().getABIInfo()), + mlirContext(lm.getMLIRContext()), dataLayout(lm.getModule()) {} diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.h new file mode 100644 index 0000000000000..9ce0c7372e35c --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.h @@ -0,0 +1,55 @@ +//===--- LowerTypes.cpp - Type lowering for CIR dialect -------------------===// +// +// 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 file partially mimics clang/lib/CodeGen/CodeGenTypes.cpp. The queries +// are adapted to operate on the CIR dialect, however. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERTYPES_H +#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERTYPES_H + +#include "ABIInfo.h" +#include "CIRCXXABI.h" +#include "CIRLowerContext.h" +#include "mlir/IR/MLIRContext.h" +#include "clang/CIR/Dialect/IR/CIRDataLayout.h" + +namespace cir { + +// Forward declarations. +class LowerModule; + +/// This class organizes lowering to ABI-specific types in CIR. +class LowerTypes { + // FIXME(cir): This abstraction could likely be replaced by a MLIR interface + // or direct queries to CIR types. It's here mostly for code parity. + +private: + LowerModule &lm; + CIRLowerContext &context; + const clang::TargetInfo ⌖ + CIRCXXABI &CXXABI; + + // This should not be moved earlier, since its initialization depends on some + // of the previous reference members being already initialized + const ABIInfo &theABIInfo; + + // Used to build types and other MLIR operations. + mlir::MLIRContext *mlirContext; + + cir::CIRDataLayout dataLayout; + +public: + LowerTypes(LowerModule &lm); + ~LowerTypes() = default; +}; + +} // namespace cir + +#endif // LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERTYPES_H diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetInfo.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetInfo.h new file mode 100644 index 0000000000000..011efa153c665 --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetInfo.h @@ -0,0 +1,27 @@ +//===---- TargetInfo.h - Encapsulate target details -------------*- C++ -*-===// +// +// 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 file partially mimics clang/lib/CodeGen/TargetInfo.h. The queries are +// adapted to operate on the CIR dialect, however. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_TARGETINFO_H +#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_TARGETINFO_H + +#include "LowerModule.h" +#include "TargetLoweringInfo.h" + +namespace cir { + +std::unique_ptr<TargetLoweringInfo> +createNVPTXTargetLoweringInfo(LowerModule &cgm); + +} // namespace cir + +#endif // LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_TARGETINFO_H diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.cpp index 5ecdb8d587552..1abb770b64f9e 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.cpp @@ -15,6 +15,9 @@ namespace cir { +TargetLoweringInfo::TargetLoweringInfo(std::unique_ptr<ABIInfo> info) + : info(std::move(info)) {} + TargetLoweringInfo::~TargetLoweringInfo() = default; cir::SyncScopeKind diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.h index 760c3b0b7cc5e..4d3844af5d700 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetLoweringInfo.h @@ -14,14 +14,21 @@ #ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_TARGETLOWERINGINFO_H #define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_TARGETLOWERINGINFO_H +#include "ABIInfo.h" #include "clang/CIR/Dialect/IR/CIROpsEnums.h" namespace cir { class TargetLoweringInfo { +private: + std::unique_ptr<ABIInfo> info; + public: + TargetLoweringInfo(std::unique_ptr<ABIInfo> info); virtual ~TargetLoweringInfo(); + const ABIInfo &getABIInfo() const { return *info; } + virtual cir::SyncScopeKind convertSyncScope(cir::SyncScopeKind syncScope) const; }; diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp new file mode 100644 index 0000000000000..35055ce5ee3d9 --- /dev/null +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp @@ -0,0 +1,39 @@ +//===- NVPTX.cpp - TargetInfo for NVPTX -----------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "LowerTypes.h" +#include "TargetInfo.h" +#include "TargetLoweringInfo.h" + +namespace cir { + +//===----------------------------------------------------------------------===// +// NVPTX ABI Implementation +//===----------------------------------------------------------------------===// + +namespace { + +class NVPTXABIInfo : public ABIInfo { +public: + NVPTXABIInfo(LowerTypes <) : ABIInfo(lt) {} +}; + +class NVPTXTargetLoweringInfo : public TargetLoweringInfo { +public: + NVPTXTargetLoweringInfo(LowerTypes <) + : TargetLoweringInfo(std::make_unique<NVPTXABIInfo>(lt)) {} +}; + +} // namespace + +std::unique_ptr<TargetLoweringInfo> +createNVPTXTargetLoweringInfo(LowerModule &lm) { + return std::make_unique<NVPTXTargetLoweringInfo>(lm.getTypes()); +} + +} // namespace cir \ No newline at end of file >From 273a8aa0dc948b965e0380e91dd09825a1bc8eb4 Mon Sep 17 00:00:00 2001 From: Ayokunle Amodu <[email protected]> Date: Fri, 20 Feb 2026 19:47:58 -0700 Subject: [PATCH 2/2] remove other build folder from .gitignore --- .gitignore | 90 ------------------------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f24f1599ed0f6..0000000000000 --- a/.gitignore +++ /dev/null @@ -1,90 +0,0 @@ -#==============================================================================# -# This file specifies intentionally untracked files that git should ignore. -# See: http://www.kernel.org/pub/software/scm/git/docs/gitignore.html -# -# This file is intentionally different from the output of `git svn show-ignore`, -# as most of those are useless. -#==============================================================================# - -#==============================================================================# -# File extensions to be ignored anywhere in the tree. -#==============================================================================# -# Temp files created by most text editors. -*~ -# Merge files created by git. -*.orig -# Reject files created by patch. -*.rej -# Byte compiled python modules. -*.pyc -# vim swap files -.*.sw? -.sw? -#macOS specific -.DS_Store - -# Ignore the user specified CMake presets in subproject directories. -/*/CMakeUserPresets.json - -# Nested build directory -/build* -/llvm/build-release* - -#==============================================================================# -# Explicit files to ignore (only matches one). -#==============================================================================# -# Various tag programs -/tags -/TAGS -/GPATH -/GRTAGS -/GSYMS -/GTAGS -/ID -.gitusers -autom4te.cache -cscope.files -cscope.out -autoconf/aclocal.m4 -autoconf/autom4te.cache -/compile_commands.json -/tablegen_compile_commands.yml -# Visual Studio built-in CMake configuration -/CMakeSettings.json -# CLion project configuration -/.idea -/cmake-build* -# Coding assistants' stuff -/CLAUDE.md -/instructions.md -.claude/ -/GEMINI.md -.gemini/ -AGENTS.md -.codex/ -# Cursor specific files -.cursor -.cursorignore -.cursorindexingignore - -#==============================================================================# -# Directories to ignore (do not add trailing '/'s, they skip symlinks). -#==============================================================================# -# VS2017 and VSCode config files. -.vscode -.vs -#zed config files -.zed -# pythonenv for github Codespaces -pythonenv* -# clangd index. (".clangd" is a config file now, thus trailing slash) -.clangd/ -.cache -.clangd -# static analyzer regression testing project files -/clang/utils/analyzer/projects/*/CachedSource -/clang/utils/analyzer/projects/*/PatchedSource -/clang/utils/analyzer/projects/*/ScanBuildResults -/clang/utils/analyzer/projects/*/RefScanBuildResults -# automodapi puts generated documentation files here. -/lldb/docs/python_api/ _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
