#include "AArch64.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Object/COFF.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/TargetParser/Triple.h"
usingnamespacellvm;
usingnamespacellvm::COFF;
OperandBundleDef;
#define DEBUG_TYPE …
STATISTIC(Arm64ECCallsLowered, "Number of Arm64EC calls lowered");
static cl::opt<bool> LowerDirectToIndirect("arm64ec-lower-direct-to-indirect",
cl::Hidden, cl::init(true));
static cl::opt<bool> GenerateThunks("arm64ec-generate-thunks", cl::Hidden,
cl::init(true));
namespace {
enum ThunkArgTranslation : uint8_t { … };
struct ThunkArgInfo { … };
class AArch64Arm64ECCallLowering : public ModulePass { … };
}
void AArch64Arm64ECCallLowering::getThunkType(
FunctionType *FT, AttributeList AttrList, Arm64ECThunkType TT,
raw_ostream &Out, FunctionType *&Arm64Ty, FunctionType *&X64Ty,
SmallVector<ThunkArgTranslation> &ArgTranslations) { … }
void AArch64Arm64ECCallLowering::getThunkArgTypes(
FunctionType *FT, AttributeList AttrList, Arm64ECThunkType TT,
raw_ostream &Out, SmallVectorImpl<Type *> &Arm64ArgTypes,
SmallVectorImpl<Type *> &X64ArgTypes,
SmallVectorImpl<ThunkArgTranslation> &ArgTranslations, bool HasSretPtr) { … }
void AArch64Arm64ECCallLowering::getThunkRetType(
FunctionType *FT, AttributeList AttrList, raw_ostream &Out,
Type *&Arm64RetTy, Type *&X64RetTy, SmallVectorImpl<Type *> &Arm64ArgTypes,
SmallVectorImpl<Type *> &X64ArgTypes,
SmallVector<ThunkArgTranslation> &ArgTranslations, bool &HasSretPtr) { … }
ThunkArgInfo AArch64Arm64ECCallLowering::canonicalizeThunkType(
Type *T, Align Alignment, bool Ret, uint64_t ArgSizeBytes,
raw_ostream &Out) { … }
Function *AArch64Arm64ECCallLowering::buildExitThunk(FunctionType *FT,
AttributeList Attrs) { … }
Function *AArch64Arm64ECCallLowering::buildEntryThunk(Function *F) { … }
Function *AArch64Arm64ECCallLowering::buildGuestExitThunk(Function *F) { … }
Function *
AArch64Arm64ECCallLowering::buildPatchableThunk(GlobalAlias *UnmangledAlias,
GlobalAlias *MangledAlias) { … }
void AArch64Arm64ECCallLowering::lowerCall(CallBase *CB) { … }
bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) { … }
bool AArch64Arm64ECCallLowering::processFunction(
Function &F, SetVector<GlobalValue *> &DirectCalledFns,
DenseMap<GlobalAlias *, GlobalAlias *> &FnsMap) { … }
char AArch64Arm64ECCallLowering::ID = …;
INITIALIZE_PASS(…)
ModulePass *llvm::createAArch64Arm64ECCallLoweringPass() { … }