1 //===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements the AArch64SelectionDAGInfo class.
11 //===----------------------------------------------------------------------===//
13 #include "AArch64TargetMachine.h"
16 #define DEBUG_TYPE "aarch64-selectiondag-info"
18 SDValue
AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
19 SelectionDAG
&DAG
, const SDLoc
&dl
, SDValue Chain
, SDValue Dst
, SDValue Src
,
20 SDValue Size
, unsigned Align
, bool isVolatile
,
21 MachinePointerInfo DstPtrInfo
) const {
22 // Check to see if there is a specialized entry-point for memory zeroing.
23 ConstantSDNode
*V
= dyn_cast
<ConstantSDNode
>(Src
);
24 ConstantSDNode
*SizeValue
= dyn_cast
<ConstantSDNode
>(Size
);
25 const AArch64Subtarget
&STI
=
26 DAG
.getMachineFunction().getSubtarget
<AArch64Subtarget
>();
27 const char *bzeroName
= (V
&& V
->isNullValue())
28 ? DAG
.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO
) : nullptr;
29 // For small size (< 256), it is not beneficial to use bzero
31 if (bzeroName
&& (!SizeValue
|| SizeValue
->getZExtValue() > 256)) {
32 const AArch64TargetLowering
&TLI
= *STI
.getTargetLowering();
34 EVT IntPtr
= TLI
.getPointerTy(DAG
.getDataLayout());
35 Type
*IntPtrTy
= DAG
.getDataLayout().getIntPtrType(*DAG
.getContext());
36 TargetLowering::ArgListTy Args
;
37 TargetLowering::ArgListEntry Entry
;
40 Args
.push_back(Entry
);
42 Args
.push_back(Entry
);
43 TargetLowering::CallLoweringInfo
CLI(DAG
);
46 .setLibCallee(CallingConv::C
, Type::getVoidTy(*DAG
.getContext()),
47 DAG
.getExternalSymbol(bzeroName
, IntPtr
),
50 std::pair
<SDValue
, SDValue
> CallResult
= TLI
.LowerCallTo(CLI
);
51 return CallResult
.second
;
55 bool AArch64SelectionDAGInfo::generateFMAsInMachineCombiner(
56 CodeGenOpt::Level OptLevel
) const {
57 return OptLevel
>= CodeGenOpt::Aggressive
;