LLVM 20.0.0git
CodeGenCWrappers.h
Go to the documentation of this file.
1//===- llvm/Target/CodeGenCWrappers.h - CodeGen C Wrappers ------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
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.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TARGET_CODEGENCWRAPPERS_H
16#define LLVM_TARGET_CODEGENCWRAPPERS_H
17
21#include <optional>
22
23namespace llvm {
24
25inline std::optional<CodeModel::Model> unwrap(LLVMCodeModel Model, bool &JIT) {
26 JIT = false;
27 switch (Model) {
29 JIT = true;
30 [[fallthrough]];
32 return std::nullopt;
34 return CodeModel::Tiny;
36 return CodeModel::Small;
38 return CodeModel::Kernel;
40 return CodeModel::Medium;
42 return CodeModel::Large;
43 }
44 return CodeModel::Small;
45}
46
48 switch (Model) {
49 case CodeModel::Tiny:
50 return LLVMCodeModelTiny;
52 return LLVMCodeModelSmall;
58 return LLVMCodeModelLarge;
59 }
60 llvm_unreachable("Bad CodeModel!");
61}
62} // namespace llvm
63
64#endif
LLVMCodeModel
Definition: TargetMachine.h:55
@ LLVMCodeModelKernel
Definition: TargetMachine.h:60
@ LLVMCodeModelTiny
Definition: TargetMachine.h:58
@ LLVMCodeModelSmall
Definition: TargetMachine.h:59
@ LLVMCodeModelMedium
Definition: TargetMachine.h:61
@ LLVMCodeModelJITDefault
Definition: TargetMachine.h:57
@ LLVMCodeModelDefault
Definition: TargetMachine.h:56
@ LLVMCodeModelLarge
Definition: TargetMachine.h:62
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:332
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:327