| 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 | |
| 21 | using namespace clang; |
| 22 | using namespace clang::CIRGen; |
| 23 | |
| 24 | namespace { |
| 25 | |
| 26 | class AArch64ABIInfo : public ABIInfo { |
| 27 | public: |
| 28 | AArch64ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {} |
| 29 | }; |
| 30 | |
| 31 | class AArch64TargetCIRGenInfo : public TargetCIRGenInfo { |
| 32 | public: |
| 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 | |
| 60 | bool 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 | |
| 67 | std::unique_ptr<TargetCIRGenInfo> |
| 68 | clang::CIRGen::createAArch64TargetCIRGenInfo(CIRGenTypes &cgt) { |
| 69 | return std::make_unique<AArch64TargetCIRGenInfo>(args&: cgt); |
| 70 | } |
| 71 |