LLVM  10.0.0
Macros | Functions | Variables
SelectionDAG.cpp File Reference
#include "llvm/CodeGen/SelectionDAG.h"
#include "SDNodeDbgValue.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/RuntimeLibcalls.h"
#include "llvm/CodeGen/SelectionDAGAddressAnalysis.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "llvm/IR/ConstrainedOps.def"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "selectiondag"
 
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)   case ISD::STRICT_##DAGN: NewOpc = ISD::DAGN; break;
 
#define CMP_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)   case ISD::STRICT_##DAGN: NewOpc = ISD::SETCC; break;
 

Functions

static SDVTList makeVTList (const EVT *VTs, unsigned NumVTs)
 makeVTList - Return an instance of the SDVTList struct initialized with the specified members. More...
 
static void NewSDValueDbgMsg (SDValue V, StringRef Msg, SelectionDAG *G)
 
static ISD::CondCode getSetCCInverseImpl (ISD::CondCode Op, bool isIntegerLike)
 
static int isSignedOp (ISD::CondCode Opcode)
 For an integer comparison, return 1 if the comparison is a signed operation and 2 if the result is an unsigned comparison. More...
 
static void AddNodeIDOpcode (FoldingSetNodeID &ID, unsigned OpC)
 AddNodeIDOpcode - Add the node opcode to the NodeID data. More...
 
static void AddNodeIDValueTypes (FoldingSetNodeID &ID, SDVTList VTList)
 AddNodeIDValueTypes - Value type lists are intern'd so we can represent them solely with their pointer. More...
 
static void AddNodeIDOperands (FoldingSetNodeID &ID, ArrayRef< SDValue > Ops)
 AddNodeIDOperands - Various routines for adding operands to the NodeID data. More...
 
static void AddNodeIDOperands (FoldingSetNodeID &ID, ArrayRef< SDUse > Ops)
 AddNodeIDOperands - Various routines for adding operands to the NodeID data. More...
 
static void AddNodeIDNode (FoldingSetNodeID &ID, unsigned short OpC, SDVTList VTList, ArrayRef< SDValue > OpList)
 
static void AddNodeIDCustom (FoldingSetNodeID &ID, const SDNode *N)
 If this is an SDNode with special info, add this info to the NodeID data. More...
 
static void AddNodeIDNode (FoldingSetNodeID &ID, const SDNode *N)
 AddNodeIDNode - Generic routine for adding a nodes info to the NodeID data. More...
 
static bool doNotCSE (SDNode *N)
 doNotCSE - Return true if CSE should not be performed for this node. More...
 
static void VerifySDNode (SDNode *N)
 VerifySDNode - Sanity check the given SDNode. Aborts if it is invalid. More...
 
static void commuteShuffle (SDValue &N1, SDValue &N2, MutableArrayRef< int > M)
 Swaps the values of N1 and N2. More...
 
static const APInt * getValidShiftAmountConstant (SDValue V, const APInt &DemandedElts)
 If a SHL/SRA/SRL node has a constant or splat constant shift amount that is less than the element bit-width of the shift node, return it. More...
 
static const APInt * getValidMinimumShiftAmountConstant (SDValue V, const APInt &DemandedElts)
 If a SHL/SRA/SRL node has constant vector shift amounts that are all less than the element bit-width of the shift node, return the minimum value. More...
 
static const APInt * getValidMaximumShiftAmountConstant (SDValue V, const APInt &DemandedElts)
 If a SHL/SRA/SRL node has constant vector shift amounts that are all less than the element bit-width of the shift node, return the maximum value. More...
 
static SDValue FoldBUILD_VECTOR (const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
 
static SDValue foldCONCAT_VECTORS (const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
 Try to simplify vector concatenation to an input value, undef, or build vector. More...
 
static llvm::Optional< APInt > FoldValue (unsigned Opcode, const APInt &C1, const APInt &C2)
 
static SDValue getMemsetValue (SDValue Value, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
 getMemsetValue - Vectorized representation of the memset value operand. More...
 
static SDValue getMemsetStringVal (EVT VT, const SDLoc &dl, SelectionDAG &DAG, const TargetLowering &TLI, const ConstantDataArraySlice &Slice)
 getMemsetStringVal - Similar to getMemsetValue. More...
 
static bool isMemSrcFromConstant (SDValue Src, ConstantDataArraySlice &Slice)
 Returns true if memcpy source is constant data. More...
 
static bool shouldLowerMemFuncForSize (const MachineFunction &MF, SelectionDAG &DAG)
 
static void chainLoadsAndStoresForMemcpy (SelectionDAG &DAG, const SDLoc &dl, SmallVector< SDValue, 32 > &OutChains, unsigned From, unsigned To, SmallVector< SDValue, 16 > &OutLoadChains, SmallVector< SDValue, 16 > &OutStoreChains)
 
static SDValue getMemcpyLoadsAndStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Alignment, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
 
static SDValue getMemmoveLoadsAndStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
 
static SDValue getMemsetStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo)
 Lower the call to 'memset' intrinsic function into a series of store operations. More...
 
static void checkAddrSpaceIsValidForLibcall (const TargetLowering *TLI, unsigned AS)
 
static MachinePointerInfo InferPointerInfo (const MachinePointerInfo &Info, SelectionDAG &DAG, SDValue Ptr, int64_t Offset=0)
 InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it. More...
 
static MachinePointerInfo InferPointerInfo (const MachinePointerInfo &Info, SelectionDAG &DAG, SDValue Ptr, SDValue OffsetOp)
 InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it. More...
 
static void checkForCyclesHelper (const SDNode *N, SmallPtrSetImpl< const SDNode *> &Visited, SmallPtrSetImpl< const SDNode *> &Checked, const llvm::SelectionDAG *DAG)
 

Variables

static cl::opt< bool > EnableMemCpyDAGOpt ("enable-memcpy-dag-opt", cl::Hidden, cl::init(true), cl::desc("Gang up loads and stores generated by inlining of memcpy"))
 
static cl::opt< int > MaxLdStGlue ("ldstmemcpy-glue-max", cl::desc("Number limit for gluing ld/st of memcpy."), cl::Hidden, cl::init(0))
 
static ManagedStatic< std::set< EVT, EVT::compareRawBits > > EVTs
 
static ManagedStatic< EVTArray > SimpleVTArray
 
static ManagedStatic< sys::SmartMutex< true > > VTMutex
 

Macro Definition Documentation

◆ CMP_INSTRUCTION

#define CMP_INSTRUCTION (   NAME,
  NARG,
  ROUND_MODE,
  INTRINSIC,
  DAGN 
)    case ISD::STRICT_##DAGN: NewOpc = ISD::SETCC; break;

◆ DEBUG_TYPE

#define DEBUG_TYPE   "selectiondag"

Definition at line 96 of file SelectionDAG.cpp.

◆ INSTRUCTION

#define INSTRUCTION (   NAME,
  NARG,
  ROUND_MODE,
  INTRINSIC,
  DAGN 
)    case ISD::STRICT_##DAGN: NewOpc = ISD::DAGN; break;

Function Documentation

◆ AddNodeIDCustom()

static void AddNodeIDCustom ( FoldingSetNodeID &  ID,
const SDNode *  N 
)
static

If this is an SDNode with special info, add this info to the NodeID data.

Definition at line 487 of file SelectionDAG.cpp.

References llvm::FoldingSetNodeID::AddBoolean(), llvm::FoldingSetNodeID::AddInteger(), llvm::FoldingSetNodeID::AddPointer(), llvm::MachineConstantPoolValue::addSelectionDAGCSEId(), llvm::ISD::ATOMIC_CMP_SWAP, llvm::ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, llvm::ISD::ATOMIC_LOAD, llvm::ISD::ATOMIC_LOAD_ADD, llvm::ISD::ATOMIC_LOAD_AND, llvm::ISD::ATOMIC_LOAD_CLR, llvm::ISD::ATOMIC_LOAD_MAX, llvm::ISD::ATOMIC_LOAD_MIN, llvm::ISD::ATOMIC_LOAD_NAND, llvm::ISD::ATOMIC_LOAD_OR, llvm::ISD::ATOMIC_LOAD_SUB, llvm::ISD::ATOMIC_LOAD_UMAX, llvm::ISD::ATOMIC_LOAD_UMIN, llvm::ISD::ATOMIC_LOAD_XOR, llvm::ISD::ATOMIC_STORE, llvm::ISD::ATOMIC_SWAP, llvm::ISD::BasicBlock, llvm::ISD::BlockAddress, C, llvm::ISD::Constant, llvm::ISD::ConstantFP, llvm::ISD::ConstantPool, llvm::HexagonISD::CP, llvm::numbers::e, llvm::ISD::ExternalSymbol, llvm::ISD::FrameIndex, llvm::MachinePointerInfo::getAddrSpace(), llvm::ConstantPoolSDNode::getAlignment(), llvm::SelectionDAG::getBasicBlock(), llvm::BlockAddressSDNode::getBlockAddress(), llvm::ConstantSDNode::getConstantIntValue(), llvm::ConstantPoolSDNode::getConstVal(), llvm::GlobalAddressSDNode::getGlobal(), llvm::TargetIndexSDNode::getIndex(), llvm::ConstantPoolSDNode::getMachineCPVal(), llvm::ShuffleVectorSDNode::getMaskElt(), llvm::MemSDNode::getMemoryVT(), llvm::getOffset(), llvm::GlobalAddressSDNode::getOffset(), llvm::ConstantPoolSDNode::getOffset(), llvm::TargetIndexSDNode::getOffset(), llvm::BlockAddressSDNode::getOffset(), llvm::SDNode::getOpcode(), llvm::MemSDNode::getPointerInfo(), llvm::EVT::getRawBits(), llvm::MemSDNode::getRawSubclassData(), getReg(), llvm::GlobalAddressSDNode::getTargetFlags(), llvm::ConstantPoolSDNode::getTargetFlags(), llvm::TargetIndexSDNode::getTargetFlags(), llvm::BlockAddressSDNode::getTargetFlags(), llvm::SDNode::getValueType(), llvm::EVT::getVectorNumElements(), llvm::ISD::GlobalAddress, llvm::ISD::GlobalTLSAddress, llvm::ConstantPoolSDNode::isMachineConstantPoolEntry(), llvm::ConstantSDNode::isOpaque(), llvm::SDNode::isTargetMemoryOpcode(), llvm::ISD::JumpTable, llvm::ARM_MB::LD, llvm::ISD::LIFETIME_END, llvm::ISD::LIFETIME_START, llvm_unreachable, llvm::ISD::LOAD, llvm::ISD::MCSymbol, llvm::ISD::MGATHER, llvm::ISD::MLOAD, llvm::ISD::MSCATTER, llvm::ISD::MSTORE, N, llvm::ISD::PREFETCH, llvm::ISD::Register, llvm::ISD::RegisterMask, llvm::ISD::SRCVALUE, llvm::ARM_MB::ST, llvm::ISD::STORE, llvm::ISD::TargetBlockAddress, llvm::ISD::TargetConstant, llvm::ISD::TargetConstantFP, llvm::ISD::TargetConstantPool, llvm::ISD::TargetExternalSymbol, llvm::ISD::TargetFrameIndex, llvm::ISD::TargetGlobalAddress, llvm::ISD::TargetGlobalTLSAddress, llvm::ISD::TargetIndex, llvm::ISD::TargetJumpTable, and llvm::ISD::VECTOR_SHUFFLE.

Referenced by AddNodeIDNode(), and VerifySDNode().

◆ AddNodeIDNode() [1/2]

static void AddNodeIDNode ( FoldingSetNodeID &  ID,
unsigned short  OpC,
SDVTList  VTList,
ArrayRef< SDValue >  OpList 
)
static

◆ AddNodeIDNode() [2/2]

static void AddNodeIDNode ( FoldingSetNodeID &  ID,
const SDNode *  N 
)
static

AddNodeIDNode - Generic routine for adding a nodes info to the NodeID data.

Definition at line 655 of file SelectionDAG.cpp.

References AddNodeIDCustom(), AddNodeIDOpcode(), AddNodeIDOperands(), AddNodeIDValueTypes(), llvm::SDNode::getOpcode(), llvm::SDNode::getVTList(), and llvm::SDNode::ops().

◆ AddNodeIDOpcode()

static void AddNodeIDOpcode ( FoldingSetNodeID &  ID,
unsigned  OpC 
)
static

AddNodeIDOpcode - Add the node opcode to the NodeID data.

Definition at line 451 of file SelectionDAG.cpp.

References llvm::FoldingSetNodeID::AddInteger().

Referenced by AddNodeIDNode().

◆ AddNodeIDOperands() [1/2]

static void AddNodeIDOperands ( FoldingSetNodeID &  ID,
ArrayRef< SDValue >  Ops 
)
static

AddNodeIDOperands - Various routines for adding operands to the NodeID data.

Definition at line 462 of file SelectionDAG.cpp.

References llvm::FoldingSetNodeID::AddInteger(), llvm::FoldingSetNodeID::AddPointer(), llvm::SDValue::getNode(), and llvm::SDValue::getResNo().

Referenced by AddNodeIDNode().

◆ AddNodeIDOperands() [2/2]

static void AddNodeIDOperands ( FoldingSetNodeID &  ID,
ArrayRef< SDUse >  Ops 
)
static

AddNodeIDOperands - Various routines for adding operands to the NodeID data.

Definition at line 471 of file SelectionDAG.cpp.

References llvm::FoldingSetNodeID::AddInteger(), llvm::FoldingSetNodeID::AddPointer(), llvm::SDValue::getNode(), and llvm::SDValue::getResNo().

◆ AddNodeIDValueTypes()

static void AddNodeIDValueTypes ( FoldingSetNodeID &  ID,
SDVTList  VTList 
)
static

AddNodeIDValueTypes - Value type lists are intern'd so we can represent them solely with their pointer.

Definition at line 457 of file SelectionDAG.cpp.

References llvm::FoldingSetNodeID::AddPointer(), and llvm::SDVTList::VTs.

Referenced by AddNodeIDNode().

◆ chainLoadsAndStoresForMemcpy()

static void chainLoadsAndStoresForMemcpy ( SelectionDAG &  DAG,
const SDLoc &  dl,
SmallVector< SDValue, 32 > &  OutChains,
unsigned  From,
unsigned  To,
SmallVector< SDValue, 16 > &  OutLoadChains,
SmallVector< SDValue, 16 > &  OutStoreChains 
)
static

◆ checkAddrSpaceIsValidForLibcall()

static void checkAddrSpaceIsValidForLibcall ( const TargetLowering *  TLI,
unsigned  AS 
)
static

◆ checkForCyclesHelper()

static void checkForCyclesHelper ( const SDNode *  N,
SmallPtrSetImpl< const SDNode *> &  Visited,
SmallPtrSetImpl< const SDNode *> &  Checked,
const llvm::SelectionDAG *  DAG 
)
static

◆ commuteShuffle()

static void commuteShuffle ( SDValue &  N1,
SDValue &  N2,
MutableArrayRef< int >  M 
)
static

Swaps the values of N1 and N2.

Swaps all indices in the shuffle mask M that point at N1 to point at N2 and indices that point at N2 to point at N1.

Definition at line 1602 of file SelectionDAG.cpp.

References llvm::ShuffleVectorSDNode::commuteMask(), and std::swap().

Referenced by llvm::SelectionDAG::getVectorShuffle().

◆ doNotCSE()

static bool doNotCSE ( SDNode *  N)
static

doNotCSE - Return true if CSE should not be performed for this node.

Definition at line 671 of file SelectionDAG.cpp.

References llvm::numbers::e, llvm::ISD::EH_LABEL, llvm::SDNode::getNumValues(), llvm::SDNode::getOpcode(), llvm::SDNode::getValueType(), llvm::MVT::Glue, and llvm::ISD::HANDLENODE.

Referenced by VerifySDNode().

◆ FoldBUILD_VECTOR()

static SDValue FoldBUILD_VECTOR ( const SDLoc &  DL,
EVT  VT,
ArrayRef< SDValue >  Ops,
SelectionDAG &  DAG 
)
static

◆ foldCONCAT_VECTORS()

static SDValue foldCONCAT_VECTORS ( const SDLoc &  DL,
EVT  VT,
ArrayRef< SDValue >  Ops,
SelectionDAG &  DAG 
)
static

◆ FoldValue()

static llvm::Optional<APInt> FoldValue ( unsigned  Opcode,
const APInt &  C1,
const APInt &  C2 
)
static

◆ getMemcpyLoadsAndStores()

static SDValue getMemcpyLoadsAndStores ( SelectionDAG &  DAG,
const SDLoc &  dl,
SDValue  Chain,
SDValue  Dst,
SDValue  Src,
uint64_t  Size,
unsigned  Alignment,
bool  isVol,
bool  AlwaysInline,
MachinePointerInfo  DstPtrInfo,
MachinePointerInfo  SrcPtrInfo 
)
static

Definition at line 5868 of file SelectionDAG.cpp.

References llvm::ConstantDataArraySlice::Array, assert(), llvm::EVT::bitsGE(), C, chainLoadsAndStoresForMemcpy(), llvm::dyn_cast(), EnableMemCpyDAGOpt, llvm::DataLayout::exceedsNaturalStackAlignment(), llvm::ISD::EXTLOAD, llvm::TargetLowering::findOptimalMemOpLowering(), llvm::DataLayout::getABITypeAlignment(), llvm::MachinePointerInfo::getAddrSpace(), llvm::Function::getAttributes(), llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getDataLayout(), llvm::SelectionDAG::getExtLoad(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::FrameIndexSDNode::getIndex(), llvm::SelectionDAG::getMachineFunction(), llvm::TargetLoweringBase::getMaxGluedStoresPerMemcpy(), llvm::TargetLoweringBase::getMaxStoresPerMemcpy(), llvm::SelectionDAG::getMemBasePlusOffset(), getMemsetStringVal(), llvm::SDValue::getNode(), llvm::SelectionDAG::getNode(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::EVT::getSizeInBits(), llvm::SelectionDAG::getStore(), llvm::MachineFunction::getSubtarget(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SelectionDAG::getTruncStore(), llvm::TargetLoweringBase::getTypeToTransformTo(), llvm::SDValue::getValue(), llvm::MachinePointerInfo::getWithOffset(), llvm::SelectionDAG::InferPtrAlignment(), llvm::MachinePointerInfo::isDereferenceable(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::EVT::isInteger(), isMemSrcFromConstant(), llvm::SDValue::isUndef(), llvm::EVT::isVector(), llvm::ConstantDataArraySlice::Length, MaxLdStGlue, llvm::MinAlign(), llvm::MachineMemOperand::MODereferenceable, llvm::MachineMemOperand::MONone, llvm::ConstantDataArraySlice::move(), llvm::MachineMemOperand::MOVolatile, llvm::TargetRegisterInfo::needsStackRealignment(), llvm::ConstantDataArraySlice::Offset, llvm::MVT::Other, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), Size, llvm::SmallVectorBase::size(), llvm::SPII::Store, llvm::ISD::TokenFactor, and TRI.

Referenced by llvm::SelectionDAG::getMemcpy().

◆ getMemmoveLoadsAndStores()

static SDValue getMemmoveLoadsAndStores ( SelectionDAG &  DAG,
const SDLoc &  dl,
SDValue  Chain,
SDValue  Dst,
SDValue  Src,
uint64_t  Size,
unsigned  Align,
bool  isVol,
bool  AlwaysInline,
MachinePointerInfo  DstPtrInfo,
MachinePointerInfo  SrcPtrInfo 
)
static

◆ getMemsetStores()

static SDValue getMemsetStores ( SelectionDAG &  DAG,
const SDLoc &  dl,
SDValue  Chain,
SDValue  Dst,
SDValue  Src,
uint64_t  Size,
unsigned  Align,
bool  isVol,
MachinePointerInfo  DstPtrInfo 
)
static

Lower the call to 'memset' intrinsic function into a series of store operations.

Parameters
DAGSelection DAG where lowered code is placed.
dlLink to corresponding IR location.
ChainControl flow dependency.
DstPointer to destination memory location.
SrcValue of byte to write into the memory.
SizeNumber of bytes to write.
AlignAlignment of the destination in bytes.
isVolTrue if destination is volatile.
DstPtrInfoIR information on the memory pointer.
Returns
New head in the control flow, if lowering was successful, empty SDValue otherwise.

The function tries to replace 'llvm.memset' intrinsic with several store operations and value calculation code. This is usually profitable for small memory size.

Definition at line 6163 of file SelectionDAG.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, assert(), llvm::EVT::bitsLT(), llvm::dyn_cast(), llvm::TargetLowering::findOptimalMemOpLowering(), llvm::DataLayout::getABITypeAlignment(), llvm::MachinePointerInfo::getAddrSpace(), llvm::Function::getAttributes(), llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getDataLayout(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::FrameIndexSDNode::getIndex(), llvm::SelectionDAG::getMachineFunction(), llvm::TargetLoweringBase::getMaxStoresPerMemset(), llvm::SelectionDAG::getMemBasePlusOffset(), getMemsetValue(), llvm::SelectionDAG::getNode(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::EVT::getSizeInBits(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SDValue::getValueType(), llvm::MachinePointerInfo::getWithOffset(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::TargetLoweringBase::isTruncateFree(), llvm::SDValue::isUndef(), llvm::EVT::isVector(), llvm::MachineMemOperand::MONone, llvm::MachineMemOperand::MOVolatile, llvm::MVT::Other, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), Size, llvm::SmallVectorBase::size(), llvm::SPII::Store, llvm::ISD::TokenFactor, and llvm::ISD::TRUNCATE.

Referenced by llvm::SelectionDAG::getMemset().

◆ getMemsetStringVal()

static SDValue getMemsetStringVal ( EVT  VT,
const SDLoc &  dl,
SelectionDAG &  DAG,
const TargetLowering &  TLI,
const ConstantDataArraySlice &  Slice 
)
static

◆ getMemsetValue()

static SDValue getMemsetValue ( SDValue  Value,
EVT  VT,
SelectionDAG &  DAG,
const SDLoc &  dl 
)
static

◆ getSetCCInverseImpl()

static ISD::CondCode getSetCCInverseImpl ( ISD::CondCode  Op,
bool  isIntegerLike 
)
static

◆ getValidMaximumShiftAmountConstant()

static const APInt* getValidMaximumShiftAmountConstant ( SDValue  V,
const APInt &  DemandedElts 
)
static

If a SHL/SRA/SRL node has constant vector shift amounts that are all less than the element bit-width of the shift node, return the maximum value.

Definition at line 2463 of file SelectionDAG.cpp.

References llvm::dyn_cast(), llvm::numbers::e, llvm::SDValue::getOperand(), llvm::SDValue::getScalarValueSizeInBits(), and llvm::APInt::uge().

Referenced by llvm::SelectionDAG::ComputeNumSignBits().

◆ getValidMinimumShiftAmountConstant()

static const APInt* getValidMinimumShiftAmountConstant ( SDValue  V,
const APInt &  DemandedElts 
)
static

If a SHL/SRA/SRL node has constant vector shift amounts that are all less than the element bit-width of the shift node, return the minimum value.

Definition at line 2437 of file SelectionDAG.cpp.

References llvm::dyn_cast(), llvm::numbers::e, llvm::SDValue::getOperand(), llvm::SDValue::getScalarValueSizeInBits(), llvm::APInt::uge(), and llvm::APInt::ule().

Referenced by llvm::SelectionDAG::computeKnownBits(), and llvm::SelectionDAG::ComputeNumSignBits().

◆ getValidShiftAmountConstant()

static const APInt* getValidShiftAmountConstant ( SDValue  V,
const APInt &  DemandedElts 
)
static

If a SHL/SRA/SRL node has a constant or splat constant shift amount that is less than the element bit-width of the shift node, return it.

Definition at line 2422 of file SelectionDAG.cpp.

References llvm::SDValue::getOperand(), llvm::SDValue::getScalarValueSizeInBits(), llvm::isConstOrConstSplat(), and llvm::APInt::ult().

Referenced by llvm::SelectionDAG::computeKnownBits(), and llvm::SelectionDAG::ComputeNumSignBits().

◆ InferPointerInfo() [1/2]

static MachinePointerInfo InferPointerInfo ( const MachinePointerInfo &  Info,
SelectionDAG &  DAG,
SDValue  Ptr,
int64_t  Offset = 0 
)
static

InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.

This is particularly useful because the code generator has many cases where it doesn't bother passing in a MachinePointerInfo to getLoad or getStore when it has "FI+Cst".

Definition at line 6759 of file SelectionDAG.cpp.

References llvm::ISD::ADD, llvm::MachinePointerInfo::getFixedStack(), llvm::SelectionDAG::getMachineFunction(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), and Info.

Referenced by llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTruncStore(), and InferPointerInfo().

◆ InferPointerInfo() [2/2]

static MachinePointerInfo InferPointerInfo ( const MachinePointerInfo &  Info,
SelectionDAG &  DAG,
SDValue  Ptr,
SDValue  OffsetOp 
)
static

InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.

This is particularly useful because the code generator has many cases where it doesn't bother passing in a MachinePointerInfo to getLoad or getStore when it has "FI+Cst".

Definition at line 6783 of file SelectionDAG.cpp.

References InferPointerInfo(), Info, and llvm::SDValue::isUndef().

◆ isMemSrcFromConstant()

static bool isMemSrcFromConstant ( SDValue  Src,
ConstantDataArraySlice &  Slice 
)
static

◆ isSignedOp()

static int isSignedOp ( ISD::CondCode  Opcode)
static

For an integer comparison, return 1 if the comparison is a signed operation and 2 if the result is an unsigned comparison.

Return zero if the operation does not depend on the sign of the input (setne and seteq).

Definition at line 384 of file SelectionDAG.cpp.

References llvm_unreachable, llvm::ISD::SETEQ, llvm::ISD::SETGE, llvm::ISD::SETGT, llvm::ISD::SETLE, llvm::ISD::SETLT, llvm::ISD::SETNE, llvm::ISD::SETUGE, llvm::ISD::SETUGT, llvm::ISD::SETULE, and llvm::ISD::SETULT.

Referenced by llvm::ISD::getSetCCAndOperation(), and llvm::ISD::getSetCCOrOperation().

◆ makeVTList()

static SDVTList makeVTList ( const EVT *  VTs,
unsigned  NumVTs 
)
static

makeVTList - Return an instance of the SDVTList struct initialized with the specified members.

Definition at line 84 of file SelectionDAG.cpp.

Referenced by llvm::SelectionDAG::getVTList().

◆ NewSDValueDbgMsg()

static void NewSDValueDbgMsg ( SDValue  V,
StringRef  Msg,
SelectionDAG *  G 
)
static

◆ shouldLowerMemFuncForSize()

static bool shouldLowerMemFuncForSize ( const MachineFunction &  MF,
SelectionDAG &  DAG 
)
static

◆ VerifySDNode()

static void VerifySDNode ( SDNode *  N)
static

Variable Documentation

◆ EnableMemCpyDAGOpt

cl::opt<bool> EnableMemCpyDAGOpt("enable-memcpy-dag-opt", cl::Hidden, cl::init(true), cl::desc("Gang up loads and stores generated by inlining of memcpy"))
static

Referenced by getMemcpyLoadsAndStores().

◆ EVTs

ManagedStatic<std::set<EVT, EVT::compareRawBits> > EVTs
static

Definition at line 9011 of file SelectionDAG.cpp.

◆ MaxLdStGlue

cl::opt<int> MaxLdStGlue("ldstmemcpy-glue-max", cl::desc("Number limit for gluing ld/st of memcpy."), cl::Hidden, cl::init(0))
static

Referenced by getMemcpyLoadsAndStores().

◆ SimpleVTArray

ManagedStatic<EVTArray> SimpleVTArray
static

Definition at line 9012 of file SelectionDAG.cpp.

◆ VTMutex

ManagedStatic<sys::SmartMutex<true> > VTMutex
static

Definition at line 9013 of file SelectionDAG.cpp.