#include "AArch64CallLowering.h"
#include "AArch64GlobalISelUtils.h"
#include "AArch64ISelLowering.h"
#include "AArch64MachineFunctionInfo.h"
#include "AArch64RegisterInfo.h"
#include "AArch64Subtarget.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/ObjCARCUtil.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelTypeUtils.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespaceAArch64GISelUtils;
extern cl::opt<bool> EnableSVEGISel;
AArch64CallLowering::AArch64CallLowering(const AArch64TargetLowering &TLI)
: … { … }
static void applyStackPassedSmallTypeDAGHack(EVT OrigVT, MVT &ValVT,
MVT &LocVT) { … }
static LLT getStackValueStoreTypeHack(const CCValAssign &VA) { … }
namespace {
struct AArch64IncomingValueAssigner
: public CallLowering::IncomingValueAssigner { … };
struct AArch64OutgoingValueAssigner
: public CallLowering::OutgoingValueAssigner { … };
struct IncomingArgHandler : public CallLowering::IncomingValueHandler { … };
struct FormalArgHandler : public IncomingArgHandler { … };
struct CallReturnHandler : public IncomingArgHandler { … };
struct ReturnedArgCallReturnHandler : public CallReturnHandler { … };
struct OutgoingArgHandler : public CallLowering::OutgoingValueHandler { … };
}
static bool doesCalleeRestoreStack(CallingConv::ID CallConv, bool TailCallOpt) { … }
bool AArch64CallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
const Value *Val,
ArrayRef<Register> VRegs,
FunctionLoweringInfo &FLI,
Register SwiftErrorVReg) const { … }
bool AArch64CallLowering::canLowerReturn(MachineFunction &MF,
CallingConv::ID CallConv,
SmallVectorImpl<BaseArgInfo> &Outs,
bool IsVarArg) const { … }
static void handleMustTailForwardedRegisters(MachineIRBuilder &MIRBuilder,
CCAssignFn *AssignFn) { … }
bool AArch64CallLowering::fallBackToDAGISel(const MachineFunction &MF) const { … }
void AArch64CallLowering::saveVarArgRegisters(
MachineIRBuilder &MIRBuilder, CallLowering::IncomingValueHandler &Handler,
CCState &CCInfo) const { … }
bool AArch64CallLowering::lowerFormalArguments(
MachineIRBuilder &MIRBuilder, const Function &F,
ArrayRef<ArrayRef<Register>> VRegs, FunctionLoweringInfo &FLI) const { … }
static bool canGuaranteeTCO(CallingConv::ID CC, bool GuaranteeTailCalls) { … }
static bool mayTailCallThisCC(CallingConv::ID CC) { … }
static std::pair<CCAssignFn *, CCAssignFn *>
getAssignFnsForCC(CallingConv::ID CC, const AArch64TargetLowering &TLI) { … }
bool AArch64CallLowering::doCallerAndCalleePassArgsTheSameWay(
CallLoweringInfo &Info, MachineFunction &MF,
SmallVectorImpl<ArgInfo> &InArgs) const { … }
bool AArch64CallLowering::areCalleeOutgoingArgsTailCallable(
CallLoweringInfo &Info, MachineFunction &MF,
SmallVectorImpl<ArgInfo> &OrigOutArgs) const { … }
bool AArch64CallLowering::isEligibleForTailCallOptimization(
MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info,
SmallVectorImpl<ArgInfo> &InArgs,
SmallVectorImpl<ArgInfo> &OutArgs) const { … }
static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect,
bool IsTailCall,
std::optional<CallLowering::PtrAuthInfo> &PAI,
MachineRegisterInfo &MRI) { … }
static const uint32_t *
getMaskForArgs(SmallVectorImpl<AArch64CallLowering::ArgInfo> &OutArgs,
AArch64CallLowering::CallLoweringInfo &Info,
const AArch64RegisterInfo &TRI, MachineFunction &MF) { … }
bool AArch64CallLowering::lowerTailCall(
MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info,
SmallVectorImpl<ArgInfo> &OutArgs) const { … }
bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
CallLoweringInfo &Info) const { … }
bool AArch64CallLowering::isTypeIsValidForThisReturn(EVT Ty) const { … }