Host.h revision 234353
1218885Sdim//===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===// 2218885Sdim// 3218885Sdim// The LLVM Compiler Infrastructure 4218885Sdim// 5218885Sdim// This file is distributed under the University of Illinois Open Source 6218885Sdim// License. See LICENSE.TXT for details. 7218885Sdim// 8218885Sdim//===----------------------------------------------------------------------===// 9218885Sdim// 10218885Sdim// Methods for querying the nature of the host machine. 11218885Sdim// 12218885Sdim//===----------------------------------------------------------------------===// 13218885Sdim 14218885Sdim#ifndef LLVM_SYSTEM_HOST_H 15218885Sdim#define LLVM_SYSTEM_HOST_H 16218885Sdim 17218885Sdim#include "llvm/ADT/StringMap.h" 18218885Sdim#include <string> 19218885Sdim 20218885Sdimnamespace llvm { 21218885Sdimnamespace sys { 22218885Sdim 23218885Sdim inline bool isLittleEndianHost() { 24218885Sdim union { 25218885Sdim int i; 26218885Sdim char c; 27218885Sdim }; 28218885Sdim i = 1; 29218885Sdim return c; 30218885Sdim } 31218885Sdim 32218885Sdim inline bool isBigEndianHost() { 33218885Sdim return !isLittleEndianHost(); 34218885Sdim } 35218885Sdim 36234353Sdim /// getDefaultTargetTriple() - Return the default target triple the compiler 37234353Sdim /// has been configured to produce code for. 38218885Sdim /// 39218885Sdim /// The target triple is a string in the format of: 40218885Sdim /// CPU_TYPE-VENDOR-OPERATING_SYSTEM 41218885Sdim /// or 42218885Sdim /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM 43234353Sdim std::string getDefaultTargetTriple(); 44218885Sdim 45218885Sdim /// getHostCPUName - Get the LLVM name for the host CPU. The particular format 46218885Sdim /// of the name is target dependent, and suitable for passing as -mcpu to the 47218885Sdim /// target which matches the host. 48218885Sdim /// 49218885Sdim /// \return - The host CPU name, or empty if the CPU could not be determined. 50218885Sdim std::string getHostCPUName(); 51218885Sdim 52218885Sdim /// getHostCPUFeatures - Get the LLVM names for the host CPU features. 53218885Sdim /// The particular format of the names are target dependent, and suitable for 54218885Sdim /// passing as -mattr to the target which matches the host. 55218885Sdim /// 56218885Sdim /// \param Features - A string mapping feature names to either 57218885Sdim /// true (if enabled) or false (if disabled). This routine makes no guarantees 58218885Sdim /// about exactly which features may appear in this map, except that they are 59218885Sdim /// all valid LLVM feature names. 60218885Sdim /// 61218885Sdim /// \return - True on success. 62218885Sdim bool getHostCPUFeatures(StringMap<bool> &Features); 63218885Sdim} 64218885Sdim} 65218885Sdim 66218885Sdim#endif 67