X86.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //===-- X86.h - Top-level interface for X86 representation ------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains the entry points for global functions defined in the x86
  10. // target library, as used by the LLVM JIT.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_X86_X86_H
  14. #define LLVM_LIB_TARGET_X86_X86_H
  15. #include "llvm/Support/CodeGen.h"
  16. namespace llvm {
  17. class FunctionPass;
  18. class InstructionSelector;
  19. class PassRegistry;
  20. class X86RegisterBankInfo;
  21. class X86Subtarget;
  22. class X86TargetMachine;
  23. /// This pass converts a legalized DAG into a X86-specific DAG, ready for
  24. /// instruction scheduling.
  25. FunctionPass *createX86ISelDag(X86TargetMachine &TM,
  26. CodeGenOpt::Level OptLevel);
  27. /// This pass initializes a global base register for PIC on x86-32.
  28. FunctionPass *createX86GlobalBaseRegPass();
  29. /// This pass combines multiple accesses to local-dynamic TLS variables so that
  30. /// the TLS base address for the module is only fetched once per execution path
  31. /// through the function.
  32. FunctionPass *createCleanupLocalDynamicTLSPass();
  33. /// This function returns a pass which converts floating-point register
  34. /// references and pseudo instructions into floating-point stack references and
  35. /// physical instructions.
  36. FunctionPass *createX86FloatingPointStackifierPass();
  37. /// This pass inserts AVX vzeroupper instructions before each call to avoid
  38. /// transition penalty between functions encoded with AVX and SSE.
  39. FunctionPass *createX86IssueVZeroUpperPass();
  40. /// This pass inserts ENDBR instructions before indirect jump/call
  41. /// destinations as part of CET IBT mechanism.
  42. FunctionPass *createX86IndirectBranchTrackingPass();
  43. /// This pass inserts KCFI checks before indirect calls.
  44. FunctionPass *createX86KCFIPass();
  45. /// Return a pass that pads short functions with NOOPs.
  46. /// This will prevent a stall when returning on the Atom.
  47. FunctionPass *createX86PadShortFunctions();
  48. /// Return a pass that selectively replaces certain instructions (like add,
  49. /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
  50. /// instructions, in order to eliminate execution delays in some processors.
  51. FunctionPass *createX86FixupLEAs();
  52. /// Return a pass that removes redundant LEA instructions and redundant address
  53. /// recalculations.
  54. FunctionPass *createX86OptimizeLEAs();
  55. /// Return a pass that transforms setcc + movzx pairs into xor + setcc.
  56. FunctionPass *createX86FixupSetCC();
  57. /// Return a pass that avoids creating store forward block issues in the hardware.
  58. FunctionPass *createX86AvoidStoreForwardingBlocks();
  59. /// Return a pass that lowers EFLAGS copy pseudo instructions.
  60. FunctionPass *createX86FlagsCopyLoweringPass();
  61. /// Return a pass that expands DynAlloca pseudo-instructions.
  62. FunctionPass *createX86DynAllocaExpander();
  63. /// Return a pass that config the tile registers.
  64. FunctionPass *createX86TileConfigPass();
  65. /// Return a pass that preconfig the tile registers before fast reg allocation.
  66. FunctionPass *createX86FastPreTileConfigPass();
  67. /// Return a pass that config the tile registers after fast reg allocation.
  68. FunctionPass *createX86FastTileConfigPass();
  69. /// Return a pass that insert pseudo tile config instruction.
  70. FunctionPass *createX86PreTileConfigPass();
  71. /// Return a pass that lower the tile copy instruction.
  72. FunctionPass *createX86LowerTileCopyPass();
  73. /// Return a pass that inserts int3 at the end of the function if it ends with a
  74. /// CALL instruction. The pass does the same for each funclet as well. This
  75. /// ensures that the open interval of function start and end PCs contains all
  76. /// return addresses for the benefit of the Windows x64 unwinder.
  77. FunctionPass *createX86AvoidTrailingCallPass();
  78. /// Return a pass that optimizes the code-size of x86 call sequences. This is
  79. /// done by replacing esp-relative movs with pushes.
  80. FunctionPass *createX86CallFrameOptimization();
  81. /// Return an IR pass that inserts EH registration stack objects and explicit
  82. /// EH state updates. This pass must run after EH preparation, which does
  83. /// Windows-specific but architecture-neutral preparation.
  84. FunctionPass *createX86WinEHStatePass();
  85. /// Return a Machine IR pass that expands X86-specific pseudo
  86. /// instructions into a sequence of actual instructions. This pass
  87. /// must run after prologue/epilogue insertion and before lowering
  88. /// the MachineInstr to MC.
  89. FunctionPass *createX86ExpandPseudoPass();
  90. /// This pass converts X86 cmov instructions into branch when profitable.
  91. FunctionPass *createX86CmovConverterPass();
  92. /// Return a Machine IR pass that selectively replaces
  93. /// certain byte and word instructions by equivalent 32 bit instructions,
  94. /// in order to eliminate partial register usage, false dependences on
  95. /// the upper portions of registers, and to save code size.
  96. FunctionPass *createX86FixupBWInsts();
  97. /// Return a Machine IR pass that reassigns instruction chains from one domain
  98. /// to another, when profitable.
  99. FunctionPass *createX86DomainReassignmentPass();
  100. /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX
  101. /// encoding when possible in order to reduce code size.
  102. FunctionPass *createX86EvexToVexInsts();
  103. /// This pass creates the thunks for the retpoline feature.
  104. FunctionPass *createX86IndirectThunksPass();
  105. /// This pass replaces ret instructions with jmp's to __x86_return thunk.
  106. FunctionPass *createX86ReturnThunksPass();
  107. /// This pass ensures instructions featuring a memory operand
  108. /// have distinctive <LineNumber, Discriminator> (with respect to eachother)
  109. FunctionPass *createX86DiscriminateMemOpsPass();
  110. /// This pass applies profiling information to insert cache prefetches.
  111. FunctionPass *createX86InsertPrefetchPass();
  112. /// This pass insert wait instruction after X87 instructions which could raise
  113. /// fp exceptions when strict-fp enabled.
  114. FunctionPass *createX86InsertX87waitPass();
  115. /// This pass optimizes arithmetic based on knowledge that is only used by
  116. /// a reduction sequence and is therefore safe to reassociate in interesting
  117. /// ways.
  118. FunctionPass *createX86PartialReductionPass();
  119. InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
  120. X86Subtarget &,
  121. X86RegisterBankInfo &);
  122. FunctionPass *createX86LoadValueInjectionLoadHardeningPass();
  123. FunctionPass *createX86LoadValueInjectionRetHardeningPass();
  124. FunctionPass *createX86SpeculativeLoadHardeningPass();
  125. FunctionPass *createX86SpeculativeExecutionSideEffectSuppression();
  126. void initializeEvexToVexInstPassPass(PassRegistry &);
  127. void initializeFPSPass(PassRegistry &);
  128. void initializeFixupBWInstPassPass(PassRegistry &);
  129. void initializeFixupLEAPassPass(PassRegistry &);
  130. void initializeWinEHStatePassPass(PassRegistry &);
  131. void initializeX86AvoidSFBPassPass(PassRegistry &);
  132. void initializeX86AvoidTrailingCallPassPass(PassRegistry &);
  133. void initializeX86CallFrameOptimizationPass(PassRegistry &);
  134. void initializeX86CmovConverterPassPass(PassRegistry &);
  135. void initializeX86DAGToDAGISelPass(PassRegistry &);
  136. void initializeX86DomainReassignmentPass(PassRegistry &);
  137. void initializeX86ExecutionDomainFixPass(PassRegistry &);
  138. void initializeX86ExpandPseudoPass(PassRegistry &);
  139. void initializeX86FastPreTileConfigPass(PassRegistry &);
  140. void initializeX86FastTileConfigPass(PassRegistry &);
  141. void initializeX86FixupSetCCPassPass(PassRegistry &);
  142. void initializeX86FlagsCopyLoweringPassPass(PassRegistry &);
  143. void initializeX86KCFIPass(PassRegistry &);
  144. void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &);
  145. void initializeX86LoadValueInjectionRetHardeningPassPass(PassRegistry &);
  146. void initializeX86LowerAMXIntrinsicsLegacyPassPass(PassRegistry &);
  147. void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &);
  148. void initializeX86LowerTileCopyPass(PassRegistry &);
  149. void initializeX86OptimizeLEAPassPass(PassRegistry &);
  150. void initializeX86PartialReductionPass(PassRegistry &);
  151. void initializeX86PreAMXConfigPassPass(PassRegistry &);
  152. void initializeX86PreTileConfigPass(PassRegistry &);
  153. void initializeX86ReturnThunksPass(PassRegistry &);
  154. void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &);
  155. void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &);
  156. void initializeX86TileConfigPass(PassRegistry &);
  157. namespace X86AS {
  158. enum : unsigned {
  159. GS = 256,
  160. FS = 257,
  161. SS = 258,
  162. PTR32_SPTR = 270,
  163. PTR32_UPTR = 271,
  164. PTR64 = 272
  165. };
  166. } // End X86AS namespace
  167. } // End llvm namespace
  168. #endif