2
0

Host.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // Methods for querying the nature of the host machine.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_SUPPORT_HOST_H
  14. #define LLVM_SUPPORT_HOST_H
  15. #include "llvm/ADT/StringMap.h"
  16. #if defined(__linux__) || defined(__GNU__)
  17. #include <endian.h>
  18. #else
  19. #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
  20. #include <machine/endian.h>
  21. #endif
  22. #endif
  23. #include <string>
  24. namespace llvm {
  25. namespace sys {
  26. #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
  27. static const bool IsBigEndianHost = true;
  28. #else
  29. static const bool IsBigEndianHost = false;
  30. #endif
  31. static const bool IsLittleEndianHost = !IsBigEndianHost;
  32. /// getDefaultTargetTriple() - Return the default target triple the compiler
  33. /// has been configured to produce code for.
  34. ///
  35. /// The target triple is a string in the format of:
  36. /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
  37. /// or
  38. /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
  39. // std::string getDefaultTargetTriple(); // HLSL Change - single triple supported, no allocation required
  40. const char *getDefaultTargetTriple();
  41. /// getProcessTriple() - Return an appropriate target triple for generating
  42. /// code to be loaded into the current process, e.g. when using the JIT.
  43. std::string getProcessTriple();
  44. /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
  45. /// of the name is target dependent, and suitable for passing as -mcpu to the
  46. /// target which matches the host.
  47. ///
  48. /// \return - The host CPU name, or empty if the CPU could not be determined.
  49. StringRef getHostCPUName();
  50. /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
  51. /// The particular format of the names are target dependent, and suitable for
  52. /// passing as -mattr to the target which matches the host.
  53. ///
  54. /// \param Features - A string mapping feature names to either
  55. /// true (if enabled) or false (if disabled). This routine makes no guarantees
  56. /// about exactly which features may appear in this map, except that they are
  57. /// all valid LLVM feature names.
  58. ///
  59. /// \return - True on success.
  60. bool getHostCPUFeatures(StringMap<bool> &Features);
  61. }
  62. }
  63. #endif