LLVM  14.0.0git
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 <string>
17 
18 namespace llvm {
19 class MallocAllocator;
20 class StringRef;
21 template <typename ValueTy, typename AllocatorTy> class StringMap;
22 
23 namespace sys {
24 
25  /// getDefaultTargetTriple() - Return the default target triple the compiler
26  /// has been configured to produce code for.
27  ///
28  /// The target triple is a string in the format of:
29  /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
30  /// or
31  /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
32  std::string getDefaultTargetTriple();
33 
34  /// getProcessTriple() - Return an appropriate target triple for generating
35  /// code to be loaded into the current process, e.g. when using the JIT.
36  std::string getProcessTriple();
37 
38  /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
39  /// of the name is target dependent, and suitable for passing as -mcpu to the
40  /// target which matches the host.
41  ///
42  /// \return - The host CPU name, or empty if the CPU could not be determined.
43  StringRef getHostCPUName();
44 
45  /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
46  /// The particular format of the names are target dependent, and suitable for
47  /// passing as -mattr to the target which matches the host.
48  ///
49  /// \param Features - A string mapping feature names to either
50  /// true (if enabled) or false (if disabled). This routine makes no guarantees
51  /// about exactly which features may appear in this map, except that they are
52  /// all valid LLVM feature names.
53  ///
54  /// \return - True on success.
55  bool getHostCPUFeatures(StringMap<bool, MallocAllocator> &Features);
56 
57  /// Get the number of physical cores (as opposed to logical cores returned
58  /// from thread::hardware_concurrency(), which includes hyperthreads).
59  /// Returns -1 if unknown for the current host system.
61 
62  namespace detail {
63  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
64  StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent);
65  StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
66  StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
68 
69  /// Helper functions to extract CPU details from CPUID on x86.
70  namespace x86 {
71  enum class VendorSignatures {
72  UNKNOWN,
75  };
76 
77  /// Returns the host CPU's vendor.
78  /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
79  /// assigned to its pointee.
80  VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
81  } // namespace x86
82  }
83 }
84 }
85 
86 #endif
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::sys::detail::x86::VendorSignatures::GENUINE_INTEL
@ GENUINE_INTEL
llvm::sys::getHostCPUFeatures
bool getHostCPUFeatures(StringMap< bool, MallocAllocator > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.
llvm::sys::detail::x86::VendorSignatures::UNKNOWN
@ UNKNOWN
x86
Note that only the low bits of effective_addr2 are used On bit we don t eliminate the computation of the top half of effective_addr2 because we don t have whole function selection dags On x86
Definition: README.txt:318
llvm::sys::detail::x86::VendorSignatures::AUTHENTIC_AMD
@ AUTHENTIC_AMD
llvm::sys::getDefaultTargetTriple
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
llvm::sys::getHostNumPhysicalCores
int getHostNumPhysicalCores()
Get the number of physical cores (as opposed to logical cores returned from thread::hardware_concurre...
Definition: Host.cpp:1494
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::sys::detail::getHostCPUNameForBPF
StringRef getHostCPUNameForBPF()
Definition: Host.cpp:381
llvm::sys::detail::getHostCPUNameForS390x
StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent)
Definition: Host.cpp:336
llvm::sys::detail::x86::VendorSignatures
VendorSignatures
Definition: Host.h:71
llvm::sys::getProcessTriple
std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Definition: Host.cpp:1748
llvm::sys::detail::getHostCPUNameForARM
StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent)
Definition: Host.cpp:156
llvm::sys::detail::getHostCPUNameForPowerPC
StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent)
Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
Definition: Host.cpp:73
llvm::sys::getHostCPUName
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
Definition: Host.cpp:1360
llvm::sys::detail::x86::getVendorSignature
VendorSignatures getVendorSignature(unsigned *MaxLeaf=nullptr)
Returns the host CPU's vendor.
Definition: Host.cpp:1366