xref: /llvm-project/llvm/lib/Target/PowerPC/PPC.h (revision aaa37d6755e635bbd62ba58896acd54ceef64610)
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 PPCRegisterBankInfo;
24 class PPCSubtarget;
25 class PPCTargetMachine;
26 class PassRegistry;
27 class FunctionPass;
28 class InstructionSelector;
29 class MachineInstr;
30 class MachineOperand;
31 class AsmPrinter;
32 class MCInst;
33 class MCOperand;
34 class ModulePass;
35 
36 #ifndef NDEBUG
37   FunctionPass *createPPCCTRLoopsVerify();
38 #endif
39   FunctionPass *createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM);
40   FunctionPass *createPPCTOCRegDepsPass();
41   FunctionPass *createPPCEarlyReturnPass();
42   FunctionPass *createPPCVSXCopyPass();
43   FunctionPass *createPPCVSXFMAMutatePass();
44   FunctionPass *createPPCVSXSwapRemovalPass();
45   FunctionPass *createPPCReduceCRLogicalsPass();
46   FunctionPass *createPPCMIPeepholePass();
47   FunctionPass *createPPCBranchSelectionPass();
48   FunctionPass *createPPCBranchCoalescingPass();
49   FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOptLevel OL);
50   FunctionPass *createPPCTLSDynamicCallPass();
51   FunctionPass *createPPCBoolRetToIntPass();
52   FunctionPass *createPPCExpandISELPass();
53   FunctionPass *createPPCPreEmitPeepholePass();
54   FunctionPass *createPPCExpandAtomicPseudoPass();
55   FunctionPass *createPPCCTRLoopsPass();
56   void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
57                                     AsmPrinter &AP);
58   bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
59                                          MCOperand &OutMO, AsmPrinter &AP);
60 
61 #ifndef NDEBUG
62   void initializePPCCTRLoopsVerifyPass(PassRegistry&);
63 #endif
64   void initializePPCLoopInstrFormPrepPass(PassRegistry&);
65   void initializePPCTOCRegDepsPass(PassRegistry&);
66   void initializePPCEarlyReturnPass(PassRegistry&);
67   void initializePPCVSXCopyPass(PassRegistry&);
68   void initializePPCVSXFMAMutatePass(PassRegistry&);
69   void initializePPCVSXSwapRemovalPass(PassRegistry&);
70   void initializePPCReduceCRLogicalsPass(PassRegistry&);
71   void initializePPCBSelPass(PassRegistry&);
72   void initializePPCBranchCoalescingPass(PassRegistry&);
73   void initializePPCBoolRetToIntPass(PassRegistry&);
74   void initializePPCExpandISELPass(PassRegistry &);
75   void initializePPCPreEmitPeepholePass(PassRegistry &);
76   void initializePPCTLSDynamicCallPass(PassRegistry &);
77   void initializePPCMIPeepholePass(PassRegistry&);
78   void initializePPCExpandAtomicPseudoPass(PassRegistry &);
79   void initializePPCCTRLoopsPass(PassRegistry &);
80   void initializePPCDAGToDAGISelLegacyPass(PassRegistry &);
81 
82   extern char &PPCVSXFMAMutateID;
83 
84   ModulePass *createPPCLowerMASSVEntriesPass();
85   void initializePPCLowerMASSVEntriesPass(PassRegistry &);
86   extern char &PPCLowerMASSVEntriesID;
87 
88   ModulePass *createPPCGenScalarMASSEntriesPass();
89   void initializePPCGenScalarMASSEntriesPass(PassRegistry &);
90   extern char &PPCGenScalarMASSEntriesID;
91 
92   InstructionSelector *
93   createPPCInstructionSelector(const PPCTargetMachine &, const PPCSubtarget &,
94                                const PPCRegisterBankInfo &);
95   namespace PPCII {
96 
97   /// Target Operand Flag enum.
98   enum TOF {
99     //===------------------------------------------------------------------===//
100     // PPC Specific MachineOperand flags.
101     MO_NO_FLAG,
102 
103     /// On PPC, the 12 bits are not enough for all target operand flags.
104     /// Treat all PPC target flags as direct flags. To define new flag that is
105     /// combination of other flags, add new enum entry instead of combining
106     /// existing flags. See example MO_GOT_TPREL_PCREL_FLAG.
107 
108     /// On a symbol operand "FOO", this indicates that the reference is actually
109     /// to "FOO@plt".  This is used for calls and jumps to external functions
110     /// and for PIC calls on 32-bit ELF systems.
111     MO_PLT,
112 
113     /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
114     /// the function's picbase, e.g. lo16(symbol-picbase).
115     MO_PIC_FLAG,
116 
117     /// MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to
118     /// the current instruction address(pc), e.g., var@pcrel. Fixup is VK_PCREL.
119     MO_PCREL_FLAG,
120 
121     /// MO_GOT_FLAG - If this bit is set the symbol reference is to be computed
122     /// via the GOT. For example when combined with the MO_PCREL_FLAG it should
123     /// produce the relocation @got@pcrel. Fixup is VK_PPC_GOT_PCREL.
124     MO_GOT_FLAG,
125 
126     /// MO_PCREL_OPT_FLAG - If this bit is set the operand is part of a
127     /// PC Relative linker optimization.
128     MO_PCREL_OPT_FLAG,
129 
130     /// MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to
131     /// TLS General Dynamic model for Linux and the variable offset of TLS
132     /// General Dynamic model for AIX.
133     MO_TLSGD_FLAG,
134 
135     /// MO_TPREL_FLAG - If this bit is set, the symbol reference is relative to
136     /// the thread pointer and the symbol can be used for the TLS Initial Exec
137     /// and Local Exec models.
138     MO_TPREL_FLAG,
139 
140     /// MO_TLSLDM_FLAG - on AIX the ML relocation type is only valid for a
141     /// reference to a TOC symbol from the symbol itself, and right now its only
142     /// user is the symbol "_$TLSML". The symbol name is used to decide that
143     /// the R_TLSML relocation is expected.
144     MO_TLSLDM_FLAG,
145 
146     /// MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to
147     /// TLS Local Dynamic model.
148     MO_TLSLD_FLAG,
149 
150     /// MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative
151     /// to the region handle of TLS General Dynamic model for AIX.
152     MO_TLSGDM_FLAG,
153 
154     /// MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set
155     /// they should produce the relocation @got@tlsgd@pcrel.
156     /// Fix up is VK_PPC_GOT_TLSGD_PCREL
157     /// MO_GOT_TLSGD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSGD_FLAG,
158     MO_GOT_TLSGD_PCREL_FLAG,
159 
160     /// MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set
161     /// they should produce the relocation @got@tlsld@pcrel.
162     /// Fix up is VK_PPC_GOT_TLSLD_PCREL
163     /// MO_GOT_TLSLD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSLD_FLAG,
164     MO_GOT_TLSLD_PCREL_FLAG,
165 
166     /// MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set
167     /// they should produce the relocation @got@tprel@pcrel.
168     /// Fix up is VK_PPC_GOT_TPREL_PCREL
169     /// MO_GOT_TPREL_PCREL_FLAG = MO_GOT_FLAG | MO_TPREL_FLAG | MO_PCREL_FLAG,
170     MO_GOT_TPREL_PCREL_FLAG,
171 
172     /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
173     MO_LO,
174     MO_HA,
175 
176     MO_TPREL_LO,
177     MO_TPREL_HA,
178 
179     /// These values identify relocations on immediates folded
180     /// into memory operations.
181     MO_DTPREL_LO,
182     MO_TLSLD_LO,
183     MO_TOC_LO,
184 
185     /// Symbol for VK_PPC_TLS fixup attached to an ADD instruction
186     MO_TLS,
187 
188     /// MO_PIC_HA_FLAG = MO_PIC_FLAG | MO_HA
189     MO_PIC_HA_FLAG,
190 
191     /// MO_PIC_LO_FLAG = MO_PIC_FLAG | MO_LO
192     MO_PIC_LO_FLAG,
193 
194     /// MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TPREL_FLAG
195     MO_TPREL_PCREL_FLAG,
196 
197     /// MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TLS
198     MO_TLS_PCREL_FLAG,
199 
200     /// MO_GOT_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG
201     MO_GOT_PCREL_FLAG,
202   };
203   } // end namespace PPCII
204 
205 } // end namespace llvm;
206 
207 #endif
208