diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2020-03-30 16:06:01 -0400 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2020-03-31 19:06:49 -0400 |
commit | c2aa543237843fa7b7c0191b6685062b3512f245 (patch) | |
tree | b565bcac29e2798e20b00bebab84e4d18f6d155f /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | [lit] Refine adoption of argparse --version action (diff) | |
download | llvm-project-c2aa543237843fa7b7c0191b6685062b3512f245.tar.gz llvm-project-c2aa543237843fa7b7c0191b6685062b3512f245.tar.bz2 llvm-project-c2aa543237843fa7b7c0191b6685062b3512f245.zip |
[OPENMP50]Codegen for array shaping expression in map clauses.
Added codegen support for array shaping operations in map/to/from
clauses.
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 31fdc320d698..6642851a56bc 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -7448,6 +7448,20 @@ private: llvm::Value *getExprTypeSize(const Expr *E) const { QualType ExprTy = E->getType().getCanonicalType(); + // Calculate the size for array shaping expression. + if (const auto *OAE = dyn_cast<OMPArrayShapingExpr>(E)) { + llvm::Value *Size = + CGF.getTypeSize(OAE->getBase()->getType()->getPointeeType()); + for (const Expr *SE : OAE->getDimensions()) { + llvm::Value *Sz = CGF.EmitScalarExpr(SE); + Sz = CGF.EmitScalarConversion(Sz, SE->getType(), + CGF.getContext().getSizeType(), + SE->getExprLoc()); + Size = CGF.Builder.CreateNUWMul(Size, Sz); + } + return Size; + } + // Reference types are ignored for mapping purposes. if (const auto *RefTy = ExprTy->getAs<ReferenceType>()) ExprTy = RefTy->getPointeeType().getCanonicalType(); @@ -7779,6 +7793,7 @@ private: const Expr *AssocExpr = I->getAssociatedExpression(); const auto *AE = dyn_cast<ArraySubscriptExpr>(AssocExpr); const auto *OASE = dyn_cast<OMPArraySectionExpr>(AssocExpr); + const auto *OAShE = dyn_cast<OMPArrayShapingExpr>(AssocExpr); if (isa<MemberExpr>(AssocExpr)) { // The base is the 'this' pointer. The content of the pointer is going @@ -7788,6 +7803,11 @@ private: (OASE && isa<CXXThisExpr>(OASE->getBase()->IgnoreParenImpCasts()))) { BP = CGF.EmitOMPSharedLValue(AssocExpr).getAddress(CGF); + } else if (OAShE && + isa<CXXThisExpr>(OAShE->getBase()->IgnoreParenCasts())) { + BP = Address( + CGF.EmitScalarExpr(OAShE->getBase()), + CGF.getContext().getTypeAlignInChars(OAShE->getBase()->getType())); } else { // The base is the reference to the variable. // BP = &Var. @@ -7870,9 +7890,12 @@ private: // types. const auto *OASE = dyn_cast<OMPArraySectionExpr>(I->getAssociatedExpression()); + const auto *OAShE = + dyn_cast<OMPArrayShapingExpr>(I->getAssociatedExpression()); const auto *UO = dyn_cast<UnaryOperator>(I->getAssociatedExpression()); const auto *BO = dyn_cast<BinaryOperator>(I->getAssociatedExpression()); bool IsPointer = + OAShE || (OASE && OMPArraySectionExpr::getBaseOriginalType(OASE) .getCanonicalType() ->isAnyPointerType()) || @@ -7890,8 +7913,15 @@ private: isa<BinaryOperator>(Next->getAssociatedExpression())) && "Unexpected expression"); - Address LB = CGF.EmitOMPSharedLValue(I->getAssociatedExpression()) - .getAddress(CGF); + Address LB = Address::invalid(); + if (OAShE) { + LB = Address(CGF.EmitScalarExpr(OAShE->getBase()), + CGF.getContext().getTypeAlignInChars( + OAShE->getBase()->getType())); + } else { + LB = CGF.EmitOMPSharedLValue(I->getAssociatedExpression()) + .getAddress(CGF); + } // If this component is a pointer inside the base struct then we don't // need to create any entry for it - it will be combined with the object |