xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/PPC.h (revision ed549cb0c53f8438c52593ce811f6fcc812248e9)
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 FunctionPass *createPPCCTRLoops();
37 #ifndef NDEBUG
38   FunctionPass *createPPCCTRLoopsVerify();
39 #endif
40   FunctionPass *createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM);
41   FunctionPass *createPPCTOCRegDepsPass();
42   FunctionPass *createPPCEarlyReturnPass();
43   FunctionPass *createPPCVSXCopyPass();
44   FunctionPass *createPPCVSXFMAMutatePass();
45   FunctionPass *createPPCVSXSwapRemovalPass();
46   FunctionPass *createPPCReduceCRLogicalsPass();
47   FunctionPass *createPPCMIPeepholePass();
48   FunctionPass *createPPCBranchSelectionPass();
49   FunctionPass *createPPCBranchCoalescingPass();
50   FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL);
51   FunctionPass *createPPCTLSDynamicCallPass();
52   FunctionPass *createPPCBoolRetToIntPass();
53   FunctionPass *createPPCExpandISELPass();
54   FunctionPass *createPPCPreEmitPeepholePass();
55   FunctionPass *createPPCExpandAtomicPseudoPass();
56   void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
57                                     AsmPrinter &AP);
58   bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
59                                          MCOperand &OutMO, AsmPrinter &AP);
60 
61   void initializePPCCTRLoopsPass(PassRegistry&);
62 #ifndef NDEBUG
63   void initializePPCCTRLoopsVerifyPass(PassRegistry&);
64 #endif
65   void initializePPCLoopInstrFormPrepPass(PassRegistry&);
66   void initializePPCTOCRegDepsPass(PassRegistry&);
67   void initializePPCEarlyReturnPass(PassRegistry&);
68   void initializePPCVSXCopyPass(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 
81   extern char &PPCVSXFMAMutateID;
82 
83   ModulePass *createPPCLowerMASSVEntriesPass();
84   void initializePPCLowerMASSVEntriesPass(PassRegistry &);
85   extern char &PPCLowerMASSVEntriesID;
86 
87   InstructionSelector *
88   createPPCInstructionSelector(const PPCTargetMachine &, const PPCSubtarget &,
89                                const PPCRegisterBankInfo &);
90   namespace PPCII {
91 
92   /// Target Operand Flag enum.
93   enum TOF {
94     //===------------------------------------------------------------------===//
95     // PPC Specific MachineOperand flags.
96     MO_NO_FLAG,
97 
98     /// On a symbol operand "FOO", this indicates that the reference is actually
99     /// to "FOO@plt".  This is used for calls and jumps to external functions
100     /// and for PIC calls on 32-bit ELF systems.
101     MO_PLT = 1,
102 
103     /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
104     /// the function's picbase, e.g. lo16(symbol-picbase).
105     MO_PIC_FLAG = 2,
106 
107     /// MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to
108     /// the current instruction address(pc), e.g., var@pcrel. Fixup is VK_PCREL.
109     MO_PCREL_FLAG = 4,
110 
111     /// MO_GOT_FLAG - If this bit is set the symbol reference is to be computed
112     /// via the GOT. For example when combined with the MO_PCREL_FLAG it should
113     /// produce the relocation @got@pcrel. Fixup is VK_PPC_GOT_PCREL.
114     MO_GOT_FLAG = 8,
115 
116     // MO_PCREL_OPT_FLAG - If this bit is set the operand is part of a
117     // PC Relative linker optimization.
118     MO_PCREL_OPT_FLAG = 16,
119 
120     /// MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to
121     /// TLS General Dynamic model for Linux and the variable offset of TLS
122     /// General Dynamic model for AIX.
123     MO_TLSGD_FLAG = 32,
124 
125     /// MO_TPREL_FLAG - If this bit is set the symbol reference is relative to
126     /// TLS Initial Exec model.
127     MO_TPREL_FLAG = 64,
128 
129     /// MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to
130     /// TLS Local Dynamic model.
131     MO_TLSLD_FLAG = 128,
132 
133     /// MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative
134     /// to the region handle of TLS General Dynamic model for AIX.
135     MO_TLSGDM_FLAG = 256,
136 
137     /// MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set
138     /// they should produce the relocation @got@tlsgd@pcrel.
139     /// Fix up is VK_PPC_GOT_TLSGD_PCREL
140     MO_GOT_TLSGD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSGD_FLAG,
141 
142     /// MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set
143     /// they should produce the relocation @got@tlsld@pcrel.
144     /// Fix up is VK_PPC_GOT_TLSLD_PCREL
145     MO_GOT_TLSLD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSLD_FLAG,
146 
147     /// MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set
148     /// they should produce the relocation @got@tprel@pcrel.
149     /// Fix up is VK_PPC_GOT_TPREL_PCREL
150     MO_GOT_TPREL_PCREL_FLAG = MO_GOT_FLAG | MO_TPREL_FLAG | MO_PCREL_FLAG,
151 
152     /// The next are not flags but distinct values.
153     MO_ACCESS_MASK = 0xf00,
154 
155     /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
156     MO_LO = 1 << 8,
157     MO_HA = 2 << 8,
158 
159     MO_TPREL_LO = 4 << 8,
160     MO_TPREL_HA = 3 << 8,
161 
162     /// These values identify relocations on immediates folded
163     /// into memory operations.
164     MO_DTPREL_LO = 5 << 8,
165     MO_TLSLD_LO = 6 << 8,
166     MO_TOC_LO = 7 << 8,
167 
168     // Symbol for VK_PPC_TLS fixup attached to an ADD instruction
169     MO_TLS = 8 << 8
170   };
171   } // end namespace PPCII
172 
173 } // end namespace llvm;
174 
175 #endif
176