1327952Sdim//==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==// 2303231Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6303231Sdim// 7303231Sdim//===----------------------------------------------------------------------===// 8303231Sdim// 9303231Sdim// This file declares the SelectionDAGTargetInfo class, which targets can 10303231Sdim// subclass to parameterize the SelectionDAG lowering and instruction 11303231Sdim// selection process. 12303231Sdim// 13303231Sdim//===----------------------------------------------------------------------===// 14303231Sdim 15303231Sdim#ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H 16303231Sdim#define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H 17303231Sdim 18327952Sdim#include "llvm/CodeGen/MachineMemOperand.h" 19303231Sdim#include "llvm/CodeGen/SelectionDAGNodes.h" 20303231Sdim#include "llvm/Support/CodeGen.h" 21327952Sdim#include <utility> 22303231Sdim 23303231Sdimnamespace llvm { 24303231Sdim 25327952Sdimclass SelectionDAG; 26327952Sdim 27303231Sdim//===----------------------------------------------------------------------===// 28303231Sdim/// Targets can subclass this to parameterize the 29303231Sdim/// SelectionDAG lowering and instruction selection process. 30303231Sdim/// 31303231Sdimclass SelectionDAGTargetInfo { 32303231Sdimpublic: 33303231Sdim explicit SelectionDAGTargetInfo() = default; 34327952Sdim SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete; 35327952Sdim SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete; 36303231Sdim virtual ~SelectionDAGTargetInfo(); 37303231Sdim 38303231Sdim /// Emit target-specific code that performs a memcpy. 39303231Sdim /// This can be used by targets to provide code sequences for cases 40303231Sdim /// that don't fit the target's parameters for simple loads/stores and can be 41303231Sdim /// more efficient than using a library call. This function can return a null 42303231Sdim /// SDValue if the target declines to use custom code and a different 43303231Sdim /// lowering strategy should be used. 44303231Sdim /// 45303231Sdim /// If AlwaysInline is true, the size is constant and the target should not 46303231Sdim /// emit any calls and is strongly encouraged to attempt to emit inline code 47303231Sdim /// even if it is beyond the usual threshold because this intrinsic is being 48303231Sdim /// expanded in a place where calls are not feasible (e.g. within the prologue 49303231Sdim /// for another call). If the target chooses to decline an AlwaysInline 50303231Sdim /// request here, legalize will resort to using simple loads and stores. 51303231Sdim virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, 52303231Sdim SDValue Chain, SDValue Op1, 53303231Sdim SDValue Op2, SDValue Op3, 54303231Sdim unsigned Align, bool isVolatile, 55303231Sdim bool AlwaysInline, 56303231Sdim MachinePointerInfo DstPtrInfo, 57303231Sdim MachinePointerInfo SrcPtrInfo) const { 58303231Sdim return SDValue(); 59303231Sdim } 60303231Sdim 61303231Sdim /// Emit target-specific code that performs a memmove. 62303231Sdim /// This can be used by targets to provide code sequences for cases 63303231Sdim /// that don't fit the target's parameters for simple loads/stores and can be 64303231Sdim /// more efficient than using a library call. This function can return a null 65303231Sdim /// SDValue if the target declines to use custom code and a different 66303231Sdim /// lowering strategy should be used. 67303231Sdim virtual SDValue EmitTargetCodeForMemmove( 68303231Sdim SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, 69303231Sdim SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, 70303231Sdim MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const { 71303231Sdim return SDValue(); 72303231Sdim } 73303231Sdim 74303231Sdim /// Emit target-specific code that performs a memset. 75303231Sdim /// This can be used by targets to provide code sequences for cases 76303231Sdim /// that don't fit the target's parameters for simple stores and can be more 77303231Sdim /// efficient than using a library call. This function can return a null 78303231Sdim /// SDValue if the target declines to use custom code and a different 79303231Sdim /// lowering strategy should be used. 80303231Sdim virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, 81303231Sdim SDValue Chain, SDValue Op1, 82303231Sdim SDValue Op2, SDValue Op3, 83303231Sdim unsigned Align, bool isVolatile, 84303231Sdim MachinePointerInfo DstPtrInfo) const { 85303231Sdim return SDValue(); 86303231Sdim } 87303231Sdim 88303231Sdim /// Emit target-specific code that performs a memcmp, in cases where that is 89303231Sdim /// faster than a libcall. The first returned SDValue is the result of the 90303231Sdim /// memcmp and the second is the chain. Both SDValues can be null if a normal 91303231Sdim /// libcall should be used. 92303231Sdim virtual std::pair<SDValue, SDValue> 93303231Sdim EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, 94303231Sdim SDValue Op1, SDValue Op2, SDValue Op3, 95303231Sdim MachinePointerInfo Op1PtrInfo, 96303231Sdim MachinePointerInfo Op2PtrInfo) const { 97303231Sdim return std::make_pair(SDValue(), SDValue()); 98303231Sdim } 99303231Sdim 100303231Sdim /// Emit target-specific code that performs a memchr, in cases where that is 101303231Sdim /// faster than a libcall. The first returned SDValue is the result of the 102303231Sdim /// memchr and the second is the chain. Both SDValues can be null if a normal 103303231Sdim /// libcall should be used. 104303231Sdim virtual std::pair<SDValue, SDValue> 105303231Sdim EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, 106303231Sdim SDValue Src, SDValue Char, SDValue Length, 107303231Sdim MachinePointerInfo SrcPtrInfo) const { 108303231Sdim return std::make_pair(SDValue(), SDValue()); 109303231Sdim } 110303231Sdim 111303231Sdim /// Emit target-specific code that performs a strcpy or stpcpy, in cases 112303231Sdim /// where that is faster than a libcall. 113303231Sdim /// The first returned SDValue is the result of the copy (the start 114303231Sdim /// of the destination string for strcpy, a pointer to the null terminator 115303231Sdim /// for stpcpy) and the second is the chain. Both SDValues can be null 116303231Sdim /// if a normal libcall should be used. 117303231Sdim virtual std::pair<SDValue, SDValue> 118303231Sdim EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, 119303231Sdim SDValue Dest, SDValue Src, 120303231Sdim MachinePointerInfo DestPtrInfo, 121303231Sdim MachinePointerInfo SrcPtrInfo, bool isStpcpy) const { 122303231Sdim return std::make_pair(SDValue(), SDValue()); 123303231Sdim } 124303231Sdim 125303231Sdim /// Emit target-specific code that performs a strcmp, in cases where that is 126303231Sdim /// faster than a libcall. 127303231Sdim /// The first returned SDValue is the result of the strcmp and the second is 128303231Sdim /// the chain. Both SDValues can be null if a normal libcall should be used. 129303231Sdim virtual std::pair<SDValue, SDValue> 130303231Sdim EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, 131303231Sdim SDValue Op1, SDValue Op2, 132303231Sdim MachinePointerInfo Op1PtrInfo, 133303231Sdim MachinePointerInfo Op2PtrInfo) const { 134303231Sdim return std::make_pair(SDValue(), SDValue()); 135303231Sdim } 136303231Sdim 137303231Sdim virtual std::pair<SDValue, SDValue> 138303231Sdim EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, 139303231Sdim SDValue Src, MachinePointerInfo SrcPtrInfo) const { 140303231Sdim return std::make_pair(SDValue(), SDValue()); 141303231Sdim } 142303231Sdim 143303231Sdim virtual std::pair<SDValue, SDValue> 144303231Sdim EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, 145303231Sdim SDValue Src, SDValue MaxLength, 146303231Sdim MachinePointerInfo SrcPtrInfo) const { 147303231Sdim return std::make_pair(SDValue(), SDValue()); 148303231Sdim } 149327952Sdim 150353358Sdim virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl, 151353358Sdim SDValue Chain, SDValue Addr, 152353358Sdim SDValue Size, 153353358Sdim MachinePointerInfo DstPtrInfo, 154353358Sdim bool ZeroData) const { 155353358Sdim return SDValue(); 156353358Sdim } 157353358Sdim 158303231Sdim // Return true when the decision to generate FMA's (or FMS, FMLA etc) rather 159303231Sdim // than FMUL and ADD is delegated to the machine combiner. 160303231Sdim virtual bool generateFMAsInMachineCombiner(CodeGenOpt::Level OptLevel) const { 161303231Sdim return false; 162303231Sdim } 163303231Sdim}; 164303231Sdim 165327952Sdim} // end namespace llvm 166303231Sdim 167327952Sdim#endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H 168