LLVM  13.0.0git
Macros | Functions | Variables
CombinerHelper.cpp File Reference
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/CodeGen/GlobalISel/Combiner.h"
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelType.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"
Include dependency graph for CombinerHelper.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "gi-combiner"
 

Functions

static unsigned littleEndianByteAt (const unsigned ByteWidth, const unsigned I)
 
static unsigned bigEndianByteAt (const unsigned ByteWidth, const unsigned I)
 
static Optional< bool > isBigEndian (const SmallDenseMap< int64_t, int64_t, 8 > &MemOffset2Idx, int64_t LowestIdx)
 Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds to a little or big endian byte pattern. More...
 
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)
 
static Optional< APFloatconstantFoldFpUnary (unsigned Opcode, LLT DstTy, const Register Op, const MachineRegisterInfo &MRI)
 
static Register peekThroughBitcast (Register Reg, const MachineRegisterInfo &MRI)
 
static bool isConstValidTrue (const TargetLowering &TLI, unsigned ScalarSizeBits, int64_t Cst, bool IsVector, bool IsFP)
 
static Optional< std::pair< MachineInstr *, int64_t > > matchLoadAndBytePosition (Register Reg, unsigned MemSizeInBits, const MachineRegisterInfo &MRI)
 Helper function for findLoadOffsetsForLoadOrCombine. More...
 

Variables

static cl::opt< bool > ForceLegalIndexing ("force-legal-indexing", cl::Hidden, cl::init(false), cl::desc("Force all indexed operations to be " "legal for the GlobalISel combiner"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "gi-combiner"

Definition at line 31 of file CombinerHelper.cpp.

Function Documentation

◆ bigEndianByteAt()

static unsigned bigEndianByteAt ( const unsigned  ByteWidth,
const unsigned  I 
)
static
Returns
The big endian in-memory byte position of byte I in a ByteWidth bytes wide type.

E.g. Given a 4-byte type x, x[0] -> byte 3

Definition at line 69 of file CombinerHelper.cpp.

References assert(), and I.

Referenced by isBigEndian(), and llvm::CombinerHelper::matchLoadOrCombine().

◆ constantFoldFpUnary()

static Optional<APFloat> constantFoldFpUnary ( unsigned  Opcode,
LLT  DstTy,
const Register  Op,
const MachineRegisterInfo MRI 
)
static

◆ findGISelOptimalMemOpLowering()

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

◆ getMemsetValue()

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

◆ getTypeForLLT()

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

◆ isBigEndian()

static Optional<bool> isBigEndian ( const SmallDenseMap< int64_t, int64_t, 8 > &  MemOffset2Idx,
int64_t  LowestIdx 
)
static

Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds to a little or big endian byte pattern.

Parameters
MemOffset2Idxmaps memory offsets to address offsets.
LowestIdxis the lowest index in MemOffset2Idx.
Returns
true if the map corresponds to a big endian byte pattern, false if it corresponds to a little endian byte pattern, and None otherwise.

E.g. given a 32-bit type x, and x[AddrOffset], the in-memory byte patterns are as follows:

AddrOffset Little endian Big endian 0 0 3 1 1 2 2 2 1 3 3 0

Definition at line 92 of file CombinerHelper.cpp.

References assert(), bigEndianByteAt(), llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), littleEndianByteAt(), llvm::None, and llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::size().

Referenced by collectInsertionElements(), createGPRPairNode(), llvm::SelectionDAG::getConstant(), llvm::CombinerHelper::matchLoadOrCombine(), PerformSTORECombine(), ReplaceCMP_SWAP_64Results(), and llvm::orc::OrcMips32_Base::writeResolverCode().

◆ isConstValidTrue()

static bool isConstValidTrue ( const TargetLowering TLI,
unsigned  ScalarSizeBits,
int64_t  Cst,
bool  IsVector,
bool  IsFP 
)
static

Definition at line 3099 of file CombinerHelper.cpp.

References llvm::isConstTrueVal().

Referenced by llvm::CombinerHelper::matchNotCmp().

◆ littleEndianByteAt()

static unsigned littleEndianByteAt ( const unsigned  ByteWidth,
const unsigned  I 
)
static
Returns
The little endian in-memory byte position of byte I in a ByteWidth bytes wide type.

E.g. Given a 4-byte type x, x[0] -> byte 0

Definition at line 60 of file CombinerHelper.cpp.

References assert(), and I.

Referenced by isBigEndian(), and llvm::CombinerHelper::matchLoadOrCombine().

◆ matchLoadAndBytePosition()

static Optional<std::pair<MachineInstr *, int64_t> > matchLoadAndBytePosition ( Register  Reg,
unsigned  MemSizeInBits,
const MachineRegisterInfo MRI 
)
static

Helper function for findLoadOffsetsForLoadOrCombine.

Check if Reg is the result of loading a MemSizeInBits wide value, and then moving that value into a specific byte offset.

e.g. x[i] << 24

Returns
The load instruction and the byte offset it is moved into.

Definition at line 3376 of file CombinerHelper.cpp.

References assert(), llvm::getOpcodeDef(), llvm::MachineRegisterInfo::hasOneNonDBGUse(), llvm::SPII::Load, llvm::MIPatternMatch::m_GShl(), llvm::MIPatternMatch::m_ICst(), llvm::MIPatternMatch::m_OneNonDBGUse(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), MRI, llvm::None, Reg, and Shift.

◆ peekThroughBitcast()

static Register peekThroughBitcast ( Register  Reg,
const MachineRegisterInfo MRI 
)
static

◆ shouldLowerMemFuncForSize()

static bool shouldLowerMemFuncForSize ( const MachineFunction MF)
static

Variable Documentation

◆ ForceLegalIndexing

cl::opt<bool> ForceLegalIndexing("force-legal-indexing", cl::Hidden, cl::init(false), cl::desc("Force all indexed operations to be " "legal for the GlobalISel combiner"))
static