LLVM 22.0.0git
Host.h
Go to the documentation of this file.
1//===- llvm/TargetParser/Host.h - Host machine detection -------*- 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_TARGETPARSER_HOST_H
14#define LLVM_TARGETPARSER_HOST_H
15
16#include "llvm/ADT/ArrayRef.h"
18#include <string>
19
20namespace llvm {
21class MallocAllocator;
22class StringRef;
23template <typename ValueTy, typename AllocatorTy> class StringMap;
24class raw_ostream;
25
26namespace sys {
27
28/// getDefaultTargetTriple() - Return the default target triple the compiler
29/// has been configured to produce code for.
30///
31/// The target triple is a string in the format of:
32/// CPU_TYPE-VENDOR-OPERATING_SYSTEM
33/// or
34/// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
36
37/// getProcessTriple() - Return an appropriate target triple for generating
38/// code to be loaded into the current process, e.g. when using the JIT.
39LLVM_ABI std::string getProcessTriple();
40
41/// getHostCPUName - Get the LLVM name for the host CPU. The particular format
42/// of the name is target dependent, and suitable for passing as -mcpu to the
43/// target which matches the host.
44///
45/// \return - The host CPU name, or empty if the CPU could not be determined.
47
48/// getHostCPUFeatures - Get the LLVM names for the host CPU features.
49/// The particular format of the names are target dependent, and suitable for
50/// passing as -mattr to the target which matches the host.
51///
52/// \return - A string map mapping feature names to either true (if enabled)
53/// or false (if disabled). This routine makes no guarantees about exactly
54/// which features may appear in this map, except that they are all valid LLVM
55/// feature names. The map can be empty, for example if feature detection
56/// fails.
58
59/// This is a function compatible with cl::AddExtraVersionPrinter, which adds
60/// info about the current target triple and detected CPU.
62
63namespace detail {
64/// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
68 ArrayRef<uint64_t> UniqueCpuInfos);
73
74/// Helper functions to extract CPU details from CPUID on x86.
75namespace x86 {
81
82/// Returns the host CPU's vendor.
83/// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
84/// assigned to its pointee.
85LLVM_ABI VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
86} // namespace x86
87} // namespace detail
88} // namespace sys
89} // namespace llvm
90
91#endif
#define LLVM_ABI
Definition Compiler.h:213
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Helper functions to extract CPU details from CPUID on x86.
Definition Host.h:75
LLVM_ABI VendorSignatures getVendorSignature(unsigned *MaxLeaf=nullptr)
Returns the host CPU's vendor.
Definition Host.cpp:1961
LLVM_ABI StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent)
LLVM_ABI StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent)
Definition Host.cpp:504
LLVM_ABI StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent)
Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
Definition Host.cpp:89
LLVM_ABI StringRef getHostCPUNameForBPF()
Definition Host.cpp:570
LLVM_ABI StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent)
Definition Host.cpp:393
LLVM_ABI StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent)
Definition Host.cpp:549
LLVM_ABI StringMap< bool, MallocAllocator > getHostCPUFeatures()
getHostCPUFeatures - Get the LLVM names for the host CPU features.
Definition Host.cpp:2394
LLVM_ABI StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
Definition Host.cpp:1955
LLVM_ABI void printDefaultTargetAndDetectedCPU(raw_ostream &OS)
This is a function compatible with cl::AddExtraVersionPrinter, which adds info about the current targ...
Definition Host.cpp:2446
LLVM_ABI std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
LLVM_ABI std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Definition Host.cpp:2428
This is an optimization pass for GlobalISel generic memory operations.