1 //===- llvm/Support/CodeGenCWrappers.h - CodeGen C Wrappers -----*- 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 defines C bindings wrappers for enums in llvm/Support/CodeGen.h 11 // that need them. The wrappers are separated to avoid adding an indirect 12 // dependency on llvm/Config/Targets.def to CodeGen.h. 13 // 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_SUPPORT_CODEGENCWRAPPERS_H 17 #define LLVM_SUPPORT_CODEGENCWRAPPERS_H 18 19 #include "llvm-c/TargetMachine.h" 20 #include "llvm/Support/CodeGen.h" 21 #include "llvm/Support/ErrorHandling.h" 22 23 namespace llvm { 24 unwrap(LLVMCodeModel Model)25inline CodeModel::Model unwrap(LLVMCodeModel Model) { 26 switch (Model) { 27 case LLVMCodeModelDefault: 28 return CodeModel::Default; 29 case LLVMCodeModelJITDefault: 30 return CodeModel::JITDefault; 31 case LLVMCodeModelSmall: 32 return CodeModel::Small; 33 case LLVMCodeModelKernel: 34 return CodeModel::Kernel; 35 case LLVMCodeModelMedium: 36 return CodeModel::Medium; 37 case LLVMCodeModelLarge: 38 return CodeModel::Large; 39 } 40 return CodeModel::Default; 41 } 42 wrap(CodeModel::Model Model)43inline LLVMCodeModel wrap(CodeModel::Model Model) { 44 switch (Model) { 45 case CodeModel::Default: 46 return LLVMCodeModelDefault; 47 case CodeModel::JITDefault: 48 return LLVMCodeModelJITDefault; 49 case CodeModel::Small: 50 return LLVMCodeModelSmall; 51 case CodeModel::Kernel: 52 return LLVMCodeModelKernel; 53 case CodeModel::Medium: 54 return LLVMCodeModelMedium; 55 case CodeModel::Large: 56 return LLVMCodeModelLarge; 57 } 58 llvm_unreachable("Bad CodeModel!"); 59 } 60 61 } // end llvm namespace 62 63 #endif 64 65