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.

146 lines
5.5 KiB

  1. /*===-- llvm-c/TargetMachine.h - Target Machine Library C Interface - 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 header declares the C interface to the Target and TargetMachine *|
  11. |* classes, which can be used to generate assembly or object files. *|
  12. |* *|
  13. |* Many exotic languages can interoperate with C code but have a harder time *|
  14. |* with C++ due to name mangling. So in addition to C, this interface enables *|
  15. |* tools written in such languages. *|
  16. |* *|
  17. \*===----------------------------------------------------------------------===*/
  18. #ifndef LLVM_C_TARGETMACHINE_H
  19. #define LLVM_C_TARGETMACHINE_H
  20. #include "llvm-c/Core.h"
  21. #include "llvm-c/Target.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. typedef struct LLVMTargetMachine *LLVMTargetMachineRef;
  26. typedef struct LLVMTarget *LLVMTargetRef;
  27. typedef enum {
  28. LLVMCodeGenLevelNone,
  29. LLVMCodeGenLevelLess,
  30. LLVMCodeGenLevelDefault,
  31. LLVMCodeGenLevelAggressive
  32. } LLVMCodeGenOptLevel;
  33. typedef enum {
  34. LLVMRelocDefault,
  35. LLVMRelocStatic,
  36. LLVMRelocPIC,
  37. LLVMRelocDynamicNoPic
  38. } LLVMRelocMode;
  39. typedef enum {
  40. LLVMCodeModelDefault,
  41. LLVMCodeModelJITDefault,
  42. LLVMCodeModelSmall,
  43. LLVMCodeModelKernel,
  44. LLVMCodeModelMedium,
  45. LLVMCodeModelLarge
  46. } LLVMCodeModel;
  47. typedef enum {
  48. LLVMAssemblyFile,
  49. LLVMObjectFile
  50. } LLVMCodeGenFileType;
  51. /** Returns the first llvm::Target in the registered targets list. */
  52. LLVMTargetRef LLVMGetFirstTarget();
  53. /** Returns the next llvm::Target given a previous one (or null if there's none) */
  54. LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T);
  55. /*===-- Target ------------------------------------------------------------===*/
  56. /** Returns the name of a target. See llvm::Target::getName */
  57. const char *LLVMGetTargetName(LLVMTargetRef T);
  58. /** Returns the description of a target. See llvm::Target::getDescription */
  59. const char *LLVMGetTargetDescription(LLVMTargetRef T);
  60. /** Returns if the target has a JIT */
  61. LLVMBool LLVMTargetHasJIT(LLVMTargetRef T);
  62. /** Returns if the target has a TargetMachine associated */
  63. LLVMBool LLVMTargetHasTargetMachine(LLVMTargetRef T);
  64. /** Returns if the target as an ASM backend (required for emitting output) */
  65. LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T);
  66. /*===-- Target Machine ----------------------------------------------------===*/
  67. /** Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine */
  68. LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, char *Triple,
  69. char *CPU, char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
  70. LLVMCodeModel CodeModel);
  71. /** Dispose the LLVMTargetMachineRef instance generated by
  72. LLVMCreateTargetMachine. */
  73. void LLVMDisposeTargetMachine(LLVMTargetMachineRef T);
  74. /** Returns the Target used in a TargetMachine */
  75. LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T);
  76. /** Returns the triple used creating this target machine. See
  77. llvm::TargetMachine::getTriple. The result needs to be disposed with
  78. LLVMDisposeMessage. */
  79. char *LLVMGetTargetMachineTriple(LLVMTargetMachineRef T);
  80. /** Returns the cpu used creating this target machine. See
  81. llvm::TargetMachine::getCPU. The result needs to be disposed with
  82. LLVMDisposeMessage. */
  83. char *LLVMGetTargetMachineCPU(LLVMTargetMachineRef T);
  84. /** Returns the feature string used creating this target machine. See
  85. llvm::TargetMachine::getFeatureString. The result needs to be disposed with
  86. LLVMDisposeMessage. */
  87. char *LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T);
  88. /** Returns the llvm::DataLayout used for this llvm:TargetMachine. */
  89. LLVMTargetDataRef LLVMGetTargetMachineData(LLVMTargetMachineRef T);
  90. /** Emits an asm or object file for the given module to the filename. This
  91. wraps several c++ only classes (among them a file stream). Returns any
  92. error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */
  93. LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
  94. char *Filename, LLVMCodeGenFileType codegen, char **ErrorMessage);
  95. /** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
  96. LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M,
  97. LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf);
  98. #ifdef __cplusplus
  99. }
  100. namespace llvm {
  101. class TargetMachine;
  102. class Target;
  103. inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
  104. return reinterpret_cast<TargetMachine*>(P);
  105. }
  106. inline Target *unwrap(LLVMTargetRef P) {
  107. return reinterpret_cast<Target*>(P);
  108. }
  109. inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
  110. return reinterpret_cast<LLVMTargetMachineRef>(
  111. const_cast<TargetMachine*>(P));
  112. }
  113. inline LLVMTargetRef wrap(const Target * P) {
  114. return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(P));
  115. }
  116. }
  117. #endif
  118. #endif