1 //===- llvm/Target/CodeGenCWrappers.h - CodeGen C Wrappers ------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines C bindings wrappers for enums in llvm/Support/CodeGen.h
10 // that need them. The wrappers are separated to avoid adding an indirect
11 // dependency on llvm/Config/Targets.def to CodeGen.h.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TARGET_CODEGENCWRAPPERS_H
16 #define LLVM_TARGET_CODEGENCWRAPPERS_H
18 #include "llvm-c/TargetMachine.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/Support/CodeGen.h"
21 #include "llvm/Support/ErrorHandling.h"
25 inline Optional
<CodeModel::Model
> unwrap(LLVMCodeModel Model
, bool &JIT
) {
28 case LLVMCodeModelJITDefault
:
31 case LLVMCodeModelDefault
:
33 case LLVMCodeModelTiny
:
34 return CodeModel::Tiny
;
35 case LLVMCodeModelSmall
:
36 return CodeModel::Small
;
37 case LLVMCodeModelKernel
:
38 return CodeModel::Kernel
;
39 case LLVMCodeModelMedium
:
40 return CodeModel::Medium
;
41 case LLVMCodeModelLarge
:
42 return CodeModel::Large
;
44 return CodeModel::Small
;
47 inline LLVMCodeModel
wrap(CodeModel::Model Model
) {
50 return LLVMCodeModelTiny
;
51 case CodeModel::Small
:
52 return LLVMCodeModelSmall
;
53 case CodeModel::Kernel
:
54 return LLVMCodeModelKernel
;
55 case CodeModel::Medium
:
56 return LLVMCodeModelMedium
;
57 case CodeModel::Large
:
58 return LLVMCodeModelLarge
;
60 llvm_unreachable("Bad CodeModel!");