================
@@ -36,6 +37,76 @@ template <typename ToTest> constexpr bool isCombinedType = 
false;
 template <typename T>
 constexpr bool isCombinedType<CombinedConstructClauseInfo<T>> = true;
 
+namespace {
+struct DataOperandInfo {
+  mlir::Location beginLoc;
+  mlir::Value varValue;
+  llvm::StringRef name;
+  mlir::ValueRange bounds;
+
+  DataOperandInfo(mlir::Location beginLoc, mlir::Value varValue,
+                  llvm::StringRef name, mlir::ValueRange bounds)
+      : beginLoc(beginLoc), varValue(varValue), name(name), bounds(bounds) {}
+};
+
+inline mlir::Value createIntExpr(CIRGen::CIRGenFunction &cgf,
+                                 CIRGen::CIRGenBuilderTy &builder,
+                                 const Expr *intExpr) {
+  mlir::Value expr = cgf.emitScalarExpr(intExpr);
+  mlir::Location exprLoc = cgf.cgm.getLoc(intExpr->getBeginLoc());
+
+  mlir::IntegerType targetType = mlir::IntegerType::get(
+      &cgf.getMLIRContext(), cgf.getContext().getIntWidth(intExpr->getType()),
+      intExpr->getType()->isSignedIntegerOrEnumerationType()
+          ? mlir::IntegerType::SignednessSemantics::Signed
+          : mlir::IntegerType::SignednessSemantics::Unsigned);
+
+  auto conversionOp = builder.create<mlir::UnrealizedConversionCastOp>(
+      exprLoc, targetType, expr);
+  return conversionOp.getResult(0);
+}
+
+// A helper function that gets the information from an operand to a data
+// clause, so that it can be used to emit the data operations.
+inline DataOperandInfo getDataOperandInfo(CIRGen::CIRGenFunction &cgf,
+                                          CIRGen::CIRGenBuilderTy &builder,
+                                          OpenACCDirectiveKind DK,
+                                          const Expr *E) {
+  // TODO: OpenACC: Cache was different enough as to need a separate
+  // `ActOnCacheVar`, so we are going to need to do some investigations here
+  // when it comes to implement this for cache.
+  assert(DK != OpenACCDirectiveKind::Cache &&
+         "Cache has different enough functionality we need to investigate "
+         "whether this function works for it");
+  const Expr *curVarExpr = E->IgnoreParenImpCasts();
+
+  mlir::Location exprLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc());
+  llvm::SmallVector<mlir::Value> bounds;
+
+  // TODO: OpenACC: Assemble the list of bounds.
+  if (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
+    cgf.cgm.errorNYI(curVarExpr->getSourceRange(),
+                     "OpenACC data clause array subscript/section");
+    return {exprLoc, {}, {}, bounds};
+  }
+
+  // TODO: OpenACC: if this is a member expr, emit the VarPtrPtr correctly.
+  if (const auto *ME = dyn_cast<MemberExpr>(curVarExpr)) {
+    cgf.cgm.errorNYI(curVarExpr->getSourceRange(),
+                     "OpenACC Data clause member expr");
+    return {exprLoc, {}, {}, bounds};
+  }
+
+  // Sema has made sure that only 4 types of things can get here, array
+  // subscript, array section, member expr, or DRE to a var decl (or the former
+  // 3 wrapping a var-decl), so we should be able to assume this is right.
+  const auto *DRE = cast<DeclRefExpr>(curVarExpr);
----------------
andykaylor wrote:

```suggestion
  const auto *dre = cast<DeclRefExpr>(curVarExpr);
```

https://github.com/llvm/llvm-project/pull/140304
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to