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"
18#include "clang/CIR/MissingFeatures.h"
19#include "clang/CodeGenUtils/TargetUtils.h"
20
21using namespace clang;
22using namespace clang::CIRGen;
23
24namespace {
25
26class AArch64ABIInfo : public ABIInfo {
27public:
28 AArch64ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
29};
30
31class AArch64TargetCIRGenInfo : public TargetCIRGenInfo {
32public:
33 AArch64TargetCIRGenInfo(CIRGenTypes &cgt)
34 : TargetCIRGenInfo(std::make_unique<AArch64ABIInfo>(args&: cgt)) {}
35
36 void setTargetAttributes(const Decl *d, mlir::Operation *gv,
37 CIRGenModule &cgm) const override {
38 auto fn = mlir::dyn_cast<cir::FuncOp>(Val: gv);
39 if (!fn)
40 return;
41 assert(!cir::MissingFeatures::branchProtection());
42 assert(!cir::MissingFeatures::pointerAuthentication());
43 }
44
45 bool isScalarizableAsmOperand(CIRGenFunction &cgf,
46 mlir::Type ty) const override {
47 if (cgf.getTarget().hasFeature(Feature: "ls64")) {
48 cgf.cgm.errorNYI(feature: "AArch64 LS64 scalarizable asm operand");
49 return true;
50 }
51 return TargetCIRGenInfo::isScalarizableAsmOperand(cgf, ty);
52 }
53
54 bool wouldInliningViolateFunctionCallABI(
55 const FunctionDecl *caller, const FunctionDecl *callee) const override;
56};
57
58} // namespace
59
60bool AArch64TargetCIRGenInfo::wouldInliningViolateFunctionCallABI(
61 const FunctionDecl *caller, const FunctionDecl *callee) const {
62 return caller && callee &&
63 CodeGenUtils::getArmSMEInlinability(Caller: caller, Callee: callee) !=
64 CodeGenUtils::ArmSMEInlinability::Ok;
65}
66
67std::unique_ptr<TargetCIRGenInfo>
68clang::CIRGen::createAArch64TargetCIRGenInfo(CIRGenTypes &cgt) {
69 return std::make_unique<AArch64TargetCIRGenInfo>(args&: cgt);
70}
71