#include "llvm/CodeGen/FastISel.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.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/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <optional>
#include <utility>
usingnamespacellvm;
usingnamespacePatternMatch;
#define DEBUG_TYPE …
STATISTIC(NumFastIselSuccessIndependent, "Number of insts selected by "
"target-independent selector");
STATISTIC(NumFastIselSuccessTarget, "Number of insts selected by "
"target-specific selector");
STATISTIC(NumFastIselDead, "Number of dead insts removed on failure");
void FastISel::startNewBlock() { … }
void FastISel::finishBasicBlock() { … }
bool FastISel::lowerArguments() { … }
static Register findLocalRegDef(MachineInstr &MI) { … }
static bool isRegUsedByPhiNodes(Register DefReg,
FunctionLoweringInfo &FuncInfo) { … }
void FastISel::flushLocalValueMap() { … }
Register FastISel::getRegForValue(const Value *V) { … }
Register FastISel::materializeConstant(const Value *V, MVT VT) { … }
Register FastISel::materializeRegForValue(const Value *V, MVT VT) { … }
Register FastISel::lookUpRegForValue(const Value *V) { … }
void FastISel::updateValueMap(const Value *I, Register Reg, unsigned NumRegs) { … }
Register FastISel::getRegForGEPIndex(const Value *Idx) { … }
void FastISel::recomputeInsertPt() { … }
void FastISel::removeDeadCode(MachineBasicBlock::iterator I,
MachineBasicBlock::iterator E) { … }
FastISel::SavePoint FastISel::enterLocalValueArea() { … }
void FastISel::leaveLocalValueArea(SavePoint OldInsertPt) { … }
bool FastISel::selectBinaryOp(const User *I, unsigned ISDOpcode) { … }
bool FastISel::selectGetElementPtr(const User *I) { … }
bool FastISel::addStackMapLiveVars(SmallVectorImpl<MachineOperand> &Ops,
const CallInst *CI, unsigned StartIdx) { … }
bool FastISel::selectStackmap(const CallInst *I) { … }
bool FastISel::lowerCallOperands(const CallInst *CI, unsigned ArgIdx,
unsigned NumArgs, const Value *Callee,
bool ForceRetVoidTy, CallLoweringInfo &CLI) { … }
FastISel::CallLoweringInfo &FastISel::CallLoweringInfo::setCallee(
const DataLayout &DL, MCContext &Ctx, CallingConv::ID CC, Type *ResultTy,
StringRef Target, ArgListTy &&ArgsList, unsigned FixedArgs) { … }
bool FastISel::selectPatchpoint(const CallInst *I) { … }
bool FastISel::selectXRayCustomEvent(const CallInst *I) { … }
bool FastISel::selectXRayTypedEvent(const CallInst *I) { … }
static AttributeList getReturnAttrs(FastISel::CallLoweringInfo &CLI) { … }
bool FastISel::lowerCallTo(const CallInst *CI, const char *SymName,
unsigned NumArgs) { … }
bool FastISel::lowerCallTo(const CallInst *CI, MCSymbol *Symbol,
unsigned NumArgs) { … }
bool FastISel::lowerCallTo(CallLoweringInfo &CLI) { … }
bool FastISel::lowerCall(const CallInst *CI) { … }
bool FastISel::selectCall(const User *I) { … }
void FastISel::handleDbgInfo(const Instruction *II) { … }
bool FastISel::lowerDbgValue(const Value *V, DIExpression *Expr,
DILocalVariable *Var, const DebugLoc &DL) { … }
bool FastISel::lowerDbgDeclare(const Value *Address, DIExpression *Expr,
DILocalVariable *Var, const DebugLoc &DL) { … }
bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) { … }
bool FastISel::selectCast(const User *I, unsigned Opcode) { … }
bool FastISel::selectBitCast(const User *I) { … }
bool FastISel::selectFreeze(const User *I) { … }
void FastISel::removeDeadLocalValueCode(MachineInstr *SavedLastLocalValue)
{ … }
bool FastISel::selectInstruction(const Instruction *I) { … }
void FastISel::fastEmitBranch(MachineBasicBlock *MSucc,
const DebugLoc &DbgLoc) { … }
void FastISel::finishCondBranch(const BasicBlock *BranchBB,
MachineBasicBlock *TrueMBB,
MachineBasicBlock *FalseMBB) { … }
bool FastISel::selectFNeg(const User *I, const Value *In) { … }
bool FastISel::selectExtractValue(const User *U) { … }
bool FastISel::selectOperator(const User *I, unsigned Opcode) { … }
FastISel::FastISel(FunctionLoweringInfo &FuncInfo,
const TargetLibraryInfo *LibInfo,
bool SkipTargetIndependentISel)
: … { … }
FastISel::~FastISel() = default;
bool FastISel::fastLowerArguments() { … }
bool FastISel::fastLowerCall(CallLoweringInfo & ) { … }
bool FastISel::fastLowerIntrinsicCall(const IntrinsicInst * ) { … }
unsigned FastISel::fastEmit_(MVT, MVT, unsigned) { … }
unsigned FastISel::fastEmit_r(MVT, MVT, unsigned, unsigned ) { … }
unsigned FastISel::fastEmit_rr(MVT, MVT, unsigned, unsigned ,
unsigned ) { … }
unsigned FastISel::fastEmit_i(MVT, MVT, unsigned, uint64_t ) { … }
unsigned FastISel::fastEmit_f(MVT, MVT, unsigned,
const ConstantFP * ) { … }
unsigned FastISel::fastEmit_ri(MVT, MVT, unsigned, unsigned ,
uint64_t ) { … }
Register FastISel::fastEmit_ri_(MVT VT, unsigned Opcode, unsigned Op0,
uint64_t Imm, MVT ImmType) { … }
Register FastISel::createResultReg(const TargetRegisterClass *RC) { … }
Register FastISel::constrainOperandRegClass(const MCInstrDesc &II, Register Op,
unsigned OpNum) { … }
Register FastISel::fastEmitInst_(unsigned MachineInstOpcode,
const TargetRegisterClass *RC) { … }
Register FastISel::fastEmitInst_r(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0) { … }
Register FastISel::fastEmitInst_rr(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0,
unsigned Op1) { … }
Register FastISel::fastEmitInst_rrr(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0,
unsigned Op1, unsigned Op2) { … }
Register FastISel::fastEmitInst_ri(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0,
uint64_t Imm) { … }
Register FastISel::fastEmitInst_rii(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0,
uint64_t Imm1, uint64_t Imm2) { … }
Register FastISel::fastEmitInst_f(unsigned MachineInstOpcode,
const TargetRegisterClass *RC,
const ConstantFP *FPImm) { … }
Register FastISel::fastEmitInst_rri(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, unsigned Op0,
unsigned Op1, uint64_t Imm) { … }
Register FastISel::fastEmitInst_i(unsigned MachineInstOpcode,
const TargetRegisterClass *RC, uint64_t Imm) { … }
Register FastISel::fastEmitInst_extractsubreg(MVT RetVT, unsigned Op0,
uint32_t Idx) { … }
Register FastISel::fastEmitZExtFromI1(MVT VT, unsigned Op0) { … }
bool FastISel::handlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) { … }
bool FastISel::tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst) { … }
bool FastISel::canFoldAddIntoGEP(const User *GEP, const Value *Add) { … }
MachineMemOperand *
FastISel::createMachineMemOperandFor(const Instruction *I) const { … }
CmpInst::Predicate FastISel::optimizeCmpPredicate(const CmpInst *CI) const { … }