LLVM  14.0.0git
HexagonSelectionDAGInfo.cpp
Go to the documentation of this file.
1 //===-- HexagonSelectionDAGInfo.cpp - Hexagon SelectionDAG Info -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the HexagonSelectionDAGInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "HexagonTargetMachine.h"
15 using namespace llvm;
16 
17 #define DEBUG_TYPE "hexagon-selectiondag-info"
18 
20  SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
21  SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
22  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
23  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
24  if (AlwaysInline || Alignment < Align(4) || !ConstantSize)
25  return SDValue();
26 
27  uint64_t SizeVal = ConstantSize->getZExtValue();
28  if (SizeVal < 32 || (SizeVal % 8) != 0)
29  return SDValue();
30 
31  // Special case aligned memcpys with size >= 32 bytes and a multiple of 8.
32  //
33  const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
36  Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
37  Entry.Node = Dst;
38  Args.push_back(Entry);
39  Entry.Node = Src;
40  Args.push_back(Entry);
41  Entry.Node = Size;
42  Args.push_back(Entry);
43 
44  const char *SpecialMemcpyName =
45  "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
46  const MachineFunction &MF = DAG.getMachineFunction();
47  bool LongCalls = MF.getSubtarget<HexagonSubtarget>().useLongCalls();
48  unsigned Flags = LongCalls ? HexagonII::HMOTF_ConstExtended : 0;
49 
51  CLI.setDebugLoc(dl)
52  .setChain(Chain)
53  .setLibCallee(
57  SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout()), Flags),
58  std::move(Args))
60 
61  std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
62  return CallResult.second;
63 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::ConstantSDNode
Definition: SelectionDAGNodes.h:1556
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SDLoc
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Definition: SelectionDAGNodes.h:1086
llvm::TargetLowering::CallLoweringInfo::setChain
CallLoweringInfo & setChain(SDValue InChain)
Definition: TargetLowering.h:3791
llvm::ARMISD::MEMCPY
@ MEMCPY
Definition: ARMISelLowering.h:309
llvm::TargetLowering::LowerCallTo
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
Definition: SelectionDAGBuilder.cpp:9534
HexagonTargetMachine.h
SelectionDAG.h
llvm::SelectionDAG::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:442
llvm::SelectionDAG::getContext
LLVMContext * getContext() const
Definition: SelectionDAG.h:447
llvm::SelectionDAG
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:216
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3189
llvm::TargetLowering::CallLoweringInfo::setDebugLoc
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
Definition: TargetLowering.h:3786
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::TargetLowering::CallLoweringInfo::setLibCallee
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
Definition: TargetLowering.h:3797
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:626
uint64_t
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:38
move
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
Definition: README.txt:546
llvm::TargetLowering::CallLoweringInfo
This structure contains all information that is necessary for lowering calls.
Definition: TargetLowering.h:3747
llvm::TargetLoweringBase::ArgListEntry
Definition: TargetLowering.h:274
llvm::ConstantSDNode::getZExtValue
uint64_t getZExtValue() const
Definition: SelectionDAGNodes.h:1571
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::HexagonII::HMOTF_ConstExtended
@ HMOTF_ConstExtended
Definition: HexagonBaseInfo.h:216
llvm::TargetLoweringBase::ArgListTy
std::vector< ArgListEntry > ArgListTy
Definition: TargetLowering.h:304
llvm::DataLayout::getIntPtrType
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.
Definition: DataLayout.cpp:834
llvm::TargetLowering::CallLoweringInfo::setDiscardResult
CallLoweringInfo & setDiscardResult(bool Value=true)
Definition: TargetLowering.h:3866
llvm::SelectionDAG::getDataLayout
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:440
llvm::SelectionDAG::getTargetExternalSymbol
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
Definition: SelectionDAG.cpp:1753
llvm::SDValue
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Definition: SelectionDAGNodes.h:138
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:186
llvm::TargetSubtargetInfo::getTargetLowering
virtual const TargetLowering * getTargetLowering() const
Definition: TargetSubtargetInfo.h:96
llvm::HexagonSubtarget
Definition: HexagonSubtarget.h:43
llvm::SelectionDAG::getMachineFunction
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:437
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::HexagonSelectionDAGInfo::EmitTargetCodeForMemcpy
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.
Definition: HexagonSelectionDAGInfo.cpp:19
llvm::TargetLoweringBase::getLibcallCallingConv
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
Definition: TargetLowering.h:2881
llvm::TargetLoweringBase::getPointerTy
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...
Definition: TargetLowering.h:346