Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:34

0001 //===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file provides utilities to make sure that certain classes of targets are
0010 // linked into the main application executable, and initialize them as
0011 // appropriate.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_SUPPORT_TARGETSELECT_H
0016 #define LLVM_SUPPORT_TARGETSELECT_H
0017 
0018 #include "llvm/Config/llvm-config.h"
0019 
0020 extern "C" {
0021   // Declare all of the target-initialization functions that are available.
0022 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
0023 #include "llvm/Config/Targets.def"
0024 
0025 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
0026 #include "llvm/Config/Targets.def"
0027 
0028   // Declare all of the target-MC-initialization functions that are available.
0029 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetMC();
0030 #include "llvm/Config/Targets.def"
0031 
0032   // Declare all of the available assembly printer initialization functions.
0033 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
0034 #include "llvm/Config/AsmPrinters.def"
0035 
0036   // Declare all of the available assembly parser initialization functions.
0037 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
0038 #include "llvm/Config/AsmParsers.def"
0039 
0040   // Declare all of the available disassembler initialization functions.
0041 #define LLVM_DISASSEMBLER(TargetName) \
0042   void LLVMInitialize##TargetName##Disassembler();
0043 #include "llvm/Config/Disassemblers.def"
0044 
0045 // Declare all of the available TargetMCA initialization functions.
0046 #define LLVM_TARGETMCA(TargetName) void LLVMInitialize##TargetName##TargetMCA();
0047 #include "llvm/Config/TargetMCAs.def"
0048 }
0049 
0050 namespace llvm {
0051   /// InitializeAllTargetInfos - The main program should call this function if
0052   /// it wants access to all available targets that LLVM is configured to
0053   /// support, to make them available via the TargetRegistry.
0054   ///
0055   /// It is legal for a client to make multiple calls to this function.
0056   inline void InitializeAllTargetInfos() {
0057 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
0058 #include "llvm/Config/Targets.def"
0059   }
0060 
0061   /// InitializeAllTargets - The main program should call this function if it
0062   /// wants access to all available target machines that LLVM is configured to
0063   /// support, to make them available via the TargetRegistry.
0064   ///
0065   /// It is legal for a client to make multiple calls to this function.
0066   inline void InitializeAllTargets() {
0067     // FIXME: Remove this, clients should do it.
0068     InitializeAllTargetInfos();
0069 
0070 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
0071 #include "llvm/Config/Targets.def"
0072   }
0073 
0074   /// InitializeAllTargetMCs - The main program should call this function if it
0075   /// wants access to all available target MC that LLVM is configured to
0076   /// support, to make them available via the TargetRegistry.
0077   ///
0078   /// It is legal for a client to make multiple calls to this function.
0079   inline void InitializeAllTargetMCs() {
0080 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
0081 #include "llvm/Config/Targets.def"
0082   }
0083 
0084   /// InitializeAllAsmPrinters - The main program should call this function if
0085   /// it wants all asm printers that LLVM is configured to support, to make them
0086   /// available via the TargetRegistry.
0087   ///
0088   /// It is legal for a client to make multiple calls to this function.
0089   inline void InitializeAllAsmPrinters() {
0090 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
0091 #include "llvm/Config/AsmPrinters.def"
0092   }
0093 
0094   /// InitializeAllAsmParsers - The main program should call this function if it
0095   /// wants all asm parsers that LLVM is configured to support, to make them
0096   /// available via the TargetRegistry.
0097   ///
0098   /// It is legal for a client to make multiple calls to this function.
0099   inline void InitializeAllAsmParsers() {
0100 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
0101 #include "llvm/Config/AsmParsers.def"
0102   }
0103 
0104   /// InitializeAllDisassemblers - The main program should call this function if
0105   /// it wants all disassemblers that LLVM is configured to support, to make
0106   /// them available via the TargetRegistry.
0107   ///
0108   /// It is legal for a client to make multiple calls to this function.
0109   inline void InitializeAllDisassemblers() {
0110 #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
0111 #include "llvm/Config/Disassemblers.def"
0112   }
0113 
0114   /// InitializeNativeTarget - The main program should call this function to
0115   /// initialize the native target corresponding to the host.  This is useful
0116   /// for JIT applications to ensure that the target gets linked in correctly.
0117   ///
0118   /// It is legal for a client to make multiple calls to this function.
0119   inline bool InitializeNativeTarget() {
0120   // If we have a native target, initialize it to ensure it is linked in.
0121 #ifdef LLVM_NATIVE_TARGET
0122     LLVM_NATIVE_TARGETINFO();
0123     LLVM_NATIVE_TARGET();
0124     LLVM_NATIVE_TARGETMC();
0125     return false;
0126 #else
0127     return true;
0128 #endif
0129   }
0130 
0131   /// InitializeNativeTargetAsmPrinter - The main program should call
0132   /// this function to initialize the native target asm printer.
0133   inline bool InitializeNativeTargetAsmPrinter() {
0134   // If we have a native target, initialize the corresponding asm printer.
0135 #ifdef LLVM_NATIVE_ASMPRINTER
0136     LLVM_NATIVE_ASMPRINTER();
0137     return false;
0138 #else
0139     return true;
0140 #endif
0141   }
0142 
0143   /// InitializeNativeTargetAsmParser - The main program should call
0144   /// this function to initialize the native target asm parser.
0145   inline bool InitializeNativeTargetAsmParser() {
0146   // If we have a native target, initialize the corresponding asm parser.
0147 #ifdef LLVM_NATIVE_ASMPARSER
0148     LLVM_NATIVE_ASMPARSER();
0149     return false;
0150 #else
0151     return true;
0152 #endif
0153   }
0154 
0155   /// InitializeNativeTargetDisassembler - The main program should call
0156   /// this function to initialize the native target disassembler.
0157   inline bool InitializeNativeTargetDisassembler() {
0158   // If we have a native target, initialize the corresponding disassembler.
0159 #ifdef LLVM_NATIVE_DISASSEMBLER
0160     LLVM_NATIVE_DISASSEMBLER();
0161     return false;
0162 #else
0163     return true;
0164 #endif
0165   }
0166 
0167   /// InitializeAllTargetMCAs - The main program should call
0168   /// this function to initialize the target CustomBehaviour and
0169   /// InstrPostProcess classes.
0170   inline void InitializeAllTargetMCAs() {
0171 #define LLVM_TARGETMCA(TargetName) LLVMInitialize##TargetName##TargetMCA();
0172 #include "llvm/Config/TargetMCAs.def"
0173   }
0174 }
0175 
0176 #endif