19 #define DEBUG_TYPE "arm-selectiondag-info"
33 if (std::strncmp(TLI->getLibcallName(LC),
"__aeabi", 7) != 0)
47 AEABILibcall = AEABI_MEMCPY;
50 AEABILibcall = AEABI_MEMMOVE;
53 AEABILibcall = AEABI_MEMSET;
55 if (ConstantSrc->getZExtValue() == 0)
56 AEABILibcall = AEABI_MEMCLR;
69 AlignVariant = ALIGN8;
70 else if ((Align & 3) == 0)
71 AlignVariant = ALIGN4;
73 AlignVariant = ALIGN1;
79 Args.push_back(Entry);
80 if (AEABILibcall == AEABI_MEMCLR) {
82 Args.push_back(Entry);
83 }
else if (AEABILibcall == AEABI_MEMSET) {
88 Args.push_back(Entry);
99 Args.push_back(Entry);
102 Args.push_back(Entry);
105 Args.push_back(Entry);
108 char const *FunctionNames[4][3] = {
109 {
"__aeabi_memcpy",
"__aeabi_memcpy4",
"__aeabi_memcpy8" },
110 {
"__aeabi_memmove",
"__aeabi_memmove4",
"__aeabi_memmove8" },
111 {
"__aeabi_memset",
"__aeabi_memset4",
"__aeabi_memset8" },
112 {
"__aeabi_memclr",
"__aeabi_memclr4",
"__aeabi_memclr8" }
123 std::pair<SDValue,SDValue> CallResult = TLI->LowerCallTo(CLI);
125 return CallResult.second;
136 if ((Align & 3) != 0)
149 unsigned BytesLeft = SizeVal & 3;
150 unsigned NumMemOps = SizeVal >> 2;
151 unsigned EmittedNumMemOps = 0;
156 const unsigned MaxLoadsInLDM = Subtarget.
isThumb1Only() ? 4 : 6;
159 uint64_t SrcOff = 0, DstOff = 0;
170 unsigned NumMEMCPYs = (NumMemOps + MaxLoadsInLDM - 1) / MaxLoadsInLDM;
180 for (
unsigned I = 0;
I != NumMEMCPYs; ++
I) {
183 unsigned NextEmittedNumMemOps = NumMemOps * (
I + 1) / NumMEMCPYs;
184 unsigned NumRegs = NextEmittedNumMemOps - EmittedNumMemOps;
194 EmittedNumMemOps = NextEmittedNumMemOps;
201 auto getRemainingValueType = [](
unsigned BytesLeft) {
204 auto getRemainingSize = [](
unsigned BytesLeft) {
205 return (BytesLeft >= 2) ? 2 : 1;
208 unsigned BytesLeftSave = BytesLeft;
211 VT = getRemainingValueType(BytesLeft);
212 VTSize = getRemainingSize(BytesLeft);
213 Loads[i] = DAG.
getLoad(VT, dl, Chain,
226 BytesLeft = BytesLeftSave;
228 VT = getRemainingValueType(BytesLeft);
229 VTSize = getRemainingSize(BytesLeft);
230 TFOps[i] = DAG.
getStore(Chain, dl, Loads[i],
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
SDValue getValue(unsigned R) const
LLVMContext * getContext() const
const ARMTargetLowering * getTargetLowering() const override
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
SDValue EmitTargetCodeForMemmove(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memmove.
SDValue EmitSpecializedLibcall(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, RTLIB::Libcall LC) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isThumb1Only() const
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
MachineFunction & getMachineFunction() const
CallLoweringInfo & setChain(SDValue InChain)
MachinePointerInfo getWithOffset(int64_t O) const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
Simple integer binary arithmetic operators.
const DataLayout & getDataLayout() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
static Type * getVoidTy(LLVMContext &C)
std::vector< ArgListEntry > ArgListTy
This structure contains all information that is necessary for lowering calls.
This class contains a discriminated union of information about pointers in memory operands...
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
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...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
unsigned getMaxInlineSizeThreshold() const
getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size that still makes it profitable t...
ZERO_EXTEND - Used for integer types, zeroing the new bits.
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static IntegerType * getInt32Ty(LLVMContext &C)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
static bool isVolatile(Instruction *Inst)
TRUNCATE - Completely drop the high bits.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo) const override
Emit target-specific code that performs a memset.
uint64_t getZExtValue() const