CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
106 lines
4.0 KiB
C++
106 lines
4.0 KiB
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 provides an abstract class for C++ code generation. Concrete subclasses
|
|
// of this implement code generation for specific C++ ABIs.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "CIRGenCXXABI.h"
|
|
#include "CIRGenFunction.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
#include "clang/AST/ExprCXX.h"
|
|
#include "clang/AST/GlobalDecl.h"
|
|
|
|
using namespace clang;
|
|
using namespace clang::CIRGen;
|
|
|
|
CIRGenCXXABI::~CIRGenCXXABI() {}
|
|
|
|
CIRGenCXXABI::AddedStructorArgCounts CIRGenCXXABI::addImplicitConstructorArgs(
|
|
CIRGenFunction &cgf, const CXXConstructorDecl *d, CXXCtorType type,
|
|
bool forVirtualBase, bool delegating, CallArgList &args) {
|
|
AddedStructorArgs addedArgs =
|
|
getImplicitConstructorArgs(cgf, d, type, forVirtualBase, delegating);
|
|
for (auto [idx, prefixArg] : llvm::enumerate(addedArgs.prefix))
|
|
args.insert(args.begin() + 1 + idx,
|
|
CallArg(RValue::get(prefixArg.value), prefixArg.type));
|
|
for (const auto &arg : addedArgs.suffix)
|
|
args.add(RValue::get(arg.value), arg.type);
|
|
return AddedStructorArgCounts(addedArgs.prefix.size(),
|
|
addedArgs.suffix.size());
|
|
}
|
|
|
|
CatchTypeInfo CIRGenCXXABI::getCatchAllTypeInfo() {
|
|
return CatchTypeInfo{{}, 0};
|
|
}
|
|
|
|
void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
|
|
FunctionArgList ¶ms) {
|
|
const auto *md = cast<CXXMethodDecl>(cgf.curGD.getDecl());
|
|
|
|
// FIXME: I'm not entirely sure I like using a fake decl just for code
|
|
// generation. Maybe we can come up with a better way?
|
|
auto *thisDecl =
|
|
ImplicitParamDecl::Create(cgm.getASTContext(), nullptr, md->getLocation(),
|
|
&cgm.getASTContext().Idents.get("this"),
|
|
md->getThisType(), ImplicitParamKind::CXXThis);
|
|
params.push_back(thisDecl);
|
|
cgf.cxxabiThisDecl = thisDecl;
|
|
|
|
// Classic codegen computes the alignment of thisDecl and saves it in
|
|
// CodeGenFunction::CXXABIThisAlignment, but it is only used in emitTypeCheck
|
|
// in CodeGenFunction::StartFunction().
|
|
assert(!cir::MissingFeatures::cxxabiThisAlignment());
|
|
}
|
|
|
|
cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
|
|
GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
|
|
// Delegate back to cgm by default.
|
|
return cgm.getCIRLinkageForDeclarator(dtor, linkage);
|
|
}
|
|
|
|
mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
|
|
ImplicitParamDecl *vd = getThisDecl(cgf);
|
|
Address addr = cgf.getAddrOfLocalVar(vd);
|
|
return cir::LoadOp::create(cgf.getBuilder(), cgf.getLoc(vd->getLocation()),
|
|
addr.getElementType(), addr.getPointer());
|
|
}
|
|
|
|
void CIRGenCXXABI::setCXXABIThisValue(CIRGenFunction &cgf,
|
|
mlir::Value thisPtr) {
|
|
/// Initialize the 'this' slot.
|
|
assert(getThisDecl(cgf) && "no 'this' variable for function");
|
|
cgf.cxxabiThisValue = thisPtr;
|
|
}
|
|
|
|
CharUnits CIRGenCXXABI::getArrayCookieSize(const CXXNewExpr *e) {
|
|
if (!requiresArrayCookie(e))
|
|
return CharUnits::Zero();
|
|
|
|
return getArrayCookieSizeImpl(e->getAllocatedType());
|
|
}
|
|
|
|
bool CIRGenCXXABI::requiresArrayCookie(const CXXNewExpr *e) {
|
|
// If the class's usual deallocation function takes two arguments,
|
|
// it needs a cookie.
|
|
if (e->doesUsualArrayDeleteWantSize())
|
|
return true;
|
|
|
|
return e->getAllocatedType().isDestructedType();
|
|
}
|
|
|
|
void CIRGenCXXABI::emitReturnFromThunk(CIRGenFunction &cgf, RValue rv,
|
|
QualType resultType) {
|
|
assert(!cgf.hasAggregateEvaluationKind(resultType) &&
|
|
"cannot handle aggregates");
|
|
mlir::Location loc = cgf.getBuilder().getUnknownLoc();
|
|
cgf.emitReturnOfRValue(loc, rv, resultType);
|
|
}
|