Skip to content

[Frontend] Introduce getDirectiveCategory for ACC/OMP directives #94689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions llvm/include/llvm/Frontend/Directive/DirectiveBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {} // See below
// The name "AS_FromLeaves" is recognized by TableGen, and there is no enum
// generated for it.

// Kinds of directive categories.
class Category<string n> {
string name = n; // Name of the enum value in enum class Category.
}

def CA_Declarative: Category<"Declarative"> {}
def CA_Executable: Category<"Executable"> {}
def CA_Informational: Category<"Informational"> {}
def CA_Meta: Category<"Meta"> {}
def CA_Subsidiary: Category<"Subsidiary"> {}
def CA_Utility: Category<"Utility"> {}

// Information about a specific directive.
class Directive<string d> {
// Name of the directive. Can be composite directive sepearted by whitespace.
Expand Down Expand Up @@ -190,4 +202,7 @@ class Directive<string d> {

// What the directive is associated with.
Association association = AS_FromLeaves;

// The category of the directive.
Category category = ?;
}
21 changes: 21 additions & 0 deletions llvm/include/llvm/Frontend/OpenACC/ACC.td
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> {
// 2.12
def ACC_Atomic : Directive<"atomic"> {
let association = AS_Block;
let category = CA_Executable;
}

// 2.6.5
Expand All @@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> {
VersionedClause<ACCC_Present>
];
let association = AS_Block;
let category = CA_Executable;
}

// 2.13
Expand All @@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> {
VersionedClause<ACCC_Link>
];
let association = AS_None;
let category = CA_Declarative;
}

// 2.5.3
Expand All @@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> {
VersionedClause<ACCC_VectorLength>
];
let association = AS_Block;
let category = CA_Executable;
}

// 2.5.1
Expand Down Expand Up @@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> {
VersionedClause<ACCC_Self>
];
let association = AS_Block;
let category = CA_Executable;
}

// 2.5.2
Expand Down Expand Up @@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> {
VersionedClause<ACCC_Self>
];
let association = AS_Block;
let category = CA_Executable;
}

// 2.9
Expand All @@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> {
VersionedClause<ACCC_Seq>
];
let association = AS_Loop;
let category = CA_Executable;
}

// 2.10
def ACC_Cache : Directive<"cache"> {
let association = AS_None;
let category = CA_Executable;
}

// 2.14.1
Expand All @@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> {
VersionedClause<ACCC_If>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.15.1
Expand All @@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> {
VersionedClause<ACCC_NoHost>
];
let association = AS_Declaration;
let category = CA_Declarative;
}

// 2.14.3
Expand All @@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> {
VersionedClause<ACCC_DeviceType>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.14.2
Expand All @@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> {
VersionedClause<ACCC_If>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.14.4
Expand All @@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> {
VersionedClause<ACCC_Self>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.16.3
Expand All @@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> {
VersionedClause<ACCC_If>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.14.6
Expand All @@ -516,6 +530,7 @@ def ACC_EnterData : Directive<"enter data"> {
VersionedClause<ACCC_Copyin>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.14.7
Expand All @@ -534,6 +549,7 @@ def ACC_ExitData : Directive<"exit data"> {
VersionedClause<ACCC_Detach>
];
let association = AS_None;
let category = CA_Executable;
}

// 2.8
Expand All @@ -546,6 +562,7 @@ def ACC_HostData : Directive<"host_data"> {
VersionedClause<ACCC_UseDevice>
];
let association = AS_Block;
let category = CA_Executable;
}

// 2.11
Expand Down Expand Up @@ -584,6 +601,7 @@ def ACC_KernelsLoop : Directive<"kernels loop"> {
VersionedClause<ACCC_Seq>
];
let leafConstructs = [ACC_Kernels, ACC_Loop];
let category = CA_Executable;
}

// 2.11
Expand Down Expand Up @@ -623,6 +641,7 @@ def ACC_ParallelLoop : Directive<"parallel loop"> {
VersionedClause<ACCC_Seq>
];
let leafConstructs = [ACC_Parallel, ACC_Loop];
let category = CA_Executable;
}

// 2.11
Expand Down Expand Up @@ -659,9 +678,11 @@ def ACC_SerialLoop : Directive<"serial loop"> {
VersionedClause<ACCC_Seq>
];
let leafConstructs = [ACC_Serial, ACC_Loop];
let category = CA_Executable;
}

def ACC_Unknown : Directive<"unknown"> {
let isDefault = true;
let association = AS_None;
let category = CA_Utility;
}
Loading
Loading