Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:36

0001 //===- llvm/TargetParser/Host.h - Host machine detection  -------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Methods for querying the nature of the host machine.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_TARGETPARSER_HOST_H
0014 #define LLVM_TARGETPARSER_HOST_H
0015 
0016 #include <string>
0017 
0018 namespace llvm {
0019 class MallocAllocator;
0020 class StringRef;
0021 template <typename ValueTy, typename AllocatorTy> class StringMap;
0022 class raw_ostream;
0023 
0024 namespace sys {
0025 
0026   /// getDefaultTargetTriple() - Return the default target triple the compiler
0027   /// has been configured to produce code for.
0028   ///
0029   /// The target triple is a string in the format of:
0030   ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
0031   /// or
0032   ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
0033   std::string getDefaultTargetTriple();
0034 
0035   /// getProcessTriple() - Return an appropriate target triple for generating
0036   /// code to be loaded into the current process, e.g. when using the JIT.
0037   std::string getProcessTriple();
0038 
0039   /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
0040   /// of the name is target dependent, and suitable for passing as -mcpu to the
0041   /// target which matches the host.
0042   ///
0043   /// \return - The host CPU name, or empty if the CPU could not be determined.
0044   StringRef getHostCPUName();
0045 
0046   /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
0047   /// The particular format of the names are target dependent, and suitable for
0048   /// passing as -mattr to the target which matches the host.
0049   ///
0050   /// \return - A string map mapping feature names to either true (if enabled)
0051   /// or false (if disabled). This routine makes no guarantees about exactly
0052   /// which features may appear in this map, except that they are all valid LLVM
0053   /// feature names. The map can be empty, for example if feature detection
0054   /// fails.
0055   const StringMap<bool, MallocAllocator> getHostCPUFeatures();
0056 
0057   /// This is a function compatible with cl::AddExtraVersionPrinter, which adds
0058   /// info about the current target triple and detected CPU.
0059   void printDefaultTargetAndDetectedCPU(raw_ostream &OS);
0060 
0061   namespace detail {
0062   /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
0063   StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent);
0064   StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
0065   StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
0066   StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent);
0067   StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent);
0068   StringRef getHostCPUNameForBPF();
0069 
0070   /// Helper functions to extract CPU details from CPUID on x86.
0071   namespace x86 {
0072   enum class VendorSignatures {
0073     UNKNOWN,
0074     GENUINE_INTEL,
0075     AUTHENTIC_AMD,
0076   };
0077 
0078   /// Returns the host CPU's vendor.
0079   /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
0080   /// assigned to its pointee.
0081   VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
0082   } // namespace x86
0083   }
0084 }
0085 }
0086 
0087 #endif