DirectiveBase.td 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. // Define aliases used in the parser.
  61. list<string> aliases = [];
  62. // Optional class holding value of the clause in clang AST.
  63. string clangClass = "";
  64. // Optional class holding value of the clause in flang AST.
  65. string flangClass = "";
  66. // If set to true, value is optional. Not optional by default.
  67. bit isValueOptional = false;
  68. // Name of enum when there is a list of allowed clause values.
  69. string enumClauseValue = "";
  70. // List of allowed clause values
  71. list<ClauseVal> allowedClauseValues = [];
  72. // If set to true, value class is part of a list. Single class by default.
  73. bit isValueList = false;
  74. // Define a default value such as "*".
  75. string defaultValue = "";
  76. // Is clause implicit? If clause is set as implicit, the default kind will
  77. // be return in get<LanguageName>ClauseKind instead of their own kind.
  78. bit isImplicit = false;
  79. // Set clause used by default when unknown. Function returning the kind
  80. // of enumeration will use this clause as the default.
  81. bit isDefault = false;
  82. // Prefix before the actual value. Used in the parser generation.
  83. // `clause(prefix: value)`
  84. string prefix = "";
  85. // Set the prefix as optional.
  86. // `clause([prefix]: value)`
  87. bit isPrefixOptional = true;
  88. }
  89. // Hold information about clause validity by version.
  90. class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> {
  91. // Actual clause.
  92. Clause clause = c;
  93. // Mininum version number where this clause is valid.
  94. int minVersion = min;
  95. // Maximum version number where this clause is valid.
  96. int maxVersion = max;
  97. }
  98. // Information about a specific directive.
  99. class Directive<string d> {
  100. // Name of the directive. Can be composite directive sepearted by whitespace.
  101. string name = d;
  102. // Define an alternative name return in get<LanguageName>DirectiveName
  103. // function.
  104. string alternativeName = "";
  105. // Clauses cannot appear twice in the three allowed lists below. Also, since
  106. // required implies allowed, the same clause cannot appear in both the
  107. // allowedClauses and requiredClauses lists.
  108. // List of allowed clauses for the directive.
  109. list<VersionedClause> allowedClauses = [];
  110. // List of clauses that are allowed to appear only once.
  111. list<VersionedClause> allowedOnceClauses = [];
  112. // List of clauses that are allowed but mutually exclusive.
  113. list<VersionedClause> allowedExclusiveClauses = [];
  114. // List of clauses that are required.
  115. list<VersionedClause> requiredClauses = [];
  116. // Set directive used by default when unknown.
  117. bit isDefault = false;
  118. }