@@ -11405,7 +11405,6 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
1140511405namespace {
1140611406 /// Kind of parameter in a function with 'declare simd' directive.
1140711407enum ParamKindTy {
11408- LinearWithVarStride,
1140911408 Linear,
1141011409 LinearRef,
1141111410 LinearUVal,
@@ -11418,6 +11417,7 @@ struct ParamAttrTy {
1141811417 ParamKindTy Kind = Vector;
1141911418 llvm::APSInt StrideOrArg;
1142011419 llvm::APSInt Alignment;
11420+ bool HasVarStride = false;
1142111421};
1142211422} // namespace
1142311423
@@ -11481,9 +11481,6 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
1148111481 llvm::raw_svector_ostream Out(Buffer);
1148211482 for (const auto &ParamAttr : ParamAttrs) {
1148311483 switch (ParamAttr.Kind) {
11484- case LinearWithVarStride:
11485- Out << "ls" << ParamAttr.StrideOrArg;
11486- break;
1148711484 case Linear:
1148811485 Out << 'l';
1148911486 break;
@@ -11503,8 +11500,10 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
1150311500 Out << 'v';
1150411501 break;
1150511502 }
11506- if (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef ||
11507- ParamAttr.Kind == LinearUVal || ParamAttr.Kind == LinearVal) {
11503+ if (ParamAttr.HasVarStride)
11504+ Out << "s" << ParamAttr.StrideOrArg;
11505+ else if (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef ||
11506+ ParamAttr.Kind == LinearUVal || ParamAttr.Kind == LinearVal) {
1150811507 // Don't print the step value if it is not present or if it is
1150911508 // equal to 1.
1151011509 if (ParamAttr.StrideOrArg != 1)
@@ -11579,11 +11578,7 @@ emitX86DeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn,
1157911578// available at
1158011579// https://developer.arm.com/products/software-development-tools/hpc/arm-compiler-for-hpc/vector-function-abi.
1158111580
11582- /// Maps To Vector (MTV), as defined in 3.1.1 of the AAVFABI.
11583- ///
11584- /// TODO: Need to implement the behavior for reference marked with a
11585- /// var or no linear modifiers (1.b in the section). For this, we
11586- /// need to extend ParamKindTy to support the linear modifiers.
11581+ /// Maps To Vector (MTV), as defined in 4.1.1 of the AAVFABI (2021Q1).
1158711582static bool getAArch64MTV(QualType QT, ParamKindTy Kind) {
1158811583 QT = QT.getCanonicalType();
1158911584
@@ -11593,12 +11588,11 @@ static bool getAArch64MTV(QualType QT, ParamKindTy Kind) {
1159311588 if (Kind == ParamKindTy::Uniform)
1159411589 return false;
1159511590
11596- if (Kind == ParamKindTy::Linear )
11591+ if (Kind == ParamKindTy::LinearUVal || ParamKindTy::LinearRef )
1159711592 return false;
1159811593
11599- // TODO: Handle linear references with modifiers
11600-
11601- if (Kind == ParamKindTy::LinearWithVarStride)
11594+ if ((Kind == ParamKindTy::Linear || Kind == ParamKindTy::LinearVal) &&
11595+ !QT->isReferenceType())
1160211596 return false;
1160311597
1160411598 return true;
@@ -11949,7 +11943,7 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD,
1194911943 cast<DeclRefExpr>((*SI)->IgnoreParenImpCasts())) {
1195011944 if (const auto *StridePVD =
1195111945 dyn_cast<ParmVarDecl>(DRE->getDecl())) {
11952- ParamAttr.Kind = LinearWithVarStride ;
11946+ ParamAttr.HasVarStride = true ;
1195311947 auto It = ParamPositions.find(StridePVD->getCanonicalDecl());
1195411948 assert(It != ParamPositions.end() &&
1195511949 "Function parameter not found");
@@ -11963,7 +11957,8 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD,
1196311957 // If we are using a linear clause on a pointer, we need to
1196411958 // rescale the value of linear_step with the byte size of the
1196511959 // pointee type.
11966- if (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef)
11960+ if (!ParamAttr.HasVarStride &&
11961+ (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef))
1196711962 ParamAttr.StrideOrArg = ParamAttr.StrideOrArg * PtrRescalingFactor;
1196811963 ++SI;
1196911964 ++MI;
0 commit comments