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   namespace PICLevel {
00034     enum Level { Default=0, Small=1, Large=2 };
00035   }
00036 
00037   // TLS models.
00038   namespace TLSModel {
00039     enum Model {
00040       GeneralDynamic,
00041       LocalDynamic,
00042       InitialExec,
00043       LocalExec
00044     };
00045   }
00046 
00047   // Code generation optimization level.
00048   namespace CodeGenOpt {
00049     enum Level {
00050       None,        // -O0
00051       Less,        // -O1
00052       Default,     // -O2, -Os
00053       Aggressive   // -O3
00054     };
00055   }
00056 
00057   // Create wrappers for C Binding types (see CBindingWrapping.h).
00058   inline CodeModel::Model unwrap(LLVMCodeModel Model) {
00059     switch (Model) {
00060       case LLVMCodeModelDefault:
00061         return CodeModel::Default;
00062       case LLVMCodeModelJITDefault:
00063         return CodeModel::JITDefault;
00064       case LLVMCodeModelSmall:
00065         return CodeModel::Small;
00066       case LLVMCodeModelKernel:
00067         return CodeModel::Kernel;
00068       case LLVMCodeModelMedium:
00069         return CodeModel::Medium;
00070       case LLVMCodeModelLarge:
00071         return CodeModel::Large;
00072     }
00073     return CodeModel::Default;
00074   }
00075 
00076   inline LLVMCodeModel wrap(CodeModel::Model Model) {
00077     switch (Model) {
00078       case CodeModel::Default:
00079         return LLVMCodeModelDefault;
00080       case CodeModel::JITDefault:
00081         return LLVMCodeModelJITDefault;
00082       case CodeModel::Small:
00083         return LLVMCodeModelSmall;
00084       case CodeModel::Kernel:
00085         return LLVMCodeModelKernel;
00086       case CodeModel::Medium:
00087         return LLVMCodeModelMedium;
00088       case CodeModel::Large:
00089         return LLVMCodeModelLarge;
00090     }
00091     llvm_unreachable("Bad CodeModel!");
00092   }
00093 }  // end llvm namespace
00094 
00095 #endif