LLVM API Documentation

CodeGen.h
Go to the documentation of this file.
00001 //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file define some types which define code generation concepts. For
00011 // example, relocation model.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_SUPPORT_CODEGEN_H
00016 #define LLVM_SUPPORT_CODEGEN_H
00017 
00018 #include "llvm-c/TargetMachine.h"
00019 #include "llvm/Support/ErrorHandling.h"
00020 
00021 namespace llvm {
00022 
00023   // Relocation model types.
00024   namespace Reloc {
00025     enum Model { Default, Static, PIC_, DynamicNoPIC };
00026   }
00027 
00028   // Code model types.
00029   namespace CodeModel {
00030     enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
00031   }
00032 
00033   // TLS models.
00034   namespace TLSModel {
00035     enum Model {
00036       GeneralDynamic,
00037       LocalDynamic,
00038       InitialExec,
00039       LocalExec
00040     };
00041   }
00042 
00043   // Code generation optimization level.
00044   namespace CodeGenOpt {
00045     enum Level {
00046       None,        // -O0
00047       Less,        // -O1
00048       Default,     // -O2, -Os
00049       Aggressive   // -O3
00050     };
00051   }
00052 
00053   // Create wrappers for C Binding types (see CBindingWrapping.h).
00054   inline CodeModel::Model unwrap(LLVMCodeModel Model) {
00055     switch (Model) {
00056       case LLVMCodeModelDefault:
00057         return CodeModel::Default;
00058       case LLVMCodeModelJITDefault:
00059         return CodeModel::JITDefault;
00060       case LLVMCodeModelSmall:
00061         return CodeModel::Small;
00062       case LLVMCodeModelKernel:
00063         return CodeModel::Kernel;
00064       case LLVMCodeModelMedium:
00065         return CodeModel::Medium;
00066       case LLVMCodeModelLarge:
00067         return CodeModel::Large;
00068     }
00069     return CodeModel::Default;
00070   }
00071 
00072   inline LLVMCodeModel wrap(CodeModel::Model Model) {
00073     switch (Model) {
00074       case CodeModel::Default:
00075         return LLVMCodeModelDefault;
00076       case CodeModel::JITDefault:
00077         return LLVMCodeModelJITDefault;
00078       case CodeModel::Small:
00079         return LLVMCodeModelSmall;
00080       case CodeModel::Kernel:
00081         return LLVMCodeModelKernel;
00082       case CodeModel::Medium:
00083         return LLVMCodeModelMedium;
00084       case CodeModel::Large:
00085         return LLVMCodeModelLarge;
00086     }
00087     llvm_unreachable("Bad CodeModel!");
00088   }
00089 }  // end llvm namespace
00090 
00091 #endif