|
14 | 14 |
|
15 | 15 | #include "CIRGenFunction.h" |
16 | 16 |
|
| 17 | +#include "clang/AST/ExprCXX.h" |
| 18 | + |
17 | 19 | #include "mlir/Dialect/Arith/IR/Arith.h" |
18 | 20 | #include "mlir/Dialect/OpenACC/OpenACC.h" |
19 | 21 | #include "llvm/ADT/TypeSwitch.h" |
@@ -188,7 +190,7 @@ class OpenACCClauseCIREmitter final |
188 | 190 | struct DataOperandInfo { |
189 | 191 | mlir::Location beginLoc; |
190 | 192 | mlir::Value varValue; |
191 | | - llvm::StringRef name; |
| 193 | + std::string name; |
192 | 194 | llvm::SmallVector<mlir::Value> bounds; |
193 | 195 | }; |
194 | 196 |
|
@@ -226,6 +228,10 @@ class OpenACCClauseCIREmitter final |
226 | 228 | mlir::Location exprLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc()); |
227 | 229 | llvm::SmallVector<mlir::Value> bounds; |
228 | 230 |
|
| 231 | + std::string exprString; |
| 232 | + llvm::raw_string_ostream OS(exprString); |
| 233 | + e->printPretty(OS, nullptr, cgf.getContext().getPrintingPolicy()); |
| 234 | + |
229 | 235 | // Assemble the list of bounds. |
230 | 236 | while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) { |
231 | 237 | mlir::Location boundLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc()); |
@@ -267,20 +273,16 @@ class OpenACCClauseCIREmitter final |
267 | 273 | bounds.push_back(createBound(boundLoc, lowerBound, upperBound, extent)); |
268 | 274 | } |
269 | 275 |
|
270 | | - // TODO: OpenACC: if this is a member expr, emit the VarPtrPtr correctly. |
271 | | - if (isa<MemberExpr>(curVarExpr)) { |
272 | | - cgf.cgm.errorNYI(curVarExpr->getSourceRange(), |
273 | | - "OpenACC Data clause member expr"); |
274 | | - return {exprLoc, {}, {}, std::move(bounds)}; |
275 | | - } |
| 276 | + if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr)) |
| 277 | + return {exprLoc, cgf.emitMemberExpr(memExpr).getPointer(), exprString, |
| 278 | + std::move(bounds)}; |
276 | 279 |
|
277 | 280 | // Sema has made sure that only 4 types of things can get here, array |
278 | 281 | // subscript, array section, member expr, or DRE to a var decl (or the |
279 | 282 | // former 3 wrapping a var-decl), so we should be able to assume this is |
280 | 283 | // right. |
281 | 284 | const auto *dre = cast<DeclRefExpr>(curVarExpr); |
282 | | - const auto *vd = cast<VarDecl>(dre->getFoundDecl()->getCanonicalDecl()); |
283 | | - return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), vd->getName(), |
| 285 | + return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), exprString, |
284 | 286 | std::move(bounds)}; |
285 | 287 | } |
286 | 288 |
|
|
0 commit comments