LLVM 20.0.0git
|
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/LostDebugLocObserver.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RuntimeLibcallUtil.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include <numeric>
#include <optional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "legalizer" |
#define | RTLIBCASE_INT(LibcallPrefix) |
#define | RTLIBCASE(LibcallPrefix) |
#define | LCALLS(A, B) {A##B##_RELAX, A##B##_ACQ, A##B##_REL, A##B##_ACQ_REL} |
#define | LCALL5(A) LCALLS(A, 1), LCALLS(A, 2), LCALLS(A, 4), LCALLS(A, 8), LCALLS(A, 16) |
#define DEBUG_TYPE "legalizer" |
Definition at line 42 of file LegalizerHelper.cpp.
#define RTLIBCASE | ( | LibcallPrefix | ) |
#define RTLIBCASE_INT | ( | LibcallPrefix | ) |
|
static |
Operand Op
is used on N
sub-instructions.
Fill Ops
with N
SrcOps made from Op
depending on operand type.
Definition at line 4425 of file LegalizerHelper.cpp.
References llvm_unreachable, N, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::LegalizerHelper::fewerElementsVectorMultiEltType().
|
static |
Emit code to insert InsertReg
into TargetRet
at OffsetBits
in TargetReg
, while preserving other bits in TargetReg
.
(InsertReg << Offset) | (TargetReg & ~(-1 >> InsertReg.size()) << Offset)
Definition at line 3483 of file LegalizerHelper.cpp.
References B, llvm::APInt::getLowBitsSet(), and llvm::LLT::getSizeInBits().
Referenced by llvm::LegalizerHelper::bitcastInsertVectorElt().
|
static |
Definition at line 4314 of file LegalizerHelper.cpp.
References B, llvm::APInt::getLowBitsSet(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::isPowerOf2_32(), llvm::Log2_32(), llvm::MIPatternMatch::m_ICst(), and llvm::MIPatternMatch::mi_match().
Referenced by llvm::LegalizerHelper::getVectorElementPointer().
|
static |
Definition at line 876 of file LegalizerHelper.cpp.
References llvm::createLibcall(), getConvRTLibDesc(), getReg(), llvm::LegalizeActions::Libcall, and MI.
Referenced by llvm::LegalizerHelper::libcall().
|
static |
Definition at line 776 of file LegalizerHelper.cpp.
References llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::buildXor(), llvm::MachineOperand::CreateES(), llvm::dbgs(), llvm::IntegerType::get(), llvm::StructType::get(), llvm::PointerType::get(), llvm::TargetSubtargetInfo::getCallLowering(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineIRBuilder::getMF(), llvm::MCInstrInfo::getName(), getOutlineAtomicLibcall(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getSizeInBits(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::MachineIRBuilder::getTII(), Info, llvm::LegalizerHelper::Legalized, LLVM_DEBUG, llvm_unreachable, MI, Name, llvm::SmallVectorTemplateBase< T, bool >::push_back(), RetTy, Success, and llvm::LegalizerHelper::UnableToLegalize.
Referenced by llvm::LegalizerHelper::libcall().
|
static |
Definition at line 3240 of file LegalizerHelper.cpp.
References Addr, llvm::MachineIRBuilder::buildConstantPool(), llvm::MachineIRBuilder::buildLoadInstr(), DL, llvm::MachineFunction::getConstantPool(), llvm::MachinePointerInfo::getConstantPool(), llvm::MachineConstantPool::getConstantPoolIndex(), llvm::MachineIRBuilder::getDataLayout(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineIRBuilder::getMF(), llvm::MachineIRBuilder::getMRI(), llvm::Value::getType(), llvm::MachineMemOperand::MOLoad, MRI, and llvm::LLT::pointer().
Referenced by llvm::LegalizerHelper::lowerConstant(), and llvm::LegalizerHelper::lowerFConstant().
|
static |
Definition at line 8841 of file LegalizerHelper.cpp.
References llvm::TargetLoweringBase::allowsMisalignedMemoryAccesses(), assert(), llvm::bit_floor(), llvm::CallingConv::Fast, llvm::getMVTForLLT(), llvm::TargetLoweringBase::getOptimalMemOpLLT(), llvm::LLT::getSizeInBits(), llvm::LLT::getSizeInBytes(), llvm::LLT::isVector(), llvm::MachineMemOperand::MONone, llvm::LLT::scalar(), and Size.
|
static |
Figure out the bit offset into a register when coercing a vector index for the wide element type.
This is only for the case when promoting vector to one with larger elements. offset_idx = G_AND idx, ~(-1 << Log2(DstEltSize / SrcEltSize)) offset_bits = G_SHL offset_idx, Log2(SrcEltSize)
Definition at line 3355 of file LegalizerHelper.cpp.
References B, llvm::APInt::getAllOnes(), llvm::LLT::getSizeInBits(), Idx, and llvm::Log2_32().
Referenced by llvm::LegalizerHelper::bitcastExtractVectorElt(), and llvm::LegalizerHelper::bitcastInsertVectorElt().
|
static |
Definition at line 853 of file LegalizerHelper.cpp.
References llvm::RTLIB::getFPEXT(), llvm::RTLIB::getFPROUND(), llvm::RTLIB::getFPTOSINT(), llvm::RTLIB::getFPTOUINT(), llvm::RTLIB::getSINTTOFP(), llvm::RTLIB::getUINTTOFP(), llvm::MVT::getVT(), and llvm_unreachable.
Referenced by conversionLibcall().
|
static |
Returns the corresponding libcall for the given Pred and the ICMP predicate that should be generated to compare with #0 after the libcall.
Definition at line 998 of file LegalizerHelper.cpp.
References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, and llvm::CmpInst::ICMP_SLT.
|
static |
Definition at line 83 of file LegalizerHelper.cpp.
References llvm::Type::getDoubleTy(), llvm::Type::getFloatTy(), llvm::Type::getFP128Ty(), llvm::Type::getHalfTy(), llvm::LLT::getSizeInBits(), llvm::Type::getX86_FP80Ty(), and llvm::LLT::isScalar().
Referenced by llvm::LegalizerHelper::libcall().
|
static |
Definition at line 8907 of file LegalizerHelper.cpp.
References llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildSplatBuildVector(), llvm::MachineIRBuilder::buildZExtOrTrunc(), llvm::getIConstantVRegValWithLookThrough(), llvm::MachineIRBuilder::getMRI(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getScalarType(), llvm::APInt::getSplat(), llvm::LLT::isVector(), and MRI.
Referenced by getMemsetStores().
|
static |
Try to break down OrigTy
into NarrowTy
sized pieces.
Returns the number of NarrowTy
elements needed to reconstruct OrigTy
, with any leftover piece as type LeftoverTy
Returns -1 in the first element of the pair if the breakdown is not satisfiable.
Definition at line 56 of file LegalizerHelper.cpp.
References assert(), llvm::LLT::getElementType(), llvm::ElementCount::getFixed(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::LLT::isValid(), llvm::LLT::isVector(), llvm::LLT::scalar(), llvm::LLT::scalarOrVector(), and Size.
Referenced by makeDstOps(), and llvm::LegalizerHelper::reduceLoadStoreWidth().
|
static |
Definition at line 728 of file LegalizerHelper.cpp.
References llvm::LLT::getSizeInBytes(), llvm::LLT::isVector(), LCALL5, and MI.
Referenced by createAtomicLibcall().
|
static |
Definition at line 382 of file LegalizerHelper.cpp.
References llvm_unreachable, RTLIBCASE, and RTLIBCASE_INT.
Referenced by llvm::LegalizerHelper::libcall(), and simpleLibcall().
|
static |
Definition at line 885 of file LegalizerHelper.cpp.
References llvm_unreachable, and MI.
|
static |
Definition at line 3233 of file LegalizerHelper.cpp.
References B, I, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::LegalizerHelper::lowerBitcast().
|
static |
Append the result registers of G_UNMERGE_VALUES MI
to Regs
.
Definition at line 225 of file LegalizerHelper.cpp.
References assert(), I, MI, llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorBase< Size_T >::size().
|
static |
Check that all vector operands have same number of elements.
Other operands should be listed in NonVecOp.
Definition at line 4364 of file LegalizerHelper.cpp.
References llvm::LLT::getNumElements(), llvm::is_contained(), llvm::LLT::isVector(), MI, and MRI.
Referenced by llvm::LegalizerHelper::fewerElementsVectorMultiEltType().
|
static |
True if an instruction is in tail position in its caller.
Intended for legalizing libcalls as tail calls when possible.
Definition at line 500 of file LegalizerHelper.cpp.
References F, llvm::MachineFunction::getFunction(), llvm::MachineBasicBlock::getParent(), llvm::AttributeList::getRetAttrs(), llvm::AttrBuilder::hasAttributes(), llvm::AttributeList::hasRetAttr(), llvm::MachineBasicBlock::instr_end(), llvm::Register::isPhysical(), llvm::HexagonInstrInfo::isTailCall(), llvm::Register::isVirtual(), MBB, MI, llvm::next_nodbg(), llvm::AttrBuilder::removeAttribute(), and TII.
Referenced by llvm::createLibcall(), and llvm::createMemLibcall().
|
static |
Definition at line 6748 of file LegalizerHelper.cpp.
References llvm::CallingConv::C, llvm::ConstantInt::getValue(), llvm::matchUnaryPredicate(), MRI, and llvm::APInt::urem().
Referenced by llvm::TargetLowering::expandFunnelShift(), expandVPFunnelShift(), llvm::LegalizerHelper::lowerFunnelShiftAsShifts(), and llvm::LegalizerHelper::lowerFunnelShiftWithInverse().
|
static |
Fill DstOps
with DstOps that have same number of elements combined as the Ty.
These DstOps have either scalar type when NumElts
= 1 or are vectors with NumElts
elements. When Ty.getNumElements() is not multiple of NumElts
last DstOp (leftover) has fewer then NumElts
elements.
Definition at line 4402 of file LegalizerHelper.cpp.
References assert(), llvm::LLT::fixed_vector(), llvm::LLT::getElementType(), getNarrowTypeBreakDown(), llvm::LLT::isValid(), llvm::LLT::isVector(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::LegalizerHelper::fewerElementsVectorMultiEltType(), and llvm::LegalizerHelper::fewerElementsVectorPhi().
|
static |
Definition at line 7424 of file LegalizerHelper.cpp.
References llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, and llvm_unreachable.
Referenced by llvm::LegalizerHelper::lowerMinMax().
|
static |
Definition at line 8831 of file LegalizerHelper.cpp.
References llvm::MachineFunction::getFunction(), llvm::MachineFunction::getTarget(), llvm::TargetMachine::getTargetTriple(), llvm::Function::hasMinSize(), llvm::Function::hasOptSize(), and llvm::Triple::isOSDarwin().
Referenced by getMemcpyLoadsAndStores(), getMemmoveLoadsAndStores(), getMemsetStores(), and llvm::LegalizerHelper::lowerMemCpyFamily().
|
static |
Definition at line 626 of file LegalizerHelper.cpp.
References llvm::createLibcall(), llvm::drop_begin(), getReg(), getRTLibDesc(), llvm::LegalizeActions::Libcall, MI, and Size.
Referenced by llvm::LegalizerHelper::libcall().
|
static |
Definition at line 8359 of file LegalizerHelper.cpp.
References B, LHS, N, and RHS.
Referenced by llvm::LegalizerHelper::lowerBitreverse().