Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 1 | //===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the AArch64SelectionDAGInfo class. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "AArch64TargetMachine.h" |
| 14 | using namespace llvm; |
| 15 | |
| 16 | #define DEBUG_TYPE "aarch64-selectiondag-info" |
| 17 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 18 | SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset( |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 19 | SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 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); |
Eric Christopher | 3ee30d0 | 2015-02-20 08:39:06 +0000 | [diff] [blame] | 25 | const AArch64Subtarget &STI = |
| 26 | DAG.getMachineFunction().getSubtarget<AArch64Subtarget>(); |
Matthias Braun | a92cecf | 2017-12-18 23:14:28 +0000 | [diff] [blame] | 27 | const char *bzeroName = (V && V->isNullValue()) |
| 28 | ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) : nullptr; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 29 | // For small size (< 256), it is not beneficial to use bzero |
| 30 | // instead of memset. |
Matthias Braun | a92cecf | 2017-12-18 23:14:28 +0000 | [diff] [blame] | 31 | if (bzeroName && (!SizeValue || SizeValue->getZExtValue() > 256)) { |
Eric Christopher | 3ee30d0 | 2015-02-20 08:39:06 +0000 | [diff] [blame] | 32 | const AArch64TargetLowering &TLI = *STI.getTargetLowering(); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 33 | |
Mehdi Amini | 44ede33 | 2015-07-09 02:09:04 +0000 | [diff] [blame] | 34 | EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout()); |
| 35 | Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 36 | TargetLowering::ArgListTy Args; |
| 37 | TargetLowering::ArgListEntry Entry; |
| 38 | Entry.Node = Dst; |
| 39 | Entry.Ty = IntPtrTy; |
| 40 | Args.push_back(Entry); |
| 41 | Entry.Node = Size; |
| 42 | Args.push_back(Entry); |
| 43 | TargetLowering::CallLoweringInfo CLI(DAG); |
Nirav Dave | 6de2c77 | 2017-03-18 00:43:57 +0000 | [diff] [blame] | 44 | CLI.setDebugLoc(dl) |
| 45 | .setChain(Chain) |
Nirav Dave | ac6081c | 2017-03-18 00:44:07 +0000 | [diff] [blame] | 46 | .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()), |
Matthias Braun | a92cecf | 2017-12-18 23:14:28 +0000 | [diff] [blame] | 47 | DAG.getExternalSymbol(bzeroName, IntPtr), |
Nirav Dave | ac6081c | 2017-03-18 00:44:07 +0000 | [diff] [blame] | 48 | std::move(Args)) |
Nirav Dave | 6de2c77 | 2017-03-18 00:43:57 +0000 | [diff] [blame] | 49 | .setDiscardResult(); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 50 | std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI); |
| 51 | return CallResult.second; |
| 52 | } |
| 53 | return SDValue(); |
| 54 | } |
Gerolf Hoflehner | 5042619 | 2016-04-27 17:27:16 +0000 | [diff] [blame] | 55 | bool AArch64SelectionDAGInfo::generateFMAsInMachineCombiner( |
Gerolf Hoflehner | 01b3a618 | 2016-04-24 05:14:01 +0000 | [diff] [blame] | 56 | CodeGenOpt::Level OptLevel) const { |
Davide Italiano | 0145e75 | 2017-03-22 23:37:58 +0000 | [diff] [blame] | 57 | return OptLevel >= CodeGenOpt::Aggressive; |
Gerolf Hoflehner | 01b3a618 | 2016-04-24 05:14:01 +0000 | [diff] [blame] | 58 | } |