LLVM 22.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
llvm::LegalizerHelper Class Reference

#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"

Public Types

enum  LegalizeResult { AlreadyLegal , Legalized , UnableToLegalize }
 

Public Member Functions

const LegalizerInfogetLegalizerInfo () const
 Expose LegalizerInfo so the clients can re-use.
 
const TargetLoweringgetTargetLowering () const
 
GISelValueTrackinggetValueTracking () const
 
LLVM_ABI LegalizerHelper (MachineFunction &MF, GISelChangeObserver &Observer, MachineIRBuilder &B)
 
LLVM_ABI LegalizerHelper (MachineFunction &MF, const LegalizerInfo &LI, GISelChangeObserver &Observer, MachineIRBuilder &B, GISelValueTracking *VT=nullptr)
 
LLVM_ABI LegalizeResult legalizeInstrStep (MachineInstr &MI, LostDebugLocObserver &LocObserver)
 Replace MI by a sequence of legal instructions that can implement the same operation.
 
LLVM_ABI LegalizeResult libcall (MachineInstr &MI, LostDebugLocObserver &LocObserver)
 Legalize an instruction by emiting a runtime library call instead.
 
LLVM_ABI LegalizeResult narrowScalar (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize an instruction by reducing the width of the underlying scalar type.
 
LLVM_ABI LegalizeResult widenScalar (MachineInstr &MI, unsigned TypeIdx, LLT WideTy)
 Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addition can be safely performed at 32-bits precision, ignoring the unused bits).
 
LLVM_ABI LegalizeResult bitcast (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 Legalize an instruction by replacing the value type.
 
LLVM_ABI LegalizeResult lower (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 Legalize an instruction by splitting it into simpler parts, hopefully understood by the target.
 
LLVM_ABI LegalizeResult fewerElementsVector (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize a vector instruction by splitting into multiple components, each acting on the same scalar type as the original but with fewer elements.
 
LLVM_ABI LegalizeResult moreElementsVector (MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
 Legalize a vector instruction by increasing the number of vector elements involved and ignoring the added elements later.
 
LLVM_ABI Register coerceToScalar (Register Val)
 Cast the given value to an LLT::scalar with an equivalent size.
 
LLVM_ABI void widenScalarSrc (MachineInstr &MI, LLT WideTy, unsigned OpIdx, unsigned ExtOpcode)
 Legalize a single operand OpIdx of the machine instruction MI as a Use by extending the operand's type to WideTy using the specified ExtOpcode for the extension instruction, and replacing the vreg of the operand in place.
 
LLVM_ABI void narrowScalarSrc (MachineInstr &MI, LLT NarrowTy, unsigned OpIdx)
 Legalize a single operand OpIdx of the machine instruction MI as a Use by truncating the operand's type to NarrowTy using G_TRUNC, and replacing the vreg of the operand in place.
 
LLVM_ABI void widenScalarDst (MachineInstr &MI, LLT WideTy, unsigned OpIdx=0, unsigned TruncOpcode=TargetOpcode::G_TRUNC)
 Legalize a single operand OpIdx of the machine instruction MI as a Def by extending the operand's type to WideTy and truncating it back with the TruncOpcode, and replacing the vreg of the operand in place.
 
LLVM_ABI void narrowScalarDst (MachineInstr &MI, LLT NarrowTy, unsigned OpIdx, unsigned ExtOpcode)
 
LLVM_ABI void moreElementsVectorDst (MachineInstr &MI, LLT MoreTy, unsigned OpIdx)
 Legalize a single operand OpIdx of the machine instruction MI as a Def by performing it with additional vector elements and extracting the result elements, and replacing the vreg of the operand in place.
 
LLVM_ABI void moreElementsVectorSrc (MachineInstr &MI, LLT MoreTy, unsigned OpIdx)
 Legalize a single operand OpIdx of the machine instruction MI as a Use by producing a vector with undefined high elements, extracting the original vector type, and replacing the vreg of the operand in place.
 
LLVM_ABI void bitcastSrc (MachineInstr &MI, LLT CastTy, unsigned OpIdx)
 Legalize a single operand OpIdx of the machine instruction MI as a use by inserting a G_BITCAST to CastTy.
 
LLVM_ABI void bitcastDst (MachineInstr &MI, LLT CastTy, unsigned OpIdx)
 Legalize a single operand OpIdx of the machine instruction MI as a def by inserting a G_BITCAST from CastTy.
 
LLVM_ABI Align getStackTemporaryAlignment (LLT Type, Align MinAlign=Align()) const
 Return the alignment to use for a stack temporary object with the given type.
 
LLVM_ABI MachineInstrBuilder createStackTemporary (TypeSize Bytes, Align Alignment, MachinePointerInfo &PtrInfo)
 Create a stack temporary based on the size in bytes and the alignment.
 
LLVM_ABI MachineInstrBuilder createStackStoreLoad (const DstOp &Res, const SrcOp &Val)
 Create a store of Val to a stack temporary and return a load as the same type as Res.
 
LLVM_ABI LegalizeResult scalarizeVectorBooleanStore (GStore &MI)
 Given a store of a boolean vector, scalarize it.
 
LLVM_ABI Register getVectorElementPointer (Register VecPtr, LLT VecTy, Register Index)
 Get a pointer to vector element Index located in memory for a vector of type VecTy starting at a base address of VecPtr.
 
LLVM_ABI LegalizeResult fewerElementsVectorMultiEltType (GenericMachineInstr &MI, unsigned NumElts, std::initializer_list< unsigned > NonVecOpIndices={})
 Handles most opcodes.
 
LLVM_ABI LegalizeResult fewerElementsVectorPhi (GenericMachineInstr &MI, unsigned NumElts)
 
LLVM_ABI LegalizeResult moreElementsVectorPhi (MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
 
LLVM_ABI LegalizeResult moreElementsVectorShuffle (MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorUnmergeValues (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorMerge (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorExtractInsertVectorElt (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult equalizeVectorShuffleLengths (MachineInstr &MI)
 Equalize source and destination vector sizes of G_SHUFFLE_VECTOR.
 
LLVM_ABI LegalizeResult reduceLoadStoreWidth (GLoadStore &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult narrowScalarShiftByConstant (MachineInstr &MI, const APInt &Amt, LLT HalfTy, LLT ShiftAmtTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorReductions (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorSeqReductions (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult fewerElementsBitcast (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult fewerElementsVectorShuffle (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult narrowScalarShift (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarAddSub (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LLVM_ABI LegalizeResult narrowScalarMul (MachineInstr &MI, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarFPTOI (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarExtract (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarInsert (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarBasic (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarExt (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarSelect (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarCTLZ (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarCTTZ (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarCTPOP (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult narrowScalarFLDEXP (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LLVM_ABI LegalizeResult bitcastExtractVectorElt (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.
 
LLVM_ABI LegalizeResult bitcastInsertVectorElt (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.
 
LLVM_ABI LegalizeResult bitcastConcatVector (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 
LLVM_ABI LegalizeResult bitcastShuffleVector (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 
LLVM_ABI LegalizeResult bitcastExtractSubvector (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 This attempts to bitcast G_EXTRACT_SUBVECTOR to CastTy.
 
LLVM_ABI LegalizeResult bitcastInsertSubvector (MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
 This attempts to bitcast G_INSERT_SUBVECTOR to CastTy.
 
LLVM_ABI LegalizeResult lowerConstant (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFConstant (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerBitcast (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerLoad (GAnyLoad &MI)
 
LLVM_ABI LegalizeResult lowerStore (GStore &MI)
 
LLVM_ABI LegalizeResult lowerBitCount (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFunnelShiftWithInverse (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFunnelShiftAsShifts (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFunnelShift (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerEXT (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerTRUNC (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerRotateWithReverseRotate (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerRotate (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerU64ToF32BitOps (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerU64ToF32WithSITOFP (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerU64ToF64BitFloatOps (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerUITOFP (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerSITOFP (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPTOUI (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPTOSI (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPTOINT_SAT (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPTRUNC_F64_TO_F16 (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPTRUNC (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFPOWI (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerISFPCLASS (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerThreewayCompare (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerMinMax (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFCopySign (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFMinNumMaxNum (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFMad (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerIntrinsicRound (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFFloor (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerMergeValues (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerUnmergeValues (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerExtractInsertVectorElt (MachineInstr &MI)
 Lower a vector extract or insert by writing the vector to a stack temporary and reloading the element or vector.
 
LLVM_ABI LegalizeResult lowerShuffleVector (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerVECTOR_COMPRESS (MachineInstr &MI)
 
LLVM_ABI Register getDynStackAllocTargetPtr (Register SPReg, Register AllocSize, Align Alignment, LLT PtrTy)
 
LLVM_ABI LegalizeResult lowerDynStackAlloc (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerStackSave (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerStackRestore (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerExtract (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerInsert (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerSADDO_SSUBO (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerAddSubSatToMinMax (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerAddSubSatToAddoSubo (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerShlSat (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerBswap (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerBitreverse (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerReadWriteRegister (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerSMULH_UMULH (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerSelect (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerDIVREM (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerAbsToAddXor (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerAbsToMaxNeg (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerAbsToCNeg (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerFAbs (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerVectorReduction (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerMemcpyInline (MachineInstr &MI)
 
LLVM_ABI LegalizeResult lowerMemCpyFamily (MachineInstr &MI, unsigned MaxLen=0)
 
LLVM_ABI LegalizeResult lowerVAArg (MachineInstr &MI)
 

Public Attributes

MachineIRBuilderMIRBuilder
 Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.
 
GISelChangeObserverObserver
 To keep track of changes made by the LegalizerHelper.
 

Detailed Description

Definition at line 49 of file LegalizerHelper.h.

Member Enumeration Documentation

◆ LegalizeResult

Enumerator
AlreadyLegal 

Instruction was already legal and no change was made to the MachineFunction.

Legalized 

Instruction has been legalized and the MachineFunction changed.

UnableToLegalize 

Some kind of error has occurred and we could not legalize this instruction.

Definition at line 65 of file LegalizerHelper.h.

Constructor & Destructor Documentation

◆ LegalizerHelper() [1/2]

LegalizerHelper::LegalizerHelper ( MachineFunction MF,
GISelChangeObserver Observer,
MachineIRBuilder B 
)

Definition at line 105 of file LegalizerHelper.cpp.

◆ LegalizerHelper() [2/2]

LegalizerHelper::LegalizerHelper ( MachineFunction MF,
const LegalizerInfo LI,
GISelChangeObserver Observer,
MachineIRBuilder B,
GISelValueTracking VT = nullptr 
)

Definition at line 112 of file LegalizerHelper.cpp.

Member Function Documentation

◆ bitcast()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcast ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ bitcastConcatVector()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastConcatVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

◆ bitcastDst()

void LegalizerHelper::bitcastDst ( MachineInstr MI,
LLT  CastTy,
unsigned  OpIdx 
)

◆ bitcastExtractSubvector()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastExtractSubvector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

This attempts to bitcast G_EXTRACT_SUBVECTOR to CastTy.

<vscale x 8 x i1> = G_EXTRACT_SUBVECTOR <vscale x 16 x i1>, N

===>

<vscale x 2 x i1> = G_BITCAST <vscale x 16 x i1> <vscale x 1 x i8> = G_EXTRACT_SUBVECTOR <vscale x 2 x i1>, N / 8 <vscale x 8 x i1> = G_BITCAST <vscale x 1 x i8>

Definition at line 3926 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildBitcast(), llvm::MachineIRBuilder::buildExtractSubvector(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::divideCoefficientBy(), llvm::MachineInstr::eraseFromParent(), llvm::LLT::getElementCount(), llvm::LLT::getElementType(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::MachineIRBuilder::getMRI(), llvm::LLT::getSizeInBits(), Idx, llvm::LLT::isVector(), Legalized, MI, MIRBuilder, MRI, UnableToLegalize, and llvm::LLT::vector().

Referenced by bitcast().

◆ bitcastExtractVectorElt()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastExtractVectorElt ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.

Perform a G_EXTRACT_VECTOR_ELT in a different sized vector element.

If this is casting to a vector with a smaller element size, perform multiple element extracts and merge the results. If this is coercing to a vector with larger elements, index the bitcasted vector and extract the target element with bit operations. This is intended to force the indexing in the native register size for architectures that can dynamically index the register file.

Definition at line 3638 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildAdd(), llvm::MachineIRBuilder::buildBitcast(), llvm::MachineIRBuilder::buildBuildVector(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildExtractVectorElement(), llvm::MachineIRBuilder::buildLShr(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildTrunc(), getBitcastWiderVectorElementOffset(), llvm::LLT::getElementType(), llvm::ElementCount::getFixed(), llvm::LLT::getNumElements(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getSizeInBits(), I, Idx, llvm::isPowerOf2_32(), llvm::LLT::isVector(), Legalized, llvm::Log2_32(), MI, MIRBuilder, llvm::LLT::scalarOrVector(), and UnableToLegalize.

Referenced by bitcast().

◆ bitcastInsertSubvector()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastInsertSubvector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

This attempts to bitcast G_INSERT_SUBVECTOR to CastTy.

<vscale x 16 x i1> = G_INSERT_SUBVECTOR <vscale x 16 x i1>, <vscale x 8 x i1>, N

===>

<vscale x 2 x i8> = G_BITCAST <vscale x 16 x i1> <vscale x 1 x i8> = G_BITCAST <vscale x 8 x i1> <vscale x 2 x i8> = G_INSERT_SUBVECTOR <vscale x 2 x i8>, <vscale x 1 x i8>, N / 8 <vscale x 16 x i1> = G_BITCAST <vscale x 2 x i8>

Definition at line 3989 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildBitcast(), llvm::MachineIRBuilder::buildInsertSubvector(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::divideCoefficientBy(), llvm::MachineInstr::eraseFromParent(), llvm::LLT::getElementCount(), llvm::LLT::getElementType(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::MachineIRBuilder::getMRI(), llvm::LLT::getSizeInBits(), Idx, llvm::LLT::isVector(), Legalized, MI, MIRBuilder, MRI, UnableToLegalize, and llvm::LLT::vector().

Referenced by bitcast().

◆ bitcastInsertVectorElt()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastInsertVectorElt ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.

Perform a G_INSERT_VECTOR_ELT in a different sized vector element.

If this is increasing the element size, perform the indexing in the target element type, and use bit operations to insert at the element position. This is intended for architectures that can dynamically index the register file and want to force indexing in the native register size.

Definition at line 3774 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildBitcast(), buildBitFieldInsert(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildExtractVectorElement(), llvm::MachineIRBuilder::buildInsertVectorElement(), llvm::MachineIRBuilder::buildLShr(), getBitcastWiderVectorElementOffset(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getSizeInBits(), Idx, llvm::isPowerOf2_32(), llvm::LLT::isVector(), Legalized, llvm::Log2_32(), MI, MIRBuilder, and UnableToLegalize.

Referenced by bitcast().

◆ bitcastShuffleVector()

LegalizerHelper::LegalizeResult LegalizerHelper::bitcastShuffleVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  CastTy 
)

◆ bitcastSrc()

void LegalizerHelper::bitcastSrc ( MachineInstr MI,
LLT  CastTy,
unsigned  OpIdx 
)

Legalize a single operand OpIdx of the machine instruction MI as a use by inserting a G_BITCAST to CastTy.

Definition at line 2130 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildBitcast(), llvm::MachineInstrBuilder::getReg(), MI, MIRBuilder, and OpIdx.

Referenced by bitcast().

◆ coerceToScalar()

Register LegalizerHelper::coerceToScalar ( Register  Val)

Cast the given value to an LLT::scalar with an equivalent size.

Returns the register to use if an instruction was inserted. Returns the original register if no coercion was necessary.

Definition at line 2061 of file LegalizerHelper.cpp.

References assert(), llvm::MachineIRBuilder::buildBitcast(), llvm::MachineIRBuilder::buildPtrToInt(), DL, llvm::LLT::getAddressSpace(), llvm::MachineIRBuilder::getDataLayout(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getSizeInBits(), llvm::LLT::isPointer(), llvm::LLT::isPointerVector(), llvm::LLT::isScalar(), llvm::LLT::isVector(), MIRBuilder, MRI, and llvm::LLT::scalar().

Referenced by lowerUnmergeValues().

◆ createStackStoreLoad()

MachineInstrBuilder LegalizerHelper::createStackStoreLoad ( const DstOp Res,
const SrcOp Val 
)

◆ createStackTemporary()

MachineInstrBuilder LegalizerHelper::createStackTemporary ( TypeSize  Bytes,
Align  Alignment,
MachinePointerInfo PtrInfo 
)

◆ equalizeVectorShuffleLengths()

LegalizerHelper::LegalizeResult LegalizerHelper::equalizeVectorShuffleLengths ( MachineInstr MI)

◆ fewerElementsBitcast()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsBitcast ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVector()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorExtractInsertVectorElt()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorExtractInsertVectorElt ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorMerge()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorMerge ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorMultiEltType()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorMultiEltType ( GenericMachineInstr MI,
unsigned  NumElts,
std::initializer_list< unsigned NonVecOpIndices = {} 
)

Handles most opcodes.

Split MI into same instruction on sub-vectors or scalars with NumElts elements (1 for scalar). Supports uneven splits: there can be leftover sub-vector with fewer then NumElts or a leftover scalar. To avoid this use moreElements first and set MI number of elements to multiple of NumElts. Non-vector operands that should be used on all sub-instructions without split are listed in NonVecOpIndices.

Definition at line 4955 of file LegalizerHelper.cpp.

References llvm::append_range(), assert(), broadcastSrcOp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildMergeLikeInstr(), llvm::extractVectorParts(), hasSameNumEltsOnAllVectorOperands(), I, llvm::is_contained(), Legalized, makeDstOps(), MI, MIRBuilder, MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::size(), and Uses.

Referenced by fewerElementsVector().

◆ fewerElementsVectorPhi()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorPhi ( GenericMachineInstr MI,
unsigned  NumElts 
)

◆ fewerElementsVectorReductions()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorReductions ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorSeqReductions()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorSeqReductions ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorShuffle()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorShuffle ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ fewerElementsVectorUnmergeValues()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVectorUnmergeValues ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ getDynStackAllocTargetPtr()

Register LegalizerHelper::getDynStackAllocTargetPtr ( Register  SPReg,
Register  AllocSize,
Align  Alignment,
LLT  PtrTy 
)

◆ getLegalizerInfo()

const LegalizerInfo & llvm::LegalizerHelper::getLegalizerInfo ( ) const
inline

Expose LegalizerInfo so the clients can re-use.

Definition at line 79 of file LegalizerHelper.h.

◆ getStackTemporaryAlignment()

Align LegalizerHelper::getStackTemporaryAlignment ( LLT  Type,
Align  MinAlign = Align() 
) const

Return the alignment to use for a stack temporary object with the given type.

Definition at line 4779 of file LegalizerHelper.cpp.

References llvm::LLT::getSizeInBytes(), llvm::MinAlign(), and llvm::PowerOf2Ceil().

Referenced by createStackStoreLoad(), lowerExtractInsertVectorElt(), and lowerVECTOR_COMPRESS().

◆ getTargetLowering()

const TargetLowering & llvm::LegalizerHelper::getTargetLowering ( ) const
inline

Definition at line 80 of file LegalizerHelper.h.

◆ getValueTracking()

GISelValueTracking * llvm::LegalizerHelper::getValueTracking ( ) const
inline

Definition at line 81 of file LegalizerHelper.h.

Referenced by llvm::AMDGPULegalizerInfo::buildMultiply().

◆ getVectorElementPointer()

Register LegalizerHelper::getVectorElementPointer ( Register  VecPtr,
LLT  VecTy,
Register  Index 
)

Get a pointer to vector element Index located in memory for a vector of type VecTy starting at a base address of VecPtr.

If Index is out of bounds the returned pointer is unspecified, but will be within the vector bounds.

Definition at line 4838 of file LegalizerHelper.cpp.

References assert(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildPtrAdd(), llvm::MachineIRBuilder::buildSExtOrTrunc(), clampVectorIndex(), DL, llvm::MachineIRBuilder::getDataLayout(), llvm::LLT::getElementType(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getSizeInBits(), MIRBuilder, MRI, and llvm::Mul.

Referenced by lowerExtractInsertVectorElt(), lowerVECTOR_COMPRESS(), and llvm::CombinerHelper::matchCombineExtractedVectorLoad().

◆ legalizeInstrStep()

LegalizerHelper::LegalizeResult LegalizerHelper::legalizeInstrStep ( MachineInstr MI,
LostDebugLocObserver LocObserver 
)

Replace MI by a sequence of legal instructions that can implement the same operation.

Note that this means MI may be deleted, so any iterator steps should be performed before calling this function. Helper should be initialized to the MachineFunction containing MI.

Considered as an opaque blob, the legal code will use and define the same registers as MI.

Definition at line 119 of file LegalizerHelper.cpp.

References AlreadyLegal, bitcast(), llvm::LegalizeActions::Bitcast, llvm::LegalizeActions::Custom, llvm::dbgs(), llvm::LegalizeActions::FewerElements, fewerElementsVector(), llvm::LegalizerInfo::getAction(), llvm::IRSimilarity::Legal, llvm::LegalizerInfo::legalizeCustom(), Legalized, llvm::LegalizerInfo::legalizeIntrinsic(), llvm::LegalizeActions::Libcall, libcall, LLVM_DEBUG, lower(), llvm::Lower, MI, MIRBuilder, llvm::LegalizeActions::MoreElements, moreElementsVector(), narrowScalar(), llvm::LegalizeActions::NarrowScalar, llvm::MachineIRBuilder::setInstrAndDebugLoc(), UnableToLegalize, widenScalar(), and llvm::LegalizeActions::WidenScalar.

Referenced by llvm::Legalizer::legalizeMachineFunction().

◆ libcall()

LegalizerHelper::LegalizeResult LegalizerHelper::libcall ( MachineInstr MI,
LostDebugLocObserver LocObserver 
)

◆ lower()

LegalizerHelper::LegalizeResult LegalizerHelper::lower ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

Legalize an instruction by splitting it into simpler parts, hopefully understood by the target.

Definition at line 4425 of file LegalizerHelper.cpp.

References Addr, assert(), llvm::MachineIRBuilder::buildAdd(), llvm::MachineIRBuilder::buildAnd(), llvm::MachineIRBuilder::buildAShr(), llvm::MachineIRBuilder::buildAtomicCmpXchg(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildCopy(), llvm::MachineIRBuilder::buildFAdd(), llvm::MachineIRBuilder::buildFNeg(), llvm::MachineIRBuilder::buildFPTOSI(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildShl(), llvm::MachineIRBuilder::buildStrictFAdd(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::buildXor(), llvm::MachineIRBuilder::buildZExt(), llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineIRBuilder::getMBB(), llvm::LLT::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::LLT::getSizeInBits(), llvm::MachineIRBuilder::getTII(), GISEL_VECREDUCE_CASES_NONSEQ, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::LegalizerInfo::isLegalOrCustom(), Legalized, LHS, lowerAbsToAddXor(), lowerAddSubSatToAddoSubo(), lowerAddSubSatToMinMax(), lowerBitcast(), lowerBitCount(), lowerBitreverse(), lowerBswap(), lowerDIVREM(), lowerDynStackAlloc(), lowerEXT(), lowerExtract(), lowerExtractInsertVectorElt(), lowerFAbs(), lowerFConstant(), lowerFCopySign(), lowerFFloor(), lowerFMad(), lowerFMinNumMaxNum(), lowerFPOWI(), lowerFPTOINT_SAT(), lowerFPTOSI(), lowerFPTOUI(), lowerFPTRUNC(), lowerFunnelShift(), lowerInsert(), lowerIntrinsicRound(), lowerISFPCLASS(), lowerLoad(), lowerMemCpyFamily(), lowerMergeValues(), lowerMinMax(), lowerReadWriteRegister(), lowerRotate(), lowerSADDO_SSUBO(), lowerSelect(), lowerShlSat(), lowerShuffleVector(), lowerSITOFP(), lowerSMULH_UMULH(), lowerStackRestore(), lowerStackSave(), lowerStore(), lowerThreewayCompare(), lowerTRUNC(), lowerUITOFP(), lowerUnmergeValues(), lowerVAArg(), lowerVECTOR_COMPRESS(), lowerVectorReduction(), MI, MIRBuilder, MRI, Observer, RHS, llvm::MachineIRBuilder::setInsertPt(), TII, and UnableToLegalize.

Referenced by llvm::RISCVLegalizerInfo::legalizeCustom(), and legalizeInstrStep().

◆ lowerAbsToAddXor()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAbsToAddXor ( MachineInstr MI)

◆ lowerAbsToCNeg()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAbsToCNeg ( MachineInstr MI)

◆ lowerAbsToMaxNeg()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAbsToMaxNeg ( MachineInstr MI)

◆ lowerAddSubSatToAddoSubo()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAddSubSatToAddoSubo ( MachineInstr MI)

◆ lowerAddSubSatToMinMax()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAddSubSatToMinMax ( MachineInstr MI)

◆ lowerBitcast()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerBitcast ( MachineInstr MI)

◆ lowerBitCount()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerBitCount ( MachineInstr MI)

◆ lowerBitreverse()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerBitreverse ( MachineInstr MI)

◆ lowerBswap()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerBswap ( MachineInstr MI)

◆ lowerConstant()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerConstant ( MachineInstr MI)

◆ lowerDIVREM()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerDIVREM ( MachineInstr MI)

Definition at line 9485 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildInstr(), getReg(), Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerDynStackAlloc()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerDynStackAlloc ( MachineInstr MI)

◆ lowerEXT()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerEXT ( MachineInstr MI)

◆ lowerExtract()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerExtract ( MachineInstr MI)

◆ lowerExtractInsertVectorElt()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerExtractInsertVectorElt ( MachineInstr MI)

◆ lowerFAbs()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFAbs ( MachineInstr MI)

◆ lowerFConstant()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFConstant ( MachineInstr MI)

◆ lowerFCopySign()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFCopySign ( MachineInstr MI)

◆ lowerFFloor()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFFloor ( MachineInstr MI)

◆ lowerFMad()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFMad ( MachineInstr MI)

◆ lowerFMinNumMaxNum()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFMinNumMaxNum ( MachineInstr MI)

◆ lowerFPOWI()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPOWI ( MachineInstr MI)

◆ lowerFPTOINT_SAT()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPTOINT_SAT ( MachineInstr MI)

◆ lowerFPTOSI()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPTOSI ( MachineInstr MI)

◆ lowerFPTOUI()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPTOUI ( MachineInstr MI)

◆ lowerFPTRUNC()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPTRUNC ( MachineInstr MI)

◆ lowerFPTRUNC_F64_TO_F16()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFPTRUNC_F64_TO_F16 ( MachineInstr MI)

◆ lowerFunnelShift()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFunnelShift ( MachineInstr MI)

Definition at line 7381 of file LegalizerHelper.cpp.

References llvm::LegalizerInfo::getAction(), MI, and MRI.

Referenced by lower().

◆ lowerFunnelShiftAsShifts()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFunnelShiftAsShifts ( MachineInstr MI)

◆ lowerFunnelShiftWithInverse()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFunnelShiftWithInverse ( MachineInstr MI)

◆ lowerInsert()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerInsert ( MachineInstr MI)

◆ lowerIntrinsicRound()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerIntrinsicRound ( MachineInstr MI)

◆ lowerISFPCLASS()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerISFPCLASS ( MachineInstr MI)

◆ lowerLoad()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerLoad ( GAnyLoad MI)

Definition at line 4046 of file LegalizerHelper.cpp.

References llvm::TargetLoweringBase::allowsMemoryAccess(), assert(), llvm::bit_floor(), llvm::MachineIRBuilder::buildAssertZExt(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildDeleteTrailingVectorElements(), llvm::MachineIRBuilder::buildIntToPtr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildLoadInstr(), llvm::MachineIRBuilder::buildObjectPtrOffset(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildSExtInReg(), llvm::MachineIRBuilder::buildShl(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineInstr::eraseFromParent(), llvm::LLT::fixed_vector(), llvm::GMemOperation::getAlign(), llvm::Function::getContext(), llvm::MachineIRBuilder::getDataLayout(), llvm::GAnyLoad::getDstReg(), llvm::LLT::getElementType(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineMemOperand::getMemoryType(), llvm::MachineIRBuilder::getMF(), llvm::GMemOperation::getMMO(), llvm::LLT::getNumElements(), llvm::MachineInstr::getOpcode(), llvm::MachineMemOperand::getPointerInfo(), llvm::GLoadStore::getPointerReg(), llvm::GenericMachineInstr::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::LLT::getSizeInBytes(), llvm::DataLayout::isBigEndian(), llvm::LLT::isPointer(), llvm::isPowerOf2_32(), llvm::isPowerOf2_64(), llvm::LLT::isVector(), Legalized, MIRBuilder, MRI, llvm::NextPowerOf2(), llvm::PowerOf2Ceil(), reduceLoadStoreWidth(), llvm::LLT::scalar(), UnableToLegalize, and llvm::Align::value().

Referenced by lower().

◆ lowerMemCpyFamily()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerMemCpyFamily ( MachineInstr MI,
unsigned  MaxLen = 0 
)

◆ lowerMemcpyInline()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerMemcpyInline ( MachineInstr MI)

◆ lowerMergeValues()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerMergeValues ( MachineInstr MI)

◆ lowerMinMax()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerMinMax ( MachineInstr MI)

◆ lowerReadWriteRegister()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerReadWriteRegister ( MachineInstr MI)

◆ lowerRotate()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerRotate ( MachineInstr MI)

◆ lowerRotateWithReverseRotate()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerRotateWithReverseRotate ( MachineInstr MI)

◆ lowerSADDO_SSUBO()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSADDO_SSUBO ( MachineInstr MI)

◆ lowerSelect()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSelect ( MachineInstr MI)

◆ lowerShlSat()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerShlSat ( MachineInstr MI)

◆ lowerShuffleVector()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerShuffleVector ( MachineInstr MI)

◆ lowerSITOFP()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSITOFP ( MachineInstr MI)

◆ lowerSMULH_UMULH()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSMULH_UMULH ( MachineInstr MI)

◆ lowerStackRestore()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerStackRestore ( MachineInstr MI)

◆ lowerStackSave()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerStackSave ( MachineInstr MI)

◆ lowerStore()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerStore ( GStore MI)

◆ lowerThreewayCompare()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerThreewayCompare ( MachineInstr MI)

◆ lowerTRUNC()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerTRUNC ( MachineInstr MI)

◆ lowerU64ToF32BitOps()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerU64ToF32BitOps ( MachineInstr MI)

◆ lowerU64ToF32WithSITOFP()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerU64ToF32WithSITOFP ( MachineInstr MI)

◆ lowerU64ToF64BitFloatOps()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerU64ToF64BitFloatOps ( MachineInstr MI)

◆ lowerUITOFP()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerUITOFP ( MachineInstr MI)

◆ lowerUnmergeValues()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerUnmergeValues ( MachineInstr MI)

◆ lowerVAArg()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerVAArg ( MachineInstr MI)

◆ lowerVECTOR_COMPRESS()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerVECTOR_COMPRESS ( llvm::MachineInstr MI)

◆ lowerVectorReduction()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerVectorReduction ( MachineInstr MI)

◆ moreElementsVector()

LegalizerHelper::LegalizeResult LegalizerHelper::moreElementsVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  MoreTy 
)

◆ moreElementsVectorDst()

void LegalizerHelper::moreElementsVectorDst ( MachineInstr MI,
LLT  MoreTy,
unsigned  OpIdx 
)

Legalize a single operand OpIdx of the machine instruction MI as a Def by performing it with additional vector elements and extracting the result elements, and replacing the vreg of the operand in place.

Definition at line 2114 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildDeleteTrailingVectorElements(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineIRBuilder::getMBB(), llvm::MachineOperand::getReg(), MI, MIRBuilder, MRI, OpIdx, llvm::MachineIRBuilder::setInsertPt(), and llvm::MachineOperand::setReg().

Referenced by equalizeVectorShuffleLengths(), llvm::AMDGPULegalizerInfo::legalizeSBufferLoad(), moreElementsVector(), moreElementsVectorPhi(), and moreElementsVectorShuffle().

◆ moreElementsVectorPhi()

LegalizerHelper::LegalizeResult LegalizerHelper::moreElementsVectorPhi ( MachineInstr MI,
unsigned  TypeIdx,
LLT  MoreTy 
)

◆ moreElementsVectorShuffle()

LegalizerHelper::LegalizeResult LegalizerHelper::moreElementsVectorShuffle ( MachineInstr MI,
unsigned  TypeIdx,
LLT  MoreTy 
)

◆ moreElementsVectorSrc()

void LegalizerHelper::moreElementsVectorSrc ( MachineInstr MI,
LLT  MoreTy,
unsigned  OpIdx 
)

Legalize a single operand OpIdx of the machine instruction MI as a Use by producing a vector with undefined high elements, extracting the original vector type, and replacing the vreg of the operand in place.

Definition at line 2124 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildPadVectorWithUndefElements(), llvm::MachineInstrBuilder::getReg(), MI, MIRBuilder, OpIdx, and llvm::MachineOperand::setReg().

Referenced by moreElementsVector(), moreElementsVectorPhi(), and moreElementsVectorShuffle().

◆ narrowScalar()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

Legalize an instruction by reducing the width of the underlying scalar type.

Definition at line 1483 of file LegalizerHelper.cpp.

References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), llvm::append_range(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::MachineIRBuilder::buildAnyExt(), llvm::MachineIRBuilder::buildAShr(), llvm::MachineIRBuilder::buildBuildVector(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildCopy(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildLoadInstr(), llvm::MachineIRBuilder::buildMergeLikeInstr(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildSelect(), llvm::MachineIRBuilder::buildSExt(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildUndef(), llvm::MachineIRBuilder::buildUnmerge(), llvm::MachineIRBuilder::buildVScale(), llvm::MachineIRBuilder::buildXor(), llvm::MachineIRBuilder::buildZExt(), llvm::CallingConv::C, llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), llvm::dbgs(), llvm::SmallVectorBase< Size_T >::empty(), llvm::extractParts(), llvm::LLT::getElementCount(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineBasicBlock::getFirstTerminatorForward(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineIRBuilder::getMBB(), getReg(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::MachineMemOperand::getSizeInBits(), llvm::LLT::getSizeInBits(), llvm::ICmpInst::getUnsignedPredicate(), llvm::LocationSize::getValue(), I, llvm::CmpInst::ICMP_EQ, llvm::ICmpInst::isEquality(), llvm::LLT::isVector(), Legalized, LHS, LLVM_DEBUG, llvm::APInt::lshr(), MBB, MI, MIRBuilder, MRI, narrowScalarAddSub(), narrowScalarBasic(), narrowScalarCTLZ(), narrowScalarCTPOP(), narrowScalarCTTZ(), narrowScalarDst(), narrowScalarExt(), narrowScalarExtract(), narrowScalarFLDEXP(), narrowScalarFPTOI(), narrowScalarInsert(), narrowScalarMul(), narrowScalarSelect(), narrowScalarShift(), narrowScalarSrc(), Observer, llvm::Offset, OpIdx, llvm::SmallVectorTemplateBase< T, bool >::push_back(), reduceLoadStoreWidth(), RHS, llvm::LLT::scalar(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineOperand::setReg(), llvm::SmallVectorBase< Size_T >::size(), llvm::APInt::trunc(), UnableToLegalize, llvm::LLT::vector(), llvm::Xor, and llvm::zip().

Referenced by llvm::AMDGPURegisterBankInfo::applyMappingImpl(), llvm::MipsRegisterBankInfo::applyMappingImpl(), llvm::AMDGPURegisterBankInfo::applyMappingLoad(), and legalizeInstrStep().

◆ narrowScalarAddSub()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarAddSub ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ narrowScalarBasic()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarBasic ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarCTLZ()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarCTLZ ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarCTPOP()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarCTPOP ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarCTTZ()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarCTTZ ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarDst()

void LegalizerHelper::narrowScalarDst ( MachineInstr MI,
LLT  NarrowTy,
unsigned  OpIdx,
unsigned  ExtOpcode 
)

◆ narrowScalarExt()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarExt ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

Definition at line 6920 of file LegalizerHelper.cpp.

References llvm::LLT::isVector(), Legalized, MI, MRI, and UnableToLegalize.

Referenced by narrowScalar().

◆ narrowScalarExtract()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarExtract ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarFLDEXP()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarFLDEXP ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarFPTOI()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarFPTOI ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarInsert()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarInsert ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarMul()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarMul ( MachineInstr MI,
LLT  Ty 
)

◆ narrowScalarSelect()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarSelect ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarShift()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarShift ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ narrowScalarShiftByConstant()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarShiftByConstant ( MachineInstr MI,
const APInt Amt,
LLT  HalfTy,
LLT  ShiftAmtTy 
)

◆ narrowScalarSrc()

void LegalizerHelper::narrowScalarSrc ( MachineInstr MI,
LLT  NarrowTy,
unsigned  OpIdx 
)

Legalize a single operand OpIdx of the machine instruction MI as a Use by truncating the operand's type to NarrowTy using G_TRUNC, and replacing the vreg of the operand in place.

Definition at line 2089 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildTrunc(), MI, MIRBuilder, OpIdx, and llvm::MachineOperand::setReg().

Referenced by narrowScalar(), and narrowScalarShift().

◆ reduceLoadStoreWidth()

LegalizerHelper::LegalizeResult LegalizerHelper::reduceLoadStoreWidth ( GLoadStore MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

◆ scalarizeVectorBooleanStore()

LegalizerHelper::LegalizeResult LegalizerHelper::scalarizeVectorBooleanStore ( GStore MI)

◆ widenScalar()

LegalizerHelper::LegalizeResult LegalizerHelper::widenScalar ( MachineInstr MI,
unsigned  TypeIdx,
LLT  WideTy 
)

Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addition can be safely performed at 32-bits precision, ignoring the unused bits).

Definition at line 2673 of file LegalizerHelper.cpp.

References assert(), llvm::APFloat::bitcastToAPInt(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInsertSubvector(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLShr(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildShl(), llvm::MachineIRBuilder::buildSMax(), llvm::MachineIRBuilder::buildSMin(), llvm::MachineIRBuilder::buildSplatVector(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildUMin(), llvm::MachineIRBuilder::buildZExt(), llvm::MachineIRBuilder::buildZExtOrTrunc(), llvm::GISelChangeObserver::changedInstr(), llvm::LLT::changeElementType(), llvm::GISelChangeObserver::changingInstr(), llvm::MCInstrInfo::get(), llvm::APInt::getAllOnes(), llvm::getApproximateEVTForLLT(), llvm::GInsertSubvector::getBigVec(), llvm::MachineIRBuilder::getBoolExtOp(), llvm::MachineOperand::getCImm(), llvm::Function::getContext(), llvm::LLT::getElementCount(), llvm::LLT::getElementType(), llvm::LegalizerInfo::getExtOpcodeForWideningConstant(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineBasicBlock::getFirstTerminatorForward(), llvm::MachineOperand::getFPImm(), llvm::MachineFunction::getFunction(), llvm::GInsertSubvector::getIndexImm(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineIRBuilder::getMBB(), llvm::MachineIRBuilder::getMF(), llvm::APInt::getOneBitSet(), llvm::MachineMemOperand::getPointerInfo(), llvm::GenericMachineInstr::getReg(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getScalarType(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::LLT::getSizeInBits(), llvm::GInsertSubvector::getSubVec(), llvm::MachineIRBuilder::getTII(), llvm::ConstantInt::getValue(), llvm::ConstantFP::getValueAPF(), I, llvm::CmpInst::ICMP_NE, llvm::LLT::isPointerOrPointerVector(), llvm::LLT::isScalar(), llvm::TargetLoweringBase::isSExtCheaperThanZExt(), llvm::CmpInst::isSigned(), llvm::LLT::isVector(), Legalized, MBB, MI, MIRBuilder, MRI, Observer, llvm::MachineOperand::setCImm(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstrAndDebugLoc(), llvm::APInt::sext(), UnableToLegalize, llvm::LLT::vector(), widenScalarDst(), widenScalarSrc(), and llvm::APInt::zext().

Referenced by llvm::AMDGPURegisterBankInfo::applyMappingImpl(), and legalizeInstrStep().

◆ widenScalarDst()

void LegalizerHelper::widenScalarDst ( MachineInstr MI,
LLT  WideTy,
unsigned  OpIdx = 0,
unsigned  TruncOpcode = TargetOpcode::G_TRUNC 
)

Legalize a single operand OpIdx of the machine instruction MI as a Def by extending the operand's type to WideTy and truncating it back with the TruncOpcode, and replacing the vreg of the operand in place.

Definition at line 2096 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineIRBuilder::getMBB(), MI, MIRBuilder, MRI, OpIdx, llvm::MachineIRBuilder::setInsertPt(), and llvm::MachineOperand::setReg().

Referenced by llvm::AMDGPURegisterBankInfo::applyMappingImpl(), llvm::RISCVLegalizerInfo::legalizeCustom(), llvm::AMDGPULegalizerInfo::legalizeSBufferLoad(), and widenScalar().

◆ widenScalarSrc()

void LegalizerHelper::widenScalarSrc ( MachineInstr MI,
LLT  WideTy,
unsigned  OpIdx,
unsigned  ExtOpcode 
)

Legalize a single operand OpIdx of the machine instruction MI as a Use by extending the operand's type to WideTy using the specified ExtOpcode for the extension instruction, and replacing the vreg of the operand in place.

Definition at line 2082 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildInstr(), MI, MIRBuilder, OpIdx, and llvm::MachineOperand::setReg().

Referenced by llvm::AMDGPURegisterBankInfo::applyMappingImpl(), llvm::RISCVLegalizerInfo::legalizeCustom(), and widenScalar().

Member Data Documentation

◆ MIRBuilder

MachineIRBuilder& llvm::LegalizerHelper::MIRBuilder

Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.

Definition at line 53 of file LegalizerHelper.h.

Referenced by bitcastDst(), bitcastExtractSubvector(), bitcastExtractVectorElt(), bitcastInsertSubvector(), bitcastInsertVectorElt(), bitcastShuffleVector(), bitcastSrc(), llvm::AMDGPULegalizerInfo::buildMultiply(), coerceToScalar(), convertPtrToInt(), createStackStoreLoad(), createStackTemporary(), equalizeVectorShuffleLengths(), fewerElementsBitcast(), fewerElementsVectorExtractInsertVectorElt(), fewerElementsVectorMerge(), fewerElementsVectorMultiEltType(), fewerElementsVectorPhi(), fewerElementsVectorReductions(), fewerElementsVectorSeqReductions(), fewerElementsVectorShuffle(), fewerElementsVectorUnmergeValues(), getDynStackAllocTargetPtr(), getVectorElementPointer(), llvm::AMDGPULegalizerInfo::legalizeBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeBufferStore(), llvm::AArch64LegalizerInfo::legalizeCustom(), llvm::AMDGPULegalizerInfo::legalizeCustom(), llvm::ARMLegalizerInfo::legalizeCustom(), llvm::MipsLegalizerInfo::legalizeCustom(), llvm::RISCVLegalizerInfo::legalizeCustom(), llvm::SPIRVLegalizerInfo::legalizeCustom(), llvm::X86LegalizerInfo::legalizeCustom(), legalizeInstrStep(), llvm::AArch64LegalizerInfo::legalizeIntrinsic(), llvm::AMDGPULegalizerInfo::legalizeIntrinsic(), llvm::MipsLegalizerInfo::legalizeIntrinsic(), llvm::RISCVLegalizerInfo::legalizeIntrinsic(), llvm::AMDGPULegalizerInfo::legalizeLaneOp(), llvm::AMDGPULegalizerInfo::legalizeLoad(), llvm::Legalizer::legalizeMachineFunction(), llvm::AMDGPULegalizerInfo::legalizeMinNumMaxNum(), llvm::AMDGPULegalizerInfo::legalizeMul(), llvm::AMDGPULegalizerInfo::legalizeSBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeSBufferPrefetch(), llvm::AMDGPULegalizerInfo::legalizeStore(), libcall(), lower(), lowerAbsToAddXor(), lowerAbsToCNeg(), lowerAbsToMaxNeg(), lowerAddSubSatToAddoSubo(), lowerAddSubSatToMinMax(), lowerBitcast(), lowerBitCount(), lowerBitreverse(), lowerBswap(), lowerConstant(), lowerDIVREM(), lowerDynStackAlloc(), lowerEXT(), lowerExtract(), lowerExtractInsertVectorElt(), lowerFAbs(), lowerFConstant(), lowerFCopySign(), lowerFFloor(), lowerFMad(), lowerFMinNumMaxNum(), lowerFPOWI(), lowerFPTOINT_SAT(), lowerFPTOSI(), lowerFPTOUI(), lowerFPTRUNC_F64_TO_F16(), lowerFunnelShiftAsShifts(), lowerFunnelShiftWithInverse(), lowerInsert(), lowerIntrinsicRound(), lowerISFPCLASS(), lowerLoad(), lowerMergeValues(), lowerMinMax(), lowerReadWriteRegister(), lowerRotate(), lowerRotateWithReverseRotate(), lowerSADDO_SSUBO(), lowerSelect(), lowerShlSat(), lowerShuffleVector(), lowerSITOFP(), lowerSMULH_UMULH(), lowerStackRestore(), lowerStackSave(), lowerStore(), lowerThreewayCompare(), lowerTRUNC(), lowerU64ToF32BitOps(), lowerU64ToF32WithSITOFP(), lowerU64ToF64BitFloatOps(), lowerUITOFP(), lowerUnmergeValues(), lowerVAArg(), lowerVECTOR_COMPRESS(), lowerVectorReduction(), moreElementsVector(), moreElementsVectorDst(), moreElementsVectorPhi(), moreElementsVectorShuffle(), moreElementsVectorSrc(), narrowScalar(), narrowScalarAddSub(), narrowScalarBasic(), narrowScalarCTLZ(), narrowScalarCTPOP(), narrowScalarCTTZ(), narrowScalarDst(), narrowScalarExtract(), narrowScalarFLDEXP(), narrowScalarInsert(), narrowScalarMul(), narrowScalarSelect(), narrowScalarShift(), narrowScalarShiftByConstant(), narrowScalarSrc(), reduceLoadStoreWidth(), scalarizeVectorBooleanStore(), widenScalar(), widenScalarDst(), and widenScalarSrc().

◆ Observer

GISelChangeObserver& llvm::LegalizerHelper::Observer

The documentation for this class was generated from the following files: