LLVM  6.0.0svn
Go to the documentation of this file.
1 //===-- HexagonSelectionDAGInfo.cpp - Hexagon SelectionDAG Info -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the HexagonSelectionDAGInfo class.
11 //
12 //===----------------------------------------------------------------------===//
14 #include "HexagonTargetMachine.h"
16 using namespace llvm;
18 #define DEBUG_TYPE "hexagon-selectiondag-info"
21  SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
22  SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
23  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
24  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
25  if (AlwaysInline || (Align & 0x3) != 0 || !ConstantSize)
26  return SDValue();
28  uint64_t SizeVal = ConstantSize->getZExtValue();
29  if (SizeVal < 32 || (SizeVal % 8) != 0)
30  return SDValue();
32  // Special case aligned memcpys with size >= 32 bytes and a multiple of 8.
33  //
34  const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
37  Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
38  Entry.Node = Dst;
39  Args.push_back(Entry);
40  Entry.Node = Src;
41  Args.push_back(Entry);
42  Entry.Node = Size;
43  Args.push_back(Entry);
45  const char *SpecialMemcpyName =
46  "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
47  const MachineFunction &MF = DAG.getMachineFunction();
48  bool LongCalls = MF.getSubtarget<HexagonSubtarget>().useLongCalls();
49  unsigned Flags = LongCalls ? HexagonII::HMOTF_ConstExtended : 0;
52  CLI.setDebugLoc(dl)
53  .setChain(Chain)
54  .setLibCallee(
58  SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout()), Flags),
59  std::move(Args))
60  .setDiscardResult();
62  std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
63  return CallResult.second;
64 }
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
virtual const TargetLowering * getTargetLowering() const
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
CallLoweringInfo & setChain(SDValue InChain)
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:388
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:385
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
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.
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:702
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...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:161
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...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:209
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:390
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static bool isVolatile(Instruction *Inst)
uint64_t getZExtValue() const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
LLVMContext * getContext() const
Definition: SelectionDAG.h:393
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)