FindTargetCodeVisitor
Traverses the AST to find target and process target regions and function and variables that are annotated by an 'omp declare target' target pragma.
#include <Visitors.h>
Inherits from clang::RecursiveASTVisitor< FindTargetCodeVisitor >
Public Functions
Name | |
---|---|
FindTargetCodeVisitor(TargetCode & Code, TypeDeclResolver & Types, FunctionDeclResolver & Functions, clang::ASTContext & Context) | |
bool | TraverseDecl(clang::Decl * D) Traverse declarations. |
bool | VisitStmt(clang::Stmt * S) Visit function for statements. |
bool | VisitDecl(clang::Decl * D) Visit function for declarations. |
Private Functions
Name | |
---|---|
bool | processTargetRegion(clang::OMPExecutableDirective * TargetDirective) Extracts the necessary information about the target region from the AST, such as captured variables and relevant OpenMP clauses, and adds an TargetCodeRegion to the TargetCode instance. |
void | addTargetRegionArgs(clang::CapturedStmt * S, clang::OMPExecutableDirective * TargetDirective, std::shared_ptr< TargetCodeRegion > TCR) Finds and adds all variables required by the target regions as arguments to the generated function. |
Private Attributes
Name | |
---|---|
clang::ASTContext & | Context |
TargetCode & | TargetCodeInfo The collection where target regions and other code is added to. |
DiscoverTypesInDeclVisitor | DiscoverTypeVisitor A Visitor to find references to the types required by the target code. |
DiscoverFunctionsInDeclVisitor | DiscoverFunctionVisitor A Visitor to find references to all functions required by the target code. |
FunctionDeclResolver & | Functions Collection of all functions referenced and required by target code (and referenced by other required functions). |
FindDeclRefExprVisitor | FindDeclRefVisitor |
std::stack< clang::FunctionDecl * > | LastVisitedFuncDecl The last function the visitor traversed. |
std::unordered_set< std::string > | FuncDeclWithoutBody Function with 'omp declare target' pragma, for which the visitor has not yet found a body. |
Public Functions Documentation
function FindTargetCodeVisitor
1 2 3 4 5 6 |
|
function TraverseDecl
1 2 3 |
|
Traverse declarations.
Parameters:
- D Declaration to traverse
Return: true While traversing
false If NULL
function VisitStmt
1 2 3 |
|
Visit function for statements.
Parameters:
- S Given statement
Statement visitor in the FindTargetCodeVisitor.
function VisitDecl
1 2 3 |
|
Visit function for declarations.
Parameters:
- D Given declaration
Declaration Visitor in the FindTargetCodeVisitor
Private Functions Documentation
function processTargetRegion
1 2 3 |
|
Extracts the necessary information about the target region from the AST, such as captured variables and relevant OpenMP clauses, and adds an TargetCodeRegion to the TargetCode instance.
Parameters:
- TargetDirective Target directive
Process the target region.
function addTargetRegionArgs
1 2 3 4 5 |
|
Finds and adds all variables required by the target regions as arguments to the generated function.
Parameters:
- S
- TargetDirective
- TCR
Add target region arguments.
Private Attributes Documentation
variable Context
1 |
|
variable TargetCodeInfo
1 |
|
The collection where target regions and other code is added to.
variable DiscoverTypeVisitor
1 |
|
A Visitor to find references to the types required by the target code.
variable DiscoverFunctionVisitor
1 |
|
A Visitor to find references to all functions required by the target code.
variable Functions
1 |
|
Collection of all functions referenced and required by target code (and referenced by other required functions).
variable FindDeclRefVisitor
1 |
|
variable LastVisitedFuncDecl
1 |
|
The last function the visitor traversed.
This is stored to be able to later compute the function name for the target region.
variable FuncDeclWithoutBody
1 |
|
Function with 'omp declare target' pragma, for which the visitor has not yet found a body.