Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:36

0001 //===- llvm/Target/CodeGenCWrappers.h - CodeGen C Wrappers ------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines C bindings wrappers for enums in llvm/Support/CodeGen.h
0010 // that need them.  The wrappers are separated to avoid adding an indirect
0011 // dependency on llvm/Config/Targets.def to CodeGen.h.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_TARGET_CODEGENCWRAPPERS_H
0016 #define LLVM_TARGET_CODEGENCWRAPPERS_H
0017 
0018 #include "llvm-c/TargetMachine.h"
0019 #include "llvm/Support/CodeGen.h"
0020 #include "llvm/Support/ErrorHandling.h"
0021 #include <optional>
0022 
0023 namespace llvm {
0024 
0025 inline std::optional<CodeModel::Model> unwrap(LLVMCodeModel Model, bool &JIT) {
0026   JIT = false;
0027   switch (Model) {
0028   case LLVMCodeModelJITDefault:
0029     JIT = true;
0030     [[fallthrough]];
0031   case LLVMCodeModelDefault:
0032     return std::nullopt;
0033   case LLVMCodeModelTiny:
0034     return CodeModel::Tiny;
0035   case LLVMCodeModelSmall:
0036     return CodeModel::Small;
0037   case LLVMCodeModelKernel:
0038     return CodeModel::Kernel;
0039   case LLVMCodeModelMedium:
0040     return CodeModel::Medium;
0041   case LLVMCodeModelLarge:
0042     return CodeModel::Large;
0043   }
0044   return CodeModel::Small;
0045 }
0046 
0047 inline LLVMCodeModel wrap(CodeModel::Model Model) {
0048   switch (Model) {
0049   case CodeModel::Tiny:
0050     return LLVMCodeModelTiny;
0051   case CodeModel::Small:
0052     return LLVMCodeModelSmall;
0053   case CodeModel::Kernel:
0054     return LLVMCodeModelKernel;
0055   case CodeModel::Medium:
0056     return LLVMCodeModelMedium;
0057   case CodeModel::Large:
0058     return LLVMCodeModelLarge;
0059   }
0060   llvm_unreachable("Bad CodeModel!");
0061 }
0062 } // namespace llvm
0063 
0064 #endif