Host.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // HLSL Change - single triple supported, no allocation required
  40. #ifdef _WIN32
  41. const char *getDefaultTargetTriple();
  42. #else
  43. std::string getDefaultTargetTriple();
  44. #endif
  45. /// getProcessTriple() - Return an appropriate target triple for generating
  46. /// code to be loaded into the current process, e.g. when using the JIT.
  47. std::string getProcessTriple();
  48. /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
  49. /// of the name is target dependent, and suitable for passing as -mcpu to the
  50. /// target which matches the host.
  51. ///
  52. /// \return - The host CPU name, or empty if the CPU could not be determined.
  53. StringRef getHostCPUName();
  54. /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
  55. /// The particular format of the names are target dependent, and suitable for
  56. /// passing as -mattr to the target which matches the host.
  57. ///
  58. /// \param Features - A string mapping feature names to either
  59. /// true (if enabled) or false (if disabled). This routine makes no guarantees
  60. /// about exactly which features may appear in this map, except that they are
  61. /// all valid LLVM feature names.
  62. ///
  63. /// \return - True on success.
  64. bool getHostCPUFeatures(StringMap<bool> &Features);
  65. }
  66. }
  67. #endif