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