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