clang 24.0.0git
AArch64.cpp
Go to the documentation of this file.
1//===---- AArch64.cpp - AArch64-specific CIR CodeGen ----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This provides AArch64-specific CIR CodeGen logic.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ABIInfo.h"
14#include "CIRGenFunction.h"
15#include "CIRGenModule.h"
16#include "TargetInfo.h"
17#include "clang/AST/Decl.h"
19
20using namespace clang;
21using namespace clang::CIRGen;
22
23namespace {
24
25class AArch64ABIInfo : public ABIInfo {
26public:
27 AArch64ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
28};
29
30class AArch64TargetCIRGenInfo : public TargetCIRGenInfo {
31public:
32 AArch64TargetCIRGenInfo(CIRGenTypes &cgt)
33 : TargetCIRGenInfo(std::make_unique<AArch64ABIInfo>(cgt)) {}
34
35 void setTargetAttributes(const Decl *d, mlir::Operation *gv,
36 CIRGenModule &cgm) const override {
37 auto fn = mlir::dyn_cast<cir::FuncOp>(gv);
38 if (!fn)
39 return;
42 }
43
44 bool isScalarizableAsmOperand(CIRGenFunction &cgf,
45 mlir::Type ty) const override {
46 if (cgf.getTarget().hasFeature("ls64")) {
47 cgf.cgm.errorNYI("AArch64 LS64 scalarizable asm operand");
48 return true;
49 }
51 }
52
53 bool wouldInliningViolateFunctionCallABI(
54 const FunctionDecl *caller, const FunctionDecl *callee) const override;
55};
56
57} // namespace
58
59// TODO(cir): Find a way to share this with classic codegen.
72
73static bool isStreamingCompatible(const FunctionDecl *fd) {
74 if (const auto *fpt = fd->getType()->getAs<FunctionProtoType>())
75 return fpt->getAArch64SMEAttributes() &
77 return false;
78}
79
80/// Determines if there are any Arm SME ABI issues with inlining \p Callee into
81/// \p Caller. Returns the issue (if any) in the ArmSMEInlinability bit enum.
83 const FunctionDecl *callee) {
84 bool callerIsStreaming =
85 clang::IsArmStreamingFunction(caller, /*IncludeLocallyStreaming=*/true);
86 bool calleeIsStreaming =
87 clang::IsArmStreamingFunction(callee, /*IncludeLocallyStreaming=*/true);
88 bool callerIsStreamingCompatible = isStreamingCompatible(caller);
89 bool calleeIsStreamingCompatible = isStreamingCompatible(callee);
90
92
93 if (!calleeIsStreamingCompatible &&
94 (callerIsStreaming != calleeIsStreaming || callerIsStreamingCompatible)) {
95 if (calleeIsStreaming)
97 else
99 }
100 if (auto *newAttr = callee->getAttr<ArmNewAttr>()) {
101 if (newAttr->isNewZA())
103 if (newAttr->isNewZT0())
105 }
106
107 return inlinability;
108}
109
110bool AArch64TargetCIRGenInfo::wouldInliningViolateFunctionCallABI(
111 const FunctionDecl *caller, const FunctionDecl *callee) const {
112 return caller && callee &&
114}
115
116std::unique_ptr<TargetCIRGenInfo>
118 return std::make_unique<AArch64TargetCIRGenInfo>(cgt);
119}
static ArmSMEInlinability getArmSMEInlinability(const FunctionDecl *caller, const FunctionDecl *callee)
Determines if there are any Arm SME ABI issues with inlining Callee into Caller.
Definition AArch64.cpp:82
ArmSMEInlinability
Definition AArch64.cpp:60
@ WarnIncompatibleStreamingModes
Definition AArch64.cpp:64
@ ErrorIncompatibleStreamingModes
Definition AArch64.cpp:65
static bool isStreamingCompatible(const FunctionDecl *fd)
Definition AArch64.cpp:73
const TargetInfo & getTarget() const
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
This class organizes the cross-module state that is used while lowering AST types to CIR types.
Definition CIRGenTypes.h:50
virtual bool isScalarizableAsmOperand(CIRGenFunction &cgf, mlir::Type ty) const
Definition TargetInfo.h:144
T * getAttr() const
Definition DeclBase.h:581
Represents a function declaration or definition.
Definition Decl.h:2029
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5421
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9340
QualType getType() const
Definition Decl.h:723
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
std::unique_ptr< TargetCIRGenInfo > createAArch64TargetCIRGenInfo(CIRGenTypes &cgt)
Definition AArch64.cpp:117
Top level wrappers for InstallAPI frontend operations.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
Definition Decl.cpp:6104
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
static bool branchProtection()
static bool pointerAuthentication()