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