Host.h revision 249423
1//===- llvm/Support/Host.h - Host machine characteristics --------*- 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// Methods for querying the nature of the host machine. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_SUPPORT_HOST_H 15#define LLVM_SUPPORT_HOST_H 16 17#include "llvm/ADT/StringMap.h" 18#include <string> 19 20namespace llvm { 21namespace sys { 22 23 inline bool isLittleEndianHost() { 24 union { 25 int i; 26 char c; 27 }; 28 i = 1; 29 return c; 30 } 31 32 inline bool isBigEndianHost() { 33 return !isLittleEndianHost(); 34 } 35 36 /// getDefaultTargetTriple() - Return the default target triple the compiler 37 /// has been configured to produce code for. 38 /// 39 /// The target triple is a string in the format of: 40 /// CPU_TYPE-VENDOR-OPERATING_SYSTEM 41 /// or 42 /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM 43 std::string getDefaultTargetTriple(); 44 45 /// getProcessTriple() - Return an appropriate target triple for generating 46 /// code to be loaded into the current process, e.g. when using the JIT. 47 std::string getProcessTriple(); 48 49 /// getHostCPUName - Get the LLVM name for the host CPU. The particular format 50 /// of the name is target dependent, and suitable for passing as -mcpu to the 51 /// target which matches the host. 52 /// 53 /// \return - The host CPU name, or empty if the CPU could not be determined. 54 std::string getHostCPUName(); 55 56 /// getHostCPUFeatures - Get the LLVM names for the host CPU features. 57 /// The particular format of the names are target dependent, and suitable for 58 /// passing as -mattr to the target which matches the host. 59 /// 60 /// \param Features - A string mapping feature names to either 61 /// true (if enabled) or false (if disabled). This routine makes no guarantees 62 /// about exactly which features may appear in this map, except that they are 63 /// all valid LLVM feature names. 64 /// 65 /// \return - True on success. 66 bool getHostCPUFeatures(StringMap<bool> &Features); 67} 68} 69 70#endif 71