CodeGen.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- 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 define some types which define code generation concepts. For
  11. // example, relocation model.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_SUPPORT_CODEGEN_H
  15. #define LLVM_SUPPORT_CODEGEN_H
  16. #include "llvm-c/TargetMachine.h"
  17. #include "llvm/Support/ErrorHandling.h"
  18. namespace llvm {
  19. // Relocation model types.
  20. namespace Reloc {
  21. enum Model { Default, Static, PIC_, DynamicNoPIC };
  22. }
  23. // Code model types.
  24. namespace CodeModel {
  25. enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
  26. }
  27. namespace PICLevel {
  28. enum Level { Default=0, Small=1, Large=2 };
  29. }
  30. // TLS models.
  31. namespace TLSModel {
  32. enum Model {
  33. GeneralDynamic,
  34. LocalDynamic,
  35. InitialExec,
  36. LocalExec
  37. };
  38. }
  39. // Code generation optimization level.
  40. namespace CodeGenOpt {
  41. enum Level {
  42. None, // -O0
  43. Less, // -O1
  44. Default, // -O2, -Os
  45. Aggressive // -O3
  46. };
  47. }
  48. // Create wrappers for C Binding types (see CBindingWrapping.h).
  49. inline CodeModel::Model unwrap(LLVMCodeModel Model) {
  50. switch (Model) {
  51. case LLVMCodeModelDefault:
  52. return CodeModel::Default;
  53. case LLVMCodeModelJITDefault:
  54. return CodeModel::JITDefault;
  55. case LLVMCodeModelSmall:
  56. return CodeModel::Small;
  57. case LLVMCodeModelKernel:
  58. return CodeModel::Kernel;
  59. case LLVMCodeModelMedium:
  60. return CodeModel::Medium;
  61. case LLVMCodeModelLarge:
  62. return CodeModel::Large;
  63. }
  64. return CodeModel::Default;
  65. }
  66. inline LLVMCodeModel wrap(CodeModel::Model Model) {
  67. switch (Model) {
  68. case CodeModel::Default:
  69. return LLVMCodeModelDefault;
  70. case CodeModel::JITDefault:
  71. return LLVMCodeModelJITDefault;
  72. case CodeModel::Small:
  73. return LLVMCodeModelSmall;
  74. case CodeModel::Kernel:
  75. return LLVMCodeModelKernel;
  76. case CodeModel::Medium:
  77. return LLVMCodeModelMedium;
  78. case CodeModel::Large:
  79. return LLVMCodeModelLarge;
  80. }
  81. llvm_unreachable("Bad CodeModel!");
  82. }
  83. } // end llvm namespace
  84. #endif