Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit bd1f749

Browse files
AutomergerAutomerger
Automerger
authored and
Automerger
committed
Propagating prior merge from 'llvm.org/master'.
2 parents b4ca6b7 + a1a49a7 commit bd1f749

34 files changed

+545
-214
lines changed

include/clang/AST/OpenMPClause.h

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,8 +4061,19 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
40614061
return getUniqueDeclarationsNum() + getTotalComponentListNum();
40624062
}
40634063

4064-
/// Map type modifier for the 'map' clause.
4065-
OpenMPMapClauseKind MapTypeModifier = OMPC_MAP_unknown;
4064+
public:
4065+
/// Number of allowed map-type-modifiers.
4066+
static constexpr unsigned NumberOfModifiers =
4067+
OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
4068+
4069+
private:
4070+
/// Map-type-modifiers for the 'map' clause.
4071+
OpenMPMapModifierKind MapTypeModifiers[NumberOfModifiers] = {
4072+
OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown
4073+
};
4074+
4075+
/// Location of map-type-modifiers for the 'map' clause.
4076+
SourceLocation MapTypeModifiersLoc[NumberOfModifiers];
40664077

40674078
/// Map type for the 'map' clause.
40684079
OpenMPMapClauseKind MapType = OMPC_MAP_unknown;
@@ -4080,7 +4091,8 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
40804091
/// NumUniqueDeclarations declarations, \a NumComponentLists total component
40814092
/// lists, and \a NumComponents total expression components.
40824093
///
4083-
/// \param MapTypeModifier Map type modifier.
4094+
/// \param MapModifiers Map-type-modifiers.
4095+
/// \param MapModifiersLoc Locations of map-type-modifiers.
40844096
/// \param MapType Map type.
40854097
/// \param MapTypeIsImplicit Map type is inferred implicitly.
40864098
/// \param MapLoc Location of the map type.
@@ -4091,7 +4103,8 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
40914103
/// clause.
40924104
/// \param NumComponentLists Number of component lists in this clause.
40934105
/// \param NumComponents Total number of expression components in the clause.
4094-
explicit OMPMapClause(OpenMPMapClauseKind MapTypeModifier,
4106+
explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
4107+
ArrayRef<SourceLocation> MapModifiersLoc,
40954108
OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
40964109
SourceLocation MapLoc, SourceLocation StartLoc,
40974110
SourceLocation LParenLoc, SourceLocation EndLoc,
@@ -4100,8 +4113,17 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
41004113
: OMPMappableExprListClause(OMPC_map, StartLoc, LParenLoc, EndLoc,
41014114
NumVars, NumUniqueDeclarations,
41024115
NumComponentLists, NumComponents),
4103-
MapTypeModifier(MapTypeModifier), MapType(MapType),
4104-
MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {}
4116+
MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit),
4117+
MapLoc(MapLoc) {
4118+
assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size()
4119+
&& "Unexpected number of map type modifiers.");
4120+
llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
4121+
4122+
assert(llvm::array_lengthof(MapTypeModifiersLoc) ==
4123+
MapModifiersLoc.size() &&
4124+
"Unexpected number of map type modifier locations.");
4125+
llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
4126+
}
41054127

41064128
/// Build an empty clause.
41074129
///
@@ -4116,10 +4138,25 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
41164138
OMPC_map, SourceLocation(), SourceLocation(), SourceLocation(),
41174139
NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
41184140

4119-
/// Set type modifier for the clause.
4141+
/// Set map-type-modifier for the clause.
41204142
///
4121-
/// \param T Type Modifier for the clause.
4122-
void setMapTypeModifier(OpenMPMapClauseKind T) { MapTypeModifier = T; }
4143+
/// \param I index for map-type-modifier.
4144+
/// \param T map-type-modifier for the clause.
4145+
void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
4146+
assert(I < NumberOfModifiers &&
4147+
"Unexpected index to store map type modifier, exceeds array size.");
4148+
MapTypeModifiers[I] = T;
4149+
}
4150+
4151+
/// Set location for the map-type-modifier.
4152+
///
4153+
/// \param I index for map-type-modifier location.
4154+
/// \param TLoc map-type-modifier location.
4155+
void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
4156+
assert(I < NumberOfModifiers &&
4157+
"Index to store map type modifier location exceeds array size.");
4158+
MapTypeModifiersLoc[I] = TLoc;
4159+
}
41234160

41244161
/// Set type for the clause.
41254162
///
@@ -4143,7 +4180,8 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
41434180
/// \param Vars The original expression used in the clause.
41444181
/// \param Declarations Declarations used in the clause.
41454182
/// \param ComponentLists Component lists used in the clause.
4146-
/// \param TypeModifier Map type modifier.
4183+
/// \param MapModifiers Map-type-modifiers.
4184+
/// \param MapModifiersLoc Location of map-type-modifiers.
41474185
/// \param Type Map type.
41484186
/// \param TypeIsImplicit Map type is inferred implicitly.
41494187
/// \param TypeLoc Location of the map type.
@@ -4152,7 +4190,8 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
41524190
ArrayRef<Expr *> Vars,
41534191
ArrayRef<ValueDecl *> Declarations,
41544192
MappableExprComponentListsRef ComponentLists,
4155-
OpenMPMapClauseKind TypeModifier,
4193+
ArrayRef<OpenMPMapModifierKind> MapModifiers,
4194+
ArrayRef<SourceLocation> MapModifiersLoc,
41564195
OpenMPMapClauseKind Type, bool TypeIsImplicit,
41574196
SourceLocation TypeLoc);
41584197

@@ -4182,9 +4221,33 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
41824221
/// messages for some target directives.
41834222
bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
41844223

4185-
/// Fetches the map type modifier for the clause.
4186-
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY {
4187-
return MapTypeModifier;
4224+
/// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
4225+
///
4226+
/// \param Cnt index for map-type-modifier.
4227+
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
4228+
assert(Cnt < NumberOfModifiers &&
4229+
"Requested modifier exceeds the total number of modifiers.");
4230+
return MapTypeModifiers[Cnt];
4231+
}
4232+
4233+
/// Fetches the map-type-modifier location at 'Cnt' index of array of
4234+
/// modifiers' locations.
4235+
///
4236+
/// \param Cnt index for map-type-modifier location.
4237+
SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
4238+
assert(Cnt < NumberOfModifiers &&
4239+
"Requested modifier location exceeds total number of modifiers.");
4240+
return MapTypeModifiersLoc[Cnt];
4241+
}
4242+
4243+
/// Fetches ArrayRef of map-type-modifiers.
4244+
ArrayRef<OpenMPMapModifierKind> getMapTypeModifiers() const LLVM_READONLY {
4245+
return llvm::makeArrayRef(MapTypeModifiers);
4246+
}
4247+
4248+
/// Fetches ArrayRef of location of map-type-modifiers.
4249+
ArrayRef<SourceLocation> getMapTypeModifiersLoc() const LLVM_READONLY {
4250+
return llvm::makeArrayRef(MapTypeModifiersLoc);
41884251
}
41894252

41904253
/// Fetches location of clause mapping kind.

include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,11 @@ def err_omp_decl_in_declare_simd : Error<
11571157
def err_omp_unknown_map_type : Error<
11581158
"incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">;
11591159
def err_omp_unknown_map_type_modifier : Error<
1160-
"incorrect map type modifier, expected 'always'">;
1160+
"incorrect map type modifier, expected 'always' or 'close'">;
11611161
def err_omp_map_type_missing : Error<
11621162
"missing map type">;
1163+
def err_omp_map_type_modifier_missing : Error<
1164+
"missing map type modifier">;
11631165
def err_omp_declare_simd_inbranch_notinbranch : Error<
11641166
"unexpected '%0' clause, '%1' is specified already">;
11651167
def err_expected_end_declare_target : Error<

include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8812,6 +8812,8 @@ def err_omp_expected_access_to_data_field : Error<
88128812
"expected access to data field">;
88138813
def err_omp_multiple_array_items_in_map_clause : Error<
88148814
"multiple array elements associated with the same variable are not allowed in map clauses of the same construct">;
8815+
def err_omp_duplicate_map_type_modifier : Error<
8816+
"same map type modifier has been specified more than once">;
88158817
def err_omp_pointer_mapped_along_with_derived_section : Error<
88168818
"pointer cannot be mapped along with a section derived from itself">;
88178819
def err_omp_original_storage_is_shared_and_does_not_contain : Error<

include/clang/Basic/OpenMPKinds.def

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
#ifndef OPENMP_MAP_KIND
121121
#define OPENMP_MAP_KIND(Name)
122122
#endif
123+
#ifndef OPENMP_MAP_MODIFIER_KIND
124+
#define OPENMP_MAP_MODIFIER_KIND(Name)
125+
#endif
123126
#ifndef OPENMP_DIST_SCHEDULE_KIND
124127
#define OPENMP_DIST_SCHEDULE_KIND(Name)
125128
#endif
@@ -559,14 +562,17 @@ OPENMP_ORDERED_CLAUSE(threads)
559562
OPENMP_ORDERED_CLAUSE(simd)
560563
OPENMP_ORDERED_CLAUSE(depend)
561564

562-
// Map types and map type modifier for 'map' clause.
565+
// Map types for 'map' clause.
563566
OPENMP_MAP_KIND(alloc)
564567
OPENMP_MAP_KIND(to)
565568
OPENMP_MAP_KIND(from)
566569
OPENMP_MAP_KIND(tofrom)
567570
OPENMP_MAP_KIND(delete)
568571
OPENMP_MAP_KIND(release)
569-
OPENMP_MAP_KIND(always)
572+
573+
// Map-type-modifiers for 'map' clause.
574+
OPENMP_MAP_MODIFIER_KIND(always)
575+
OPENMP_MAP_MODIFIER_KIND(close)
570576

571577
// Clauses allowed for OpenMP directive 'taskloop'.
572578
OPENMP_TASKLOOP_CLAUSE(if)
@@ -919,6 +925,7 @@ OPENMP_TASKGROUP_CLAUSE(task_reduction)
919925
#undef OPENMP_FOR_CLAUSE
920926
#undef OPENMP_FOR_SIMD_CLAUSE
921927
#undef OPENMP_MAP_KIND
928+
#undef OPENMP_MAP_MODIFIER_KIND
922929
#undef OPENMP_DISTRIBUTE_CLAUSE
923930
#undef OPENMP_DIST_SCHEDULE_KIND
924931
#undef OPENMP_DEFAULTMAP_KIND

include/clang/Basic/OpenMPKinds.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ enum OpenMPMapClauseKind {
9696
OMPC_MAP_unknown
9797
};
9898

99+
/// OpenMP modifier kind for 'map' clause.
100+
enum OpenMPMapModifierKind {
101+
OMPC_MAP_MODIFIER_unknown = OMPC_MAP_unknown,
102+
#define OPENMP_MAP_MODIFIER_KIND(Name) \
103+
OMPC_MAP_MODIFIER_##Name,
104+
#include "clang/Basic/OpenMPKinds.def"
105+
OMPC_MAP_MODIFIER_last
106+
};
107+
99108
/// OpenMP attributes for 'dist_schedule' clause.
100109
enum OpenMPDistScheduleClauseKind {
101110
#define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,

include/clang/Parse/Parser.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_CLANG_PARSE_PARSER_H
1515
#define LLVM_CLANG_PARSE_PARSER_H
1616

17+
#include "clang/AST/OpenMPClause.h"
1718
#include "clang/AST/Availability.h"
1819
#include "clang/Basic/BitmaskEnum.h"
1920
#include "clang/Basic/OpenMPKinds.h"
@@ -2884,7 +2885,10 @@ class Parser : public CodeCompletionHandler {
28842885
DeclarationNameInfo ReductionId;
28852886
OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown;
28862887
OpenMPLinearClauseKind LinKind = OMPC_LINEAR_val;
2887-
OpenMPMapClauseKind MapTypeModifier = OMPC_MAP_unknown;
2888+
SmallVector<OpenMPMapModifierKind, OMPMapClause::NumberOfModifiers>
2889+
MapTypeModifiers;
2890+
SmallVector<SourceLocation, OMPMapClause::NumberOfModifiers>
2891+
MapTypeModifiersLoc;
28882892
OpenMPMapClauseKind MapType = OMPC_MAP_unknown;
28892893
bool IsMapTypeImplicit = false;
28902894
SourceLocation DepLinMapLoc;

include/clang/Sema/Sema.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9298,7 +9298,9 @@ class Sema {
92989298
SourceLocation ColonLoc, SourceLocation EndLoc,
92999299
CXXScopeSpec &ReductionIdScopeSpec,
93009300
const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind,
9301-
OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier,
9301+
OpenMPLinearClauseKind LinKind,
9302+
ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9303+
ArrayRef<SourceLocation> MapTypeModifiersLoc,
93029304
OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
93039305
SourceLocation DepLinMapLoc);
93049306
/// Called on well-formed 'private' clause.
@@ -9382,7 +9384,8 @@ class Sema {
93829384
SourceLocation EndLoc);
93839385
/// Called on well-formed 'map' clause.
93849386
OMPClause *
9385-
ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier,
9387+
ActOnOpenMPMapClause(ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9388+
ArrayRef<SourceLocation> MapTypeModifiersLoc,
93869389
OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
93879390
SourceLocation MapLoc, SourceLocation ColonLoc,
93889391
ArrayRef<Expr *> VarList, SourceLocation StartLoc,

lib/AST/OpenMPClause.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,10 @@ OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
796796
SourceLocation LParenLoc, SourceLocation EndLoc,
797797
ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
798798
MappableExprComponentListsRef ComponentLists,
799-
OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type,
800-
bool TypeIsImplicit, SourceLocation TypeLoc) {
799+
ArrayRef<OpenMPMapModifierKind> MapModifiers,
800+
ArrayRef<SourceLocation> MapModifiersLoc,
801+
OpenMPMapClauseKind Type, bool TypeIsImplicit,
802+
SourceLocation TypeLoc) {
801803
unsigned NumVars = Vars.size();
802804
unsigned NumUniqueDeclarations =
803805
getUniqueDeclarationsTotalNumber(Declarations);
@@ -820,12 +822,12 @@ OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
820822
NumVars, NumUniqueDeclarations,
821823
NumUniqueDeclarations + NumComponentLists, NumComponents));
822824
OMPMapClause *Clause = new (Mem) OMPMapClause(
823-
TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
824-
NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
825+
MapModifiers, MapModifiersLoc, Type, TypeIsImplicit, TypeLoc, StartLoc,
826+
LParenLoc, EndLoc, NumVars, NumUniqueDeclarations, NumComponentLists,
827+
NumComponents);
825828

826829
Clause->setVarRefs(Vars);
827830
Clause->setClauseInfo(Declarations, ComponentLists);
828-
Clause->setMapTypeModifier(TypeModifier);
829831
Clause->setMapType(Type);
830832
Clause->setMapLoc(TypeLoc);
831833
return Clause;
@@ -1426,10 +1428,12 @@ void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
14261428
if (!Node->varlist_empty()) {
14271429
OS << "map(";
14281430
if (Node->getMapType() != OMPC_MAP_unknown) {
1429-
if (Node->getMapTypeModifier() != OMPC_MAP_unknown) {
1430-
OS << getOpenMPSimpleClauseTypeName(OMPC_map,
1431-
Node->getMapTypeModifier());
1432-
OS << ',';
1431+
for (unsigned I = 0; I < OMPMapClause::NumberOfModifiers; ++I) {
1432+
if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) {
1433+
OS << getOpenMPSimpleClauseTypeName(OMPC_map,
1434+
Node->getMapTypeModifier(I));
1435+
OS << ',';
1436+
}
14331437
}
14341438
OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
14351439
OS << ':';

lib/Basic/OpenMPKinds.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
108108
#include "clang/Basic/OpenMPKinds.def"
109109
.Default(OMPC_LINEAR_unknown);
110110
case OMPC_map:
111-
return llvm::StringSwitch<OpenMPMapClauseKind>(Str)
112-
#define OPENMP_MAP_KIND(Name) .Case(#Name, OMPC_MAP_##Name)
111+
return llvm::StringSwitch<unsigned>(Str)
112+
#define OPENMP_MAP_KIND(Name) \
113+
.Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
114+
#define OPENMP_MAP_MODIFIER_KIND(Name) \
115+
.Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
113116
#include "clang/Basic/OpenMPKinds.def"
114117
.Default(OMPC_MAP_unknown);
115118
case OMPC_dist_schedule:
@@ -243,10 +246,14 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
243246
case OMPC_map:
244247
switch (Type) {
245248
case OMPC_MAP_unknown:
249+
case OMPC_MAP_MODIFIER_last:
246250
return "unknown";
247251
#define OPENMP_MAP_KIND(Name) \
248252
case OMPC_MAP_##Name: \
249253
return #Name;
254+
#define OPENMP_MAP_MODIFIER_KIND(Name) \
255+
case OMPC_MAP_MODIFIER_##Name: \
256+
return #Name;
250257
#include "clang/Basic/OpenMPKinds.def"
251258
default:
252259
break;

lib/Basic/TargetInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,9 @@ bool TargetInfo::validateInputConstraint(
685685
// FIXME: Fail if % is used with the last operand.
686686
break;
687687
case 'i': // immediate integer.
688+
break;
688689
case 'n': // immediate integer with a known value.
690+
Info.setRequiresImmediate();
689691
break;
690692
case 'I': // Various constant constraints with target-specific meanings.
691693
case 'J':

0 commit comments

Comments
 (0)