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