Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:36

0001 //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file declares the SelectionDAGTargetInfo class, which targets can
0010 // subclass to parameterize the SelectionDAG lowering and instruction
0011 // selection process.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
0016 #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
0017 
0018 #include "llvm/CodeGen/MachineMemOperand.h"
0019 #include "llvm/CodeGen/SelectionDAGNodes.h"
0020 #include "llvm/Support/CodeGen.h"
0021 #include <utility>
0022 
0023 namespace llvm {
0024 
0025 class SelectionDAG;
0026 
0027 //===----------------------------------------------------------------------===//
0028 /// Targets can subclass this to parameterize the
0029 /// SelectionDAG lowering and instruction selection process.
0030 ///
0031 class SelectionDAGTargetInfo {
0032 public:
0033   explicit SelectionDAGTargetInfo() = default;
0034   SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete;
0035   SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete;
0036   virtual ~SelectionDAGTargetInfo();
0037 
0038   /// Returns true if a node with the given target-specific opcode has
0039   /// a memory operand. Nodes with such opcodes can only be created with
0040   /// `SelectionDAG::getMemIntrinsicNode`.
0041   virtual bool isTargetMemoryOpcode(unsigned Opcode) const { return false; }
0042 
0043   /// Returns true if a node with the given target-specific opcode has
0044   /// strict floating-point semantics.
0045   virtual bool isTargetStrictFPOpcode(unsigned Opcode) const { return false; }
0046 
0047   /// Returns true if a node with the given target-specific opcode
0048   /// may raise a floating-point exception.
0049   virtual bool mayRaiseFPException(unsigned Opcode) const;
0050 
0051   /// Emit target-specific code that performs a memcpy.
0052   /// This can be used by targets to provide code sequences for cases
0053   /// that don't fit the target's parameters for simple loads/stores and can be
0054   /// more efficient than using a library call. This function can return a null
0055   /// SDValue if the target declines to use custom code and a different
0056   /// lowering strategy should be used.
0057   ///
0058   /// If AlwaysInline is true, the size is constant and the target should not
0059   /// emit any calls and is strongly encouraged to attempt to emit inline code
0060   /// even if it is beyond the usual threshold because this intrinsic is being
0061   /// expanded in a place where calls are not feasible (e.g. within the prologue
0062   /// for another call). If the target chooses to decline an AlwaysInline
0063   /// request here, legalize will resort to using simple loads and stores.
0064   virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
0065                                           SDValue Chain, SDValue Op1,
0066                                           SDValue Op2, SDValue Op3,
0067                                           Align Alignment, bool isVolatile,
0068                                           bool AlwaysInline,
0069                                           MachinePointerInfo DstPtrInfo,
0070                                           MachinePointerInfo SrcPtrInfo) const {
0071     return SDValue();
0072   }
0073 
0074   /// Emit target-specific code that performs a memmove.
0075   /// This can be used by targets to provide code sequences for cases
0076   /// that don't fit the target's parameters for simple loads/stores and can be
0077   /// more efficient than using a library call. This function can return a null
0078   /// SDValue if the target declines to use custom code and a different
0079   /// lowering strategy should be used.
0080   virtual SDValue EmitTargetCodeForMemmove(
0081       SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
0082       SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
0083       MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
0084     return SDValue();
0085   }
0086 
0087   /// Emit target-specific code that performs a memset.
0088   /// This can be used by targets to provide code sequences for cases
0089   /// that don't fit the target's parameters for simple stores and can be more
0090   /// efficient than using a library call. This function can return a null
0091   /// SDValue if the target declines to use custom code and a different
0092   /// lowering strategy should be used. Note that if AlwaysInline is true the
0093   /// function has to return a valid SDValue.
0094   virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
0095                                           SDValue Chain, SDValue Op1,
0096                                           SDValue Op2, SDValue Op3,
0097                                           Align Alignment, bool isVolatile,
0098                                           bool AlwaysInline,
0099                                           MachinePointerInfo DstPtrInfo) const {
0100     return SDValue();
0101   }
0102 
0103   /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
0104   /// faster than a libcall. The first returned SDValue is the result of the
0105   /// memcmp and the second is the chain. Both SDValues can be null if a normal
0106   /// libcall should be used.
0107   virtual std::pair<SDValue, SDValue>
0108   EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
0109                           SDValue Op1, SDValue Op2, SDValue Op3,
0110                           MachinePointerInfo Op1PtrInfo,
0111                           MachinePointerInfo Op2PtrInfo) const {
0112     return std::make_pair(SDValue(), SDValue());
0113   }
0114 
0115   /// Emit target-specific code that performs a memchr, in cases where that is
0116   /// faster than a libcall. The first returned SDValue is the result of the
0117   /// memchr and the second is the chain. Both SDValues can be null if a normal
0118   /// libcall should be used.
0119   virtual std::pair<SDValue, SDValue>
0120   EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
0121                           SDValue Src, SDValue Char, SDValue Length,
0122                           MachinePointerInfo SrcPtrInfo) const {
0123     return std::make_pair(SDValue(), SDValue());
0124   }
0125 
0126   /// Emit target-specific code that performs a strcpy or stpcpy, in cases
0127   /// where that is faster than a libcall.
0128   /// The first returned SDValue is the result of the copy (the start
0129   /// of the destination string for strcpy, a pointer to the null terminator
0130   /// for stpcpy) and the second is the chain.  Both SDValues can be null
0131   /// if a normal libcall should be used.
0132   virtual std::pair<SDValue, SDValue>
0133   EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
0134                           SDValue Dest, SDValue Src,
0135                           MachinePointerInfo DestPtrInfo,
0136                           MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
0137     return std::make_pair(SDValue(), SDValue());
0138   }
0139 
0140   /// Emit target-specific code that performs a strcmp, in cases where that is
0141   /// faster than a libcall.
0142   /// The first returned SDValue is the result of the strcmp and the second is
0143   /// the chain. Both SDValues can be null if a normal libcall should be used.
0144   virtual std::pair<SDValue, SDValue>
0145   EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
0146                           SDValue Op1, SDValue Op2,
0147                           MachinePointerInfo Op1PtrInfo,
0148                           MachinePointerInfo Op2PtrInfo) const {
0149     return std::make_pair(SDValue(), SDValue());
0150   }
0151 
0152   virtual std::pair<SDValue, SDValue>
0153   EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
0154                           SDValue Src, MachinePointerInfo SrcPtrInfo) const {
0155     return std::make_pair(SDValue(), SDValue());
0156   }
0157 
0158   virtual std::pair<SDValue, SDValue>
0159   EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
0160                            SDValue Src, SDValue MaxLength,
0161                            MachinePointerInfo SrcPtrInfo) const {
0162     return std::make_pair(SDValue(), SDValue());
0163   }
0164 
0165   virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
0166                                           SDValue Chain, SDValue Addr,
0167                                           SDValue Size,
0168                                           MachinePointerInfo DstPtrInfo,
0169                                           bool ZeroData) const {
0170     return SDValue();
0171   }
0172 
0173   // Return true if the DAG Combiner should disable generic combines.
0174   virtual bool disableGenericCombines(CodeGenOptLevel OptLevel) const {
0175     return false;
0176   }
0177 };
0178 
0179 } // end namespace llvm
0180 
0181 #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H