21#define GET_SDNODE_DESC
22#include "X86GenSDNodeInfo.inc"
26#define DEBUG_TYPE "x86-selectiondag-info"
32#define NODE_NAME_CASE(NODE) \
34 return "X86ISD::" #NODE;
68 switch (
N->getOpcode()) {
72 case X86ISD::TC_RETURN:
73 case X86ISD::TC_RETURN_GLOBALADDR: {
88 EVT ExpectedVT = WantI64 ? MVT::i64 : MVT::i32;
92 " operand #1 must have type " +
113 return Subtarget.is64Bit() ? MVT::i64 : MVT::i32;
117bool X86SelectionDAGInfo::isBaseRegConflictPossible(
128 const X86RegisterInfo *
TRI =
static_cast<const X86RegisterInfo *
>(
138 unsigned AX = X86::AL;
154 const unsigned CX = Use64BitRegs ? X86::RCX : X86::ECX;
155 const unsigned DI = Use64BitRegs ? X86::RDI : X86::EDI;
167 return DAG.
getNode(X86ISD::REP_STOS, dl, Tys,
Ops);
174 return emitRepstos(Subtarget, DAG, dl, Chain, Dst, Val,
187 bool isVolatile,
bool AlwaysInline,
195 if ((
Size & 31) == 0 && (ValC->getZExtValue() & 255) == 0) {
196 MVT BlockType = MVT::i32;
197 const uint64_t BlockBits = BlockType.getSizeInBits();
198 const uint64_t BlockBytes = BlockBits / 8;
203 return emitRepstos(Subtarget, DAG, dl, Chain, Dst, Val,
216 if (Alignment <
Align(4))
219 MVT BlockType = MVT::i8;
227 const uint64_t BlockBits = BlockType.getSizeInBits();
238 const uint64_t BlockBytes = BlockBits / 8;
239 BlockCount =
Size / BlockBytes;
240 BytesLeft =
Size % BlockBytes;
255 EVT AddrVT = Dst.getValueType();
261 OriginalVal, DAG.
getConstant(BytesLeft, dl, SizeVT),
262 Alignment, isVolatile, AlwaysInline,
285 const MCPhysReg ClobberSet[] = {X86::RCX, X86::RAX, X86::RDI,
286 X86::ECX, X86::EAX, X86::EDI};
287 if (isBaseRegConflictPossible(DAG, ClobberSet))
295 DAG, Subtarget, dl, Chain, Dst, Val, ConstantSize->
getZExtValue(),
296 Size.getValueType(), Alignment, isVolatile, AlwaysInline, DstPtrInfo);
304 const unsigned CX = Use64BitRegs ? X86::RCX : X86::ECX;
305 const unsigned DI = Use64BitRegs ? X86::RDI : X86::EDI;
306 const unsigned SI = Use64BitRegs ? X86::RSI : X86::ESI;
318 return DAG.
getNode(X86ISD::REP_MOVS, dl, Tys,
Ops);
325 return emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src,
336 Align Alignment,
bool isVolatile,
bool AlwaysInline,
349 if (Subtarget.hasERMSB())
352 assert(!Subtarget.hasERMSB() &&
"No efficient RepMovs");
355 if (!AlwaysInline && (Alignment <
Align(4)))
359 const uint64_t BlockBytes = BlockType.getSizeInBits() / 8;
370 assert(BytesLeft &&
"We have leftover at this point");
376 EVT DstVT = Dst.getValueType();
377 EVT SrcVT = Src.getValueType();
382 DAG.
getConstant(BytesLeft, dl, SizeVT), Alignment, Alignment, isVolatile,
383 true,
nullptr, std::nullopt,
407 const MCPhysReg ClobberSet[] = {X86::RCX, X86::RSI, X86::RDI,
408 X86::ECX, X86::ESI, X86::EDI};
409 if (isBaseRegConflictPossible(DAG, ClobberSet))
413 if (Subtarget.
getCLOpts().use_fsrm_for_memcpy && Subtarget.hasFSRM())
414 return emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src,
Size, MVT::i8);
418 Align Alignment = std::min(DstAlign, SrcAlign);
420 ConstantSize->getZExtValue(),
421 Size.getValueType(), Alignment, isVolatile,
422 AlwaysInline, DstPtrInfo, SrcPtrInfo);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define NODE_NAME_CASE(node)
Function Alias Analysis Results
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
This file describes how to lower LLVM code to machine code.
static SDValue emitRepstos(const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, SDValue Size, MVT AVT)
Emit a single REP STOSB instruction for a particular constant size.
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.
static SDValue emitRepstosB(const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, uint64_t Size)
Emit a single REP STOSB instruction for a particular constant size.
static SDValue emitConstantSizeRepmov(SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, EVT SizeVT, Align Alignment, 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...
static MVT getOptimalRepType(const X86Subtarget &Subtarget, Align Alignment)
Returns the best type to use with repmovs/repstos depending on alignment.
static SDValue emitConstantSizeRepstos(SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, uint64_t Size, EVT SizeVT, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo)
Returns a REP STOS instruction, possibly with a few load/stores to implement a constant size memory s...
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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
uint64_t getZExtValue() const
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDValue getValue(unsigned R) const
const char * getTargetNodeName(unsigned Opcode) const override
Returns the name of the given target-specific opcode, suitable for debug printing.
SelectionDAGGenTargetInfo(const SDNodeInfo &GenNodeInfo)
bool isTargetMemoryOpcode(unsigned Opcode) const override
Returns true if a node with the given target-specific opcode has a memory operand.
void verifyTargetNode(const SelectionDAG &DAG, const SDNode *N) const override
Checks that the given target-specific node is valid. Aborts if it is not.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, MachinePointerInfo DstPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
MachineFunction & getMachineFunction() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
bool isTargetMemoryOpcode(unsigned Opcode) const override
Returns true if a node with the given target-specific opcode has a memory operand.
void verifyTargetNode(const SelectionDAG &DAG, const SDNode *N) const override
Checks that the given target-specific node is valid. Aborts if it is not.
const char * getTargetNodeName(unsigned Opcode) const override
Returns the name of the given target-specific opcode, suitable for debug printing.
SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline, 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 DstAlign, Align SrcAlign, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
bool isRegisterReservedByUser(Register i) const override
unsigned getMaxInlineSizeThreshold() const
Returns the maximum memset / memcpy size that still makes it profitable to inline the call.
const X86Options & getCLOpts() const
@ ADD
Simple integer binary arithmetic operators.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
This struct is a compact representation of a valid (non-zero power of two) alignment.
LLVM_ABI std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
This class contains a discriminated union of information about pointers in memory operands,...
LLVM_ABI unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
MachinePointerInfo getWithOffset(int64_t O) const
This represents a list of ValueType's that has been intern'd by a SelectionDAG.