LLVM  3.7.0
XCoreSelectionDAGInfo.cpp
Go to the documentation of this file.
1 //===-- XCoreSelectionDAGInfo.cpp - XCore 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 XCoreSelectionDAGInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "XCoreTargetMachine.h"
15 using namespace llvm;
16 
17 #define DEBUG_TYPE "xcore-selectiondag-info"
18 
21  SDValue Dst, SDValue Src, SDValue Size, unsigned Align,
22  bool isVolatile, bool AlwaysInline,
23  MachinePointerInfo DstPtrInfo,
24  MachinePointerInfo SrcPtrInfo) const
25 {
26  unsigned SizeBitWidth = Size.getValueType().getSizeInBits();
27  // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
28  if (!AlwaysInline && (Align & 3) == 0 &&
29  DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) {
30  const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
33  Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
34  Entry.Node = Dst; Args.push_back(Entry);
35  Entry.Node = Src; Args.push_back(Entry);
36  Entry.Node = Size; Args.push_back(Entry);
37 
39  CLI.setDebugLoc(dl)
40  .setChain(Chain)
43  DAG.getExternalSymbol("__memcpy_4",
44  TLI.getPointerTy(DAG.getDataLayout())),
45  std::move(Args), 0)
46  .setDiscardResult();
47 
48  std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
49  return CallResult.second;
50  }
51 
52  // Otherwise have the target-independent code call memcpy.
53  return SDValue();
54 }
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList, unsigned FixedArgs=-1)
LLVMContext * getContext() const
Definition: SelectionDAG.h:289
CallLoweringInfo & setDebugLoc(SDLoc dl)
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:286
SDValue getExternalSymbol(const char *Sym, EVT VT)
CallLoweringInfo & setChain(SDValue InChain)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:284
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:225
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
std::vector< ArgListEntry > ArgListTy
This structure contains all information that is necessary for lowering calls.
MachinePointerInfo - This class contains a discriminated union of information about pointers in memor...
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:694
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
EmitTargetCodeForMemcpy - Emit target-specific code that performs a memcpy.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:179
virtual const TargetLowering * getTargetLowering() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Class for arbitrary precision integers.
Definition: APInt.h:73
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
Definition: ValueTypes.h:233
EVT getValueType() const
Return the ValueType of the referenced return value.
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...
static bool isVolatile(Instruction *Inst)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...