1 //===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Methods for querying the nature of the host machine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_HOST_H
15 #define LLVM_SUPPORT_HOST_H
17 #include "llvm/ADT/StringMap.h"
19 #if defined(__linux__)
23 #include <machine/endian.h>
32 #if BYTE_ORDER == BIG_ENDIAN
33 static const bool IsBigEndianHost = true;
35 static const bool IsBigEndianHost = false;
38 static const bool IsLittleEndianHost = !IsBigEndianHost;
40 inline bool isBigEndianHost() {
41 return IsBigEndianHost;
44 /// getDefaultTargetTriple() - Return the default target triple the compiler
45 /// has been configured to produce code for.
47 /// The target triple is a string in the format of:
48 /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
50 /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
51 std::string getDefaultTargetTriple();
53 /// getProcessTriple() - Return an appropriate target triple for generating
54 /// code to be loaded into the current process, e.g. when using the JIT.
55 std::string getProcessTriple();
57 /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
58 /// of the name is target dependent, and suitable for passing as -mcpu to the
59 /// target which matches the host.
61 /// \return - The host CPU name, or empty if the CPU could not be determined.
62 std::string getHostCPUName();
64 /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
65 /// The particular format of the names are target dependent, and suitable for
66 /// passing as -mattr to the target which matches the host.
68 /// \param Features - A string mapping feature names to either
69 /// true (if enabled) or false (if disabled). This routine makes no guarantees
70 /// about exactly which features may appear in this map, except that they are
71 /// all valid LLVM feature names.
73 /// \return - True on success.
74 bool getHostCPUFeatures(StringMap<bool> &Features);