SelectionDAGTargetInfo.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares the SelectionDAGTargetInfo class, which targets can
  15. // subclass to parameterize the SelectionDAG lowering and instruction
  16. // selection process.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
  20. #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
  21. #include "llvm/CodeGen/MachineMemOperand.h"
  22. #include "llvm/CodeGen/SelectionDAGNodes.h"
  23. #include "llvm/Support/CodeGen.h"
  24. #include <utility>
  25. namespace llvm {
  26. class SelectionDAG;
  27. //===----------------------------------------------------------------------===//
  28. /// Targets can subclass this to parameterize the
  29. /// SelectionDAG lowering and instruction selection process.
  30. ///
  31. class SelectionDAGTargetInfo {
  32. public:
  33. explicit SelectionDAGTargetInfo() = default;
  34. SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete;
  35. SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete;
  36. virtual ~SelectionDAGTargetInfo();
  37. /// Emit target-specific code that performs a memcpy.
  38. /// This can be used by targets to provide code sequences for cases
  39. /// that don't fit the target's parameters for simple loads/stores and can be
  40. /// more efficient than using a library call. This function can return a null
  41. /// SDValue if the target declines to use custom code and a different
  42. /// lowering strategy should be used.
  43. ///
  44. /// If AlwaysInline is true, the size is constant and the target should not
  45. /// emit any calls and is strongly encouraged to attempt to emit inline code
  46. /// even if it is beyond the usual threshold because this intrinsic is being
  47. /// expanded in a place where calls are not feasible (e.g. within the prologue
  48. /// for another call). If the target chooses to decline an AlwaysInline
  49. /// request here, legalize will resort to using simple loads and stores.
  50. virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
  51. SDValue Chain, SDValue Op1,
  52. SDValue Op2, SDValue Op3,
  53. Align Alignment, bool isVolatile,
  54. bool AlwaysInline,
  55. MachinePointerInfo DstPtrInfo,
  56. MachinePointerInfo SrcPtrInfo) const {
  57. return SDValue();
  58. }
  59. /// Emit target-specific code that performs a memmove.
  60. /// This can be used by targets to provide code sequences for cases
  61. /// that don't fit the target's parameters for simple loads/stores and can be
  62. /// more efficient than using a library call. This function can return a null
  63. /// SDValue if the target declines to use custom code and a different
  64. /// lowering strategy should be used.
  65. virtual SDValue EmitTargetCodeForMemmove(
  66. SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
  67. SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
  68. MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
  69. return SDValue();
  70. }
  71. /// Emit target-specific code that performs a memset.
  72. /// This can be used by targets to provide code sequences for cases
  73. /// that don't fit the target's parameters for simple stores and can be more
  74. /// efficient than using a library call. This function can return a null
  75. /// SDValue if the target declines to use custom code and a different
  76. /// lowering strategy should be used.
  77. virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
  78. SDValue Chain, SDValue Op1,
  79. SDValue Op2, SDValue Op3,
  80. Align Alignment, bool isVolatile,
  81. MachinePointerInfo DstPtrInfo) const {
  82. return SDValue();
  83. }
  84. /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
  85. /// faster than a libcall. The first returned SDValue is the result of the
  86. /// memcmp and the second is the chain. Both SDValues can be null if a normal
  87. /// libcall should be used.
  88. virtual std::pair<SDValue, SDValue>
  89. EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  90. SDValue Op1, SDValue Op2, SDValue Op3,
  91. MachinePointerInfo Op1PtrInfo,
  92. MachinePointerInfo Op2PtrInfo) const {
  93. return std::make_pair(SDValue(), SDValue());
  94. }
  95. /// Emit target-specific code that performs a memchr, in cases where that is
  96. /// faster than a libcall. The first returned SDValue is the result of the
  97. /// memchr and the second is the chain. Both SDValues can be null if a normal
  98. /// libcall should be used.
  99. virtual std::pair<SDValue, SDValue>
  100. EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  101. SDValue Src, SDValue Char, SDValue Length,
  102. MachinePointerInfo SrcPtrInfo) const {
  103. return std::make_pair(SDValue(), SDValue());
  104. }
  105. /// Emit target-specific code that performs a strcpy or stpcpy, in cases
  106. /// where that is faster than a libcall.
  107. /// The first returned SDValue is the result of the copy (the start
  108. /// of the destination string for strcpy, a pointer to the null terminator
  109. /// for stpcpy) and the second is the chain. Both SDValues can be null
  110. /// if a normal libcall should be used.
  111. virtual std::pair<SDValue, SDValue>
  112. EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  113. SDValue Dest, SDValue Src,
  114. MachinePointerInfo DestPtrInfo,
  115. MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
  116. return std::make_pair(SDValue(), SDValue());
  117. }
  118. /// Emit target-specific code that performs a strcmp, in cases where that is
  119. /// faster than a libcall.
  120. /// The first returned SDValue is the result of the strcmp and the second is
  121. /// the chain. Both SDValues can be null if a normal libcall should be used.
  122. virtual std::pair<SDValue, SDValue>
  123. EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  124. SDValue Op1, SDValue Op2,
  125. MachinePointerInfo Op1PtrInfo,
  126. MachinePointerInfo Op2PtrInfo) const {
  127. return std::make_pair(SDValue(), SDValue());
  128. }
  129. virtual std::pair<SDValue, SDValue>
  130. EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  131. SDValue Src, MachinePointerInfo SrcPtrInfo) const {
  132. return std::make_pair(SDValue(), SDValue());
  133. }
  134. virtual std::pair<SDValue, SDValue>
  135. EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  136. SDValue Src, SDValue MaxLength,
  137. MachinePointerInfo SrcPtrInfo) const {
  138. return std::make_pair(SDValue(), SDValue());
  139. }
  140. virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
  141. SDValue Chain, SDValue Addr,
  142. SDValue Size,
  143. MachinePointerInfo DstPtrInfo,
  144. bool ZeroData) const {
  145. return SDValue();
  146. }
  147. // Return true if the DAG Combiner should disable generic combines.
  148. virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const {
  149. return false;
  150. }
  151. };
  152. } // end namespace llvm
  153. #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
  154. #ifdef __GNUC__
  155. #pragma GCC diagnostic pop
  156. #endif