PPC.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //===-- PPC.h - Top-level interface for PowerPC Target ----------*- 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 LLVM
  10. // PowerPC back-end.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_POWERPC_PPC_H
  14. #define LLVM_LIB_TARGET_POWERPC_PPC_H
  15. #include "llvm/Support/CodeGen.h"
  16. // GCC #defines PPC on Linux but we use it as our namespace name
  17. #undef PPC
  18. namespace llvm {
  19. class PPCRegisterBankInfo;
  20. class PPCSubtarget;
  21. class PPCTargetMachine;
  22. class PassRegistry;
  23. class FunctionPass;
  24. class InstructionSelector;
  25. class MachineInstr;
  26. class MachineOperand;
  27. class AsmPrinter;
  28. class MCInst;
  29. class MCOperand;
  30. class ModulePass;
  31. #ifndef NDEBUG
  32. FunctionPass *createPPCCTRLoopsVerify();
  33. #endif
  34. FunctionPass *createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM);
  35. FunctionPass *createPPCTOCRegDepsPass();
  36. FunctionPass *createPPCEarlyReturnPass();
  37. FunctionPass *createPPCVSXCopyPass();
  38. FunctionPass *createPPCVSXFMAMutatePass();
  39. FunctionPass *createPPCVSXSwapRemovalPass();
  40. FunctionPass *createPPCReduceCRLogicalsPass();
  41. FunctionPass *createPPCMIPeepholePass();
  42. FunctionPass *createPPCBranchSelectionPass();
  43. FunctionPass *createPPCBranchCoalescingPass();
  44. FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL);
  45. FunctionPass *createPPCTLSDynamicCallPass();
  46. FunctionPass *createPPCBoolRetToIntPass();
  47. FunctionPass *createPPCExpandISELPass();
  48. FunctionPass *createPPCPreEmitPeepholePass();
  49. FunctionPass *createPPCExpandAtomicPseudoPass();
  50. FunctionPass *createPPCCTRLoopsPass();
  51. void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
  52. AsmPrinter &AP);
  53. bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
  54. MCOperand &OutMO, AsmPrinter &AP);
  55. #ifndef NDEBUG
  56. void initializePPCCTRLoopsVerifyPass(PassRegistry&);
  57. #endif
  58. void initializePPCLoopInstrFormPrepPass(PassRegistry&);
  59. void initializePPCTOCRegDepsPass(PassRegistry&);
  60. void initializePPCEarlyReturnPass(PassRegistry&);
  61. void initializePPCVSXCopyPass(PassRegistry&);
  62. void initializePPCVSXFMAMutatePass(PassRegistry&);
  63. void initializePPCVSXSwapRemovalPass(PassRegistry&);
  64. void initializePPCReduceCRLogicalsPass(PassRegistry&);
  65. void initializePPCBSelPass(PassRegistry&);
  66. void initializePPCBranchCoalescingPass(PassRegistry&);
  67. void initializePPCBoolRetToIntPass(PassRegistry&);
  68. void initializePPCExpandISELPass(PassRegistry &);
  69. void initializePPCPreEmitPeepholePass(PassRegistry &);
  70. void initializePPCTLSDynamicCallPass(PassRegistry &);
  71. void initializePPCMIPeepholePass(PassRegistry&);
  72. void initializePPCExpandAtomicPseudoPass(PassRegistry &);
  73. void initializePPCCTRLoopsPass(PassRegistry &);
  74. void initializePPCDAGToDAGISelPass(PassRegistry &);
  75. extern char &PPCVSXFMAMutateID;
  76. ModulePass *createPPCLowerMASSVEntriesPass();
  77. void initializePPCLowerMASSVEntriesPass(PassRegistry &);
  78. extern char &PPCLowerMASSVEntriesID;
  79. ModulePass *createPPCGenScalarMASSEntriesPass();
  80. void initializePPCGenScalarMASSEntriesPass(PassRegistry &);
  81. extern char &PPCGenScalarMASSEntriesID;
  82. InstructionSelector *
  83. createPPCInstructionSelector(const PPCTargetMachine &, const PPCSubtarget &,
  84. const PPCRegisterBankInfo &);
  85. namespace PPCII {
  86. /// Target Operand Flag enum.
  87. enum TOF {
  88. //===------------------------------------------------------------------===//
  89. // PPC Specific MachineOperand flags.
  90. MO_NO_FLAG,
  91. /// On a symbol operand "FOO", this indicates that the reference is actually
  92. /// to "FOO@plt". This is used for calls and jumps to external functions
  93. /// and for PIC calls on 32-bit ELF systems.
  94. MO_PLT = 1,
  95. /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
  96. /// the function's picbase, e.g. lo16(symbol-picbase).
  97. MO_PIC_FLAG = 2,
  98. /// MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to
  99. /// the current instruction address(pc), e.g., var@pcrel. Fixup is VK_PCREL.
  100. MO_PCREL_FLAG = 4,
  101. /// MO_GOT_FLAG - If this bit is set the symbol reference is to be computed
  102. /// via the GOT. For example when combined with the MO_PCREL_FLAG it should
  103. /// produce the relocation @got@pcrel. Fixup is VK_PPC_GOT_PCREL.
  104. MO_GOT_FLAG = 8,
  105. // MO_PCREL_OPT_FLAG - If this bit is set the operand is part of a
  106. // PC Relative linker optimization.
  107. MO_PCREL_OPT_FLAG = 16,
  108. /// MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to
  109. /// TLS General Dynamic model for Linux and the variable offset of TLS
  110. /// General Dynamic model for AIX.
  111. MO_TLSGD_FLAG = 32,
  112. /// MO_TPREL_FLAG - If this bit is set the symbol reference is relative to
  113. /// TLS Initial Exec model.
  114. MO_TPREL_FLAG = 64,
  115. /// MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to
  116. /// TLS Local Dynamic model.
  117. MO_TLSLD_FLAG = 128,
  118. /// MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative
  119. /// to the region handle of TLS General Dynamic model for AIX.
  120. MO_TLSGDM_FLAG = 256,
  121. /// MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set
  122. /// they should produce the relocation @got@tlsgd@pcrel.
  123. /// Fix up is VK_PPC_GOT_TLSGD_PCREL
  124. MO_GOT_TLSGD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSGD_FLAG,
  125. /// MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set
  126. /// they should produce the relocation @got@tlsld@pcrel.
  127. /// Fix up is VK_PPC_GOT_TLSLD_PCREL
  128. MO_GOT_TLSLD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSLD_FLAG,
  129. /// MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set
  130. /// they should produce the relocation @got@tprel@pcrel.
  131. /// Fix up is VK_PPC_GOT_TPREL_PCREL
  132. MO_GOT_TPREL_PCREL_FLAG = MO_GOT_FLAG | MO_TPREL_FLAG | MO_PCREL_FLAG,
  133. /// The next are not flags but distinct values.
  134. MO_ACCESS_MASK = 0xf00,
  135. /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
  136. MO_LO = 1 << 8,
  137. MO_HA = 2 << 8,
  138. MO_TPREL_LO = 4 << 8,
  139. MO_TPREL_HA = 3 << 8,
  140. /// These values identify relocations on immediates folded
  141. /// into memory operations.
  142. MO_DTPREL_LO = 5 << 8,
  143. MO_TLSLD_LO = 6 << 8,
  144. MO_TOC_LO = 7 << 8,
  145. // Symbol for VK_PPC_TLS fixup attached to an ADD instruction
  146. MO_TLS = 8 << 8
  147. };
  148. } // end namespace PPCII
  149. } // end namespace llvm;
  150. #endif