xref: /openbsd-src/gnu/llvm/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h (revision d415bd752c734aee168c4ee86ff32e8cc249eb16)
109467b48Spatrick //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==//
209467b48Spatrick //
309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information.
509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
609467b48Spatrick //
709467b48Spatrick //===----------------------------------------------------------------------===//
809467b48Spatrick //
909467b48Spatrick // This file declares the SelectionDAGTargetInfo class, which targets can
1009467b48Spatrick // subclass to parameterize the SelectionDAG lowering and instruction
1109467b48Spatrick // selection process.
1209467b48Spatrick //
1309467b48Spatrick //===----------------------------------------------------------------------===//
1409467b48Spatrick 
1509467b48Spatrick #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
1609467b48Spatrick #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
1709467b48Spatrick 
1809467b48Spatrick #include "llvm/CodeGen/MachineMemOperand.h"
1909467b48Spatrick #include "llvm/CodeGen/SelectionDAGNodes.h"
2009467b48Spatrick #include "llvm/Support/CodeGen.h"
2109467b48Spatrick #include <utility>
2209467b48Spatrick 
2309467b48Spatrick namespace llvm {
2409467b48Spatrick 
2509467b48Spatrick class SelectionDAG;
2609467b48Spatrick 
2709467b48Spatrick //===----------------------------------------------------------------------===//
2809467b48Spatrick /// Targets can subclass this to parameterize the
2909467b48Spatrick /// SelectionDAG lowering and instruction selection process.
3009467b48Spatrick ///
3109467b48Spatrick class SelectionDAGTargetInfo {
3209467b48Spatrick public:
3309467b48Spatrick   explicit SelectionDAGTargetInfo() = default;
3409467b48Spatrick   SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete;
3509467b48Spatrick   SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete;
3609467b48Spatrick   virtual ~SelectionDAGTargetInfo();
3709467b48Spatrick 
3809467b48Spatrick   /// Emit target-specific code that performs a memcpy.
3909467b48Spatrick   /// This can be used by targets to provide code sequences for cases
4009467b48Spatrick   /// that don't fit the target's parameters for simple loads/stores and can be
4109467b48Spatrick   /// more efficient than using a library call. This function can return a null
4209467b48Spatrick   /// SDValue if the target declines to use custom code and a different
4309467b48Spatrick   /// lowering strategy should be used.
4409467b48Spatrick   ///
4509467b48Spatrick   /// If AlwaysInline is true, the size is constant and the target should not
4609467b48Spatrick   /// emit any calls and is strongly encouraged to attempt to emit inline code
4709467b48Spatrick   /// even if it is beyond the usual threshold because this intrinsic is being
4809467b48Spatrick   /// expanded in a place where calls are not feasible (e.g. within the prologue
4909467b48Spatrick   /// for another call). If the target chooses to decline an AlwaysInline
5009467b48Spatrick   /// request here, legalize will resort to using simple loads and stores.
EmitTargetCodeForMemcpy(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,Align Alignment,bool isVolatile,bool AlwaysInline,MachinePointerInfo DstPtrInfo,MachinePointerInfo SrcPtrInfo)5109467b48Spatrick   virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
5209467b48Spatrick                                           SDValue Chain, SDValue Op1,
5309467b48Spatrick                                           SDValue Op2, SDValue Op3,
54097a140dSpatrick                                           Align Alignment, bool isVolatile,
5509467b48Spatrick                                           bool AlwaysInline,
5609467b48Spatrick                                           MachinePointerInfo DstPtrInfo,
5709467b48Spatrick                                           MachinePointerInfo SrcPtrInfo) const {
5809467b48Spatrick     return SDValue();
5909467b48Spatrick   }
6009467b48Spatrick 
6109467b48Spatrick   /// Emit target-specific code that performs a memmove.
6209467b48Spatrick   /// This can be used by targets to provide code sequences for cases
6309467b48Spatrick   /// that don't fit the target's parameters for simple loads/stores and can be
6409467b48Spatrick   /// more efficient than using a library call. This function can return a null
6509467b48Spatrick   /// SDValue if the target declines to use custom code and a different
6609467b48Spatrick   /// lowering strategy should be used.
EmitTargetCodeForMemmove(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,Align Alignment,bool isVolatile,MachinePointerInfo DstPtrInfo,MachinePointerInfo SrcPtrInfo)6709467b48Spatrick   virtual SDValue EmitTargetCodeForMemmove(
6809467b48Spatrick       SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
69097a140dSpatrick       SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
7009467b48Spatrick       MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
7109467b48Spatrick     return SDValue();
7209467b48Spatrick   }
7309467b48Spatrick 
7409467b48Spatrick   /// Emit target-specific code that performs a memset.
7509467b48Spatrick   /// This can be used by targets to provide code sequences for cases
7609467b48Spatrick   /// that don't fit the target's parameters for simple stores and can be more
7709467b48Spatrick   /// efficient than using a library call. This function can return a null
7809467b48Spatrick   /// SDValue if the target declines to use custom code and a different
79*d415bd75Srobert   /// lowering strategy should be used. Note that if AlwaysInline is true the
80*d415bd75Srobert   /// function has to return a valid SDValue.
EmitTargetCodeForMemset(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,Align Alignment,bool isVolatile,bool AlwaysInline,MachinePointerInfo DstPtrInfo)8109467b48Spatrick   virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
8209467b48Spatrick                                           SDValue Chain, SDValue Op1,
8309467b48Spatrick                                           SDValue Op2, SDValue Op3,
84097a140dSpatrick                                           Align Alignment, bool isVolatile,
85*d415bd75Srobert                                           bool AlwaysInline,
8609467b48Spatrick                                           MachinePointerInfo DstPtrInfo) const {
8709467b48Spatrick     return SDValue();
8809467b48Spatrick   }
8909467b48Spatrick 
9073471bf0Spatrick   /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
9109467b48Spatrick   /// faster than a libcall. The first returned SDValue is the result of the
9209467b48Spatrick   /// memcmp and the second is the chain. Both SDValues can be null if a normal
9309467b48Spatrick   /// libcall should be used.
9409467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemcmp(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)9509467b48Spatrick   EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
9609467b48Spatrick                           SDValue Op1, SDValue Op2, SDValue Op3,
9709467b48Spatrick                           MachinePointerInfo Op1PtrInfo,
9809467b48Spatrick                           MachinePointerInfo Op2PtrInfo) const {
9909467b48Spatrick     return std::make_pair(SDValue(), SDValue());
10009467b48Spatrick   }
10109467b48Spatrick 
10209467b48Spatrick   /// Emit target-specific code that performs a memchr, in cases where that is
10309467b48Spatrick   /// faster than a libcall. The first returned SDValue is the result of the
10409467b48Spatrick   /// memchr and the second is the chain. Both SDValues can be null if a normal
10509467b48Spatrick   /// libcall should be used.
10609467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemchr(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Src,SDValue Char,SDValue Length,MachinePointerInfo SrcPtrInfo)10709467b48Spatrick   EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
10809467b48Spatrick                           SDValue Src, SDValue Char, SDValue Length,
10909467b48Spatrick                           MachinePointerInfo SrcPtrInfo) const {
11009467b48Spatrick     return std::make_pair(SDValue(), SDValue());
11109467b48Spatrick   }
11209467b48Spatrick 
11309467b48Spatrick   /// Emit target-specific code that performs a strcpy or stpcpy, in cases
11409467b48Spatrick   /// where that is faster than a libcall.
11509467b48Spatrick   /// The first returned SDValue is the result of the copy (the start
11609467b48Spatrick   /// of the destination string for strcpy, a pointer to the null terminator
11709467b48Spatrick   /// for stpcpy) and the second is the chain.  Both SDValues can be null
11809467b48Spatrick   /// if a normal libcall should be used.
11909467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcpy(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Dest,SDValue Src,MachinePointerInfo DestPtrInfo,MachinePointerInfo SrcPtrInfo,bool isStpcpy)12009467b48Spatrick   EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
12109467b48Spatrick                           SDValue Dest, SDValue Src,
12209467b48Spatrick                           MachinePointerInfo DestPtrInfo,
12309467b48Spatrick                           MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
12409467b48Spatrick     return std::make_pair(SDValue(), SDValue());
12509467b48Spatrick   }
12609467b48Spatrick 
12709467b48Spatrick   /// Emit target-specific code that performs a strcmp, in cases where that is
12809467b48Spatrick   /// faster than a libcall.
12909467b48Spatrick   /// The first returned SDValue is the result of the strcmp and the second is
13009467b48Spatrick   /// the chain. Both SDValues can be null if a normal libcall should be used.
13109467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcmp(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)13209467b48Spatrick   EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
13309467b48Spatrick                           SDValue Op1, SDValue Op2,
13409467b48Spatrick                           MachinePointerInfo Op1PtrInfo,
13509467b48Spatrick                           MachinePointerInfo Op2PtrInfo) const {
13609467b48Spatrick     return std::make_pair(SDValue(), SDValue());
13709467b48Spatrick   }
13809467b48Spatrick 
13909467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrlen(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Src,MachinePointerInfo SrcPtrInfo)14009467b48Spatrick   EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
14109467b48Spatrick                           SDValue Src, MachinePointerInfo SrcPtrInfo) const {
14209467b48Spatrick     return std::make_pair(SDValue(), SDValue());
14309467b48Spatrick   }
14409467b48Spatrick 
14509467b48Spatrick   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrnlen(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Src,SDValue MaxLength,MachinePointerInfo SrcPtrInfo)14609467b48Spatrick   EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
14709467b48Spatrick                            SDValue Src, SDValue MaxLength,
14809467b48Spatrick                            MachinePointerInfo SrcPtrInfo) const {
14909467b48Spatrick     return std::make_pair(SDValue(), SDValue());
15009467b48Spatrick   }
15109467b48Spatrick 
EmitTargetCodeForSetTag(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Addr,SDValue Size,MachinePointerInfo DstPtrInfo,bool ZeroData)15209467b48Spatrick   virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
15309467b48Spatrick                                           SDValue Chain, SDValue Addr,
15409467b48Spatrick                                           SDValue Size,
15509467b48Spatrick                                           MachinePointerInfo DstPtrInfo,
15609467b48Spatrick                                           bool ZeroData) const {
15709467b48Spatrick     return SDValue();
15809467b48Spatrick   }
15909467b48Spatrick 
160097a140dSpatrick   // Return true if the DAG Combiner should disable generic combines.
disableGenericCombines(CodeGenOpt::Level OptLevel)161097a140dSpatrick   virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const {
162097a140dSpatrick     return false;
163097a140dSpatrick   }
16409467b48Spatrick };
16509467b48Spatrick 
16609467b48Spatrick } // end namespace llvm
16709467b48Spatrick 
16809467b48Spatrick #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
169