LLVM 22.0.0git
llvm::LegalizerHelper Class Reference

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

Classes

struct  ShiftParams

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 narrowScalarShiftMultiway (MachineInstr &MI, LLT TargetTy)
 Multi-way shift legalization: directly split wide shifts into target-sized parts in a single step, avoiding recursive binary splitting.
LLVM_ABI LegalizeResult narrowScalarShiftByConstantMultiway (MachineInstr &MI, const APInt &Amt, LLT TargetTy, LLT ShiftAmtTy)
 Optimized path for constant shift amounts using static indexing.
LLVM_ABI Register buildConstantShiftPart (unsigned Opcode, unsigned PartIdx, unsigned NumParts, ArrayRef< Register > SrcParts, const ShiftParams &Params, LLT TargetTy, LLT ShiftAmtTy)
 Generates a single output part for constant shifts using direct indexing.
LLVM_ABI Register buildVariableShiftPart (unsigned Opcode, Register MainOperand, Register ShiftAmt, LLT TargetTy, Register CarryOperand=Register())
 Generates a shift part with carry for variable shifts.
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 lowerSADDE (MachineInstr &MI)
LLVM_ABI LegalizeResult lowerSSUBE (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 lowerAbsDiffToSelect (MachineInstr &MI)
LLVM_ABI LegalizeResult lowerAbsDiffToMinMax (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.

References getLegalizerInfo(), getTargetLowering(), MIRBuilder, and Observer.

◆ 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.

References B(), getTargetLowering(), MIRBuilder, and Observer.

Member Function Documentation

◆ bitcast()

◆ bitcastConcatVector()

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

Definition at line 3855 of file LegalizerHelper.cpp.

References llvm::dyn_cast(), MI, llvm::LLT::scalar(), and UnableToLegalize.

Referenced by bitcast().

◆ bitcastDst()

void LegalizerHelper::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.

Definition at line 2141 of file LegalizerHelper.cpp.

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

Referenced by bitcast(), llvm::AMDGPULegalizerInfo::legalizeBufferLoad(), and llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().

◆ 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 3934 of file LegalizerHelper.cpp.

References llvm::cast(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::divideCoefficientBy(), llvm::LLT::getElementCount(), llvm::LLT::getElementType(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), Legalized, MI, MIRBuilder, 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 3646 of file LegalizerHelper.cpp.

References getBitcastWiderVectorElementOffset(), llvm::LLT::getElementType(), llvm::ElementCount::getFixed(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), I, 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 3997 of file LegalizerHelper.cpp.

References llvm::cast(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::divideCoefficientBy(), llvm::LLT::getElementCount(), llvm::LLT::getElementType(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), Legalized, MI, MIRBuilder, 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 3782 of file LegalizerHelper.cpp.

References buildBitFieldInsert(), getBitcastWiderVectorElementOffset(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::isPowerOf2_32(), llvm::LLT::isVector(), Legalized, llvm::Log2_32(), MI, MIRBuilder, and UnableToLegalize.

Referenced by bitcast().

◆ bitcastShuffleVector()

◆ 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 2136 of file LegalizerHelper.cpp.

References MI, MIRBuilder, and OpIdx.

Referenced by bitcast().

◆ buildConstantShiftPart()

Register LegalizerHelper::buildConstantShiftPart ( unsigned Opcode,
unsigned PartIdx,
unsigned NumParts,
ArrayRef< Register > SrcParts,
const ShiftParams & Params,
LLT TargetTy,
LLT ShiftAmtTy )

◆ buildVariableShiftPart()

Register LegalizerHelper::buildVariableShiftPart ( unsigned Opcode,
Register MainOperand,
Register ShiftAmt,
LLT TargetTy,
Register CarryOperand = Register() )

Generates a shift part with carry for variable shifts.

Combines main operand shifted by BitShift with carry bits from adjacent operand.

Definition at line 6218 of file LegalizerHelper.cpp.

References getReg(), llvm::LLT::getScalarSizeInBits(), llvm::CmpInst::ICMP_EQ, llvm::Register::isValid(), MIRBuilder, and llvm::LLT::scalar().

Referenced by narrowScalarShiftMultiway().

◆ 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 2067 of file LegalizerHelper.cpp.

References assert(), DL, MIRBuilder, Register, and llvm::LLT::scalar().

Referenced by lowerUnmergeValues().

◆ createStackStoreLoad()

MachineInstrBuilder LegalizerHelper::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.

Definition at line 4835 of file LegalizerHelper.cpp.

References createStackTemporary(), llvm::DstOp::getLLTTy(), llvm::SrcOp::getLLTTy(), getStackTemporaryAlignment(), and MIRBuilder.

◆ createStackTemporary()

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

◆ equalizeVectorShuffleLengths()

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

◆ fewerElementsBitcast()

◆ fewerElementsVector()

◆ fewerElementsVectorExtractInsertVectorElt()

◆ fewerElementsVectorMerge()

◆ 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 4987 of file LegalizerHelper.cpp.

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

Referenced by fewerElementsVector().

◆ fewerElementsVectorPhi()

◆ fewerElementsVectorReductions()

◆ fewerElementsVectorSeqReductions()

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

◆ fewerElementsVectorShuffle()

◆ 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.

Referenced by LegalizerHelper().

◆ 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 4811 of file LegalizerHelper.cpp.

References 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.

Referenced by LegalizerHelper(), and LegalizerHelper().

◆ 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 4870 of file LegalizerHelper.cpp.

References assert(), llvm::LLT::changeElementSize(), clampVectorIndex(), DL, llvm::LLT::getElementType(), llvm::LLT::getSizeInBits(), MIRBuilder, 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, llvm::LegalizeActions::Bitcast, bitcast(), llvm::LegalizeActions::Custom, llvm::dbgs(), llvm::LegalizeActions::FewerElements, fewerElementsVector(), llvm::isa(), llvm::IRSimilarity::Legal, Legalized, llvm::LegalizeActions::Libcall, libcall, LLVM_DEBUG, llvm::Lower, lower(), MI, MIRBuilder, llvm::LegalizeActions::MoreElements, moreElementsVector(), llvm::LegalizeActions::NarrowScalar, narrowScalar(), UnableToLegalize, llvm::LegalizeActions::WidenScalar, and widenScalar().

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

◆ libcall()

◆ lower()

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

◆ lowerAbsDiffToMinMax()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAbsDiffToMinMax ( MachineInstr & MI)

Definition at line 10017 of file LegalizerHelper.cpp.

References assert(), Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerAbsDiffToSelect()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerAbsDiffToSelect ( MachineInstr & MI)

◆ lowerAbsToAddXor()

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

Definition at line 9949 of file LegalizerHelper.cpp.

References llvm::Add, llvm::LLT::getScalarSizeInBits(), Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerAbsToCNeg()

◆ lowerAbsToMaxNeg()

◆ lowerAddSubSatToAddoSubo()

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

◆ lowerAddSubSatToMinMax()

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

◆ lowerBitcast()

◆ lowerBitCount()

◆ lowerBitreverse()

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

Definition at line 9574 of file LegalizerHelper.cpp.

References llvm::LLT::fixed_vector(), llvm::APInt::getSplat(), MI, MIRBuilder, Size, and SwapN().

Referenced by lower().

◆ lowerBswap()

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

Definition at line 9529 of file LegalizerHelper.cpp.

References Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerConstant()

◆ lowerDIVREM()

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

Definition at line 9932 of file LegalizerHelper.cpp.

References Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerDynStackAlloc()

◆ lowerEXT()

◆ lowerExtract()

◆ lowerExtractInsertVectorElt()

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

Lower a vector extract or insert by writing the vector to a stack temporary and reloading the element or vector.

dst = G_EXTRACT_VECTOR_ELT vec, idx => stack_temp = G_FRAME_INDEX G_STORE vec, stack_temp idx = clamp(idx, vec.getNumElements()) element_ptr = G_PTR_ADD stack_temp, idx dst = G_LOAD element_ptr

Definition at line 8865 of file LegalizerHelper.cpp.

References llvm::commonAlignment(), createStackTemporary(), llvm::dbgs(), llvm::extractParts(), llvm::LLT::getElementType(), llvm::TypeSize::getFixed(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBytes(), getStackTemporaryAlignment(), getVectorElementPointer(), llvm::MachinePointerInfo::getWithOffset(), llvm::LLT::isByteSized(), Legalized, LLVM_DEBUG, llvm::MIPatternMatch::m_ICst(), MI, llvm::MIPatternMatch::mi_match(), MIRBuilder, llvm::Offset, and UnableToLegalize.

Referenced by fewerElementsVectorExtractInsertVectorElt(), and lower().

◆ lowerFAbs()

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

Definition at line 10041 of file LegalizerHelper.cpp.

References llvm::APInt::getSignedMaxValue(), Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerFConstant()

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

◆ lowerFCopySign()

◆ lowerFFloor()

◆ lowerFMad()

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

Definition at line 8714 of file LegalizerHelper.cpp.

References Legalized, MI, MIRBuilder, and llvm::Mul.

Referenced by llvm::AMDGPULegalizerInfo::legalizeFMad(), and lower().

◆ lowerFMinNumMaxNum()

◆ lowerFPOWI()

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

Definition at line 8539 of file LegalizerHelper.cpp.

References Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerFPTOINT_SAT()

◆ lowerFPTOSI()

◆ lowerFPTOUI()

◆ lowerFPTRUNC()

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

Definition at line 8528 of file LegalizerHelper.cpp.

References lowerFPTRUNC_F64_TO_F16(), MI, S16, S64, llvm::LLT::scalar(), and UnableToLegalize.

Referenced by lower().

◆ lowerFPTRUNC_F64_TO_F16()

◆ lowerFunnelShift()

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

Definition at line 7785 of file LegalizerHelper.cpp.

References MI.

Referenced by lower().

◆ lowerFunnelShiftAsShifts()

◆ lowerFunnelShiftWithInverse()

◆ lowerInsert()

◆ lowerIntrinsicRound()

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

Definition at line 8728 of file LegalizerHelper.cpp.

References llvm::LLT::changeElementSize(), llvm::CmpInst::FCMP_OGE, Legalized, MI, MIRBuilder, T, and X.

Referenced by lower().

◆ lowerISFPCLASS()

◆ lowerLoad()

◆ lowerMemCpyFamily()

◆ lowerMemcpyInline()

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

◆ lowerMergeValues()

◆ lowerMinMax()

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

Definition at line 8564 of file LegalizerHelper.cpp.

References llvm::LLT::changeElementSize(), Legalized, MI, minMaxToCompare(), and MIRBuilder.

Referenced by lower().

◆ lowerReadWriteRegister()

◆ lowerRotate()

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

Definition at line 7918 of file LegalizerHelper.cpp.

References MI, and MIRBuilder.

Referenced by lower().

◆ lowerRotateWithReverseRotate()

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

Definition at line 7907 of file LegalizerHelper.cpp.

References Legalized, MI, and MIRBuilder.

◆ lowerSADDE()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSADDE ( MachineInstr & MI)

Definition at line 9313 of file LegalizerHelper.cpp.

References llvm::CmpInst::ICMP_SLT, Legalized, MI, MIRBuilder, and T.

Referenced by lower().

◆ lowerSADDO_SSUBO()

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

Definition at line 9275 of file LegalizerHelper.cpp.

References llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, Legalized, MI, and MIRBuilder.

Referenced by lower().

◆ lowerSelect()

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

◆ lowerShlSat()

◆ lowerShuffleVector()

◆ lowerSITOFP()

◆ lowerSMULH_UMULH()

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

◆ lowerSSUBE()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerSSUBE ( MachineInstr & MI)

Definition at line 9335 of file LegalizerHelper.cpp.

References llvm::CmpInst::ICMP_SLT, Legalized, MI, MIRBuilder, and T.

Referenced by lower().

◆ lowerStackRestore()

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

Definition at line 9120 of file LegalizerHelper.cpp.

References Legalized, MI, MIRBuilder, and UnableToLegalize.

Referenced by lower().

◆ lowerStackSave()

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

Definition at line 9109 of file LegalizerHelper.cpp.

References Legalized, MI, MIRBuilder, and UnableToLegalize.

Referenced by lower().

◆ lowerStore()

◆ lowerThreewayCompare()

◆ lowerTRUNC()

◆ lowerU64ToF32BitOps()

◆ lowerU64ToF32WithSITOFP()

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

Definition at line 8046 of file LegalizerHelper.cpp.

References assert(), llvm::CmpInst::ICMP_SLT, Legalized, MI, MIRBuilder, S1, S32, S64, and llvm::LLT::scalar().

Referenced by lowerUITOFP().

◆ lowerU64ToF64BitFloatOps()

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

Definition at line 8081 of file LegalizerHelper.cpp.

References assert(), llvm::bit_cast(), Legalized, MI, MIRBuilder, S32, S64, and llvm::LLT::scalar().

Referenced by lowerUITOFP().

◆ lowerUITOFP()

◆ lowerUnmergeValues()

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

◆ lowerVAArg()

◆ lowerVECTOR_COMPRESS()

◆ lowerVectorReduction()

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

Definition at line 10058 of file LegalizerHelper.cpp.

References llvm::LLT::getSizeInBits(), Legalized, MI, MIRBuilder, Observer, and UnableToLegalize.

Referenced by lower().

◆ moreElementsVector()

◆ 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 2120 of file LegalizerHelper.cpp.

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

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

◆ moreElementsVectorPhi()

◆ moreElementsVectorShuffle()

◆ 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 2130 of file LegalizerHelper.cpp.

References 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 1489 of file LegalizerHelper.cpp.

References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addUse(), llvm::append_range(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::CallingConv::C, llvm::cast(), llvm::dbgs(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::extractParts(), llvm::LLT::getElementCount(), llvm::MachineBasicBlock::getFirstTerminatorForward(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::MachineMemOperand::getSizeInBits(), llvm::ICmpInst::getUnsignedPredicate(), llvm::LocationSize::getValue(), I, llvm::CmpInst::ICMP_EQ, llvm::isa(), llvm::ICmpInst::isEquality(), llvm::LLT::isVector(), Legalized, LLVM_DEBUG, llvm::APInt::lshr(), MBB, MI, MIRBuilder, 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(), llvm::LLT::scalar(), llvm::MachineOperand::setReg(), llvm::SmallVectorTemplateCommon< T, typename >::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()

◆ narrowScalarBasic()

◆ narrowScalarCTLZ()

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

◆ narrowScalarCTPOP()

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

Definition at line 7457 of file LegalizerHelper.cpp.

References llvm::LLT::getSizeInBits(), Legalized, MI, MIRBuilder, and UnableToLegalize.

Referenced by narrowScalar().

◆ narrowScalarCTTZ()

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

◆ narrowScalarDst()

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

Definition at line 2111 of file LegalizerHelper.cpp.

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

Referenced by narrowScalar(), and narrowScalarFPTOI().

◆ narrowScalarExt()

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

Definition at line 7324 of file LegalizerHelper.cpp.

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

Referenced by narrowScalar().

◆ narrowScalarExtract()

◆ narrowScalarFLDEXP()

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

◆ narrowScalarFPTOI()

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

◆ narrowScalarInsert()

◆ narrowScalarMul()

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

◆ narrowScalarSelect()

◆ narrowScalarShift()

◆ narrowScalarShiftByConstant()

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

◆ narrowScalarShiftByConstantMultiway()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarShiftByConstantMultiway ( MachineInstr & MI,
const APInt & Amt,
LLT TargetTy,
LLT ShiftAmtTy )

◆ narrowScalarShiftMultiway()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarShiftMultiway ( MachineInstr & MI,
LLT TargetTy )

Multi-way shift legalization: directly split wide shifts into target-sized parts in a single step, avoiding recursive binary splitting.

Definition at line 6341 of file LegalizerHelper.cpp.

References assert(), buildVariableShiftPart(), llvm::extractParts(), llvm::getIConstantVRegValWithLookThrough(), llvm::LLT::getScalarSizeInBits(), I, llvm::CmpInst::ICMP_EQ, llvm::isPowerOf2_32(), Legalized, llvm_unreachable, llvm::Log2_32(), MI, MIRBuilder, narrowScalarShiftByConstantMultiway(), and llvm::LLT::scalar().

Referenced by narrowScalarShift().

◆ 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 2095 of file LegalizerHelper.cpp.

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

Referenced by narrowScalar(), and narrowScalarShift().

◆ reduceLoadStoreWidth()

◆ scalarizeVectorBooleanStore()

◆ widenScalar()

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

◆ 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 2102 of file LegalizerHelper.cpp.

References MI, MIRBuilder, OpIdx, 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 2088 of file LegalizerHelper.cpp.

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

Referenced by llvm::AMDGPURegisterBankInfo::applyMappingImpl(), llvm::RISCVLegalizerInfo::legalizeCustom(), llvm::RISCVLegalizerInfo::legalizeIntrinsic(), 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(), buildConstantShiftPart(), llvm::AMDGPULegalizerInfo::buildMultiply(), buildVariableShiftPart(), 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(), LegalizerHelper(), LegalizerHelper(), llvm::AMDGPULegalizerInfo::legalizeSBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeSBufferPrefetch(), llvm::AMDGPULegalizerInfo::legalizeStore(), libcall(), lower(), lowerAbsDiffToMinMax(), lowerAbsDiffToSelect(), 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(), lowerSADDE(), lowerSADDO_SSUBO(), lowerSelect(), lowerShlSat(), lowerShuffleVector(), lowerSITOFP(), lowerSMULH_UMULH(), lowerSSUBE(), 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(), narrowScalarShiftByConstantMultiway(), narrowScalarShiftMultiway(), narrowScalarSrc(), reduceLoadStoreWidth(), scalarizeVectorBooleanStore(), widenScalar(), widenScalarDst(), and widenScalarSrc().

◆ Observer


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