TargetID.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- TargetID.h - Utilities for target ID -------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_BASIC_TARGETID_H
  14. #define LLVM_CLANG_BASIC_TARGETID_H
  15. #include "llvm/ADT/SmallVector.h"
  16. #include "llvm/ADT/StringMap.h"
  17. #include "llvm/ADT/Triple.h"
  18. #include <set>
  19. namespace clang {
  20. /// Get all feature strings that can be used in target ID for \p Processor.
  21. /// Target ID is a processor name with optional feature strings
  22. /// postfixed by a plus or minus sign delimited by colons, e.g.
  23. /// gfx908:xnack+:sramecc-. Each processor have a limited
  24. /// number of predefined features when showing up in a target ID.
  25. llvm::SmallVector<llvm::StringRef, 4>
  26. getAllPossibleTargetIDFeatures(const llvm::Triple &T,
  27. llvm::StringRef Processor);
  28. /// Get processor name from target ID.
  29. /// Returns canonical processor name or empty if the processor name is invalid.
  30. llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T,
  31. llvm::StringRef OffloadArch);
  32. /// Parse a target ID to get processor and feature map.
  33. /// Returns canonicalized processor name or None if the target ID is invalid.
  34. /// Returns target ID features in \p FeatureMap if it is not null pointer.
  35. /// This function assumes \p OffloadArch is a valid target ID.
  36. /// If the target ID contains feature+, map it to true.
  37. /// If the target ID contains feature-, map it to false.
  38. /// If the target ID does not contain a feature (default), do not map it.
  39. llvm::Optional<llvm::StringRef>
  40. parseTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch,
  41. llvm::StringMap<bool> *FeatureMap);
  42. /// Returns canonical target ID, assuming \p Processor is canonical and all
  43. /// entries in \p Features are valid.
  44. std::string getCanonicalTargetID(llvm::StringRef Processor,
  45. const llvm::StringMap<bool> &Features);
  46. /// Get the conflicted pair of target IDs for a compilation or a bundled code
  47. /// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
  48. /// returns None.
  49. llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
  50. getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs);
  51. } // namespace clang
  52. #endif
  53. #ifdef __GNUC__
  54. #pragma GCC diagnostic pop
  55. #endif