xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file declares the SelectionDAGTargetInfo class, which targets can
100b57cec5SDimitry Andric // subclass to parameterize the SelectionDAG lowering and instruction
110b57cec5SDimitry Andric // selection process.
120b57cec5SDimitry Andric //
130b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
160b57cec5SDimitry Andric #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric #include "llvm/CodeGen/MachineMemOperand.h"
190b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAGNodes.h"
200b57cec5SDimitry Andric #include "llvm/Support/CodeGen.h"
210b57cec5SDimitry Andric #include <utility>
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric namespace llvm {
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric class SelectionDAG;
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
280b57cec5SDimitry Andric /// Targets can subclass this to parameterize the
290b57cec5SDimitry Andric /// SelectionDAG lowering and instruction selection process.
300b57cec5SDimitry Andric ///
310b57cec5SDimitry Andric class SelectionDAGTargetInfo {
320b57cec5SDimitry Andric public:
330b57cec5SDimitry Andric   explicit SelectionDAGTargetInfo() = default;
340b57cec5SDimitry Andric   SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete;
350b57cec5SDimitry Andric   SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete;
360b57cec5SDimitry Andric   virtual ~SelectionDAGTargetInfo();
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   /// Emit target-specific code that performs a memcpy.
390b57cec5SDimitry Andric   /// This can be used by targets to provide code sequences for cases
400b57cec5SDimitry Andric   /// that don't fit the target's parameters for simple loads/stores and can be
410b57cec5SDimitry Andric   /// more efficient than using a library call. This function can return a null
420b57cec5SDimitry Andric   /// SDValue if the target declines to use custom code and a different
430b57cec5SDimitry Andric   /// lowering strategy should be used.
440b57cec5SDimitry Andric   ///
450b57cec5SDimitry Andric   /// If AlwaysInline is true, the size is constant and the target should not
460b57cec5SDimitry Andric   /// emit any calls and is strongly encouraged to attempt to emit inline code
470b57cec5SDimitry Andric   /// even if it is beyond the usual threshold because this intrinsic is being
480b57cec5SDimitry Andric   /// expanded in a place where calls are not feasible (e.g. within the prologue
490b57cec5SDimitry Andric   /// for another call). If the target chooses to decline an AlwaysInline
500b57cec5SDimitry Andric   /// 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)510b57cec5SDimitry Andric   virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
520b57cec5SDimitry Andric                                           SDValue Chain, SDValue Op1,
530b57cec5SDimitry Andric                                           SDValue Op2, SDValue Op3,
545ffd83dbSDimitry Andric                                           Align Alignment, bool isVolatile,
550b57cec5SDimitry Andric                                           bool AlwaysInline,
560b57cec5SDimitry Andric                                           MachinePointerInfo DstPtrInfo,
570b57cec5SDimitry Andric                                           MachinePointerInfo SrcPtrInfo) const {
580b57cec5SDimitry Andric     return SDValue();
590b57cec5SDimitry Andric   }
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   /// Emit target-specific code that performs a memmove.
620b57cec5SDimitry Andric   /// This can be used by targets to provide code sequences for cases
630b57cec5SDimitry Andric   /// that don't fit the target's parameters for simple loads/stores and can be
640b57cec5SDimitry Andric   /// more efficient than using a library call. This function can return a null
650b57cec5SDimitry Andric   /// SDValue if the target declines to use custom code and a different
660b57cec5SDimitry Andric   /// 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)670b57cec5SDimitry Andric   virtual SDValue EmitTargetCodeForMemmove(
680b57cec5SDimitry Andric       SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
695ffd83dbSDimitry Andric       SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
700b57cec5SDimitry Andric       MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
710b57cec5SDimitry Andric     return SDValue();
720b57cec5SDimitry Andric   }
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   /// Emit target-specific code that performs a memset.
750b57cec5SDimitry Andric   /// This can be used by targets to provide code sequences for cases
760b57cec5SDimitry Andric   /// that don't fit the target's parameters for simple stores and can be more
770b57cec5SDimitry Andric   /// efficient than using a library call. This function can return a null
780b57cec5SDimitry Andric   /// SDValue if the target declines to use custom code and a different
7981ad6265SDimitry Andric   /// lowering strategy should be used. Note that if AlwaysInline is true the
8081ad6265SDimitry Andric   /// 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)810b57cec5SDimitry Andric   virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
820b57cec5SDimitry Andric                                           SDValue Chain, SDValue Op1,
830b57cec5SDimitry Andric                                           SDValue Op2, SDValue Op3,
845ffd83dbSDimitry Andric                                           Align Alignment, bool isVolatile,
8581ad6265SDimitry Andric                                           bool AlwaysInline,
860b57cec5SDimitry Andric                                           MachinePointerInfo DstPtrInfo) const {
870b57cec5SDimitry Andric     return SDValue();
880b57cec5SDimitry Andric   }
890b57cec5SDimitry Andric 
90e8d8bef9SDimitry Andric   /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
910b57cec5SDimitry Andric   /// faster than a libcall. The first returned SDValue is the result of the
920b57cec5SDimitry Andric   /// memcmp and the second is the chain. Both SDValues can be null if a normal
930b57cec5SDimitry Andric   /// libcall should be used.
940b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemcmp(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)950b57cec5SDimitry Andric   EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
960b57cec5SDimitry Andric                           SDValue Op1, SDValue Op2, SDValue Op3,
970b57cec5SDimitry Andric                           MachinePointerInfo Op1PtrInfo,
980b57cec5SDimitry Andric                           MachinePointerInfo Op2PtrInfo) const {
990b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1000b57cec5SDimitry Andric   }
1010b57cec5SDimitry Andric 
1020b57cec5SDimitry Andric   /// Emit target-specific code that performs a memchr, in cases where that is
1030b57cec5SDimitry Andric   /// faster than a libcall. The first returned SDValue is the result of the
1040b57cec5SDimitry Andric   /// memchr and the second is the chain. Both SDValues can be null if a normal
1050b57cec5SDimitry Andric   /// libcall should be used.
1060b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemchr(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Src,SDValue Char,SDValue Length,MachinePointerInfo SrcPtrInfo)1070b57cec5SDimitry Andric   EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
1080b57cec5SDimitry Andric                           SDValue Src, SDValue Char, SDValue Length,
1090b57cec5SDimitry Andric                           MachinePointerInfo SrcPtrInfo) const {
1100b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1110b57cec5SDimitry Andric   }
1120b57cec5SDimitry Andric 
1130b57cec5SDimitry Andric   /// Emit target-specific code that performs a strcpy or stpcpy, in cases
1140b57cec5SDimitry Andric   /// where that is faster than a libcall.
1150b57cec5SDimitry Andric   /// The first returned SDValue is the result of the copy (the start
1160b57cec5SDimitry Andric   /// of the destination string for strcpy, a pointer to the null terminator
1170b57cec5SDimitry Andric   /// for stpcpy) and the second is the chain.  Both SDValues can be null
1180b57cec5SDimitry Andric   /// if a normal libcall should be used.
1190b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcpy(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Dest,SDValue Src,MachinePointerInfo DestPtrInfo,MachinePointerInfo SrcPtrInfo,bool isStpcpy)1200b57cec5SDimitry Andric   EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
1210b57cec5SDimitry Andric                           SDValue Dest, SDValue Src,
1220b57cec5SDimitry Andric                           MachinePointerInfo DestPtrInfo,
1230b57cec5SDimitry Andric                           MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
1240b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1250b57cec5SDimitry Andric   }
1260b57cec5SDimitry Andric 
1270b57cec5SDimitry Andric   /// Emit target-specific code that performs a strcmp, in cases where that is
1280b57cec5SDimitry Andric   /// faster than a libcall.
1290b57cec5SDimitry Andric   /// The first returned SDValue is the result of the strcmp and the second is
1300b57cec5SDimitry Andric   /// the chain. Both SDValues can be null if a normal libcall should be used.
1310b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcmp(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Op1,SDValue Op2,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)1320b57cec5SDimitry Andric   EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
1330b57cec5SDimitry Andric                           SDValue Op1, SDValue Op2,
1340b57cec5SDimitry Andric                           MachinePointerInfo Op1PtrInfo,
1350b57cec5SDimitry Andric                           MachinePointerInfo Op2PtrInfo) const {
1360b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1370b57cec5SDimitry Andric   }
1380b57cec5SDimitry Andric 
1390b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrlen(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Src,MachinePointerInfo SrcPtrInfo)1400b57cec5SDimitry Andric   EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
1410b57cec5SDimitry Andric                           SDValue Src, MachinePointerInfo SrcPtrInfo) const {
1420b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1430b57cec5SDimitry Andric   }
1440b57cec5SDimitry Andric 
1450b57cec5SDimitry Andric   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrnlen(SelectionDAG & DAG,const SDLoc & DL,SDValue Chain,SDValue Src,SDValue MaxLength,MachinePointerInfo SrcPtrInfo)1460b57cec5SDimitry Andric   EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
1470b57cec5SDimitry Andric                            SDValue Src, SDValue MaxLength,
1480b57cec5SDimitry Andric                            MachinePointerInfo SrcPtrInfo) const {
1490b57cec5SDimitry Andric     return std::make_pair(SDValue(), SDValue());
1500b57cec5SDimitry Andric   }
1510b57cec5SDimitry Andric 
EmitTargetCodeForSetTag(SelectionDAG & DAG,const SDLoc & dl,SDValue Chain,SDValue Addr,SDValue Size,MachinePointerInfo DstPtrInfo,bool ZeroData)1520b57cec5SDimitry Andric   virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
1530b57cec5SDimitry Andric                                           SDValue Chain, SDValue Addr,
1540b57cec5SDimitry Andric                                           SDValue Size,
1550b57cec5SDimitry Andric                                           MachinePointerInfo DstPtrInfo,
1560b57cec5SDimitry Andric                                           bool ZeroData) const {
1570b57cec5SDimitry Andric     return SDValue();
1580b57cec5SDimitry Andric   }
1590b57cec5SDimitry Andric 
1605ffd83dbSDimitry Andric   // Return true if the DAG Combiner should disable generic combines.
disableGenericCombines(CodeGenOptLevel OptLevel)161*5f757f3fSDimitry Andric   virtual bool disableGenericCombines(CodeGenOptLevel OptLevel) const {
1625ffd83dbSDimitry Andric     return false;
1635ffd83dbSDimitry Andric   }
1640b57cec5SDimitry Andric };
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric } // end namespace llvm
1670b57cec5SDimitry Andric 
1680b57cec5SDimitry Andric #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
169