#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RuntimeLibcallUtil.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <iterator>
#include <string>
#include <tuple>
#include <utility>
usingnamespacellvm;
static cl::opt<bool> JumpIsExpensiveOverride(
"jump-is-expensive", cl::init(false),
cl::desc("Do not create extra branches to split comparison logic."),
cl::Hidden);
static cl::opt<unsigned> MinimumJumpTableEntries
("min-jump-table-entries", cl::init(4), cl::Hidden,
cl::desc("Set minimum number of entries to use a jump table."));
static cl::opt<unsigned> MaximumJumpTableSize
("max-jump-table-size", cl::init(UINT_MAX), cl::Hidden,
cl::desc("Set maximum size of jump tables."));
static cl::opt<unsigned>
JumpTableDensity("jump-table-density", cl::init(10), cl::Hidden,
cl::desc("Minimum density for building a jump table in "
"a normal function"));
static cl::opt<unsigned> OptsizeJumpTableDensity(
"optsize-jump-table-density", cl::init(40), cl::Hidden,
cl::desc("Minimum density for building a jump table in "
"an optsize function"));
static cl::opt<bool> DisableStrictNodeMutation("disable-strictnode-mutation",
cl::desc("Don't mutate strict-float node to a legalize node"),
cl::init(false), cl::Hidden);
RTLIB::Libcall RTLIB::getFPLibCall(EVT VT,
RTLIB::Libcall Call_F32,
RTLIB::Libcall Call_F64,
RTLIB::Libcall Call_F80,
RTLIB::Libcall Call_F128,
RTLIB::Libcall Call_PPCF128) { … }
RTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getFPTOSINT(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getFPTOUINT(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getSINTTOFP(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getUINTTOFP(EVT OpVT, EVT RetVT) { … }
RTLIB::Libcall RTLIB::getPOWI(EVT RetVT) { … }
RTLIB::Libcall RTLIB::getLDEXP(EVT RetVT) { … }
RTLIB::Libcall RTLIB::getFREXP(EVT RetVT) { … }
RTLIB::Libcall RTLIB::getOutlineAtomicHelper(const Libcall (&LC)[5][4],
AtomicOrdering Order,
uint64_t MemSize) { … }
RTLIB::Libcall RTLIB::getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order,
MVT VT) { … }
RTLIB::Libcall RTLIB::getSYNC(unsigned Opc, MVT VT) { … }
RTLIB::Libcall RTLIB::getMEMCPY_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize) { … }
RTLIB::Libcall RTLIB::getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize) { … }
RTLIB::Libcall RTLIB::getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize) { … }
void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) { … }
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
: … { … }
void TargetLoweringBase::initActions() { … }
MVT TargetLoweringBase::getScalarShiftAmountTy(const DataLayout &DL,
EVT) const { … }
EVT TargetLoweringBase::getShiftAmountTy(EVT LHSTy,
const DataLayout &DL) const { … }
bool TargetLoweringBase::canOpTrap(unsigned Op, EVT VT) const { … }
bool TargetLoweringBase::isFreeAddrSpaceCast(unsigned SrcAS,
unsigned DestAS) const { … }
unsigned TargetLoweringBase::getBitWidthForCttzElements(
Type *RetTy, ElementCount EC, bool ZeroIsPoison,
const ConstantRange *VScaleRange) const { … }
void TargetLoweringBase::setJumpIsExpensive(bool isExpensive) { … }
TargetLoweringBase::LegalizeKind
TargetLoweringBase::getTypeConversion(LLVMContext &Context, EVT VT) const { … }
static unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT,
unsigned &NumIntermediates,
MVT &RegisterVT,
TargetLoweringBase *TLI) { … }
bool TargetLoweringBase::isLegalRC(const TargetRegisterInfo &TRI,
const TargetRegisterClass &RC) const { … }
MachineBasicBlock *
TargetLoweringBase::emitPatchPoint(MachineInstr &InitialMI,
MachineBasicBlock *MBB) const { … }
std::pair<const TargetRegisterClass *, uint8_t>
TargetLoweringBase::findRepresentativeClass(const TargetRegisterInfo *TRI,
MVT VT) const { … }
void TargetLoweringBase::computeRegisterProperties(
const TargetRegisterInfo *TRI) { … }
EVT TargetLoweringBase::getSetCCResultType(const DataLayout &DL, LLVMContext &,
EVT VT) const { … }
MVT::SimpleValueType TargetLoweringBase::getCmpLibcallReturnType() const { … }
unsigned TargetLoweringBase::getVectorTypeBreakdown(LLVMContext &Context,
EVT VT, EVT &IntermediateVT,
unsigned &NumIntermediates,
MVT &RegisterVT) const { … }
bool TargetLoweringBase::isSuitableForJumpTable(const SwitchInst *SI,
uint64_t NumCases,
uint64_t Range,
ProfileSummaryInfo *PSI,
BlockFrequencyInfo *BFI) const { … }
MVT TargetLoweringBase::getPreferredSwitchConditionType(LLVMContext &Context,
EVT ConditionVT) const { … }
void llvm::GetReturnInfo(CallingConv::ID CC, Type *ReturnType,
AttributeList attr,
SmallVectorImpl<ISD::OutputArg> &Outs,
const TargetLowering &TLI, const DataLayout &DL) { … }
uint64_t TargetLoweringBase::getByValTypeAlignment(Type *Ty,
const DataLayout &DL) const { … }
bool TargetLoweringBase::allowsMemoryAccessForAlignment(
LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace,
Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const { … }
bool TargetLoweringBase::allowsMemoryAccessForAlignment(
LLVMContext &Context, const DataLayout &DL, EVT VT,
const MachineMemOperand &MMO, unsigned *Fast) const { … }
bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context,
const DataLayout &DL, EVT VT,
unsigned AddrSpace, Align Alignment,
MachineMemOperand::Flags Flags,
unsigned *Fast) const { … }
bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context,
const DataLayout &DL, EVT VT,
const MachineMemOperand &MMO,
unsigned *Fast) const { … }
bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context,
const DataLayout &DL, LLT Ty,
const MachineMemOperand &MMO,
unsigned *Fast) const { … }
int TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode) const { … }
Value *
TargetLoweringBase::getDefaultSafeStackPointerLocation(IRBuilderBase &IRB,
bool UseTLS) const { … }
Value *
TargetLoweringBase::getSafeStackPointerLocation(IRBuilderBase &IRB) const { … }
bool TargetLoweringBase::isLegalAddressingMode(const DataLayout &DL,
const AddrMode &AM, Type *Ty,
unsigned AS, Instruction *I) const { … }
Value *TargetLoweringBase::getIRStackGuard(IRBuilderBase &IRB) const { … }
void TargetLoweringBase::insertSSPDeclarations(Module &M) const { … }
Value *TargetLoweringBase::getSDagStackGuard(const Module &M) const { … }
Function *TargetLoweringBase::getSSPStackGuardCheck(const Module &M) const { … }
unsigned TargetLoweringBase::getMinimumJumpTableEntries() const { … }
void TargetLoweringBase::setMinimumJumpTableEntries(unsigned Val) { … }
unsigned TargetLoweringBase::getMinimumJumpTableDensity(bool OptForSize) const { … }
unsigned TargetLoweringBase::getMaximumJumpTableSize() const { … }
void TargetLoweringBase::setMaximumJumpTableSize(unsigned Val) { … }
bool TargetLoweringBase::isJumpTableRelative() const { … }
Align TargetLoweringBase::getPrefLoopAlignment(MachineLoop *ML) const { … }
unsigned TargetLoweringBase::getMaxPermittedBytesForAlignment(
MachineBasicBlock *MBB) const { … }
static StringRef getRecipEstimateForFunc(MachineFunction &MF) { … }
static std::string getReciprocalOpName(bool IsSqrt, EVT VT) { … }
static bool parseRefinementStep(StringRef In, size_t &Position,
uint8_t &Value) { … }
static int getOpEnabled(bool IsSqrt, EVT VT, StringRef Override) { … }
static int getOpRefinementSteps(bool IsSqrt, EVT VT, StringRef Override) { … }
int TargetLoweringBase::getRecipEstimateSqrtEnabled(EVT VT,
MachineFunction &MF) const { … }
int TargetLoweringBase::getRecipEstimateDivEnabled(EVT VT,
MachineFunction &MF) const { … }
int TargetLoweringBase::getSqrtRefinementSteps(EVT VT,
MachineFunction &MF) const { … }
int TargetLoweringBase::getDivRefinementSteps(EVT VT,
MachineFunction &MF) const { … }
bool TargetLoweringBase::isLoadBitCastBeneficial(
EVT LoadVT, EVT BitcastVT, const SelectionDAG &DAG,
const MachineMemOperand &MMO) const { … }
void TargetLoweringBase::finalizeLowering(MachineFunction &MF) const { … }
MachineMemOperand::Flags TargetLoweringBase::getLoadMemOperandFlags(
const LoadInst &LI, const DataLayout &DL, AssumptionCache *AC,
const TargetLibraryInfo *LibInfo) const { … }
MachineMemOperand::Flags
TargetLoweringBase::getStoreMemOperandFlags(const StoreInst &SI,
const DataLayout &DL) const { … }
MachineMemOperand::Flags
TargetLoweringBase::getAtomicMemOperandFlags(const Instruction &AI,
const DataLayout &DL) const { … }
Instruction *TargetLoweringBase::emitLeadingFence(IRBuilderBase &Builder,
Instruction *Inst,
AtomicOrdering Ord) const { … }
Instruction *TargetLoweringBase::emitTrailingFence(IRBuilderBase &Builder,
Instruction *Inst,
AtomicOrdering Ord) const { … }
bool TargetLoweringBase::shouldLocalize(const MachineInstr &MI,
const TargetTransformInfo *TTI) const { … }