[flang-commits] [flang] c5abddb - Enable CUDA Fortran for bbc
Zhen Wang via flang-commits
flang-commits at lists.llvm.org
Thu Aug 3 14:04:16 PDT 2023
Author: Zhen Wang
Date: 2023-08-03T14:04:03-07:00
New Revision: c5abddbf29de7eb83e6fcc3f1eac070da3fcc02f
URL: https://github.com/llvm/llvm-project/commit/c5abddbf29de7eb83e6fcc3f1eac070da3fcc02f
DIFF: https://github.com/llvm/llvm-project/commit/c5abddbf29de7eb83e6fcc3f1eac070da3fcc02f.diff
LOG: Enable CUDA Fortran for bbc
Added:
flang/test/Driver/bbc-cuda-macro.cuf
Modified:
flang/tools/bbc/bbc.cpp
Removed:
################################################################################
diff --git a/flang/test/Driver/bbc-cuda-macro.cuf b/flang/test/Driver/bbc-cuda-macro.cuf
new file mode 100644
index 00000000000000..d7f29c0cd682cc
--- /dev/null
+++ b/flang/test/Driver/bbc-cuda-macro.cuf
@@ -0,0 +1,11 @@
+! Test -fcuda option for bbc
+! RUN: bbc -fcuda -o - %s | FileCheck %s
+
+! CHECK-NOT: Unknown command line argument
+
+program main
+#if _CUDA
+ integer :: var = _CUDA
+#endif
+ integer, device :: dvar
+end program
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index f617743d932fab..ab34fbdb0fa110 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -190,6 +190,10 @@ static llvm::cl::opt<bool> useHLFIR("hlfir",
llvm::cl::desc("Lower to high level FIR"),
llvm::cl::init(false));
+static llvm::cl::opt<bool> enableCUDA("fcuda",
+ llvm::cl::desc("enable CUDA Fortran"),
+ llvm::cl::init(false));
+
#define FLANG_EXCLUDE_CODEGEN
#include "flang/Tools/CLOptions.inc"
@@ -412,6 +416,11 @@ int main(int argc, char **argv) {
options.predefinitions.emplace_back("_OPENACC", "202211");
}
+ // enable parsing of CUDA Fortran
+ if (enableCUDA) {
+ options.features.Enable(Fortran::common::LanguageFeature::CUDA);
+ }
+
Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
Fortran::parser::AllSources allSources;
Fortran::parser::AllCookedSources allCookedSources(allSources);
More information about the flang-commits
mailing list