forked from OSchip/llvm-project
[OpenMP][Fix] Make the arch selector for x86_64 work
The triple uses a bar "x86-64" instead of an underscore. Since we have troubles accepting x86-64 as an identifier, we stick with x86_64 in the frontend and translate it explicitly. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D93786
This commit is contained in:
parent
9ae171bcd3
commit
d970a285b8
|
@ -0,0 +1,10 @@
|
|||
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown %s -ast-dump | FileCheck %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
#pragma omp begin declare variant match(device={arch(x86_64)})
|
||||
|
||||
void bar() {}
|
||||
|
||||
// CHECK: FunctionDecl {{.*}} bar[device={arch(x86_64)}] 'void ()'
|
||||
|
||||
#pragma omp end declare variant
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
#include "llvm/Frontend/OpenMP/OMPContext.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
|
@ -58,9 +60,12 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple TargetTriple) {
|
|||
|
||||
// Add the appropriate device architecture trait based on the triple.
|
||||
#define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
|
||||
if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) \
|
||||
if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) { \
|
||||
if (TargetTriple.getArch() == TargetTriple.getArchTypeForLLVMName(Str)) \
|
||||
ActiveTraits.set(unsigned(TraitProperty::Enum));
|
||||
ActiveTraits.set(unsigned(TraitProperty::Enum)); \
|
||||
if (Str == "x86_64" && TargetTriple.getArch() == Triple::x86_64) \
|
||||
ActiveTraits.set(unsigned(TraitProperty::Enum)); \
|
||||
}
|
||||
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
||||
|
||||
// TODO: What exactly do we want to see as device ISA trait?
|
||||
|
|
Loading…
Reference in New Issue