DirectiveBase.td 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //===-- DirectiveBase.td - Base directive definition file --*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This is the base definition file directives and clauses.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // General information about the directive language.
  13. class DirectiveLanguage {
  14. // Name of the directive language such as omp or acc.
  15. string name = ?;
  16. // The C++ namespace that code of this directive language should be placed
  17. // into. This namespace is nested in llvm namespace.
  18. //
  19. // By default, uses the name of the directive language as the only namespace.
  20. // To avoid placing in any namespace, use "". To specify nested namespaces,
  21. // use "::" as the delimiter, e.g., given "A::B", ops will be placed in
  22. // `namespace A { namespace B { <directives-clauses> } }`.
  23. string cppNamespace = name;
  24. // Optional prefix used for the generation of the enumerator in the Directive
  25. // enum.
  26. string directivePrefix = "";
  27. // Optional prefix used for the generation of the enumerator in the Clause
  28. // enum.
  29. string clausePrefix = "";
  30. // Make the enum values available in the namespace. This allows us to
  31. // write something like Enum_X if we have a `using namespace cppNamespace`.
  32. bit makeEnumAvailableInNamespace = false;
  33. // Generate include and macro to enable LLVM BitmaskEnum.
  34. bit enableBitmaskEnumInNamespace = false;
  35. // Header file included in the implementation code generated. Ususally the
  36. // output file of the declaration code generation. Can be left blank.
  37. string includeHeader = "";
  38. // EnumSet class name used for clauses to generated the allowed clauses map.
  39. string clauseEnumSetClass = "";
  40. // Class holding the clauses in the flang parse-tree.
  41. string flangClauseBaseClass = "";
  42. }
  43. // Information about values accepted by enum-like clauses
  44. class ClauseVal<string n, int v, bit uv> {
  45. // Name of the clause value.
  46. string name = n;
  47. // Integer value of the clause.
  48. int value = v;
  49. // Can user specify this value?
  50. bit isUserValue = uv;
  51. // Set clause value used by default when unknown.
  52. bit isDefault = false;
  53. }
  54. // Information about a specific clause.
  55. class Clause<string c> {
  56. // Name of the clause.
  57. string name = c;
  58. // Define an alternative name return in get<LanguageName>ClauseName function.
  59. string alternativeName = "";
  60. // Optional class holding value of the clause in clang AST.
  61. string clangClass = "";
  62. // Optional class holding value of the clause in flang AST.
  63. string flangClass = "";
  64. // If set to true, value is optional. Not optional by default.
  65. bit isValueOptional = false;
  66. // Name of enum when there is a list of allowed clause values.
  67. string enumClauseValue = "";
  68. // List of allowed clause values
  69. list<ClauseVal> allowedClauseValues = [];
  70. // If set to true, value class is part of a list. Single class by default.
  71. bit isValueList = false;
  72. // Define a default value such as "*".
  73. string defaultValue = "";
  74. // Is clause implicit? If clause is set as implicit, the default kind will
  75. // be return in get<LanguageName>ClauseKind instead of their own kind.
  76. bit isImplicit = false;
  77. // Set clause used by default when unknown. Function returning the kind
  78. // of enumeration will use this clause as the default.
  79. bit isDefault = false;
  80. }
  81. // Hold information about clause validity by version.
  82. class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> {
  83. // Actual clause.
  84. Clause clause = c;
  85. // Mininum version number where this clause is valid.
  86. int minVersion = min;
  87. // Maximum version number where this clause is valid.
  88. int maxVersion = max;
  89. }
  90. // Information about a specific directive.
  91. class Directive<string d> {
  92. // Name of the directive. Can be composite directive sepearted by whitespace.
  93. string name = d;
  94. // Define an alternative name return in get<LanguageName>DirectiveName
  95. // function.
  96. string alternativeName = "";
  97. // Clauses cannot appear twice in the three allowed lists below. Also, since
  98. // required implies allowed, the same clause cannot appear in both the
  99. // allowedClauses and requiredClauses lists.
  100. // List of allowed clauses for the directive.
  101. list<VersionedClause> allowedClauses = [];
  102. // List of clauses that are allowed to appear only once.
  103. list<VersionedClause> allowedOnceClauses = [];
  104. // List of clauses that are allowed but mutually exclusive.
  105. list<VersionedClause> allowedExclusiveClauses = [];
  106. // List of clauses that are required.
  107. list<VersionedClause> requiredClauses = [];
  108. // Set directive used by default when unknown.
  109. bit isDefault = false;
  110. }