LLVM  14.0.0git
Macros | Functions
LegalizerHelper.cpp File Reference
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/LostDebugLocObserver.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
Include dependency graph for LegalizerHelper.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "legalizer"
 
#define RTLIBCASE_INT(LibcallPrefix)
 
#define RTLIBCASE(LibcallPrefix)
 

Functions

static std::pair< int, intgetNarrowTypeBreakDown (LLT OrigTy, LLT NarrowTy, LLT &LeftoverTy)
 Try to break down OrigTy into NarrowTy sized pieces. More...
 
static TypegetFloatTypeForLLT (LLVMContext &Ctx, LLT Ty)
 
static void getUnmergeResults (SmallVectorImpl< Register > &Regs, const MachineInstr &MI)
 Append the result registers of G_UNMERGE_VALUES MI to Regs. More...
 
static RTLIB::Libcall getRTLibDesc (unsigned Opcode, unsigned Size)
 
static bool isLibCallInTailPosition (MachineInstr &MI, const TargetInstrInfo &TII, MachineRegisterInfo &MRI)
 True if an instruction is in tail position in its caller. More...
 
static LegalizerHelper::LegalizeResult simpleLibcall (MachineInstr &MI, MachineIRBuilder &MIRBuilder, unsigned Size, Type *OpType)
 
static RTLIB::Libcall getConvRTLibDesc (unsigned Opcode, Type *ToType, Type *FromType)
 
static LegalizerHelper::LegalizeResult conversionLibcall (MachineInstr &MI, MachineIRBuilder &MIRBuilder, Type *ToType, Type *FromType)
 
static void getUnmergePieces (SmallVectorImpl< Register > &Pieces, MachineIRBuilder &B, Register Src, LLT Ty)
 
static Register getBitcastWiderVectorElementOffset (MachineIRBuilder &B, Register Idx, unsigned NewEltSize, unsigned OldEltSize)
 Figure out the bit offset into a register when coercing a vector index for the wide element type. More...
 
static Register buildBitFieldInsert (MachineIRBuilder &B, Register TargetReg, Register InsertReg, Register OffsetBits)
 Emit code to insert InsertReg into TargetRet at OffsetBits in TargetReg, while preserving other bits in TargetReg. More...
 
static Register clampDynamicVectorIndex (MachineIRBuilder &B, Register IdxReg, LLT VecTy)
 
static unsigned getScalarOpcForReduction (unsigned Opc)
 
static bool isNonZeroModBitWidthOrUndef (const MachineRegisterInfo &MRI, Register Reg, unsigned BW)
 
static CmpInst::Predicate minMaxToCompare (unsigned Opc)
 
static MachineInstrBuilder SwapN (unsigned N, DstOp Dst, MachineIRBuilder &B, MachineInstrBuilder Src, APInt Mask)
 
static bool shouldLowerMemFuncForSize (const MachineFunction &MF)
 
static bool findGISelOptimalMemOpLowering (std::vector< LLT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes, const TargetLowering &TLI)
 
static TypegetTypeForLLT (LLT Ty, LLVMContext &C)
 
static Register getMemsetValue (Register Val, LLT Ty, MachineIRBuilder &MIB)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "legalizer"

Definition at line 34 of file LegalizerHelper.cpp.

◆ RTLIBCASE

#define RTLIBCASE (   LibcallPrefix)
Value:
do { \
switch (Size) { \
case 32: \
return RTLIB::LibcallPrefix##32; \
case 64: \
return RTLIB::LibcallPrefix##64; \
case 80: \
return RTLIB::LibcallPrefix##80; \
case 128: \
return RTLIB::LibcallPrefix##128; \
default: \
llvm_unreachable("unexpected size"); \
} \
} while (0)

◆ RTLIBCASE_INT

#define RTLIBCASE_INT (   LibcallPrefix)
Value:
do { \
switch (Size) { \
case 32: \
return RTLIB::LibcallPrefix##32; \
case 64: \
return RTLIB::LibcallPrefix##64; \
case 128: \
return RTLIB::LibcallPrefix##128; \
default: \
llvm_unreachable("unexpected size"); \
} \
} while (0)

Function Documentation

◆ buildBitFieldInsert()

static Register buildBitFieldInsert ( MachineIRBuilder B,
Register  TargetReg,
Register  InsertReg,
Register  OffsetBits 
)
static

Emit code to insert InsertReg into TargetRet at OffsetBits in TargetReg, while preserving other bits in TargetReg.

(InsertReg << Offset) | (TargetReg & ~(-1 >> InsertReg.size()) << Offset)

Definition at line 2796 of file LegalizerHelper.cpp.

References B, llvm::APInt::getLowBitsSet(), and llvm::LLT::getSizeInBits().

Referenced by llvm::LegalizerHelper::bitcastInsertVectorElt().

◆ clampDynamicVectorIndex()

static Register clampDynamicVectorIndex ( MachineIRBuilder B,
Register  IdxReg,
LLT  VecTy 
)
static

◆ conversionLibcall()

static LegalizerHelper::LegalizeResult conversionLibcall ( MachineInstr MI,
MachineIRBuilder MIRBuilder,
Type ToType,
Type FromType 
)
static

Definition at line 705 of file LegalizerHelper.cpp.

References llvm::createLibcall(), getConvRTLibDesc(), getReg(), and MI.

Referenced by llvm::LegalizerHelper::libcall().

◆ findGISelOptimalMemOpLowering()

static bool findGISelOptimalMemOpLowering ( std::vector< LLT > &  MemOps,
unsigned  Limit,
const MemOp Op,
unsigned  DstAS,
unsigned  SrcAS,
const AttributeList FuncAttributes,
const TargetLowering TLI 
)
static

◆ getBitcastWiderVectorElementOffset()

static Register getBitcastWiderVectorElementOffset ( MachineIRBuilder B,
Register  Idx,
unsigned  NewEltSize,
unsigned  OldEltSize 
)
static

Figure out the bit offset into a register when coercing a vector index for the wide element type.

This is only for the case when promoting vector to one with larger elements. offset_idx = G_AND idx, ~(-1 << Log2(DstEltSize / SrcEltSize)) offset_bits = G_SHL offset_idx, Log2(SrcEltSize)

Definition at line 2664 of file LegalizerHelper.cpp.

References B, llvm::APInt::getAllOnes(), llvm::LLT::getSizeInBits(), and llvm::Log2_32().

Referenced by llvm::LegalizerHelper::bitcastExtractVectorElt(), and llvm::LegalizerHelper::bitcastInsertVectorElt().

◆ getConvRTLibDesc()

static RTLIB::Libcall getConvRTLibDesc ( unsigned  Opcode,
Type ToType,
Type FromType 
)
static

◆ getFloatTypeForLLT()

static Type* getFloatTypeForLLT ( LLVMContext Ctx,
LLT  Ty 
)
static

◆ getMemsetValue()

static Register getMemsetValue ( Register  Val,
LLT  Ty,
MachineIRBuilder MIB 
)
static

◆ getNarrowTypeBreakDown()

static std::pair<int, int> getNarrowTypeBreakDown ( LLT  OrigTy,
LLT  NarrowTy,
LLT LeftoverTy 
)
static

Try to break down OrigTy into NarrowTy sized pieces.

Returns the number of NarrowTy elements needed to reconstruct OrigTy, with any leftover piece as type LeftoverTy

Returns -1 in the first element of the pair if the breakdown is not satisfiable.

Definition at line 48 of file LegalizerHelper.cpp.

References assert(), llvm::LinearPolySize< ElementCount >::getFixed(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::LLT::isValid(), llvm::LLT::isVector(), llvm::LLT::scalar(), llvm::LLT::scalarOrVector(), and llvm::Check::Size.

Referenced by llvm::LegalizerHelper::fewerElementsVectorMultiEltType(), llvm::LegalizerHelper::fewerElementsVectorPhi(), and llvm::LegalizerHelper::reduceLoadStoreWidth().

◆ getRTLibDesc()

static RTLIB::Libcall getRTLibDesc ( unsigned  Opcode,
unsigned  Size 
)
static

Definition at line 392 of file LegalizerHelper.cpp.

References llvm_unreachable, RTLIBCASE, and RTLIBCASE_INT.

Referenced by simpleLibcall().

◆ getScalarOpcForReduction()

static unsigned getScalarOpcForReduction ( unsigned  Opc)
static

◆ getTypeForLLT()

static Type* getTypeForLLT ( LLT  Ty,
LLVMContext C 
)
static

◆ getUnmergePieces()

static void getUnmergePieces ( SmallVectorImpl< Register > &  Pieces,
MachineIRBuilder B,
Register  Src,
LLT  Ty 
)
static

Definition at line 2582 of file LegalizerHelper.cpp.

References B, E, and I.

Referenced by llvm::LegalizerHelper::lowerBitcast().

◆ getUnmergeResults()

static void getUnmergeResults ( SmallVectorImpl< Register > &  Regs,
const MachineInstr MI 
)
static

Append the result registers of G_UNMERGE_VALUES MI to Regs.

Definition at line 235 of file LegalizerHelper.cpp.

References assert(), I, MI, and llvm::SmallVectorImpl< T >::resize().

◆ isLibCallInTailPosition()

static bool isLibCallInTailPosition ( MachineInstr MI,
const TargetInstrInfo TII,
MachineRegisterInfo MRI 
)
static

◆ isNonZeroModBitWidthOrUndef()

static bool isNonZeroModBitWidthOrUndef ( const MachineRegisterInfo MRI,
Register  Reg,
unsigned  BW 
)
static

◆ minMaxToCompare()

static CmpInst::Predicate minMaxToCompare ( unsigned  Opc)
static

◆ shouldLowerMemFuncForSize()

static bool shouldLowerMemFuncForSize ( const MachineFunction MF)
static

◆ simpleLibcall()

static LegalizerHelper::LegalizeResult simpleLibcall ( MachineInstr MI,
MachineIRBuilder MIRBuilder,
unsigned  Size,
Type OpType 
)
static

◆ SwapN()

static MachineInstrBuilder SwapN ( unsigned  N,
DstOp  Dst,
MachineIRBuilder B,
MachineInstrBuilder  Src,
APInt  Mask 
)
static

Definition at line 7256 of file LegalizerHelper.cpp.

References B, llvm::BitmaskEnumDetail::Mask(), and N.

Referenced by llvm::LegalizerHelper::lowerBitreverse().

llvm::Check::Size
@ Size
Definition: FileCheck.h:73