xref: /openbsd/gnu/llvm/llvm/lib/Target/PowerPC/PPC.h (revision d415bd75)
109467b48Spatrick //===-- PPC.h - Top-level interface for PowerPC Target ----------*- C++ -*-===//
209467b48Spatrick //
309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information.
509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
609467b48Spatrick //
709467b48Spatrick //===----------------------------------------------------------------------===//
809467b48Spatrick //
909467b48Spatrick // This file contains the entry points for global functions defined in the LLVM
1009467b48Spatrick // PowerPC back-end.
1109467b48Spatrick //
1209467b48Spatrick //===----------------------------------------------------------------------===//
1309467b48Spatrick 
1409467b48Spatrick #ifndef LLVM_LIB_TARGET_POWERPC_PPC_H
1509467b48Spatrick #define LLVM_LIB_TARGET_POWERPC_PPC_H
1609467b48Spatrick 
1709467b48Spatrick #include "llvm/Support/CodeGen.h"
1809467b48Spatrick 
1909467b48Spatrick // GCC #defines PPC on Linux but we use it as our namespace name
2009467b48Spatrick #undef PPC
2109467b48Spatrick 
2209467b48Spatrick namespace llvm {
2373471bf0Spatrick class PPCRegisterBankInfo;
2473471bf0Spatrick class PPCSubtarget;
2509467b48Spatrick class PPCTargetMachine;
2609467b48Spatrick class PassRegistry;
2709467b48Spatrick class FunctionPass;
2873471bf0Spatrick class InstructionSelector;
2909467b48Spatrick class MachineInstr;
3009467b48Spatrick class MachineOperand;
3109467b48Spatrick class AsmPrinter;
3209467b48Spatrick class MCInst;
3309467b48Spatrick class MCOperand;
3409467b48Spatrick class ModulePass;
3509467b48Spatrick 
3609467b48Spatrick #ifndef NDEBUG
3709467b48Spatrick   FunctionPass *createPPCCTRLoopsVerify();
3809467b48Spatrick #endif
3909467b48Spatrick   FunctionPass *createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM);
4009467b48Spatrick   FunctionPass *createPPCTOCRegDepsPass();
4109467b48Spatrick   FunctionPass *createPPCEarlyReturnPass();
4209467b48Spatrick   FunctionPass *createPPCVSXCopyPass();
4309467b48Spatrick   FunctionPass *createPPCVSXFMAMutatePass();
4409467b48Spatrick   FunctionPass *createPPCVSXSwapRemovalPass();
4509467b48Spatrick   FunctionPass *createPPCReduceCRLogicalsPass();
4609467b48Spatrick   FunctionPass *createPPCMIPeepholePass();
4709467b48Spatrick   FunctionPass *createPPCBranchSelectionPass();
4809467b48Spatrick   FunctionPass *createPPCBranchCoalescingPass();
4909467b48Spatrick   FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL);
5009467b48Spatrick   FunctionPass *createPPCTLSDynamicCallPass();
5109467b48Spatrick   FunctionPass *createPPCBoolRetToIntPass();
5209467b48Spatrick   FunctionPass *createPPCExpandISELPass();
5309467b48Spatrick   FunctionPass *createPPCPreEmitPeepholePass();
5473471bf0Spatrick   FunctionPass *createPPCExpandAtomicPseudoPass();
55*d415bd75Srobert   FunctionPass *createPPCCTRLoopsPass();
5609467b48Spatrick   void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
57097a140dSpatrick                                     AsmPrinter &AP);
5809467b48Spatrick   bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
59097a140dSpatrick                                          MCOperand &OutMO, AsmPrinter &AP);
6009467b48Spatrick 
6109467b48Spatrick #ifndef NDEBUG
6209467b48Spatrick   void initializePPCCTRLoopsVerifyPass(PassRegistry&);
6309467b48Spatrick #endif
6409467b48Spatrick   void initializePPCLoopInstrFormPrepPass(PassRegistry&);
6509467b48Spatrick   void initializePPCTOCRegDepsPass(PassRegistry&);
6609467b48Spatrick   void initializePPCEarlyReturnPass(PassRegistry&);
6709467b48Spatrick   void initializePPCVSXCopyPass(PassRegistry&);
6809467b48Spatrick   void initializePPCVSXFMAMutatePass(PassRegistry&);
6909467b48Spatrick   void initializePPCVSXSwapRemovalPass(PassRegistry&);
7009467b48Spatrick   void initializePPCReduceCRLogicalsPass(PassRegistry&);
7109467b48Spatrick   void initializePPCBSelPass(PassRegistry&);
7209467b48Spatrick   void initializePPCBranchCoalescingPass(PassRegistry&);
7309467b48Spatrick   void initializePPCBoolRetToIntPass(PassRegistry&);
7409467b48Spatrick   void initializePPCExpandISELPass(PassRegistry &);
7509467b48Spatrick   void initializePPCPreEmitPeepholePass(PassRegistry &);
7609467b48Spatrick   void initializePPCTLSDynamicCallPass(PassRegistry &);
7709467b48Spatrick   void initializePPCMIPeepholePass(PassRegistry&);
7873471bf0Spatrick   void initializePPCExpandAtomicPseudoPass(PassRegistry &);
79*d415bd75Srobert   void initializePPCCTRLoopsPass(PassRegistry &);
80*d415bd75Srobert   void initializePPCDAGToDAGISelPass(PassRegistry &);
8109467b48Spatrick 
8209467b48Spatrick   extern char &PPCVSXFMAMutateID;
8309467b48Spatrick 
8409467b48Spatrick   ModulePass *createPPCLowerMASSVEntriesPass();
8509467b48Spatrick   void initializePPCLowerMASSVEntriesPass(PassRegistry &);
8609467b48Spatrick   extern char &PPCLowerMASSVEntriesID;
8709467b48Spatrick 
88*d415bd75Srobert   ModulePass *createPPCGenScalarMASSEntriesPass();
89*d415bd75Srobert   void initializePPCGenScalarMASSEntriesPass(PassRegistry &);
90*d415bd75Srobert   extern char &PPCGenScalarMASSEntriesID;
91*d415bd75Srobert 
9273471bf0Spatrick   InstructionSelector *
9373471bf0Spatrick   createPPCInstructionSelector(const PPCTargetMachine &, const PPCSubtarget &,
9473471bf0Spatrick                                const PPCRegisterBankInfo &);
9509467b48Spatrick   namespace PPCII {
9609467b48Spatrick 
9709467b48Spatrick   /// Target Operand Flag enum.
9809467b48Spatrick   enum TOF {
9909467b48Spatrick     //===------------------------------------------------------------------===//
10009467b48Spatrick     // PPC Specific MachineOperand flags.
10109467b48Spatrick     MO_NO_FLAG,
10209467b48Spatrick 
10309467b48Spatrick     /// On a symbol operand "FOO", this indicates that the reference is actually
10409467b48Spatrick     /// to "FOO@plt".  This is used for calls and jumps to external functions
10509467b48Spatrick     /// and for PIC calls on 32-bit ELF systems.
10609467b48Spatrick     MO_PLT = 1,
10709467b48Spatrick 
10809467b48Spatrick     /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
10909467b48Spatrick     /// the function's picbase, e.g. lo16(symbol-picbase).
11009467b48Spatrick     MO_PIC_FLAG = 2,
11109467b48Spatrick 
112097a140dSpatrick     /// MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to
113097a140dSpatrick     /// the current instruction address(pc), e.g., var@pcrel. Fixup is VK_PCREL.
114097a140dSpatrick     MO_PCREL_FLAG = 4,
11509467b48Spatrick 
116097a140dSpatrick     /// MO_GOT_FLAG - If this bit is set the symbol reference is to be computed
117097a140dSpatrick     /// via the GOT. For example when combined with the MO_PCREL_FLAG it should
118097a140dSpatrick     /// produce the relocation @got@pcrel. Fixup is VK_PPC_GOT_PCREL.
119097a140dSpatrick     MO_GOT_FLAG = 8,
12009467b48Spatrick 
12173471bf0Spatrick     // MO_PCREL_OPT_FLAG - If this bit is set the operand is part of a
12273471bf0Spatrick     // PC Relative linker optimization.
12373471bf0Spatrick     MO_PCREL_OPT_FLAG = 16,
12473471bf0Spatrick 
12573471bf0Spatrick     /// MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to
12673471bf0Spatrick     /// TLS General Dynamic model for Linux and the variable offset of TLS
12773471bf0Spatrick     /// General Dynamic model for AIX.
12873471bf0Spatrick     MO_TLSGD_FLAG = 32,
12973471bf0Spatrick 
13073471bf0Spatrick     /// MO_TPREL_FLAG - If this bit is set the symbol reference is relative to
13173471bf0Spatrick     /// TLS Initial Exec model.
13273471bf0Spatrick     MO_TPREL_FLAG = 64,
13373471bf0Spatrick 
13473471bf0Spatrick     /// MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to
13573471bf0Spatrick     /// TLS Local Dynamic model.
13673471bf0Spatrick     MO_TLSLD_FLAG = 128,
13773471bf0Spatrick 
13873471bf0Spatrick     /// MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative
13973471bf0Spatrick     /// to the region handle of TLS General Dynamic model for AIX.
14073471bf0Spatrick     MO_TLSGDM_FLAG = 256,
14173471bf0Spatrick 
14273471bf0Spatrick     /// MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set
14373471bf0Spatrick     /// they should produce the relocation @got@tlsgd@pcrel.
14473471bf0Spatrick     /// Fix up is VK_PPC_GOT_TLSGD_PCREL
14573471bf0Spatrick     MO_GOT_TLSGD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSGD_FLAG,
14673471bf0Spatrick 
14773471bf0Spatrick     /// MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set
14873471bf0Spatrick     /// they should produce the relocation @got@tlsld@pcrel.
14973471bf0Spatrick     /// Fix up is VK_PPC_GOT_TLSLD_PCREL
15073471bf0Spatrick     MO_GOT_TLSLD_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG | MO_TLSLD_FLAG,
15173471bf0Spatrick 
15273471bf0Spatrick     /// MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set
15373471bf0Spatrick     /// they should produce the relocation @got@tprel@pcrel.
15473471bf0Spatrick     /// Fix up is VK_PPC_GOT_TPREL_PCREL
15573471bf0Spatrick     MO_GOT_TPREL_PCREL_FLAG = MO_GOT_FLAG | MO_TPREL_FLAG | MO_PCREL_FLAG,
15673471bf0Spatrick 
15709467b48Spatrick     /// The next are not flags but distinct values.
158097a140dSpatrick     MO_ACCESS_MASK = 0xf00,
15909467b48Spatrick 
16009467b48Spatrick     /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
161097a140dSpatrick     MO_LO = 1 << 8,
162097a140dSpatrick     MO_HA = 2 << 8,
16309467b48Spatrick 
164097a140dSpatrick     MO_TPREL_LO = 4 << 8,
165097a140dSpatrick     MO_TPREL_HA = 3 << 8,
16609467b48Spatrick 
16709467b48Spatrick     /// These values identify relocations on immediates folded
16809467b48Spatrick     /// into memory operations.
169097a140dSpatrick     MO_DTPREL_LO = 5 << 8,
170097a140dSpatrick     MO_TLSLD_LO = 6 << 8,
171097a140dSpatrick     MO_TOC_LO = 7 << 8,
17209467b48Spatrick 
17309467b48Spatrick     // Symbol for VK_PPC_TLS fixup attached to an ADD instruction
174097a140dSpatrick     MO_TLS = 8 << 8
17509467b48Spatrick   };
17609467b48Spatrick   } // end namespace PPCII
17709467b48Spatrick 
17809467b48Spatrick } // end namespace llvm;
17909467b48Spatrick 
18009467b48Spatrick #endif
181