LLVM  13.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 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 (const TargetInstrInfo &TII, MachineInstr &MI)
 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 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)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "legalizer"

Definition at line 33 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 2661 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 675 of file LegalizerHelper.cpp.

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

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

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

References B, llvm::APInt::getAllOnesValue(), 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

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

References assert(), 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 406 of file LegalizerHelper.cpp.

References llvm_unreachable, RTLIBCASE, and RTLIBCASE_INT.

Referenced by simpleLibcall().

◆ getUnmergePieces()

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

Definition at line 2448 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 249 of file LegalizerHelper.cpp.

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

◆ isLibCallInTailPosition()

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

True if an instruction is in tail position in its caller.

Intended for legalizing libcalls as tail calls when possible.

Definition at line 498 of file LegalizerHelper.cpp.

References F, llvm::MachineFunction::getFunction(), llvm::MachineBasicBlock::getParent(), llvm::AttributeList::hasAttribute(), llvm::MachineBasicBlock::instr_end(), llvm::HexagonInstrInfo::isTailCall(), MBB, MI, llvm::next_nodbg(), llvm::AttributeList::ReturnIndex, and TII.

Referenced by llvm::createMemLibcall().

◆ isNonZeroModBitWidthOrUndef()

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

◆ minMaxToCompare()

static CmpInst::Predicate minMaxToCompare ( unsigned  Opc)
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
llvm::Check::Size
@ Size
Definition: FileCheck.h:73