SelectionDAGTargetInfo.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. Note that if AlwaysInline is true the
  77. /// function has to return a valid SDValue.
  78. virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
  79. SDValue Chain, SDValue Op1,
  80. SDValue Op2, SDValue Op3,
  81. Align Alignment, bool isVolatile,
  82. bool AlwaysInline,
  83. MachinePointerInfo DstPtrInfo) const {
  84. return SDValue();
  85. }
  86. /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
  87. /// faster than a libcall. The first returned SDValue is the result of the
  88. /// memcmp and the second is the chain. Both SDValues can be null if a normal
  89. /// libcall should be used.
  90. virtual std::pair<SDValue, SDValue>
  91. EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  92. SDValue Op1, SDValue Op2, SDValue Op3,
  93. MachinePointerInfo Op1PtrInfo,
  94. MachinePointerInfo Op2PtrInfo) const {
  95. return std::make_pair(SDValue(), SDValue());
  96. }
  97. /// Emit target-specific code that performs a memchr, in cases where that is
  98. /// faster than a libcall. The first returned SDValue is the result of the
  99. /// memchr and the second is the chain. Both SDValues can be null if a normal
  100. /// libcall should be used.
  101. virtual std::pair<SDValue, SDValue>
  102. EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  103. SDValue Src, SDValue Char, SDValue Length,
  104. MachinePointerInfo SrcPtrInfo) const {
  105. return std::make_pair(SDValue(), SDValue());
  106. }
  107. /// Emit target-specific code that performs a strcpy or stpcpy, in cases
  108. /// where that is faster than a libcall.
  109. /// The first returned SDValue is the result of the copy (the start
  110. /// of the destination string for strcpy, a pointer to the null terminator
  111. /// for stpcpy) and the second is the chain. Both SDValues can be null
  112. /// if a normal libcall should be used.
  113. virtual std::pair<SDValue, SDValue>
  114. EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  115. SDValue Dest, SDValue Src,
  116. MachinePointerInfo DestPtrInfo,
  117. MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
  118. return std::make_pair(SDValue(), SDValue());
  119. }
  120. /// Emit target-specific code that performs a strcmp, in cases where that is
  121. /// faster than a libcall.
  122. /// The first returned SDValue is the result of the strcmp and the second is
  123. /// the chain. Both SDValues can be null if a normal libcall should be used.
  124. virtual std::pair<SDValue, SDValue>
  125. EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
  126. SDValue Op1, SDValue Op2,
  127. MachinePointerInfo Op1PtrInfo,
  128. MachinePointerInfo Op2PtrInfo) const {
  129. return std::make_pair(SDValue(), SDValue());
  130. }
  131. virtual std::pair<SDValue, SDValue>
  132. EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  133. SDValue Src, MachinePointerInfo SrcPtrInfo) const {
  134. return std::make_pair(SDValue(), SDValue());
  135. }
  136. virtual std::pair<SDValue, SDValue>
  137. EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
  138. SDValue Src, SDValue MaxLength,
  139. MachinePointerInfo SrcPtrInfo) const {
  140. return std::make_pair(SDValue(), SDValue());
  141. }
  142. virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
  143. SDValue Chain, SDValue Addr,
  144. SDValue Size,
  145. MachinePointerInfo DstPtrInfo,
  146. bool ZeroData) const {
  147. return SDValue();
  148. }
  149. // Return true if the DAG Combiner should disable generic combines.
  150. virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const {
  151. return false;
  152. }
  153. };
  154. } // end namespace llvm
  155. #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
  156. #ifdef __GNUC__
  157. #pragma GCC diagnostic pop
  158. #endif