1 //===- llvm/Target/CodeGenCWrappers.h - CodeGen C Wrappers ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_CODEGENCWRAPPERS_H
17 #define LLVM_TARGET_CODEGENCWRAPPERS_H
19 #include "llvm-c/TargetMachine.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Support/ErrorHandling.h"
26 inline Optional<CodeModel::Model> unwrap(LLVMCodeModel Model, bool &JIT) {
29 case LLVMCodeModelJITDefault:
32 case LLVMCodeModelDefault:
34 case LLVMCodeModelSmall:
35 return CodeModel::Small;
36 case LLVMCodeModelKernel:
37 return CodeModel::Kernel;
38 case LLVMCodeModelMedium:
39 return CodeModel::Medium;
40 case LLVMCodeModelLarge:
41 return CodeModel::Large;
43 return CodeModel::Small;
46 inline LLVMCodeModel wrap(CodeModel::Model Model) {
48 case CodeModel::Small:
49 return LLVMCodeModelSmall;
50 case CodeModel::Kernel:
51 return LLVMCodeModelKernel;
52 case CodeModel::Medium:
53 return LLVMCodeModelMedium;
54 case CodeModel::Large:
55 return LLVMCodeModelLarge;
57 llvm_unreachable("Bad CodeModel!");