1 //===-- X86.h - Top-level interface for X86 representation ------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file contains the entry points for global functions defined in the x86 11 // target library, as used by the LLVM JIT. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_LIB_TARGET_X86_X86_H 16 #define LLVM_LIB_TARGET_X86_X86_H 17 18 #include "llvm/Support/CodeGen.h" 19 20 namespace llvm { 21 22 class FunctionPass; 23 class ImmutablePass; 24 class InstructionSelector; 25 class ModulePass; 26 class PassRegistry; 27 class X86RegisterBankInfo; 28 class X86Subtarget; 29 class X86TargetMachine; 30 31 /// This pass converts a legalized DAG into a X86-specific DAG, ready for 32 /// instruction scheduling. 33 FunctionPass *createX86ISelDag(X86TargetMachine &TM, 34 CodeGenOpt::Level OptLevel); 35 36 /// This pass initializes a global base register for PIC on x86-32. 37 FunctionPass *createX86GlobalBaseRegPass(); 38 39 /// This pass combines multiple accesses to local-dynamic TLS variables so that 40 /// the TLS base address for the module is only fetched once per execution path 41 /// through the function. 42 FunctionPass *createCleanupLocalDynamicTLSPass(); 43 44 /// This function returns a pass which converts floating-point register 45 /// references and pseudo instructions into floating-point stack references and 46 /// physical instructions. 47 FunctionPass *createX86FloatingPointStackifierPass(); 48 49 /// This pass inserts AVX vzeroupper instructions before each call to avoid 50 /// transition penalty between functions encoded with AVX and SSE. 51 FunctionPass *createX86IssueVZeroUpperPass(); 52 53 /// This pass instruments the function prolog to save the return address to a 54 /// 'shadow call stack' and the function epilog to check that the return address 55 /// did not change during function execution. 56 FunctionPass *createShadowCallStackPass(); 57 58 /// This pass inserts ENDBR instructions before indirect jump/call 59 /// destinations as part of CET IBT mechanism. 60 FunctionPass *createX86IndirectBranchTrackingPass(); 61 62 /// Return a pass that pads short functions with NOOPs. 63 /// This will prevent a stall when returning on the Atom. 64 FunctionPass *createX86PadShortFunctions(); 65 66 /// Return a pass that selectively replaces certain instructions (like add, 67 /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA 68 /// instructions, in order to eliminate execution delays in some processors. 69 FunctionPass *createX86FixupLEAs(); 70 71 /// Return a pass that removes redundant LEA instructions and redundant address 72 /// recalculations. 73 FunctionPass *createX86OptimizeLEAs(); 74 75 /// Return a pass that transforms setcc + movzx pairs into xor + setcc. 76 FunctionPass *createX86FixupSetCC(); 77 78 /// Return a pass that avoids creating store forward block issues in the hardware. 79 FunctionPass *createX86AvoidStoreForwardingBlocks(); 80 81 /// Return a pass that lowers EFLAGS copy pseudo instructions. 82 FunctionPass *createX86FlagsCopyLoweringPass(); 83 84 /// Return a pass that expands WinAlloca pseudo-instructions. 85 FunctionPass *createX86WinAllocaExpander(); 86 87 /// Return a pass that optimizes the code-size of x86 call sequences. This is 88 /// done by replacing esp-relative movs with pushes. 89 FunctionPass *createX86CallFrameOptimization(); 90 91 /// Return an IR pass that inserts EH registration stack objects and explicit 92 /// EH state updates. This pass must run after EH preparation, which does 93 /// Windows-specific but architecture-neutral preparation. 94 FunctionPass *createX86WinEHStatePass(); 95 96 /// Return a Machine IR pass that expands X86-specific pseudo 97 /// instructions into a sequence of actual instructions. This pass 98 /// must run after prologue/epilogue insertion and before lowering 99 /// the MachineInstr to MC. 100 FunctionPass *createX86ExpandPseudoPass(); 101 102 /// This pass converts X86 cmov instructions into branch when profitable. 103 FunctionPass *createX86CmovConverterPass(); 104 105 /// Return a Machine IR pass that selectively replaces 106 /// certain byte and word instructions by equivalent 32 bit instructions, 107 /// in order to eliminate partial register usage, false dependences on 108 /// the upper portions of registers, and to save code size. 109 FunctionPass *createX86FixupBWInsts(); 110 111 /// Return a Machine IR pass that reassigns instruction chains from one domain 112 /// to another, when profitable. 113 FunctionPass *createX86DomainReassignmentPass(); 114 115 void initializeFixupBWInstPassPass(PassRegistry &); 116 117 /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX 118 /// encoding when possible in order to reduce code size. 119 FunctionPass *createX86EvexToVexInsts(); 120 121 /// This pass creates the thunks for the retpoline feature. 122 FunctionPass *createX86RetpolineThunksPass(); 123 124 InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM, 125 X86Subtarget &, 126 X86RegisterBankInfo &); 127 128 void initializeEvexToVexInstPassPass(PassRegistry &); 129 130 FunctionPass *createX86SpeculativeLoadHardeningPass(); 131 132 } // End llvm namespace 133 134 #endif 135