1 //===- AArch64CallLowering.h - Call lowering --------------------*- C++ -*-===// 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 /// \file 10 /// This file describes how to lower LLVM calls to machine code calls. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H 15 #define LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H 16 17 #include "llvm/ADT/ArrayRef.h" 18 #include "llvm/CodeGen/GlobalISel/CallLowering.h" 19 #include "llvm/IR/CallingConv.h" 20 #include <cstdint> 21 #include <functional> 22 23 namespace llvm { 24 25 class AArch64TargetLowering; 26 class CCValAssign; 27 class MachineIRBuilder; 28 class Type; 29 30 class AArch64CallLowering: public CallLowering { 31 public: 32 AArch64CallLowering(const AArch64TargetLowering &TLI); 33 34 bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, 35 ArrayRef<Register> VRegs, FunctionLoweringInfo &FLI, 36 Register SwiftErrorVReg) const override; 37 38 bool fallBackToDAGISel(const MachineFunction &MF) const override; 39 40 bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, 41 ArrayRef<ArrayRef<Register>> VRegs, 42 FunctionLoweringInfo &FLI) const override; 43 44 bool lowerCall(MachineIRBuilder &MIRBuilder, 45 CallLoweringInfo &Info) const override; 46 47 /// Returns true if the call can be lowered as a tail call. 48 bool 49 isEligibleForTailCallOptimization(MachineIRBuilder &MIRBuilder, 50 CallLoweringInfo &Info, 51 SmallVectorImpl<ArgInfo> &InArgs, 52 SmallVectorImpl<ArgInfo> &OutArgs) const; 53 54 bool supportSwiftError() const override { return true; } 55 56 bool isTypeIsValidForThisReturn(EVT Ty) const override; 57 58 private: 59 using RegHandler = std::function<void(MachineIRBuilder &, Type *, unsigned, 60 CCValAssign &)>; 61 62 using MemHandler = 63 std::function<void(MachineIRBuilder &, int, CCValAssign &)>; 64 65 bool lowerTailCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info, 66 SmallVectorImpl<ArgInfo> &OutArgs) const; 67 68 bool 69 doCallerAndCalleePassArgsTheSameWay(CallLoweringInfo &Info, 70 MachineFunction &MF, 71 SmallVectorImpl<ArgInfo> &InArgs) const; 72 73 bool 74 areCalleeOutgoingArgsTailCallable(CallLoweringInfo &Info, MachineFunction &MF, 75 SmallVectorImpl<ArgInfo> &OutArgs) const; 76 }; 77 78 } // end namespace llvm 79 80 #endif // LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H 81