LLVM 20.0.0git
XCoreSelectionDAGInfo.cpp
Go to the documentation of this file.
1//===-- XCoreSelectionDAGInfo.cpp - XCore 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 XCoreSelectionDAGInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "XCoreTargetMachine.h"
14using namespace llvm;
15
16#define DEBUG_TYPE "xcore-selectiondag-info"
17
19 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
20 SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
21 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
22 unsigned SizeBitWidth = Size.getValueSizeInBits();
23 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
24 if (!AlwaysInline && Alignment >= Align(4) &&
25 DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) {
26 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
29 Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
30 Entry.Node = Dst; Args.push_back(Entry);
31 Entry.Node = Src; Args.push_back(Entry);
32 Entry.Node = Size; Args.push_back(Entry);
33
35 CLI.setDebugLoc(dl)
36 .setChain(Chain)
37 .setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
40 "__memcpy_4", TLI.getPointerTy(DAG.getDataLayout())),
41 std::move(Args))
43
44 std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
45 return CallResult.second;
46 }
47
48 // Otherwise have the target-independent code call memcpy.
49 return SDValue();
50}
uint64_t Size
Class for arbitrary precision integers.
Definition: APInt.h:78
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:851
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:228
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:497
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:495
SDValue getExternalSymbol(const char *Sym, EVT VT)
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
LLVMContext * getContext() const
Definition: SelectionDAG.h:508
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
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...
std::vector< ArgListEntry > ArgListTy
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.
virtual const TargetLowering * getTargetLowering() const
static Type * getVoidTy(LLVMContext &C)
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
This class contains a discriminated union of information about pointers in memory operands,...
This structure contains all information that is necessary for lowering calls.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
CallLoweringInfo & setDiscardResult(bool Value=true)
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CallLoweringInfo & setChain(SDValue InChain)