[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
//===- OMPContext.cpp ------ Collection of helpers for OpenMP contexts ----===//
|
|
|
|
//
|
|
|
|
// 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 implements helper functions and classes to deal with OpenMP
|
|
|
|
/// contexts as used by `[begin/end] declare variant` and `metadirective`.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPContext.h"
|
|
|
|
#include "llvm/ADT/SetOperations.h"
|
2020-12-24 07:58:07 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
2020-12-24 07:58:07 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "openmp-ir-builder"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace omp;
|
|
|
|
|
|
|
|
OMPContext::OMPContext(bool IsDeviceCompilation, Triple TargetTriple) {
|
|
|
|
// Add the appropriate device kind trait based on the triple and the
|
|
|
|
// IsDeviceCompilation flag.
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(IsDeviceCompilation
|
|
|
|
? TraitProperty::device_kind_nohost
|
|
|
|
: TraitProperty::device_kind_host));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
switch (TargetTriple.getArch()) {
|
|
|
|
case Triple::arm:
|
|
|
|
case Triple::armeb:
|
|
|
|
case Triple::aarch64:
|
|
|
|
case Triple::aarch64_be:
|
|
|
|
case Triple::aarch64_32:
|
|
|
|
case Triple::mips:
|
|
|
|
case Triple::mipsel:
|
|
|
|
case Triple::mips64:
|
|
|
|
case Triple::mips64el:
|
|
|
|
case Triple::ppc:
|
2021-01-03 02:18:07 +08:00
|
|
|
case Triple::ppcle:
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
case Triple::ppc64:
|
|
|
|
case Triple::ppc64le:
|
|
|
|
case Triple::x86:
|
|
|
|
case Triple::x86_64:
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::device_kind_cpu));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
break;
|
|
|
|
case Triple::amdgcn:
|
|
|
|
case Triple::nvptx:
|
|
|
|
case Triple::nvptx64:
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::device_kind_gpu));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the appropriate device architecture trait based on the triple.
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
2020-12-24 07:58:07 +08:00
|
|
|
if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) { \
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
if (TargetTriple.getArch() == TargetTriple.getArchTypeForLLVMName(Str)) \
|
2020-12-24 07:58:07 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::Enum)); \
|
2021-01-08 04:48:50 +08:00
|
|
|
if (StringRef(Str) == StringRef("x86_64") && \
|
|
|
|
TargetTriple.getArch() == Triple::x86_64) \
|
2020-12-24 07:58:07 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::Enum)); \
|
|
|
|
}
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
|
|
|
|
// TODO: What exactly do we want to see as device ISA trait?
|
|
|
|
// The discussion on the list did not seem to have come to an agreed
|
|
|
|
// upon solution.
|
|
|
|
|
|
|
|
// LLVM is the "OpenMP vendor" but we could also interpret vendor as the
|
|
|
|
// target vendor.
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::implementation_vendor_llvm));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
|
|
|
// The user condition true is accepted but not false.
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::user_condition_true));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
|
|
|
// This is for sure some device.
|
2020-03-14 08:39:09 +08:00
|
|
|
ActiveTraits.set(unsigned(TraitProperty::device_kind_any));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
|
|
|
LLVM_DEBUG({
|
|
|
|
dbgs() << "[" << DEBUG_TYPE
|
|
|
|
<< "] New OpenMP context with the following properties:\n";
|
2020-03-30 00:05:29 +08:00
|
|
|
for (unsigned Bit : ActiveTraits.set_bits()) {
|
|
|
|
TraitProperty Property = TraitProperty(Bit);
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
dbgs() << "\t " << getOpenMPContextTraitPropertyFullName(Property)
|
|
|
|
<< "\n";
|
2020-03-14 08:39:09 +08:00
|
|
|
}
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return true if \p C0 is a subset of \p C1. Note that both arrays are
|
|
|
|
/// expected to be sorted.
|
|
|
|
template <typename T> static bool isSubset(ArrayRef<T> C0, ArrayRef<T> C1) {
|
|
|
|
#ifdef EXPENSIVE_CHECKS
|
2020-04-13 19:46:41 +08:00
|
|
|
assert(llvm::is_sorted(C0) && llvm::is_sorted(C1) &&
|
|
|
|
"Expected sorted arrays!");
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
#endif
|
|
|
|
if (C0.size() > C1.size())
|
|
|
|
return false;
|
|
|
|
auto It0 = C0.begin(), End0 = C0.end();
|
|
|
|
auto It1 = C1.begin(), End1 = C1.end();
|
|
|
|
while (It0 != End0) {
|
|
|
|
if (It1 == End1)
|
|
|
|
return false;
|
|
|
|
if (*It0 == *It1) {
|
|
|
|
++It0;
|
|
|
|
++It1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
++It0;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return true if \p C0 is a strict subset of \p C1. Note that both arrays are
|
|
|
|
/// expected to be sorted.
|
|
|
|
template <typename T>
|
|
|
|
static bool isStrictSubset(ArrayRef<T> C0, ArrayRef<T> C1) {
|
|
|
|
if (C0.size() >= C1.size())
|
|
|
|
return false;
|
|
|
|
return isSubset<T>(C0, C1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isStrictSubset(const VariantMatchInfo &VMI0,
|
|
|
|
const VariantMatchInfo &VMI1) {
|
|
|
|
// If all required traits are a strict subset and the ordered vectors storing
|
|
|
|
// the construct traits, we say it is a strict subset. Note that the latter
|
|
|
|
// relation is not required to be strict.
|
2020-03-14 08:39:09 +08:00
|
|
|
if (VMI0.RequiredTraits.count() >= VMI1.RequiredTraits.count())
|
|
|
|
return false;
|
2020-03-30 00:05:29 +08:00
|
|
|
for (unsigned Bit : VMI0.RequiredTraits.set_bits())
|
|
|
|
if (!VMI1.RequiredTraits.test(Bit))
|
2020-03-14 08:39:09 +08:00
|
|
|
return false;
|
|
|
|
if (!isSubset<TraitProperty>(VMI0.ConstructTraits, VMI1.ConstructTraits))
|
|
|
|
return false;
|
|
|
|
return true;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int isVariantApplicableInContextHelper(
|
|
|
|
const VariantMatchInfo &VMI, const OMPContext &Ctx,
|
2020-04-04 00:29:53 +08:00
|
|
|
SmallVectorImpl<unsigned> *ConstructMatches, bool DeviceSetOnly) {
|
|
|
|
|
|
|
|
// The match kind determines if we need to match all traits, any of the
|
|
|
|
// traits, or none of the traits for it to be an applicable context.
|
|
|
|
enum MatchKind { MK_ALL, MK_ANY, MK_NONE };
|
|
|
|
|
|
|
|
MatchKind MK = MK_ALL;
|
|
|
|
// Determine the match kind the user wants, "all" is the default and provided
|
|
|
|
// to the user only for completeness.
|
|
|
|
if (VMI.RequiredTraits.test(
|
|
|
|
unsigned(TraitProperty::implementation_extension_match_any)))
|
|
|
|
MK = MK_ANY;
|
|
|
|
if (VMI.RequiredTraits.test(
|
|
|
|
unsigned(TraitProperty::implementation_extension_match_none)))
|
|
|
|
MK = MK_NONE;
|
|
|
|
|
|
|
|
// Helper to deal with a single property that was (not) found in the OpenMP
|
|
|
|
// context based on the match kind selected by the user via
|
|
|
|
// `implementation={extensions(match_[all,any,none])}'
|
|
|
|
auto HandleTrait = [MK](TraitProperty Property,
|
|
|
|
bool WasFound) -> Optional<bool> /* Result */ {
|
|
|
|
// For kind "any" a single match is enough but we ignore non-matched
|
|
|
|
// properties.
|
|
|
|
if (MK == MK_ANY) {
|
2021-03-12 13:47:19 +08:00
|
|
|
if (WasFound)
|
2020-04-04 00:29:53 +08:00
|
|
|
return true;
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In "all" or "none" mode we accept a matching or non-matching property
|
|
|
|
// respectively and move on. We are not done yet!
|
|
|
|
if ((WasFound && MK == MK_ALL) || (!WasFound && MK == MK_NONE))
|
|
|
|
return None;
|
|
|
|
|
|
|
|
// We missed a property, provide some debug output and indicate failure.
|
|
|
|
LLVM_DEBUG({
|
|
|
|
if (MK == MK_ALL)
|
|
|
|
dbgs() << "[" << DEBUG_TYPE << "] Property "
|
2020-07-07 14:08:03 +08:00
|
|
|
<< getOpenMPContextTraitPropertyName(Property, "")
|
2020-04-04 00:29:53 +08:00
|
|
|
<< " was not in the OpenMP context but match kind is all.\n";
|
|
|
|
if (MK == MK_NONE)
|
|
|
|
dbgs() << "[" << DEBUG_TYPE << "] Property "
|
2020-07-07 14:08:03 +08:00
|
|
|
<< getOpenMPContextTraitPropertyName(Property, "")
|
2020-04-04 00:29:53 +08:00
|
|
|
<< " was in the OpenMP context but match kind is none.\n";
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
};
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
2020-03-30 00:05:29 +08:00
|
|
|
for (unsigned Bit : VMI.RequiredTraits.set_bits()) {
|
|
|
|
TraitProperty Property = TraitProperty(Bit);
|
2020-04-04 00:29:53 +08:00
|
|
|
if (DeviceSetOnly &&
|
|
|
|
getOpenMPContextTraitSetForProperty(Property) != TraitSet::device)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// So far all extensions are handled elsewhere, we skip them here as they
|
|
|
|
// are not part of the OpenMP context.
|
|
|
|
if (getOpenMPContextTraitSelectorForProperty(Property) ==
|
|
|
|
TraitSelector::implementation_extension)
|
|
|
|
continue;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
2020-03-14 08:39:09 +08:00
|
|
|
bool IsActiveTrait = Ctx.ActiveTraits.test(unsigned(Property));
|
2020-07-07 14:08:03 +08:00
|
|
|
|
|
|
|
// We overwrite the isa trait as it is actually up to the OMPContext hook to
|
|
|
|
// check the raw string(s).
|
|
|
|
if (Property == TraitProperty::device_isa___ANY)
|
|
|
|
IsActiveTrait = llvm::all_of(VMI.ISATraits, [&](StringRef RawString) {
|
|
|
|
return Ctx.matchesISATrait(RawString);
|
|
|
|
});
|
|
|
|
|
2020-04-04 00:29:53 +08:00
|
|
|
Optional<bool> Result = HandleTrait(Property, IsActiveTrait);
|
|
|
|
if (Result.hasValue())
|
|
|
|
return Result.getValue();
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
2020-04-04 00:29:53 +08:00
|
|
|
if (!DeviceSetOnly) {
|
|
|
|
// We could use isSubset here but we also want to record the match
|
|
|
|
// locations.
|
|
|
|
unsigned ConstructIdx = 0, NoConstructTraits = Ctx.ConstructTraits.size();
|
|
|
|
for (TraitProperty Property : VMI.ConstructTraits) {
|
|
|
|
assert(getOpenMPContextTraitSetForProperty(Property) ==
|
|
|
|
TraitSet::construct &&
|
|
|
|
"Variant context is ill-formed!");
|
|
|
|
|
|
|
|
// Verify the nesting.
|
|
|
|
bool FoundInOrder = false;
|
|
|
|
while (!FoundInOrder && ConstructIdx != NoConstructTraits)
|
|
|
|
FoundInOrder = (Ctx.ConstructTraits[ConstructIdx++] == Property);
|
|
|
|
if (ConstructMatches)
|
|
|
|
ConstructMatches->push_back(ConstructIdx - 1);
|
|
|
|
|
|
|
|
Optional<bool> Result = HandleTrait(Property, FoundInOrder);
|
|
|
|
if (Result.hasValue())
|
|
|
|
return Result.getValue();
|
|
|
|
|
|
|
|
if (!FoundInOrder) {
|
|
|
|
LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] Construct property "
|
2020-07-07 14:08:03 +08:00
|
|
|
<< getOpenMPContextTraitPropertyName(Property, "")
|
2020-04-04 00:29:53 +08:00
|
|
|
<< " was not nested properly.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Verify SIMD
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
2020-04-04 00:29:53 +08:00
|
|
|
assert(isSubset<TraitProperty>(VMI.ConstructTraits, Ctx.ConstructTraits) &&
|
|
|
|
"Broken invariant!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MK == MK_ANY) {
|
|
|
|
LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE
|
|
|
|
<< "] None of the properties was in the OpenMP context "
|
|
|
|
"but match kind is any.\n");
|
|
|
|
return false;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool llvm::omp::isVariantApplicableInContext(const VariantMatchInfo &VMI,
|
2020-04-04 00:29:53 +08:00
|
|
|
const OMPContext &Ctx,
|
|
|
|
bool DeviceSetOnly) {
|
|
|
|
return isVariantApplicableInContextHelper(
|
|
|
|
VMI, Ctx, /* ConstructMatches */ nullptr, DeviceSetOnly);
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static APInt getVariantMatchScore(const VariantMatchInfo &VMI,
|
|
|
|
const OMPContext &Ctx,
|
|
|
|
SmallVectorImpl<unsigned> &ConstructMatches) {
|
|
|
|
APInt Score(64, 1);
|
|
|
|
|
|
|
|
unsigned NoConstructTraits = VMI.ConstructTraits.size();
|
2020-03-30 00:05:29 +08:00
|
|
|
for (unsigned Bit : VMI.RequiredTraits.set_bits()) {
|
|
|
|
TraitProperty Property = TraitProperty(Bit);
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
// If there is a user score attached, use it.
|
|
|
|
if (VMI.ScoreMap.count(Property)) {
|
|
|
|
const APInt &UserScore = VMI.ScoreMap.lookup(Property);
|
|
|
|
assert(UserScore.uge(0) && "Expect non-negative user scores!");
|
|
|
|
Score += UserScore.getZExtValue();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getOpenMPContextTraitSetForProperty(Property)) {
|
|
|
|
case TraitSet::construct:
|
|
|
|
// We handle the construct traits later via the VMI.ConstructTraits
|
|
|
|
// container.
|
|
|
|
continue;
|
|
|
|
case TraitSet::implementation:
|
|
|
|
// No effect on the score (implementation defined).
|
|
|
|
continue;
|
|
|
|
case TraitSet::user:
|
|
|
|
// No effect on the score.
|
|
|
|
continue;
|
|
|
|
case TraitSet::device:
|
|
|
|
// Handled separately below.
|
|
|
|
break;
|
|
|
|
case TraitSet::invalid:
|
|
|
|
llvm_unreachable("Unknown trait set is not to be used!");
|
|
|
|
}
|
|
|
|
|
|
|
|
// device={kind(any)} is "as if" no kind selector was specified.
|
|
|
|
if (Property == TraitProperty::device_kind_any)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (getOpenMPContextTraitSelectorForProperty(Property)) {
|
|
|
|
case TraitSelector::device_kind:
|
2020-02-03 19:08:48 +08:00
|
|
|
Score += (1ULL << (NoConstructTraits + 0));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
continue;
|
|
|
|
case TraitSelector::device_arch:
|
2020-02-03 19:08:48 +08:00
|
|
|
Score += (1ULL << (NoConstructTraits + 1));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
continue;
|
|
|
|
case TraitSelector::device_isa:
|
2020-02-03 19:08:48 +08:00
|
|
|
Score += (1ULL << (NoConstructTraits + 2));
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned ConstructIdx = 0;
|
|
|
|
assert(NoConstructTraits == ConstructMatches.size() &&
|
|
|
|
"Mismatch in the construct traits!");
|
|
|
|
for (TraitProperty Property : VMI.ConstructTraits) {
|
|
|
|
assert(getOpenMPContextTraitSetForProperty(Property) ==
|
|
|
|
TraitSet::construct &&
|
|
|
|
"Ill-formed variant match info!");
|
2020-02-03 18:49:11 +08:00
|
|
|
(void)Property;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
// ConstructMatches is the position p - 1 and we need 2^(p-1).
|
2020-02-03 19:08:48 +08:00
|
|
|
Score += (1ULL << ConstructMatches[ConstructIdx++]);
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] Variant has a score of " << Score
|
|
|
|
<< "\n");
|
|
|
|
return Score;
|
2020-02-03 15:45:03 +08:00
|
|
|
}
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
|
|
|
|
int llvm::omp::getBestVariantMatchForContext(
|
|
|
|
const SmallVectorImpl<VariantMatchInfo> &VMIs, const OMPContext &Ctx) {
|
|
|
|
|
|
|
|
APInt BestScore(64, 0);
|
|
|
|
int BestVMIIdx = -1;
|
|
|
|
const VariantMatchInfo *BestVMI = nullptr;
|
|
|
|
|
|
|
|
for (unsigned u = 0, e = VMIs.size(); u < e; ++u) {
|
|
|
|
const VariantMatchInfo &VMI = VMIs[u];
|
|
|
|
|
|
|
|
SmallVector<unsigned, 8> ConstructMatches;
|
|
|
|
// If the variant is not applicable its not the best.
|
2020-04-04 00:29:53 +08:00
|
|
|
if (!isVariantApplicableInContextHelper(VMI, Ctx, &ConstructMatches,
|
|
|
|
/* DeviceSetOnly */ false))
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
continue;
|
|
|
|
// Check if its clearly not the best.
|
|
|
|
APInt Score = getVariantMatchScore(VMI, Ctx, ConstructMatches);
|
|
|
|
if (Score.ult(BestScore))
|
|
|
|
continue;
|
|
|
|
// Equal score need subset checks.
|
|
|
|
if (Score.eq(BestScore)) {
|
|
|
|
// Strict subset are never best.
|
|
|
|
if (isStrictSubset(VMI, *BestVMI))
|
|
|
|
continue;
|
|
|
|
// Same score and the current best is no strict subset so we keep it.
|
|
|
|
if (!isStrictSubset(*BestVMI, VMI))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// New best found.
|
|
|
|
BestVMI = &VMI;
|
|
|
|
BestVMIIdx = u;
|
|
|
|
BestScore = Score;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BestVMIIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
TraitSet llvm::omp::getOpenMPContextTraitSetKind(StringRef S) {
|
|
|
|
return StringSwitch<TraitSet>(S)
|
|
|
|
#define OMP_TRAIT_SET(Enum, Str) .Case(Str, TraitSet::Enum)
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
.Default(TraitSet::invalid);
|
|
|
|
}
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
|
|
|
TraitSet
|
|
|
|
llvm::omp::getOpenMPContextTraitSetForSelector(TraitSelector Selector) {
|
|
|
|
switch (Selector) {
|
|
|
|
#define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp) \
|
|
|
|
case TraitSelector::Enum: \
|
|
|
|
return TraitSet::TraitSetEnum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
2020-02-15 14:59:08 +08:00
|
|
|
llvm_unreachable("Unknown trait selector!");
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
}
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
TraitSet
|
|
|
|
llvm::omp::getOpenMPContextTraitSetForProperty(TraitProperty Property) {
|
|
|
|
switch (Property) {
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
case TraitProperty::Enum: \
|
|
|
|
return TraitSet::TraitSetEnum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
2020-02-03 15:45:03 +08:00
|
|
|
llvm_unreachable("Unknown trait set!");
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
StringRef llvm::omp::getOpenMPContextTraitSetName(TraitSet Kind) {
|
|
|
|
switch (Kind) {
|
|
|
|
#define OMP_TRAIT_SET(Enum, Str) \
|
|
|
|
case TraitSet::Enum: \
|
|
|
|
return Str;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait set!");
|
|
|
|
}
|
|
|
|
|
|
|
|
TraitSelector llvm::omp::getOpenMPContextTraitSelectorKind(StringRef S) {
|
|
|
|
return StringSwitch<TraitSelector>(S)
|
|
|
|
#define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp) \
|
|
|
|
.Case(Str, TraitSelector::Enum)
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
.Default(TraitSelector::invalid);
|
|
|
|
}
|
|
|
|
TraitSelector
|
|
|
|
llvm::omp::getOpenMPContextTraitSelectorForProperty(TraitProperty Property) {
|
|
|
|
switch (Property) {
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
case TraitProperty::Enum: \
|
|
|
|
return TraitSelector::TraitSelectorEnum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
2020-02-03 15:45:03 +08:00
|
|
|
llvm_unreachable("Unknown trait set!");
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
}
|
|
|
|
StringRef llvm::omp::getOpenMPContextTraitSelectorName(TraitSelector Kind) {
|
|
|
|
switch (Kind) {
|
|
|
|
#define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp) \
|
|
|
|
case TraitSelector::Enum: \
|
|
|
|
return Str;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait selector!");
|
|
|
|
}
|
|
|
|
|
2020-07-07 14:08:03 +08:00
|
|
|
TraitProperty llvm::omp::getOpenMPContextTraitPropertyKind(
|
|
|
|
TraitSet Set, TraitSelector Selector, StringRef S) {
|
|
|
|
// Special handling for `device={isa(...)}` as we accept anything here. It is
|
|
|
|
// up to the target to decide if the feature is available.
|
|
|
|
if (Set == TraitSet::device && Selector == TraitSelector::device_isa)
|
|
|
|
return TraitProperty::device_isa___ANY;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
if (Set == TraitSet::TraitSetEnum && Str == S) \
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
return TraitProperty::Enum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
return TraitProperty::invalid;
|
|
|
|
}
|
|
|
|
TraitProperty
|
|
|
|
llvm::omp::getOpenMPContextTraitPropertyForSelector(TraitSelector Selector) {
|
|
|
|
return StringSwitch<TraitProperty>(
|
|
|
|
getOpenMPContextTraitSelectorName(Selector))
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
.Case(Str, Selector == TraitSelector::TraitSelectorEnum \
|
|
|
|
? TraitProperty::Enum \
|
|
|
|
: TraitProperty::invalid)
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
.Default(TraitProperty::invalid);
|
|
|
|
}
|
2020-07-07 14:08:03 +08:00
|
|
|
StringRef llvm::omp::getOpenMPContextTraitPropertyName(TraitProperty Kind,
|
|
|
|
StringRef RawString) {
|
|
|
|
if (Kind == TraitProperty::device_isa___ANY)
|
|
|
|
return RawString;
|
[OpenMP][Part 1] Reusable OpenMP context/traits handling
This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D71847
2019-12-24 05:50:27 +08:00
|
|
|
switch (Kind) {
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
case TraitProperty::Enum: \
|
|
|
|
return Str;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait property!");
|
|
|
|
}
|
|
|
|
StringRef llvm::omp::getOpenMPContextTraitPropertyFullName(TraitProperty Kind) {
|
|
|
|
switch (Kind) {
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
case TraitProperty::Enum: \
|
|
|
|
return "(" #TraitSetEnum "," #TraitSelectorEnum "," Str ")";
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait property!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool llvm::omp::isValidTraitSelectorForTraitSet(TraitSelector Selector,
|
|
|
|
TraitSet Set,
|
|
|
|
bool &AllowsTraitScore,
|
|
|
|
bool &RequiresProperty) {
|
|
|
|
AllowsTraitScore = Set != TraitSet::construct && Set != TraitSet::device;
|
|
|
|
switch (Selector) {
|
|
|
|
#define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp) \
|
|
|
|
case TraitSelector::Enum: \
|
|
|
|
RequiresProperty = ReqProp; \
|
|
|
|
return Set == TraitSet::TraitSetEnum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait selector!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool llvm::omp::isValidTraitPropertyForTraitSetAndSelector(
|
|
|
|
TraitProperty Property, TraitSelector Selector, TraitSet Set) {
|
|
|
|
switch (Property) {
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
case TraitProperty::Enum: \
|
|
|
|
return Set == TraitSet::TraitSetEnum && \
|
|
|
|
Selector == TraitSelector::TraitSelectorEnum;
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown trait property!");
|
|
|
|
}
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
|
|
|
std::string llvm::omp::listOpenMPContextTraitSets() {
|
|
|
|
std::string S;
|
|
|
|
#define OMP_TRAIT_SET(Enum, Str) \
|
2020-02-15 15:38:58 +08:00
|
|
|
if (StringRef(Str) != "invalid") \
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
S.append("'").append(Str).append("'").append(" ");
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
S.pop_back();
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string llvm::omp::listOpenMPContextTraitSelectors(TraitSet Set) {
|
|
|
|
std::string S;
|
|
|
|
#define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp) \
|
2020-02-15 15:38:58 +08:00
|
|
|
if (TraitSet::TraitSetEnum == Set && StringRef(Str) != "Invalid") \
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
S.append("'").append(Str).append("'").append(" ");
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
|
|
|
S.pop_back();
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
llvm::omp::listOpenMPContextTraitProperties(TraitSet Set,
|
|
|
|
TraitSelector Selector) {
|
|
|
|
std::string S;
|
|
|
|
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
|
|
|
if (TraitSet::TraitSetEnum == Set && \
|
2020-02-15 07:23:42 +08:00
|
|
|
TraitSelector::TraitSelectorEnum == Selector && \
|
2020-02-15 15:38:58 +08:00
|
|
|
StringRef(Str) != "invalid") \
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
S.append("'").append(Str).append("'").append(" ");
|
|
|
|
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
2020-02-21 09:50:47 +08:00
|
|
|
if (S.empty())
|
|
|
|
return "<none>";
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
S.pop_back();
|
|
|
|
return S;
|
|
|
|
}
|