210 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file contains the entry points for global functions defined in the LLVM10// PowerPC back-end.11//12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_LIB_TARGET_POWERPC_PPC_H15#define LLVM_LIB_TARGET_POWERPC_PPC_H16 17#include "llvm/Support/CodeGen.h"18 19// GCC #defines PPC on Linux but we use it as our namespace name20#undef PPC21 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 NDEBUG37 FunctionPass *createPPCCTRLoopsVerify();38#endif39 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 void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,57 AsmPrinter &AP);58 bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,59 MCOperand &OutMO, AsmPrinter &AP);60 61#ifndef NDEBUG62 void initializePPCCTRLoopsVerifyPass(PassRegistry&);63#endif64 void initializePPCLoopInstrFormPrepPass(PassRegistry&);65 void initializePPCTOCRegDepsPass(PassRegistry&);66 void initializePPCEarlyReturnPass(PassRegistry&);67 void initializePPCVSXWACCCopyPass(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 void initializePPCLinuxAsmPrinterPass(PassRegistry &);82 void initializePPCAIXAsmPrinterPass(PassRegistry &);83 84 extern char &PPCVSXFMAMutateID;85 86 ModulePass *createPPCLowerMASSVEntriesPass();87 void initializePPCLowerMASSVEntriesPass(PassRegistry &);88 extern char &PPCLowerMASSVEntriesID;89 90 ModulePass *createPPCGenScalarMASSEntriesPass();91 void initializePPCGenScalarMASSEntriesPass(PassRegistry &);92 extern char &PPCGenScalarMASSEntriesID;93 94 InstructionSelector *95 createPPCInstructionSelector(const PPCTargetMachine &, const PPCSubtarget &,96 const PPCRegisterBankInfo &);97 namespace PPCII {98 99 /// Target Operand Flag enum.100 enum TOF {101 //===------------------------------------------------------------------===//102 // PPC Specific MachineOperand flags.103 MO_NO_FLAG,104 105 /// On PPC, the 12 bits are not enough for all target operand flags.106 /// Treat all PPC target flags as direct flags. To define new flag that is107 /// combination of other flags, add new enum entry instead of combining108 /// existing flags. See example MO_GOT_TPREL_PCREL_FLAG.109 110 /// On a symbol operand "FOO", this indicates that the reference is actually111 /// to "FOO@plt". This is used for calls and jumps to external functions112 /// and for PIC calls on 32-bit ELF systems.113 MO_PLT,114 115 /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to116 /// the function's picbase, e.g. lo16(symbol-picbase).117 MO_PIC_FLAG,118 119 /// MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to120 /// the current instruction address(pc), e.g., var@pcrel. Fixup is VK_PCREL.121 MO_PCREL_FLAG,122 123 /// MO_GOT_FLAG - If this bit is set the symbol reference is to be computed124 /// via the GOT. For example when combined with the MO_PCREL_FLAG it should125 /// produce the relocation @got@pcrel. Fixup is VK_GOT_PCREL.126 MO_GOT_FLAG,127 128 /// MO_PCREL_OPT_FLAG - If this bit is set the operand is part of a129 /// PC Relative linker optimization.130 MO_PCREL_OPT_FLAG,131 132 /// MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to133 /// TLS General Dynamic model for Linux and the variable offset of TLS134 /// General Dynamic model for AIX.135 MO_TLSGD_FLAG,136 137 /// MO_TPREL_FLAG - If this bit is set, the symbol reference is relative to138 /// the thread pointer and the symbol can be used for the TLS Initial Exec139 /// and Local Exec models.140 MO_TPREL_FLAG,141 142 /// MO_TLSLDM_FLAG - on AIX the ML relocation type is only valid for a143 /// reference to a TOC symbol from the symbol itself, and right now its only144 /// user is the symbol "_$TLSML". The symbol name is used to decide that145 /// the R_TLSML relocation is expected.146 MO_TLSLDM_FLAG,147 148 /// MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to149 /// TLS Local Dynamic model.150 MO_TLSLD_FLAG,151 152 /// MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative153 /// to the region handle of TLS General Dynamic model for AIX.154 MO_TLSGDM_FLAG,155 156 /// MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set157 /// they should produce the relocation @got@tlsgd@pcrel.158 /// Fix up is VK_GOT_TLSGD_PCREL159 /// MO_GOT_TLSGD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSGD_FLAG,160 MO_GOT_TLSGD_PCREL_FLAG,161 162 /// MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set163 /// they should produce the relocation @got@tlsld@pcrel.164 /// Fix up is VK_GOT_TLSLD_PCREL165 /// MO_GOT_TLSLD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSLD_FLAG,166 MO_GOT_TLSLD_PCREL_FLAG,167 168 /// MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set169 /// they should produce the relocation @got@tprel@pcrel.170 /// Fix up is VK_GOT_TPREL_PCREL171 /// MO_GOT_TPREL_PCREL_FLAG = MO_GOT_FLAG | MO_TPREL_FLAG | MO_PCREL_FLAG,172 MO_GOT_TPREL_PCREL_FLAG,173 174 /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)175 MO_LO,176 MO_HA,177 178 MO_TPREL_LO,179 MO_TPREL_HA,180 181 /// These values identify relocations on immediates folded182 /// into memory operations.183 MO_DTPREL_LO,184 MO_TLSLD_LO,185 MO_TOC_LO,186 187 /// Symbol for VK_TLS fixup attached to an ADD instruction188 MO_TLS,189 190 /// MO_PIC_HA_FLAG = MO_PIC_FLAG | MO_HA191 MO_PIC_HA_FLAG,192 193 /// MO_PIC_LO_FLAG = MO_PIC_FLAG | MO_LO194 MO_PIC_LO_FLAG,195 196 /// MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TPREL_FLAG197 MO_TPREL_PCREL_FLAG,198 199 /// MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TLS200 MO_TLS_PCREL_FLAG,201 202 /// MO_GOT_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG203 MO_GOT_PCREL_FLAG,204 };205 } // end namespace PPCII206 207} // end namespace llvm;208 209#endif210