OMPAssume.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- OpenMP/OMPAssume.h --- OpenMP assumption helper functions - 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. /// \file
  14. ///
  15. /// This file provides helper functions and classes to deal with OpenMP
  16. /// assumptions, e.g., as used by `[begin/end] assumes` and `assume`.
  17. ///
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_FRONTEND_OPENMP_OMPASSUME_H
  20. #define LLVM_FRONTEND_OPENMP_OMPASSUME_H
  21. #include "llvm/ADT/StringRef.h"
  22. namespace llvm {
  23. namespace omp {
  24. /// Helper to describe assume clauses.
  25. struct AssumptionClauseMappingInfo {
  26. /// The identifier describing the (beginning of the) clause.
  27. llvm::StringLiteral Identifier;
  28. /// Flag to determine if the identifier is a full name or the start of a name.
  29. bool StartsWith;
  30. /// Flag to determine if a directive lists follows.
  31. bool HasDirectiveList;
  32. /// Flag to determine if an expression follows.
  33. bool HasExpression;
  34. };
  35. /// All known assume clauses.
  36. static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = {
  37. #define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, \
  38. HasExpression) \
  39. {Identifier, StartsWith, HasDirectiveList, HasExpression},
  40. #include "llvm/Frontend/OpenMP/OMPKinds.def"
  41. };
  42. inline std::string getAllAssumeClauseOptions() {
  43. std::string S;
  44. for (const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings)
  45. S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str();
  46. return S + "'";
  47. }
  48. } // namespace omp
  49. } // namespace llvm
  50. #endif // LLVM_FRONTEND_OPENMP_OMPASSUME_H
  51. #ifdef __GNUC__
  52. #pragma GCC diagnostic pop
  53. #endif