Go to the documentation of this file.
25 #define DEBUG_TYPE "x86-selectiondag-info"
29 cl::desc(
"Use fast short rep mov in memcpy lowering"));
31 bool X86SelectionDAGInfo::isBaseRegConflictPossible(
57 const MCPhysReg ClobberSet[] = {X86::RCX, X86::RAX, X86::RDI,
59 assert(!isBaseRegConflictPossible(DAG, ClobberSet));
69 if (Alignment <
Align(4) || !ConstantSize ||
74 if (
const char *bzeroName =
85 Args.push_back(Entry);
87 Args.push_back(Entry);
97 std::pair<SDValue,SDValue> CallResult = TLI.
LowerCallTo(CLI);
98 return CallResult.second;
110 unsigned BytesLeft = 0;
116 if (Alignment >
Align(2)) {
120 Val = (Val << 8) | Val;
121 Val = (Val << 16) | Val;
122 if (Subtarget.is64Bit() && Alignment >
Align(8)) {
125 Val = (Val << 32) | Val;
127 }
else if (Alignment ==
Align(2)) {
131 Val = (Val << 8) | Val;
142 BytesLeft = SizeVal % UBytes;
169 unsigned Offset = SizeVal - BytesLeft;
170 EVT AddrVT = Dst.getValueType();
171 EVT SizeVT = Size.getValueType();
177 Val, DAG.
getConstant(BytesLeft, dl, SizeVT), Alignment,
190 const unsigned CX = Use64BitRegs ? X86::RCX :
X86::ECX;
191 const unsigned DI = Use64BitRegs ? X86::RDI :
X86::EDI;
192 const unsigned SI = Use64BitRegs ? X86::RSI :
X86::ESI;
211 return emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src,
239 unsigned Align,
bool isVolatile,
bool AlwaysInline,
248 if (Subtarget.hasERMSB())
249 return emitRepmovsB(Subtarget, DAG, dl, Chain, Dst, Src, Size);
251 assert(!Subtarget.hasERMSB() &&
"No efficient RepMovs");
254 if (!AlwaysInline && (
Align & 3) != 0)
259 const uint64_t BlockCount = Size / BlockBytes;
260 const uint64_t BytesLeft = Size % BlockBytes;
269 assert(BytesLeft &&
"We have leftover at this point");
274 return emitRepmovsB(Subtarget, DAG, dl, Chain, Dst, Src, Size);
279 unsigned Offset = Size - BytesLeft;
280 EVT DstVT = Dst.getValueType();
281 EVT SrcVT = Src.getValueType();
294 SDValue Size,
Align Alignment,
bool isVolatile,
bool AlwaysInline,
302 const MCPhysReg ClobberSet[] = {X86::RCX, X86::RSI, X86::RDI,
304 if (isBaseRegConflictPossible(DAG, ClobberSet))
315 if (
ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size))
317 DAG, Subtarget, dl, Chain, Dst, Src, ConstantSize->getZExtValue(),
318 Size.getValueType(), Alignment.value(), isVolatile, AlwaysInline,
319 DstPtrInfo, SrcPtrInfo);
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
This is an optimization pass for GlobalISel generic memory operations.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
CallLoweringInfo & setChain(SDValue InChain)
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
SDValue getValueType(EVT)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static cl::opt< bool > UseFSRMForMemcpy("x86-use-fsrm-for-memcpy", cl::Hidden, cl::init(false), cl::desc("Use fast short rep mov in memcpy lowering"))
The instances of the Type class are immutable: once they are created, they are never changed.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
Function Alias Analysis Results
static SDValue emitConstantSizeRepmov(SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, EVT SizeVT, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
Returns a REP MOVS instruction, possibly with a few load/stores to implement a constant size memory c...
const TargetSubtargetInfo & getSubtarget() const
unsigned const TargetRegisterInfo * TRI
static SDValue emitRepmovsB(const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size)
Emit a single REP MOVSB instruction for a particular constant size.
LLVMContext * getContext() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const TargetLowering & getTargetLoweringInfo() const
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVolatile, MachinePointerInfo DstPtrInfo) const override
Emit target-specific code that performs a memset.
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
static SDValue emitRepmovs(const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, MVT AVT)
Emit a single REP MOVS{B,W,D,Q} instruction.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
static MVT getOptimalRepmovsType(const X86Subtarget &Subtarget, uint64_t Align)
Returns the best type to use with repmovs depending on alignment.
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
This class contains a discriminated union of information about pointers in memory operands,...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
initializer< Ty > init(const Ty &Val)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
SDValue getValue(unsigned R) const
This structure contains all information that is necessary for lowering calls.
@ REP_STOS
Repeat fill, corresponds to X86::REP_STOSx.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
StandardInstrumentations SI(Debug, VerifyEach)
uint64_t getZExtValue() const
MachinePointerInfo getWithOffset(int64_t O) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
@ REP_MOVS
Repeat move, corresponds to X86::REP_MOVSx.
@ C
C - The default llvm calling convention, compatible with C.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
std::vector< ArgListEntry > ArgListTy
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space.
Function & getFunction()
Return the LLVM function that this machine code represents.
CallLoweringInfo & setDiscardResult(bool Value=true)
const DataLayout & getDataLayout() const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
@ ADD
Simple integer binary arithmetic operators.
static Type * getVoidTy(LLVMContext &C)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
BlockType
Used as immediate MachineOperands for block signatures.
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
MachineFunction & getMachineFunction() const
SDValue getExternalSymbol(const char *Sym, EVT VT)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
unsigned getMaxInlineSizeThreshold() const
Returns the maximum memset / memcpy size that still makes it profitable to inline the call.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.