xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/PPC.h (revision e40139ff33b48b56a24c808b166b04b8ee6f5b21)
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 
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPC_H
15 #define LLVM_LIB_TARGET_POWERPC_PPC_H
16 
17 #include "llvm/Support/CodeGen.h"
18 
19 // GCC #defines PPC on Linux but we use it as our namespace name
20 #undef PPC
21 
22 namespace llvm {
23   class PPCTargetMachine;
24   class PassRegistry;
25   class FunctionPass;
26   class MachineInstr;
27   class MachineOperand;
28   class AsmPrinter;
29   class MCInst;
30   class MCOperand;
31 
32   FunctionPass *createPPCCTRLoops();
33 #ifndef NDEBUG
34   FunctionPass *createPPCCTRLoopsVerify();
35 #endif
36   FunctionPass *createPPCLoopPreIncPrepPass(PPCTargetMachine &TM);
37   FunctionPass *createPPCTOCRegDepsPass();
38   FunctionPass *createPPCEarlyReturnPass();
39   FunctionPass *createPPCVSXCopyPass();
40   FunctionPass *createPPCVSXFMAMutatePass();
41   FunctionPass *createPPCVSXSwapRemovalPass();
42   FunctionPass *createPPCReduceCRLogicalsPass();
43   FunctionPass *createPPCMIPeepholePass();
44   FunctionPass *createPPCBranchSelectionPass();
45   FunctionPass *createPPCBranchCoalescingPass();
46   FunctionPass *createPPCQPXLoadSplatPass();
47   FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL);
48   FunctionPass *createPPCTLSDynamicCallPass();
49   FunctionPass *createPPCBoolRetToIntPass();
50   FunctionPass *createPPCExpandISELPass();
51   FunctionPass *createPPCPreEmitPeepholePass();
52   void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
53                                     AsmPrinter &AP, bool IsDarwin);
54   bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
55                                          MCOperand &OutMO, AsmPrinter &AP,
56                                          bool IsDarwin);
57 
58   void initializePPCCTRLoopsPass(PassRegistry&);
59 #ifndef NDEBUG
60   void initializePPCCTRLoopsVerifyPass(PassRegistry&);
61 #endif
62   void initializePPCLoopPreIncPrepPass(PassRegistry&);
63   void initializePPCTOCRegDepsPass(PassRegistry&);
64   void initializePPCEarlyReturnPass(PassRegistry&);
65   void initializePPCVSXCopyPass(PassRegistry&);
66   void initializePPCVSXFMAMutatePass(PassRegistry&);
67   void initializePPCVSXSwapRemovalPass(PassRegistry&);
68   void initializePPCReduceCRLogicalsPass(PassRegistry&);
69   void initializePPCBSelPass(PassRegistry&);
70   void initializePPCBranchCoalescingPass(PassRegistry&);
71   void initializePPCQPXLoadSplatPass(PassRegistry&);
72   void initializePPCBoolRetToIntPass(PassRegistry&);
73   void initializePPCExpandISELPass(PassRegistry &);
74   void initializePPCPreEmitPeepholePass(PassRegistry &);
75   void initializePPCTLSDynamicCallPass(PassRegistry &);
76   void initializePPCMIPeepholePass(PassRegistry&);
77 
78   extern char &PPCVSXFMAMutateID;
79 
80   namespace PPCII {
81 
82   /// Target Operand Flag enum.
83   enum TOF {
84     //===------------------------------------------------------------------===//
85     // PPC Specific MachineOperand flags.
86     MO_NO_FLAG,
87 
88     /// On a symbol operand "FOO", this indicates that the reference is actually
89     /// to "FOO@plt".  This is used for calls and jumps to external functions
90     /// and for PIC calls on 32-bit ELF systems.
91     MO_PLT = 1,
92 
93     /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
94     /// the function's picbase, e.g. lo16(symbol-picbase).
95     MO_PIC_FLAG = 2,
96 
97     /// MO_NLP_FLAG - If this bit is set, the symbol reference is actually to
98     /// the non_lazy_ptr for the global, e.g. lo16(symbol$non_lazy_ptr-picbase).
99     MO_NLP_FLAG = 4,
100 
101     /// MO_NLP_HIDDEN_FLAG - If this bit is set, the symbol reference is to a
102     /// symbol with hidden visibility.  This causes a different kind of
103     /// non-lazy-pointer to be generated.
104     MO_NLP_HIDDEN_FLAG = 8,
105 
106     /// The next are not flags but distinct values.
107     MO_ACCESS_MASK = 0xf0,
108 
109     /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
110     MO_LO = 1 << 4,
111     MO_HA = 2 << 4,
112 
113     MO_TPREL_LO = 4 << 4,
114     MO_TPREL_HA = 3 << 4,
115 
116     /// These values identify relocations on immediates folded
117     /// into memory operations.
118     MO_DTPREL_LO = 5 << 4,
119     MO_TLSLD_LO = 6 << 4,
120     MO_TOC_LO = 7 << 4,
121 
122     // Symbol for VK_PPC_TLS fixup attached to an ADD instruction
123     MO_TLS = 8 << 4
124   };
125   } // end namespace PPCII
126 
127 } // end namespace llvm;
128 
129 #endif
130