Skip to content

TargetCodeRegion

Represents one target region.

#include <TargetCodeFragment.h>

Inherits from TargetCodeFragment

Public Types

Name
using std::vector< TargetRegionVariable >::const_iterator captured_vars_const_iterator
using llvm::iterator_range< captured_vars_const_iterator > captured_vars_const_range
using std::set< clang::VarDecl * >::const_iterator private_vars_const_iterator
using llvm::iterator_range< private_vars_const_iterator > private_vars_const_range
using std::vector< clang::VarDecl * >::const_iterator ompclauses_params_const_iterator
using llvm::iterator_range< ompclauses_params_const_iterator > ompclauses_params_const_range

Public Functions

Name
bool classof(const TargetCodeFragment * TCF)
TargetCodeRegion(clang::CapturedStmt * CapturedStmtNode, clang::OMPExecutableDirective * TargetDirective, clang::FunctionDecl * ParentFunctionDecl, clang::ASTContext & Context)
void addCapture(const clang::CapturedStmt::Capture * Capture)
Add a captured variable of the target region.
captured_vars_const_iterator getCapturedVarsBegin()
captured_vars_const_iterator getCapturedVarsEnd()
captured_vars_const_range capturedVars()
void addOMPClause(clang::OMPClause * Clause)
Adds a (top level) OpenMP clause for the target region.
const std::vector< clang::OMPClause * > & getOMPClauses() const
void setPrivateVars(const std::set< clang::VarDecl * > & VarSet)
Sets the private variables of this target region.
private_vars_const_range privateVars()
Returns a range over the private variables of this region.
ompclauses_params_const_range ompClausesParams()
Returns a range over the parameters to the top level OpenMP clauses.
void addOMPClauseParam(clang::VarDecl * Param)
Adds a parameter of a top level OpenMP clause to the target regions function as a function parameter.
bool hasCombineConstruct()
virtual std::string PrintPretty() override
Do pretty printing in order to resolve Macros.
virtual clang::SourceRange getRealRange() override
Get source range.
virtual clang::SourceRange getInnerRange() override
Get inner range.
virtual clang::SourceRange getSpellingRange() override
Get spelling range.
clang::SourceLocation getStartLoc()
Returns a source location at the start of a pragma in the captured statement.
clang::SourceLocation getEndLoc()
Get end location.
const std::string getParentFuncName()
Returns the name of the function in which the target region is declared.
clang::SourceLocation getTargetDirectiveLocation()
Returns the SourceLocation for the target directive (we need the source location of the first pragma of the target region to compose the name of the function generated for that region)

Public Attributes

Name
std::map< clang::VarDecl *, clang::Expr * > CapturedLowerBounds
Lower bounds of mapped array slices (if lower then 0).

Private Attributes

Name
clang::CapturedStmt * CapturedStmtNode
The AST node for the captured statement of the target region.
clang::OMPExecutableDirective * TargetDirective
AST node for the target directive.
clang::FunctionDecl * ParentFunctionDecl
Declaration of the function this region is declared in.
std::vector< TargetRegionVariable > CapturedVars
All variable captured by this target region.
std::vector< clang::OMPClause * > OMPClauses
All omp clauses relevant to the execution of the region.
std::vector< clang::VarDecl * > OMPClausesParams
The variables which are parameters for top level OpenMP clauses.
std::set< clang::VarDecl * > PrivateVars
All private variables in a Target Region i.e.

Additional inherited members

Public Types inherited from TargetCodeFragment

Name
enum TargetCodeFragmentKind { TCFK_TargetCodeFragment, TCFK_TargetCodeRegion, TCFK_TargetCodeDecl}
Enum for LLVMs RTTI.

Public Functions inherited from TargetCodeFragment

Name
TargetCodeFragmentKind getKind() const
Accessor for LLVMs RTTI.
TargetCodeFragment(clang::ASTContext & Context, TargetCodeFragmentKind Kind)
virtual ~TargetCodeFragment() =0
Destroy the Target Code Fragment:: Target Code Fragment object.
clang::OpenMPDirectiveKind getTargetCodeKind()
Accessor to TargetCodeKind.
const clang::LangOptions & GetLangOpts()
Accessor to lang opts of the current context.
clang::PrintingPolicy getPP()

Public Attributes inherited from TargetCodeFragment

Name
bool NeedsSemicolon
Does the source code generation need to add a semicolon to this fragment.
clang::OpenMPDirectiveKind TargetCodeKind
What kind of code are we copying.
bool HasExtraBraces

Protected Attributes inherited from TargetCodeFragment

Name
const TargetCodeFragmentKind Kind
Variable for LLVMs RTTI.
clang::ASTContext & Context
clang::PrintingPolicy PP

Public Types Documentation

using captured_vars_const_iterator

1
using TargetCodeRegion::captured_vars_const_iterator =  std::vector<TargetRegionVariable>::const_iterator;

using captured_vars_const_range

1
using TargetCodeRegion::captured_vars_const_range =  llvm::iterator_range<captured_vars_const_iterator>;

using private_vars_const_iterator

1
using TargetCodeRegion::private_vars_const_iterator =  std::set<clang::VarDecl *>::const_iterator;

using private_vars_const_range

1
using TargetCodeRegion::private_vars_const_range =  llvm::iterator_range<private_vars_const_iterator>;

using ompclauses_params_const_iterator

1
using TargetCodeRegion::ompclauses_params_const_iterator =  std::vector<clang::VarDecl *>::const_iterator;

using ompclauses_params_const_range

1
using TargetCodeRegion::ompclauses_params_const_range =  llvm::iterator_range<ompclauses_params_const_iterator>;

Public Functions Documentation

function classof

1
2
3
static inline bool classof(
    const TargetCodeFragment * TCF
)

function TargetCodeRegion

1
2
3
4
5
6
inline TargetCodeRegion(
    clang::CapturedStmt * CapturedStmtNode,
    clang::OMPExecutableDirective * TargetDirective,
    clang::FunctionDecl * ParentFunctionDecl,
    clang::ASTContext & Context
)

function addCapture

1
2
3
void addCapture(
    const clang::CapturedStmt::Capture * Capture
)

Add a captured variable of the target region.

Parameters:

  • Capture Captures element

Add capture.

This will automatically create and save a TargetRegionVariable which holds all information to generate parameters for the generated target region function.

This will automatically create and save a TargetRegionVariable which holds all information to generate parameters for the generated target region function.

function getCapturedVarsBegin

1
inline captured_vars_const_iterator getCapturedVarsBegin()

function getCapturedVarsEnd

1
inline captured_vars_const_iterator getCapturedVarsEnd()

function capturedVars

1
inline captured_vars_const_range capturedVars()

function addOMPClause

1
2
3
void addOMPClause(
    clang::OMPClause * Clause
)

Adds a (top level) OpenMP clause for the target region.

Parameters:

  • Clause OMP Clause

Add OMP clauses.

These clauses are later used to determine which OpenMP #pragma needs to be generated at the top level of the target region function.

Adds a (top level) OpenMP clause for the target region. These clauses are later used to determine which OpenMP #pragma needs to be generated at the top level of the target region function.

function getOMPClauses

1
inline const std::vector< clang::OMPClause * > & getOMPClauses() const

function setPrivateVars

1
2
3
inline void setPrivateVars(
    const std::set< clang::VarDecl * > & VarSet
)

Sets the private variables of this target region.

function privateVars

1
inline private_vars_const_range privateVars()

Returns a range over the private variables of this region.

function ompClausesParams

1
inline ompclauses_params_const_range ompClausesParams()

Returns a range over the parameters to the top level OpenMP clauses.

function addOMPClauseParam

1
2
3
void addOMPClauseParam(
    clang::VarDecl * Param
)

Adds a parameter of a top level OpenMP clause to the target regions function as a function parameter.

Parameters:

  • Param Parameter

Add OMP clause parameters.

Adds OMP clause paramenters to a TargetCodeRegion

function hasCombineConstruct

1
inline bool hasCombineConstruct()

function PrintPretty

1
virtual std::string PrintPretty() override

Do pretty printing in order to resolve Macros.

Return: std::string Pretty output

Reimplements: TargetCodeFragment::PrintPretty

function getRealRange

1
virtual clang::SourceRange getRealRange() override

Get source range.

Return: clang::SourceRange

Reimplements: TargetCodeFragment::getRealRange

function getInnerRange

1
virtual clang::SourceRange getInnerRange() override

Get inner range.

Return: clang::SourceRange

Reimplements: TargetCodeFragment::getInnerRange

function getSpellingRange

1
virtual clang::SourceRange getSpellingRange() override

Get spelling range.

Return: clang::SourceRange

Reimplements: TargetCodeFragment::getSpellingRange

function getStartLoc

1
clang::SourceLocation getStartLoc()

Returns a source location at the start of a pragma in the captured statement.

Return: clang::SourceLocation Start location

function getEndLoc

1
clang::SourceLocation getEndLoc()

Get end location.

Return: clang::SourceLocation End location

function getParentFuncName

1
const std::string getParentFuncName()

Returns the name of the function in which the target region is declared.

Return: const std::string

function getTargetDirectiveLocation

1
clang::SourceLocation getTargetDirectiveLocation()

Returns the SourceLocation for the target directive (we need the source location of the first pragma of the target region to compose the name of the function generated for that region)

Return: clang::SourceLocation Location

Get target directive location.

Returns the SourceLocation for the target directive (we need the source location of the first pragma of the target region to compose the name of the function generated for that region)

Public Attributes Documentation

variable CapturedLowerBounds

1
std::map< clang::VarDecl *, clang::Expr * > CapturedLowerBounds;

Lower bounds of mapped array slices (if lower then 0).

If the captured variable is an array, of which only a slice is mapped (by a map() clause), the incoming pointer argument will need to be shifted to the right if the lower bound of that slice is not 0. If this is the case, the lower bound is saved into this map.

Private Attributes Documentation

variable CapturedStmtNode

1
clang::CapturedStmt * CapturedStmtNode;

The AST node for the captured statement of the target region.

variable TargetDirective

1
clang::OMPExecutableDirective * TargetDirective;

AST node for the target directive.

variable ParentFunctionDecl

1
clang::FunctionDecl * ParentFunctionDecl;

Declaration of the function this region is declared in.

Necessary to compose the function name of this region in the generated code.

variable CapturedVars

1
std::vector< TargetRegionVariable > CapturedVars;

All variable captured by this target region.

We will need to generated pointers to them as arguments to the generated functions and copy the variables into scope.

variable OMPClauses

1
std::vector< clang::OMPClause * > OMPClauses;

All omp clauses relevant to the execution of the region.

variable OMPClausesParams

1
std::vector< clang::VarDecl * > OMPClausesParams;

The variables which are parameters for top level OpenMP clauses.

These are not captured but still needs passed as (first private) arguments to the target region.

variable PrivateVars

1
std::set< clang::VarDecl * > PrivateVars;

All private variables in a Target Region i.e.

all variables that are not passed as arguments into the region. For these, we need to generate declarations inside the target region.


Last update: 2021-11-24
Back to top