xref: /aosp_15_r20/external/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file implements the AArch64SelectionDAGInfo class.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #include "AArch64TargetMachine.h"
15*9880d681SAndroid Build Coastguard Worker using namespace llvm;
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #define DEBUG_TYPE "aarch64-selectiondag-info"
18*9880d681SAndroid Build Coastguard Worker 
EmitTargetCodeForMemset(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Dst,SDValue Src,SDValue Size,unsigned Align,bool isVolatile,MachinePointerInfo DstPtrInfo) const19*9880d681SAndroid Build Coastguard Worker SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
20*9880d681SAndroid Build Coastguard Worker     SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
21*9880d681SAndroid Build Coastguard Worker     SDValue Size, unsigned Align, bool isVolatile,
22*9880d681SAndroid Build Coastguard Worker     MachinePointerInfo DstPtrInfo) const {
23*9880d681SAndroid Build Coastguard Worker   // Check to see if there is a specialized entry-point for memory zeroing.
24*9880d681SAndroid Build Coastguard Worker   ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
25*9880d681SAndroid Build Coastguard Worker   ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
26*9880d681SAndroid Build Coastguard Worker   const AArch64Subtarget &STI =
27*9880d681SAndroid Build Coastguard Worker       DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
28*9880d681SAndroid Build Coastguard Worker   const char *bzeroEntry =
29*9880d681SAndroid Build Coastguard Worker       (V && V->isNullValue()) ? STI.getBZeroEntry() : nullptr;
30*9880d681SAndroid Build Coastguard Worker   // For small size (< 256), it is not beneficial to use bzero
31*9880d681SAndroid Build Coastguard Worker   // instead of memset.
32*9880d681SAndroid Build Coastguard Worker   if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
33*9880d681SAndroid Build Coastguard Worker     const AArch64TargetLowering &TLI = *STI.getTargetLowering();
34*9880d681SAndroid Build Coastguard Worker 
35*9880d681SAndroid Build Coastguard Worker     EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout());
36*9880d681SAndroid Build Coastguard Worker     Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
37*9880d681SAndroid Build Coastguard Worker     TargetLowering::ArgListTy Args;
38*9880d681SAndroid Build Coastguard Worker     TargetLowering::ArgListEntry Entry;
39*9880d681SAndroid Build Coastguard Worker     Entry.Node = Dst;
40*9880d681SAndroid Build Coastguard Worker     Entry.Ty = IntPtrTy;
41*9880d681SAndroid Build Coastguard Worker     Args.push_back(Entry);
42*9880d681SAndroid Build Coastguard Worker     Entry.Node = Size;
43*9880d681SAndroid Build Coastguard Worker     Args.push_back(Entry);
44*9880d681SAndroid Build Coastguard Worker     TargetLowering::CallLoweringInfo CLI(DAG);
45*9880d681SAndroid Build Coastguard Worker     CLI.setDebugLoc(dl).setChain(Chain)
46*9880d681SAndroid Build Coastguard Worker       .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
47*9880d681SAndroid Build Coastguard Worker                  DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args))
48*9880d681SAndroid Build Coastguard Worker       .setDiscardResult();
49*9880d681SAndroid Build Coastguard Worker     std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
50*9880d681SAndroid Build Coastguard Worker     return CallResult.second;
51*9880d681SAndroid Build Coastguard Worker   }
52*9880d681SAndroid Build Coastguard Worker   return SDValue();
53*9880d681SAndroid Build Coastguard Worker }
generateFMAsInMachineCombiner(CodeGenOpt::Level OptLevel) const54*9880d681SAndroid Build Coastguard Worker bool AArch64SelectionDAGInfo::generateFMAsInMachineCombiner(
55*9880d681SAndroid Build Coastguard Worker     CodeGenOpt::Level OptLevel) const {
56*9880d681SAndroid Build Coastguard Worker   if (OptLevel >= CodeGenOpt::Aggressive)
57*9880d681SAndroid Build Coastguard Worker     return true;
58*9880d681SAndroid Build Coastguard Worker   return false;
59*9880d681SAndroid Build Coastguard Worker }
60