LLVM API Documentation
00001 //===- llvm/Support/Host.h - Host machine characteristics --------*- 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 // Methods for querying the nature of the host machine. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_SUPPORT_HOST_H 00015 #define LLVM_SUPPORT_HOST_H 00016 00017 #include "llvm/ADT/StringMap.h" 00018 00019 #if defined(__linux__) || defined(__GNU__) 00020 #include <endian.h> 00021 #else 00022 #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32) 00023 #include <machine/endian.h> 00024 #endif 00025 #endif 00026 00027 #include <string> 00028 00029 namespace llvm { 00030 namespace sys { 00031 00032 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN 00033 static const bool IsBigEndianHost = true; 00034 #else 00035 static const bool IsBigEndianHost = false; 00036 #endif 00037 00038 static const bool IsLittleEndianHost = !IsBigEndianHost; 00039 00040 /// getDefaultTargetTriple() - Return the default target triple the compiler 00041 /// has been configured to produce code for. 00042 /// 00043 /// The target triple is a string in the format of: 00044 /// CPU_TYPE-VENDOR-OPERATING_SYSTEM 00045 /// or 00046 /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM 00047 std::string getDefaultTargetTriple(); 00048 00049 /// getProcessTriple() - Return an appropriate target triple for generating 00050 /// code to be loaded into the current process, e.g. when using the JIT. 00051 std::string getProcessTriple(); 00052 00053 /// getHostCPUName - Get the LLVM name for the host CPU. The particular format 00054 /// of the name is target dependent, and suitable for passing as -mcpu to the 00055 /// target which matches the host. 00056 /// 00057 /// \return - The host CPU name, or empty if the CPU could not be determined. 00058 StringRef getHostCPUName(); 00059 00060 /// getHostCPUFeatures - Get the LLVM names for the host CPU features. 00061 /// The particular format of the names are target dependent, and suitable for 00062 /// passing as -mattr to the target which matches the host. 00063 /// 00064 /// \param Features - A string mapping feature names to either 00065 /// true (if enabled) or false (if disabled). This routine makes no guarantees 00066 /// about exactly which features may appear in this map, except that they are 00067 /// all valid LLVM feature names. 00068 /// 00069 /// \return - True on success. 00070 bool getHostCPUFeatures(StringMap<bool> &Features); 00071 } 00072 } 00073 00074 #endif