Re-landing "Refactoring cl::list_storage from "is a" to "has a" std::vector."
[oota-llvm.git] / include / llvm / Support / CodeGen.h
1 //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- 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 define some types which define code generation concepts. For
11 // example, relocation model.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_CODEGEN_H
16 #define LLVM_SUPPORT_CODEGEN_H
17
18 #include "llvm-c/TargetMachine.h"
19 #include "llvm/Support/ErrorHandling.h"
20
21 namespace llvm {
22
23   // Relocation model types.
24   namespace Reloc {
25     enum Model { Default, Static, PIC_, DynamicNoPIC };
26   }
27
28   // Code model types.
29   namespace CodeModel {
30     enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
31   }
32
33   namespace PICLevel {
34     enum Level { Default=0, Small=1, Large=2 };
35   }
36
37   // TLS models.
38   namespace TLSModel {
39     enum Model {
40       GeneralDynamic,
41       LocalDynamic,
42       InitialExec,
43       LocalExec
44     };
45   }
46
47   // Code generation optimization level.
48   namespace CodeGenOpt {
49     enum Level {
50       None,        // -O0
51       Less,        // -O1
52       Default,     // -O2, -Os
53       Aggressive   // -O3
54     };
55   }
56
57   // Create wrappers for C Binding types (see CBindingWrapping.h).
58   inline CodeModel::Model unwrap(LLVMCodeModel Model) {
59     switch (Model) {
60       case LLVMCodeModelDefault:
61         return CodeModel::Default;
62       case LLVMCodeModelJITDefault:
63         return CodeModel::JITDefault;
64       case LLVMCodeModelSmall:
65         return CodeModel::Small;
66       case LLVMCodeModelKernel:
67         return CodeModel::Kernel;
68       case LLVMCodeModelMedium:
69         return CodeModel::Medium;
70       case LLVMCodeModelLarge:
71         return CodeModel::Large;
72     }
73     return CodeModel::Default;
74   }
75
76   inline LLVMCodeModel wrap(CodeModel::Model Model) {
77     switch (Model) {
78       case CodeModel::Default:
79         return LLVMCodeModelDefault;
80       case CodeModel::JITDefault:
81         return LLVMCodeModelJITDefault;
82       case CodeModel::Small:
83         return LLVMCodeModelSmall;
84       case CodeModel::Kernel:
85         return LLVMCodeModelKernel;
86       case CodeModel::Medium:
87         return LLVMCodeModelMedium;
88       case CodeModel::Large:
89         return LLVMCodeModelLarge;
90     }
91     llvm_unreachable("Bad CodeModel!");
92   }
93 }  // end llvm namespace
94
95 #endif