Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
6.2 KiB

  1. //===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file provides utilities to make sure that certain classes of targets are
  11. // linked into the main application executable, and initialize them as
  12. // appropriate.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_SUPPORT_TARGETSELECT_H
  16. #define LLVM_SUPPORT_TARGETSELECT_H
  17. #include "llvm/Config/llvm-config.h"
  18. extern "C" {
  19. // Declare all of the target-initialization functions that are available.
  20. #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
  21. #include "llvm/Config/Targets.def"
  22. #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
  23. #include "llvm/Config/Targets.def"
  24. // Declare all of the target-MC-initialization functions that are available.
  25. #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetMC();
  26. #include "llvm/Config/Targets.def"
  27. // Declare all of the available assembly printer initialization functions.
  28. #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
  29. #include "llvm/Config/AsmPrinters.def"
  30. // Declare all of the available assembly parser initialization functions.
  31. #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
  32. #include "llvm/Config/AsmParsers.def"
  33. // Declare all of the available disassembler initialization functions.
  34. #define LLVM_DISASSEMBLER(TargetName) \
  35. void LLVMInitialize##TargetName##Disassembler();
  36. #include "llvm/Config/Disassemblers.def"
  37. }
  38. namespace llvm {
  39. /// InitializeAllTargetInfos - The main program should call this function if
  40. /// it wants access to all available targets that LLVM is configured to
  41. /// support, to make them available via the TargetRegistry.
  42. ///
  43. /// It is legal for a client to make multiple calls to this function.
  44. inline void InitializeAllTargetInfos() {
  45. #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
  46. #include "llvm/Config/Targets.def"
  47. }
  48. /// InitializeAllTargets - The main program should call this function if it
  49. /// wants access to all available target machines that LLVM is configured to
  50. /// support, to make them available via the TargetRegistry.
  51. ///
  52. /// It is legal for a client to make multiple calls to this function.
  53. inline void InitializeAllTargets() {
  54. // FIXME: Remove this, clients should do it.
  55. InitializeAllTargetInfos();
  56. #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
  57. #include "llvm/Config/Targets.def"
  58. }
  59. /// InitializeAllTargetMCs - The main program should call this function if it
  60. /// wants access to all available target MC that LLVM is configured to
  61. /// support, to make them available via the TargetRegistry.
  62. ///
  63. /// It is legal for a client to make multiple calls to this function.
  64. inline void InitializeAllTargetMCs() {
  65. #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
  66. #include "llvm/Config/Targets.def"
  67. }
  68. /// InitializeAllAsmPrinters - The main program should call this function if
  69. /// it wants all asm printers that LLVM is configured to support, to make them
  70. /// available via the TargetRegistry.
  71. ///
  72. /// It is legal for a client to make multiple calls to this function.
  73. inline void InitializeAllAsmPrinters() {
  74. #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
  75. #include "llvm/Config/AsmPrinters.def"
  76. }
  77. /// InitializeAllAsmParsers - The main program should call this function if it
  78. /// wants all asm parsers that LLVM is configured to support, to make them
  79. /// available via the TargetRegistry.
  80. ///
  81. /// It is legal for a client to make multiple calls to this function.
  82. inline void InitializeAllAsmParsers() {
  83. #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
  84. #include "llvm/Config/AsmParsers.def"
  85. }
  86. /// InitializeAllDisassemblers - The main program should call this function if
  87. /// it wants all disassemblers that LLVM is configured to support, to make
  88. /// them available via the TargetRegistry.
  89. ///
  90. /// It is legal for a client to make multiple calls to this function.
  91. inline void InitializeAllDisassemblers() {
  92. #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
  93. #include "llvm/Config/Disassemblers.def"
  94. }
  95. /// InitializeNativeTarget - The main program should call this function to
  96. /// initialize the native target corresponding to the host. This is useful
  97. /// for JIT applications to ensure that the target gets linked in correctly.
  98. ///
  99. /// It is legal for a client to make multiple calls to this function.
  100. inline bool InitializeNativeTarget() {
  101. // If we have a native target, initialize it to ensure it is linked in.
  102. #ifdef LLVM_NATIVE_TARGET
  103. LLVM_NATIVE_TARGETINFO();
  104. LLVM_NATIVE_TARGET();
  105. LLVM_NATIVE_TARGETMC();
  106. return false;
  107. #else
  108. return true;
  109. #endif
  110. }
  111. /// InitializeNativeTargetAsmPrinter - The main program should call
  112. /// this function to initialize the native target asm printer.
  113. inline bool InitializeNativeTargetAsmPrinter() {
  114. // If we have a native target, initialize the corresponding asm printer.
  115. #ifdef LLVM_NATIVE_ASMPRINTER
  116. LLVM_NATIVE_ASMPRINTER();
  117. return false;
  118. #else
  119. return true;
  120. #endif
  121. }
  122. /// InitializeNativeTargetAsmParser - The main program should call
  123. /// this function to initialize the native target asm parser.
  124. inline bool InitializeNativeTargetAsmParser() {
  125. // If we have a native target, initialize the corresponding asm parser.
  126. #ifdef LLVM_NATIVE_ASMPARSER
  127. LLVM_NATIVE_ASMPARSER();
  128. return false;
  129. #else
  130. return true;
  131. #endif
  132. }
  133. /// InitializeNativeTargetDisassembler - The main program should call
  134. /// this function to initialize the native target disassembler.
  135. inline bool InitializeNativeTargetDisassembler() {
  136. // If we have a native target, initialize the corresponding disassembler.
  137. #ifdef LLVM_NATIVE_DISASSEMBLER
  138. LLVM_NATIVE_DISASSEMBLER();
  139. return false;
  140. #else
  141. return true;
  142. #endif
  143. }
  144. }
  145. #endif