diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Frontend/OpenMP/OMPConstants.h | 46 | ||||
-rw-r--r-- | llvm/include/llvm/Frontend/OpenMP/OMPKinds.def | 102 | ||||
-rw-r--r-- | llvm/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/Frontend/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/Frontend/LLVMBuild.txt | 23 | ||||
-rw-r--r-- | llvm/lib/Frontend/OpenMP/CMakeLists.txt | 10 | ||||
-rw-r--r-- | llvm/lib/Frontend/OpenMP/LLVMBuild.txt | 21 | ||||
-rw-r--r-- | llvm/lib/Frontend/OpenMP/OMPConstants.cpp | 34 | ||||
-rw-r--r-- | llvm/lib/LLVMBuild.txt | 1 |
9 files changed, 239 insertions, 0 deletions
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h new file mode 100644 index 00000000000..42b19091c14 --- /dev/null +++ b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h @@ -0,0 +1,46 @@ +//===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This file defines constans and helpers used when dealing with OpenMP. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OPENMP_CONSTANTS_H +#define LLVM_OPENMP_CONSTANTS_H + +#include "llvm/ADT/StringRef.h" + +namespace llvm { + +namespace omp { + +/// IDs for all OpenMP directives. +enum class Directive { +#define OMP_DIRECTIVE(Enum, ...) Enum, +#include "llvm/Frontend/OpenMP/OMPKinds.def" +}; + +/// Make the enum values available in the llvm::omp namespace. This allows us to +/// write something like OMPD_parallel if we have a `using namespace omp`. At +/// the same time we do not loose the strong type guarantees of the enum class, +/// that is we cannot pass an unsigned as Directive without an explicit cast. +#define OMP_DIRECTIVE(Enum, ...) constexpr auto Enum = omp::Directive::Enum; +#include "llvm/Frontend/OpenMP/OMPKinds.def" + +/// Parse \p Str and return the directive it matches or OMPD_unknown if none. +Directive getOpenMPDirectiveKind(StringRef Str); + +/// Return a textual representation of the directive \p D. +StringRef getOpenMPDirectiveName(Directive D); + +} // end namespace omp + +} // end namespace llvm + +#endif // LLVM_OPENMP_CONSTANTS_H diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def new file mode 100644 index 00000000000..fc84ffb578c --- /dev/null +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -0,0 +1,102 @@ +//===--- OMPKinds.def - OpenMP directives, clauses, rt-calls -*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This file defines the list of supported OpenMP directives, clauses, runtime +/// calls, and other things that need to be listed in enums. +/// +//===----------------------------------------------------------------------===// + +/// OpenMP Directives and combined directives +/// +///{ + +#ifndef OMP_DIRECTIVE +#define OMP_DIRECTIVE(Enum, Str) +#endif + +#define __OMP_DIRECTIVE_EXT(Name, Str) OMP_DIRECTIVE(OMPD_##Name, Str) +#define __OMP_DIRECTIVE(Name) __OMP_DIRECTIVE_EXT(Name, #Name) + +__OMP_DIRECTIVE(threadprivate) +__OMP_DIRECTIVE(parallel) +__OMP_DIRECTIVE(task) +__OMP_DIRECTIVE(simd) +__OMP_DIRECTIVE(for) +__OMP_DIRECTIVE(sections) +__OMP_DIRECTIVE(section) +__OMP_DIRECTIVE(single) +__OMP_DIRECTIVE(master) +__OMP_DIRECTIVE(critical) +__OMP_DIRECTIVE(taskyield) +__OMP_DIRECTIVE(barrier) +__OMP_DIRECTIVE(taskwait) +__OMP_DIRECTIVE(taskgroup) +__OMP_DIRECTIVE(flush) +__OMP_DIRECTIVE(ordered) +__OMP_DIRECTIVE(atomic) +__OMP_DIRECTIVE(target) +__OMP_DIRECTIVE(teams) +__OMP_DIRECTIVE(cancel) +__OMP_DIRECTIVE(requires) +__OMP_DIRECTIVE_EXT(target_data, "target data") +__OMP_DIRECTIVE_EXT(target_enter_data, "target enter data") +__OMP_DIRECTIVE_EXT(target_exit_data, "target exit data") +__OMP_DIRECTIVE_EXT(target_parallel, "target parallel") +__OMP_DIRECTIVE_EXT(target_parallel_for, "target parallel for") +__OMP_DIRECTIVE_EXT(target_update, "target update") +__OMP_DIRECTIVE_EXT(parallel_for, "parallel for") +__OMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd") +__OMP_DIRECTIVE_EXT(parallel_master, "parallel master") +__OMP_DIRECTIVE_EXT(parallel_sections, "parallel sections") +__OMP_DIRECTIVE_EXT(for_simd, "for simd") +__OMP_DIRECTIVE_EXT(cancellation_point, "cancellation point") +__OMP_DIRECTIVE_EXT(declare_reduction, "declare reduction") +__OMP_DIRECTIVE_EXT(declare_mapper, "declare mapper") +__OMP_DIRECTIVE_EXT(declare_simd, "declare simd") +__OMP_DIRECTIVE(taskloop) +__OMP_DIRECTIVE_EXT(taskloop_simd, "taskloop simd") +__OMP_DIRECTIVE(distribute) +__OMP_DIRECTIVE_EXT(declare_target, "declare target") +__OMP_DIRECTIVE_EXT(end_declare_target, "end declare target") +__OMP_DIRECTIVE_EXT(distribute_parallel_for, "distribute parallel for") +__OMP_DIRECTIVE_EXT(distribute_parallel_for_simd, + "distribute parallel for simd") +__OMP_DIRECTIVE_EXT(distribute_simd, "distribute simd") +__OMP_DIRECTIVE_EXT(target_parallel_for_simd, "target parallel for simd") +__OMP_DIRECTIVE_EXT(target_simd, "target simd") +__OMP_DIRECTIVE_EXT(teams_distribute, "teams distribute") +__OMP_DIRECTIVE_EXT(teams_distribute_simd, "teams distribute simd") +__OMP_DIRECTIVE_EXT(teams_distribute_parallel_for_simd, + "teams distribute parallel for simd") +__OMP_DIRECTIVE_EXT(teams_distribute_parallel_for, + "teams distribute parallel for") +__OMP_DIRECTIVE_EXT(target_teams, "target teams") +__OMP_DIRECTIVE_EXT(target_teams_distribute, "target teams distribute") +__OMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for, + "target teams distribute parallel for") +__OMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for_simd, + "target teams distribute parallel for simd") +__OMP_DIRECTIVE_EXT(target_teams_distribute_simd, + "target teams distribute simd") +__OMP_DIRECTIVE(allocate) +__OMP_DIRECTIVE_EXT(declare_variant, "declare variant") +__OMP_DIRECTIVE_EXT(master_taskloop, "master taskloop") +__OMP_DIRECTIVE_EXT(parallel_master_taskloop, "parallel master taskloop") +__OMP_DIRECTIVE_EXT(master_taskloop_simd, "master taskloop simd") +__OMP_DIRECTIVE_EXT(parallel_master_taskloop_simd, + "parallel master taskloop simd") + +// Has to be the last because Clang implicitly expects it to be. +__OMP_DIRECTIVE(unknown) + +#undef __OMP_DIRECTIVE_EXT +#undef __OMP_DIRECTIVE +#undef OMP_DIRECTIVE + +///} diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 5a41d65b0cf..f7e08a68e67 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(CodeGen) add_subdirectory(BinaryFormat) add_subdirectory(Bitcode) add_subdirectory(Bitstream) +add_subdirectory(Frontend) add_subdirectory(Transforms) add_subdirectory(Linker) add_subdirectory(Analysis) diff --git a/llvm/lib/Frontend/CMakeLists.txt b/llvm/lib/Frontend/CMakeLists.txt new file mode 100644 index 00000000000..9730c8414ed --- /dev/null +++ b/llvm/lib/Frontend/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(OpenMP) diff --git a/llvm/lib/Frontend/LLVMBuild.txt b/llvm/lib/Frontend/LLVMBuild.txt new file mode 100644 index 00000000000..78ec6ae5186 --- /dev/null +++ b/llvm/lib/Frontend/LLVMBuild.txt @@ -0,0 +1,23 @@ +;===- ./lib/Frontend/LLVMBuild.txt -----------------------------*- Conf -*--===; +; +; 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 +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[common] +subdirectories = OpenMP + +[component_0] +type = Group +name = Frontend +parent = Libraries diff --git a/llvm/lib/Frontend/OpenMP/CMakeLists.txt b/llvm/lib/Frontend/OpenMP/CMakeLists.txt new file mode 100644 index 00000000000..5d74bcf3b9f --- /dev/null +++ b/llvm/lib/Frontend/OpenMP/CMakeLists.txt @@ -0,0 +1,10 @@ +add_llvm_component_library(LLVMFrontendOpenMP + OMPConstants.cpp + + ADDITIONAL_HEADER_DIRS + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend/OpenMP + + DEPENDS + intrinsics_gen + ) diff --git a/llvm/lib/Frontend/OpenMP/LLVMBuild.txt b/llvm/lib/Frontend/OpenMP/LLVMBuild.txt new file mode 100644 index 00000000000..dfabe72fcd2 --- /dev/null +++ b/llvm/lib/Frontend/OpenMP/LLVMBuild.txt @@ -0,0 +1,21 @@ +;===- ./lib/Frontend/OpenMP/LLVMBuild.txt ----------------------*- Conf -*--===; +; +; 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 +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[component_0] +type = Library +name = FrontendOpenMP +parent = Frontend +required_libraries = Core Support TransformUtils diff --git a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp new file mode 100644 index 00000000000..994fb4e2fa8 --- /dev/null +++ b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp @@ -0,0 +1,34 @@ +//===- OMPConstants.cpp - Helpers related to OpenMP code generation ---===// +// +// 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 "llvm/Frontend/OpenMP/OMPConstants.h" + +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSwitch.h" + +using namespace llvm; +using namespace omp; + +Directive llvm::omp::getOpenMPDirectiveKind(StringRef Str) { + return llvm::StringSwitch<Directive>(Str) +#define OMP_DIRECTIVE(Enum, Str) .Case(Str, Enum) +#include "llvm/Frontend/OpenMP/OMPKinds.def" + .Default(OMPD_unknown); +} + +StringRef llvm::omp::getOpenMPDirectiveName(Directive Kind) { + switch (Kind) { +#define OMP_DIRECTIVE(Enum, Str) \ + case Enum: \ + return Str; +#include "llvm/Frontend/OpenMP/OMPKinds.def" + } + llvm_unreachable("Invalid OpenMP directive kind"); +} diff --git a/llvm/lib/LLVMBuild.txt b/llvm/lib/LLVMBuild.txt index 4c039176267..3f5383d9b1f 100644 --- a/llvm/lib/LLVMBuild.txt +++ b/llvm/lib/LLVMBuild.txt @@ -24,6 +24,7 @@ subdirectories = DebugInfo Demangle ExecutionEngine + Frontend FuzzMutate LineEditor Linker |