Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/AST/OpenMPClause.h
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,814 Lines • ▼ Show 20 Lines | class OMPMappableExprListClause : public OMPVarListClause<T>, | ||||
unsigned NumUniqueDeclarations; | unsigned NumUniqueDeclarations; | ||||
/// Number of component lists in this clause. | /// Number of component lists in this clause. | ||||
unsigned NumComponentLists; | unsigned NumComponentLists; | ||||
/// Total number of components in this clause. | /// Total number of components in this clause. | ||||
unsigned NumComponents; | unsigned NumComponents; | ||||
/// Whether this clause is possible to have user-defined mappers associated. | |||||
/// It should be true for map, to, and from clauses, and false for | |||||
/// use_device_ptr and is_device_ptr. | |||||
const bool SupportsMapper; | |||||
/// C++ nested name specifier for the associated user-defined mapper. | /// C++ nested name specifier for the associated user-defined mapper. | ||||
NestedNameSpecifierLoc MapperQualifierLoc; | NestedNameSpecifierLoc MapperQualifierLoc; | ||||
/// The associated user-defined mapper identifier information. | /// The associated user-defined mapper identifier information. | ||||
DeclarationNameInfo MapperIdInfo; | DeclarationNameInfo MapperIdInfo; | ||||
protected: | protected: | ||||
/// Build a clause for \a NumUniqueDeclarations declarations, \a | /// Build a clause for \a NumUniqueDeclarations declarations, \a | ||||
/// NumComponentLists total component lists, and \a NumComponents total | /// NumComponentLists total component lists, and \a NumComponents total | ||||
/// components. | /// components. | ||||
/// | /// | ||||
/// \param K Kind of the clause. | /// \param K Kind of the clause. | ||||
/// \param Locs Locations needed to build a mappable clause. It includes 1) | /// \param Locs Locations needed to build a mappable clause. It includes 1) | ||||
/// StartLoc: starting location of the clause (the clause keyword); 2) | /// StartLoc: starting location of the clause (the clause keyword); 2) | ||||
/// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. | ||||
/// \param Sizes All required sizes to build a mappable clause. It includes 1) | /// \param Sizes All required sizes to build a mappable clause. It includes 1) | ||||
/// NumVars: number of expressions listed in this clause; 2) | /// NumVars: number of expressions listed in this clause; 2) | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
/// \param SupportsMapper Indicates whether this clause is possible to have | |||||
/// user-defined mappers associated. | |||||
/// \param MapperQualifierLocPtr C++ nested name specifier for the associated | /// \param MapperQualifierLocPtr C++ nested name specifier for the associated | ||||
/// user-defined mapper. | /// user-defined mapper. | ||||
/// \param MapperIdInfoPtr The identifier of associated user-defined mapper. | /// \param MapperIdInfoPtr The identifier of associated user-defined mapper. | ||||
OMPMappableExprListClause( | OMPMappableExprListClause( | ||||
OpenMPClauseKind K, const OMPVarListLocTy &Locs, | OpenMPClauseKind K, const OMPVarListLocTy &Locs, | ||||
const OMPMappableExprListSizeTy &Sizes, | const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false, | ||||
NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr, | NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr, | ||||
DeclarationNameInfo *MapperIdInfoPtr = nullptr) | DeclarationNameInfo *MapperIdInfoPtr = nullptr) | ||||
: OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc, | : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc, | ||||
Sizes.NumVars), | Sizes.NumVars), | ||||
NumUniqueDeclarations(Sizes.NumUniqueDeclarations), | NumUniqueDeclarations(Sizes.NumUniqueDeclarations), | ||||
NumComponentLists(Sizes.NumComponentLists), | NumComponentLists(Sizes.NumComponentLists), | ||||
NumComponents(Sizes.NumComponents) { | NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) { | ||||
if (MapperQualifierLocPtr) | if (MapperQualifierLocPtr) | ||||
MapperQualifierLoc = *MapperQualifierLocPtr; | MapperQualifierLoc = *MapperQualifierLocPtr; | ||||
if (MapperIdInfoPtr) | if (MapperIdInfoPtr) | ||||
MapperIdInfo = *MapperIdInfoPtr; | MapperIdInfo = *MapperIdInfoPtr; | ||||
} | } | ||||
/// Get the unique declarations that are in the trailing objects of the | /// Get the unique declarations that are in the trailing objects of the | ||||
/// class. | /// class. | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | protected: | ||||
/// Set the name of associated user-defined mapper. | /// Set the name of associated user-defined mapper. | ||||
void setMapperIdInfo(DeclarationNameInfo MapperId) { | void setMapperIdInfo(DeclarationNameInfo MapperId) { | ||||
MapperIdInfo = MapperId; | MapperIdInfo = MapperId; | ||||
} | } | ||||
/// Get the user-defined mapper references that are in the trailing objects of | /// Get the user-defined mapper references that are in the trailing objects of | ||||
/// the class. | /// the class. | ||||
MutableArrayRef<Expr *> getUDMapperRefs() { | MutableArrayRef<Expr *> getUDMapperRefs() { | ||||
assert(SupportsMapper && | |||||
"Must be a clause that is possible to have user-defined mappers"); | |||||
return llvm::makeMutableArrayRef<Expr *>( | return llvm::makeMutableArrayRef<Expr *>( | ||||
static_cast<T *>(this)->template getTrailingObjects<Expr *>() + | static_cast<T *>(this)->template getTrailingObjects<Expr *>() + | ||||
OMPVarListClause<T>::varlist_size(), | OMPVarListClause<T>::varlist_size(), | ||||
OMPVarListClause<T>::varlist_size()); | OMPVarListClause<T>::varlist_size()); | ||||
} | } | ||||
/// Get the user-defined mappers references that are in the trailing objects | /// Get the user-defined mappers references that are in the trailing objects | ||||
/// of the class. | /// of the class. | ||||
ArrayRef<Expr *> getUDMapperRefs() const { | ArrayRef<Expr *> getUDMapperRefs() const { | ||||
assert(SupportsMapper && | |||||
"Must be a clause that is possible to have user-defined mappers"); | |||||
return llvm::makeArrayRef<Expr *>( | return llvm::makeArrayRef<Expr *>( | ||||
static_cast<T *>(this)->template getTrailingObjects<Expr *>() + | static_cast<const T *>(this)->template getTrailingObjects<Expr *>() + | ||||
OMPVarListClause<T>::varlist_size(), | OMPVarListClause<T>::varlist_size(), | ||||
OMPVarListClause<T>::varlist_size()); | OMPVarListClause<T>::varlist_size()); | ||||
} | } | ||||
/// Set the user-defined mappers that are in the trailing objects of the | /// Set the user-defined mappers that are in the trailing objects of the | ||||
/// class. | /// class. | ||||
void setUDMapperRefs(ArrayRef<Expr *> DMDs) { | void setUDMapperRefs(ArrayRef<Expr *> DMDs) { | ||||
assert(DMDs.size() == OMPVarListClause<T>::varlist_size() && | assert(DMDs.size() == OMPVarListClause<T>::varlist_size() && | ||||
"Unexpected number of user-defined mappers."); | "Unexpected number of user-defined mappers."); | ||||
assert(SupportsMapper && | |||||
"Must be a clause that is possible to have user-defined mappers"); | |||||
std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin()); | std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin()); | ||||
} | } | ||||
public: | public: | ||||
/// Return the number of unique base declarations in this clause. | /// Return the number of unique base declarations in this clause. | ||||
unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; } | unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; } | ||||
/// Return the number of lists derived from the clause expressions. | /// Return the number of lists derived from the clause expressions. | ||||
Show All 20 Lines | class const_component_lists_iterator | ||||
std::forward_iterator_tag, MappableComponent, ptrdiff_t, | std::forward_iterator_tag, MappableComponent, ptrdiff_t, | ||||
MappableComponent, MappableComponent> { | MappableComponent, MappableComponent> { | ||||
// The declaration the iterator currently refers to. | // The declaration the iterator currently refers to. | ||||
ArrayRef<ValueDecl *>::iterator DeclCur; | ArrayRef<ValueDecl *>::iterator DeclCur; | ||||
// The list number associated with the current declaration. | // The list number associated with the current declaration. | ||||
ArrayRef<unsigned>::iterator NumListsCur; | ArrayRef<unsigned>::iterator NumListsCur; | ||||
// Whether this clause is possible to have user-defined mappers associated. | |||||
const bool SupportsMapper; | |||||
// The user-defined mapper associated with the current declaration. | |||||
ArrayRef<Expr *>::iterator MapperCur; | |||||
// Remaining lists for the current declaration. | // Remaining lists for the current declaration. | ||||
unsigned RemainingLists = 0; | unsigned RemainingLists = 0; | ||||
// The cumulative size of the previous list, or zero if there is no previous | // The cumulative size of the previous list, or zero if there is no previous | ||||
// list. | // list. | ||||
unsigned PrevListSize = 0; | unsigned PrevListSize = 0; | ||||
// The cumulative sizes of the current list - it will delimit the remaining | // The cumulative sizes of the current list - it will delimit the remaining | ||||
// range of interest. | // range of interest. | ||||
ArrayRef<unsigned>::const_iterator ListSizeCur; | ArrayRef<unsigned>::const_iterator ListSizeCur; | ||||
ArrayRef<unsigned>::const_iterator ListSizeEnd; | ArrayRef<unsigned>::const_iterator ListSizeEnd; | ||||
// Iterator to the end of the components storage. | // Iterator to the end of the components storage. | ||||
MappableExprComponentListRef::const_iterator End; | MappableExprComponentListRef::const_iterator End; | ||||
public: | public: | ||||
/// Construct an iterator that scans all lists. | /// Construct an iterator that scans all lists. | ||||
explicit const_component_lists_iterator( | explicit const_component_lists_iterator( | ||||
ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum, | ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum, | ||||
ArrayRef<unsigned> CumulativeListSizes, | ArrayRef<unsigned> CumulativeListSizes, | ||||
MappableExprComponentListRef Components) | MappableExprComponentListRef Components, bool SupportsMapper, | ||||
ArrayRef<Expr *> Mappers) | |||||
: const_component_lists_iterator::iterator_adaptor_base( | : const_component_lists_iterator::iterator_adaptor_base( | ||||
Components.begin()), | Components.begin()), | ||||
DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()), | DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()), | ||||
SupportsMapper(SupportsMapper), | |||||
ListSizeCur(CumulativeListSizes.begin()), | ListSizeCur(CumulativeListSizes.begin()), | ||||
ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) { | ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) { | ||||
assert(UniqueDecls.size() == DeclsListNum.size() && | assert(UniqueDecls.size() == DeclsListNum.size() && | ||||
"Inconsistent number of declarations and list sizes!"); | "Inconsistent number of declarations and list sizes!"); | ||||
if (!DeclsListNum.empty()) | if (!DeclsListNum.empty()) | ||||
RemainingLists = *NumListsCur; | RemainingLists = *NumListsCur; | ||||
if (SupportsMapper) | |||||
MapperCur = Mappers.begin(); | |||||
} | } | ||||
/// Construct an iterator that scan lists for a given declaration \a | /// Construct an iterator that scan lists for a given declaration \a | ||||
/// Declaration. | /// Declaration. | ||||
explicit const_component_lists_iterator( | explicit const_component_lists_iterator( | ||||
const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls, | const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls, | ||||
ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes, | ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes, | ||||
MappableExprComponentListRef Components) | MappableExprComponentListRef Components, bool SupportsMapper, | ||||
ArrayRef<Expr *> Mappers) | |||||
: const_component_lists_iterator(UniqueDecls, DeclsListNum, | : const_component_lists_iterator(UniqueDecls, DeclsListNum, | ||||
CumulativeListSizes, Components) { | CumulativeListSizes, Components, | ||||
SupportsMapper, Mappers) { | |||||
// Look for the desired declaration. While we are looking for it, we | // Look for the desired declaration. While we are looking for it, we | ||||
// update the state so that we know the component where a given list | // update the state so that we know the component where a given list | ||||
// starts. | // starts. | ||||
for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) { | for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) { | ||||
if (*DeclCur == Declaration) | if (*DeclCur == Declaration) | ||||
break; | break; | ||||
assert(*NumListsCur > 0 && "No lists associated with declaration??"); | assert(*NumListsCur > 0 && "No lists associated with declaration??"); | ||||
// Skip the lists associated with the current declaration, but save the | // Skip the lists associated with the current declaration, but save the | ||||
// last list size that was skipped. | // last list size that was skipped. | ||||
std::advance(ListSizeCur, *NumListsCur - 1); | std::advance(ListSizeCur, *NumListsCur - 1); | ||||
PrevListSize = *ListSizeCur; | PrevListSize = *ListSizeCur; | ||||
++ListSizeCur; | ++ListSizeCur; | ||||
if (SupportsMapper) | |||||
++MapperCur; | |||||
} | } | ||||
// If we didn't find any declaration, advance the iterator to after the | // If we didn't find any declaration, advance the iterator to after the | ||||
// last component and set remaining lists to zero. | // last component and set remaining lists to zero. | ||||
if (ListSizeCur == CumulativeListSizes.end()) { | if (ListSizeCur == CumulativeListSizes.end()) { | ||||
this->I = End; | this->I = End; | ||||
RemainingLists = 0u; | RemainingLists = 0u; | ||||
return; | return; | ||||
Show All 9 Lines | explicit const_component_lists_iterator( | ||||
// Given that the list sizes are cumulative, the index of the component | // Given that the list sizes are cumulative, the index of the component | ||||
// that start the list is the size of the previous list. | // that start the list is the size of the previous list. | ||||
std::advance(this->I, PrevListSize); | std::advance(this->I, PrevListSize); | ||||
} | } | ||||
// Return the array with the current list. The sizes are cumulative, so the | // Return the array with the current list. The sizes are cumulative, so the | ||||
// array size is the difference between the current size and previous one. | // array size is the difference between the current size and previous one. | ||||
std::pair<const ValueDecl *, MappableExprComponentListRef> | std::tuple<const ValueDecl *, MappableExprComponentListRef, | ||||
const ValueDecl *> | |||||
operator*() const { | operator*() const { | ||||
assert(ListSizeCur != ListSizeEnd && "Invalid iterator!"); | assert(ListSizeCur != ListSizeEnd && "Invalid iterator!"); | ||||
return std::make_pair( | const ValueDecl *Mapper = nullptr; | ||||
if (SupportsMapper && *MapperCur) | |||||
Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl()); | |||||
return std::make_tuple( | |||||
*DeclCur, | *DeclCur, | ||||
MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize)); | MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize), | ||||
Mapper); | |||||
} | } | ||||
std::pair<const ValueDecl *, MappableExprComponentListRef> | std::tuple<const ValueDecl *, MappableExprComponentListRef, | ||||
const ValueDecl *> | |||||
operator->() const { | operator->() const { | ||||
return **this; | return **this; | ||||
} | } | ||||
// Skip the components of the current list. | // Skip the components of the current list. | ||||
const_component_lists_iterator &operator++() { | const_component_lists_iterator &operator++() { | ||||
assert(ListSizeCur != ListSizeEnd && RemainingLists && | assert(ListSizeCur != ListSizeEnd && RemainingLists && | ||||
"Invalid iterator!"); | "Invalid iterator!"); | ||||
// If we don't have more lists just skip all the components. Otherwise, | // If we don't have more lists just skip all the components. Otherwise, | ||||
// advance the iterator by the number of components in the current list. | // advance the iterator by the number of components in the current list. | ||||
if (std::next(ListSizeCur) == ListSizeEnd) { | if (std::next(ListSizeCur) == ListSizeEnd) { | ||||
this->I = End; | this->I = End; | ||||
RemainingLists = 0; | RemainingLists = 0; | ||||
} else { | } else { | ||||
std::advance(this->I, *ListSizeCur - PrevListSize); | std::advance(this->I, *ListSizeCur - PrevListSize); | ||||
PrevListSize = *ListSizeCur; | PrevListSize = *ListSizeCur; | ||||
// We are done with a declaration, move to the next one. | // We are done with a declaration, move to the next one. | ||||
if (!(--RemainingLists)) { | if (!(--RemainingLists)) { | ||||
++DeclCur; | ++DeclCur; | ||||
++NumListsCur; | ++NumListsCur; | ||||
if (SupportsMapper) | |||||
++MapperCur; | |||||
RemainingLists = *NumListsCur; | RemainingLists = *NumListsCur; | ||||
assert(RemainingLists && "No lists in the following declaration??"); | assert(RemainingLists && "No lists in the following declaration??"); | ||||
} | } | ||||
} | } | ||||
++ListSizeCur; | ++ListSizeCur; | ||||
return *this; | return *this; | ||||
} | } | ||||
}; | }; | ||||
using const_component_lists_range = | using const_component_lists_range = | ||||
llvm::iterator_range<const_component_lists_iterator>; | llvm::iterator_range<const_component_lists_iterator>; | ||||
/// Iterators for all component lists. | /// Iterators for all component lists. | ||||
const_component_lists_iterator component_lists_begin() const { | const_component_lists_iterator component_lists_begin() const { | ||||
return const_component_lists_iterator( | return const_component_lists_iterator( | ||||
getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(), | getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(), | ||||
getComponentsRef()); | getComponentsRef(), SupportsMapper, | ||||
SupportsMapper ? getUDMapperRefs() : llvm::None); | |||||
} | } | ||||
const_component_lists_iterator component_lists_end() const { | const_component_lists_iterator component_lists_end() const { | ||||
return const_component_lists_iterator( | return const_component_lists_iterator( | ||||
ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(), | ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(), | ||||
MappableExprComponentListRef(getComponentsRef().end(), | MappableExprComponentListRef(getComponentsRef().end(), | ||||
getComponentsRef().end())); | getComponentsRef().end()), | ||||
SupportsMapper, llvm::None); | |||||
} | } | ||||
const_component_lists_range component_lists() const { | const_component_lists_range component_lists() const { | ||||
return {component_lists_begin(), component_lists_end()}; | return {component_lists_begin(), component_lists_end()}; | ||||
} | } | ||||
/// Iterators for component lists associated with the provided | /// Iterators for component lists associated with the provided | ||||
/// declaration. | /// declaration. | ||||
const_component_lists_iterator | const_component_lists_iterator | ||||
decl_component_lists_begin(const ValueDecl *VD) const { | decl_component_lists_begin(const ValueDecl *VD) const { | ||||
return const_component_lists_iterator( | return const_component_lists_iterator( | ||||
VD, getUniqueDeclsRef(), getDeclNumListsRef(), | VD, getUniqueDeclsRef(), getDeclNumListsRef(), | ||||
getComponentListSizesRef(), getComponentsRef()); | getComponentListSizesRef(), getComponentsRef(), SupportsMapper, | ||||
SupportsMapper ? getUDMapperRefs() : llvm::None); | |||||
} | } | ||||
const_component_lists_iterator decl_component_lists_end() const { | const_component_lists_iterator decl_component_lists_end() const { | ||||
return component_lists_end(); | return component_lists_end(); | ||||
} | } | ||||
const_component_lists_range decl_component_lists(const ValueDecl *VD) const { | const_component_lists_range decl_component_lists(const ValueDecl *VD) const { | ||||
return {decl_component_lists_begin(VD), decl_component_lists_end()}; | return {decl_component_lists_begin(VD), decl_component_lists_end()}; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | private: | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers, | explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers, | ||||
ArrayRef<SourceLocation> MapModifiersLoc, | ArrayRef<SourceLocation> MapModifiersLoc, | ||||
NestedNameSpecifierLoc MapperQualifierLoc, | NestedNameSpecifierLoc MapperQualifierLoc, | ||||
DeclarationNameInfo MapperIdInfo, | DeclarationNameInfo MapperIdInfo, | ||||
OpenMPMapClauseKind MapType, bool MapTypeIsImplicit, | OpenMPMapClauseKind MapType, bool MapTypeIsImplicit, | ||||
SourceLocation MapLoc, const OMPVarListLocTy &Locs, | SourceLocation MapLoc, const OMPVarListLocTy &Locs, | ||||
const OMPMappableExprListSizeTy &Sizes) | const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes, | : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes, | ||||
&MapperQualifierLoc, &MapperIdInfo), | /*SupportsMapper=*/true, &MapperQualifierLoc, | ||||
&MapperIdInfo), | |||||
ABataev: Do we really need to set `HasMapper` to `true` unconditionally here and in other places? | |||||
For map, to, and from clauses, they can have mappers, so it's set to true. For is_device_ptr and use_device_ptr, it's set to false. lildmh: For `map`, `to`, and `from` clauses, they can have mappers, so it's set to `true`. For… | |||||
So, it completely depends on the clause kind, right? If so, can we just remove it and rely on the clause kind? ABataev: So, it completely depends on the clause kind, right? If so, can we just remove it and rely on… | |||||
This is used in OMPMappableExprListClause which is inherited by all these clauses. Do you mean to check the template type there to get the clause kind? lildmh: This is used in `OMPMappableExprListClause` which is inherited by all these clauses. Do you… | |||||
I see. I think it is better to rename it to ClauseSupportsMapper (or something like this) and make it const. Currently, it is confusing. I thought that this flag shows the use of the mapper in the clause. ABataev: I see. I think it is better to rename it to `ClauseSupportsMapper` (or something like this) and… | |||||
Ok, will do that lildmh: Ok, will do that | |||||
MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { | MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { | ||||
assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && | assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && | ||||
"Unexpected number of map type modifiers."); | "Unexpected number of map type modifiers."); | ||||
llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); | llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); | ||||
assert(llvm::array_lengthof(MapTypeModifiersLoc) == | assert(llvm::array_lengthof(MapTypeModifiersLoc) == | ||||
MapModifiersLoc.size() && | MapModifiersLoc.size() && | ||||
"Unexpected number of map type modifier locations."); | "Unexpected number of map type modifier locations."); | ||||
llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); | llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); | ||||
} | } | ||||
/// Build an empty clause. | /// Build an empty clause. | ||||
/// | /// | ||||
/// \param Sizes All required sizes to build a mappable clause. It includes 1) | /// \param Sizes All required sizes to build a mappable clause. It includes 1) | ||||
/// NumVars: number of expressions listed in this clause; 2) | /// NumVars: number of expressions listed in this clause; 2) | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes) | explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), | : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes, | ||||
Sizes) {} | /*SupportsMapper=*/true) {} | ||||
/// Set map-type-modifier for the clause. | /// Set map-type-modifier for the clause. | ||||
/// | /// | ||||
/// \param I index for map-type-modifier. | /// \param I index for map-type-modifier. | ||||
/// \param T map-type-modifier for the clause. | /// \param T map-type-modifier for the clause. | ||||
void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) { | void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) { | ||||
assert(I < NumberOfOMPMapClauseModifiers && | assert(I < NumberOfOMPMapClauseModifiers && | ||||
"Unexpected index to store map type modifier, exceeds array size."); | "Unexpected index to store map type modifier, exceeds array size."); | ||||
▲ Show 20 Lines • Show All 870 Lines • ▼ Show 20 Lines | class OMPToClause final : public OMPMappableExprListClause<OMPToClause>, | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc, | explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc, | ||||
DeclarationNameInfo MapperIdInfo, | DeclarationNameInfo MapperIdInfo, | ||||
const OMPVarListLocTy &Locs, | const OMPVarListLocTy &Locs, | ||||
const OMPMappableExprListSizeTy &Sizes) | const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, | : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, | ||||
&MapperQualifierLoc, &MapperIdInfo) {} | /*SupportsMapper=*/true, &MapperQualifierLoc, | ||||
&MapperIdInfo) {} | |||||
/// Build an empty clause. | /// Build an empty clause. | ||||
/// | /// | ||||
/// \param Sizes All required sizes to build a mappable clause. It includes 1) | /// \param Sizes All required sizes to build a mappable clause. It includes 1) | ||||
/// NumVars: number of expressions listed in this clause; 2) | /// NumVars: number of expressions listed in this clause; 2) | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes) | explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), | : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes, | ||||
Sizes) {} | /*SupportsMapper=*/true) {} | ||||
/// Define the sizes of each trailing object array except the last one. This | /// Define the sizes of each trailing object array except the last one. This | ||||
/// is required for TrailingObjects to work properly. | /// is required for TrailingObjects to work properly. | ||||
size_t numTrailingObjects(OverloadToken<Expr *>) const { | size_t numTrailingObjects(OverloadToken<Expr *>) const { | ||||
// There are varlist_size() of expressions, and varlist_size() of | // There are varlist_size() of expressions, and varlist_size() of | ||||
// user-defined mappers. | // user-defined mappers. | ||||
return 2 * varlist_size(); | return 2 * varlist_size(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | class OMPFromClause final | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc, | explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc, | ||||
DeclarationNameInfo MapperIdInfo, | DeclarationNameInfo MapperIdInfo, | ||||
const OMPVarListLocTy &Locs, | const OMPVarListLocTy &Locs, | ||||
const OMPMappableExprListSizeTy &Sizes) | const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, | : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, | ||||
&MapperQualifierLoc, &MapperIdInfo) {} | /*SupportsMapper=*/true, &MapperQualifierLoc, | ||||
&MapperIdInfo) {} | |||||
/// Build an empty clause. | /// Build an empty clause. | ||||
/// | /// | ||||
/// \param Sizes All required sizes to build a mappable clause. It includes 1) | /// \param Sizes All required sizes to build a mappable clause. It includes 1) | ||||
/// NumVars: number of expressions listed in this clause; 2) | /// NumVars: number of expressions listed in this clause; 2) | ||||
/// NumUniqueDeclarations: number of unique base declarations in this clause; | /// NumUniqueDeclarations: number of unique base declarations in this clause; | ||||
/// 3) NumComponentLists: number of component lists in this clause; and 4) | /// 3) NumComponentLists: number of component lists in this clause; and 4) | ||||
/// NumComponents: total number of expression components in the clause. | /// NumComponents: total number of expression components in the clause. | ||||
explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes) | explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes) | ||||
: OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(), | : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(), | ||||
Sizes) {} | Sizes, /*SupportsMapper=*/true) {} | ||||
/// Define the sizes of each trailing object array except the last one. This | /// Define the sizes of each trailing object array except the last one. This | ||||
/// is required for TrailingObjects to work properly. | /// is required for TrailingObjects to work properly. | ||||
size_t numTrailingObjects(OverloadToken<Expr *>) const { | size_t numTrailingObjects(OverloadToken<Expr *>) const { | ||||
// There are varlist_size() of expressions, and varlist_size() of | // There are varlist_size() of expressions, and varlist_size() of | ||||
// user-defined mappers. | // user-defined mappers. | ||||
return 2 * varlist_size(); | return 2 * varlist_size(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,207 Lines • Show Last 20 Lines |
Do we really need to set HasMapper to true unconditionally here and in other places?