LLVM 19.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 <string>
17
18namespace llvm {
19class MallocAllocator;
20class StringRef;
21template <typename ValueTy, typename AllocatorTy> class StringMap;
22class raw_ostream;
23
24namespace sys {
25
26 /// getDefaultTargetTriple() - Return the default target triple the compiler
27 /// has been configured to produce code for.
28 ///
29 /// The target triple is a string in the format of:
30 /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
31 /// or
32 /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
34
35 /// getProcessTriple() - Return an appropriate target triple for generating
36 /// code to be loaded into the current process, e.g. when using the JIT.
37 std::string getProcessTriple();
38
39 /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
40 /// of the name is target dependent, and suitable for passing as -mcpu to the
41 /// target which matches the host.
42 ///
43 /// \return - The host CPU name, or empty if the CPU could not be determined.
45
46 /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
47 /// The particular format of the names are target dependent, and suitable for
48 /// passing as -mattr to the target which matches the host.
49 ///
50 /// \param Features - A string mapping feature names to either
51 /// true (if enabled) or false (if disabled). This routine makes no guarantees
52 /// about exactly which features may appear in this map, except that they are
53 /// all valid LLVM feature names.
54 ///
55 /// \return - True on success.
57
58 /// This is a function compatible with cl::AddExtraVersionPrinter, which adds
59 /// info about the current target triple and detected CPU.
61
62 namespace detail {
63 /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
65 StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
66 StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
67 StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent);
70
71 /// Helper functions to extract CPU details from CPUID on x86.
72 namespace x86 {
73 enum class VendorSignatures {
74 UNKNOWN,
77 };
78
79 /// Returns the host CPU's vendor.
80 /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
81 /// assigned to its pointee.
82 VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
83 } // namespace x86
84 }
85}
86}
87
88#endif
raw_pwrite_stream & OS
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
VendorSignatures getVendorSignature(unsigned *MaxLeaf=nullptr)
Returns the host CPU's vendor.
Definition: Host.cpp:1695
StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent)
Definition: Host.cpp:383
StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent)
Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
Definition: Host.cpp:76
StringRef getHostCPUNameForBPF()
Definition: Host.cpp:448
StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent)
Definition: Host.cpp:159
StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent)
Definition: Host.cpp:428
StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent)
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
Definition: Host.cpp:1689
void printDefaultTargetAndDetectedCPU(raw_ostream &OS)
This is a function compatible with cl::AddExtraVersionPrinter, which adds info about the current targ...
Definition: Host.cpp:2053
bool getHostCPUFeatures(StringMap< bool, MallocAllocator > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.
std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Definition: Host.cpp:2035
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18