================
@@ -0,0 +1,51 @@
+//===-- OpenACCIntrinsicCall.cpp 
------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/Builder/OpenACCIntrinsicCall.h"
+#include "flang/Optimizer/Builder/FIRBuilder.h"
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+
+namespace fir {
+
+using OAI = OpenACCIntrinsicLibrary;
+
+static constexpr IntrinsicHandler openaccHandlers[]{
+    {"acc_on_device",
+     static_cast<OpenACCIntrinsicLibrary::ElementalGenerator>(
+         &OAI::genACCOnDevice),
+     {{{"devtype", asValue}}},
+     /*isElemental=*/false},
+};
+static_assert(fir::isSorted(openaccHandlers) && "map must be sorted");
+
+const IntrinsicHandler *findOpenACCIntrinsicHandler(llvm::StringRef name,
+                                                    bool isBindcCall) {
+  if (!isBindcCall)
+    return nullptr;
+  auto compare = [](const IntrinsicHandler &openaccHandler,
+                    llvm::StringRef name) {
+    return name.compare(openaccHandler.name) > 0;
+  };
+  auto result = llvm::lower_bound(openaccHandlers, name, compare);
+  return result != std::end(openaccHandlers) && result->name == name ? result
+                                                                     : nullptr;
+}
+
+mlir::Value
+OpenACCIntrinsicLibrary::genACCOnDevice(mlir::Type resultType,
+                                        llvm::ArrayRef<mlir::Value> args) {
+  assert(args.size() == 1);
+  mlir::Value deviceType = args[0];
+  if (deviceType.getType() != builder.getI32Type())
+    deviceType = builder.createConvert(loc, builder.getI32Type(), deviceType);
----------------
ivanradanov wrote:

The op now takes `IntOrIndex`, I will let the op builder/verifier assert that.

https://github.com/llvm/llvm-project/pull/208098
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to