@@ -11405,7 +11405,6 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
11405
11405
namespace {
11406
11406
/// Kind of parameter in a function with 'declare simd' directive.
11407
11407
enum ParamKindTy {
11408
- LinearWithVarStride,
11409
11408
Linear,
11410
11409
LinearRef,
11411
11410
LinearUVal,
@@ -11418,6 +11417,7 @@ struct ParamAttrTy {
11418
11417
ParamKindTy Kind = Vector;
11419
11418
llvm::APSInt StrideOrArg;
11420
11419
llvm::APSInt Alignment;
11420
+ bool HasVarStride = false;
11421
11421
};
11422
11422
} // namespace
11423
11423
@@ -11481,9 +11481,6 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
11481
11481
llvm::raw_svector_ostream Out(Buffer);
11482
11482
for (const auto &ParamAttr : ParamAttrs) {
11483
11483
switch (ParamAttr.Kind) {
11484
- case LinearWithVarStride:
11485
- Out << "ls" << ParamAttr.StrideOrArg;
11486
- break;
11487
11484
case Linear:
11488
11485
Out << 'l';
11489
11486
break;
@@ -11503,8 +11500,10 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
11503
11500
Out << 'v';
11504
11501
break;
11505
11502
}
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) {
11508
11507
// Don't print the step value if it is not present or if it is
11509
11508
// equal to 1.
11510
11509
if (ParamAttr.StrideOrArg != 1)
@@ -11579,11 +11578,7 @@ emitX86DeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn,
11579
11578
// available at
11580
11579
// https://developer.arm.com/products/software-development-tools/hpc/arm-compiler-for-hpc/vector-function-abi.
11581
11580
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).
11587
11582
static bool getAArch64MTV(QualType QT, ParamKindTy Kind) {
11588
11583
QT = QT.getCanonicalType();
11589
11584
@@ -11593,12 +11588,11 @@ static bool getAArch64MTV(QualType QT, ParamKindTy Kind) {
11593
11588
if (Kind == ParamKindTy::Uniform)
11594
11589
return false;
11595
11590
11596
- if (Kind == ParamKindTy::Linear )
11591
+ if (Kind == ParamKindTy::LinearUVal || ParamKindTy::LinearRef )
11597
11592
return false;
11598
11593
11599
- // TODO: Handle linear references with modifiers
11600
-
11601
- if (Kind == ParamKindTy::LinearWithVarStride)
11594
+ if ((Kind == ParamKindTy::Linear || Kind == ParamKindTy::LinearVal) &&
11595
+ !QT->isReferenceType())
11602
11596
return false;
11603
11597
11604
11598
return true;
@@ -11949,7 +11943,7 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD,
11949
11943
cast<DeclRefExpr>((*SI)->IgnoreParenImpCasts())) {
11950
11944
if (const auto *StridePVD =
11951
11945
dyn_cast<ParmVarDecl>(DRE->getDecl())) {
11952
- ParamAttr.Kind = LinearWithVarStride ;
11946
+ ParamAttr.HasVarStride = true ;
11953
11947
auto It = ParamPositions.find(StridePVD->getCanonicalDecl());
11954
11948
assert(It != ParamPositions.end() &&
11955
11949
"Function parameter not found");
@@ -11963,7 +11957,8 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD,
11963
11957
// If we are using a linear clause on a pointer, we need to
11964
11958
// rescale the value of linear_step with the byte size of the
11965
11959
// pointee type.
11966
- if (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef)
11960
+ if (!ParamAttr.HasVarStride &&
11961
+ (ParamAttr.Kind == Linear || ParamAttr.Kind == LinearRef))
11967
11962
ParamAttr.StrideOrArg = ParamAttr.StrideOrArg * PtrRescalingFactor;
11968
11963
++SI;
11969
11964
++MI;
0 commit comments