Skip to content
Merged
63 changes: 41 additions & 22 deletions llvm/include/llvm/Frontend/Directive/DirectiveBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,37 @@ class DirectiveLanguage {
string flangClauseBaseClass = "";
}

// Information about values accepted by enum-like clauses
class ClauseVal<string n, int v, bit uv> {
// Name of the clause value.
// Base class for versioned entities.
class Versioned<int min = 1, int max = 0x7FFFFFFF> {
// Mininum version number where this object is valid.
int minVersion = min;

// Maximum version number where this object is valid.
int maxVersion = max;
}

class Spelling<string s, int min = 1, int max = 0x7FFFFFFF>
: Versioned<min, max> {
string spelling = s;
}

// Some clauses take an argument from a predefined list of allowed keyword
// values. For example, assume a clause "someclause" with an argument from
// the list "foo", "bar", "baz". In the user source code this would look
// like "someclause(foo)", whereas in the compiler the values would be
// represented as
// enum someclause.enumClauseValue {
// Xyz_foo = v_foo,
// Xyz_bar = v_bar,
// Xyz_baz = v_baz,
// }
// The "Xyz_..." are the _record_ names of EnumVal's:
// def Xyz_foo = EnumVal<"foo", v_foo>;
// def Xyz_bar = EnumVal<"bar", v_bar>;
// def Xyz_baz = EnumVal<"baz", v_baz>;
//
class EnumVal<string n, int v, bit uv> {
// Spelling of the value.
string name = n;

// Integer value of the clause.
Expand All @@ -67,12 +95,9 @@ class ClauseVal<string n, int v, bit uv> {
}

// Information about a specific clause.
class Clause<string c> {
// Name of the clause.
string name = c;

// Define aliases used in the parser.
list<string> aliases = [];
class Clause<list<Spelling> ss> {
// Spellings of the clause.
list<Spelling> spellings = ss;

// Optional class holding value of the clause in clang AST.
string clangClass = "";
Expand All @@ -90,7 +115,7 @@ class Clause<string c> {
string enumClauseValue = "";

// List of allowed clause values
list<ClauseVal> allowedClauseValues = [];
list<EnumVal> allowedClauseValues = [];

// If set to true, value class is part of a list. Single class by default.
bit isValueList = false;
Expand Down Expand Up @@ -120,15 +145,9 @@ class Clause<string c> {
}

// Hold information about clause validity by version.
class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> {
// Actual clause.
class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF>
: Versioned<min, max> {
Clause clause = c;

// Mininum version number where this clause is valid.
int minVersion = min;

// Maximum version number where this clause is valid.
int maxVersion = max;
}

// Kinds of directive associations.
Expand Down Expand Up @@ -176,15 +195,15 @@ class SourceLanguage<string n> {
string name = n; // Name of the enum value in enum class Association.
}

// The C languages also implies C++ until there is a reason to add C++
// The C language also implies C++ until there is a reason to add C++
// separately.
def L_C : SourceLanguage<"C"> {}
def L_Fortran : SourceLanguage<"Fortran"> {}

// Information about a specific directive.
class Directive<string d> {
// Name of the directive. Can be composite directive sepearted by whitespace.
string name = d;
class Directive<list<Spelling> ss> {
// Spellings of the directive.
list<Spelling> spellings = ss;

// Clauses cannot appear twice in the three allowed lists below. Also, since
// required implies allowed, the same clause cannot appear in both the
Expand Down
Loading