LLVM  10.0.0svn
Host.h
Go to the documentation of this file.
1 //===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Methods for querying the nature of the host machine.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_SUPPORT_HOST_H
14 #define LLVM_SUPPORT_HOST_H
15 
16 #include "llvm/ADT/StringMap.h"
17 
18 #include <string>
19 
20 namespace llvm {
21 namespace sys {
22 
23  /// getDefaultTargetTriple() - Return the default target triple the compiler
24  /// has been configured to produce code for.
25  ///
26  /// The target triple is a string in the format of:
27  /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
28  /// or
29  /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
30  std::string getDefaultTargetTriple();
31 
32  /// getProcessTriple() - Return an appropriate target triple for generating
33  /// code to be loaded into the current process, e.g. when using the JIT.
34  std::string getProcessTriple();
35 
36  /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
37  /// of the name is target dependent, and suitable for passing as -mcpu to the
38  /// target which matches the host.
39  ///
40  /// \return - The host CPU name, or empty if the CPU could not be determined.
41  StringRef getHostCPUName();
42 
43  /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
44  /// The particular format of the names are target dependent, and suitable for
45  /// passing as -mattr to the target which matches the host.
46  ///
47  /// \param Features - A string mapping feature names to either
48  /// true (if enabled) or false (if disabled). This routine makes no guarantees
49  /// about exactly which features may appear in this map, except that they are
50  /// all valid LLVM feature names.
51  ///
52  /// \return - True on success.
53  bool getHostCPUFeatures(StringMap<bool> &Features);
54 
55  /// Get the number of physical cores (as opposed to logical cores returned
56  /// from thread::hardware_concurrency(), which includes hyperthreads).
57  /// Returns -1 if unknown for the current host system.
59 
60  namespace detail {
61  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
62  StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent);
63  StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
64  StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
66  }
67 }
68 }
69 
70 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent)
Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
Definition: Host.cpp:67
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent)
Definition: Host.cpp:282
int getHostNumPhysicalCores()
Get the number of physical cores (as opposed to logical cores returned from thread::hardware_concurre...
Definition: Host.cpp:1298
StringRef getHostCPUNameForBPF()
Definition: Host.cpp:337
std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Definition: Host.cpp:1530
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
Definition: Host.cpp:1226
StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent)
Definition: Host.cpp:146
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool getHostCPUFeatures(StringMap< bool > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.
Definition: Host.cpp:1527