Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions clang/lib/Basic/Targets/AMDGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@ bool AMDGPUTargetInfo::initFeatureMap(
const std::vector<std::string> &FeatureVec) const {

using namespace llvm::AMDGPU;
fillAMDGPUFeatureMap(CPU, getTriple(), Features);

if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeatureVec))
return false;

// TODO: Should move this logic into TargetParser
auto HasError = insertWaveSizeFeature(CPU, getTriple(), Features);
auto HasError = fillAMDGPUFeatureMap(CPU, getTriple(), Features);
switch (HasError.first) {
default:
break;
Expand Down
2 changes: 2 additions & 0 deletions clang/test/CodeGenOpenCL/amdgpu-features-illegal.cl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// RUN: not %clang_cc1 -triple amdgcn -target-feature +wavefrontsize32 -target-feature +wavefrontsize64 -o /dev/null %s 2>&1 | FileCheck %s
// RUN: not %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature +wavefrontsize32 -target-feature +wavefrontsize64 -o /dev/null %s 2>&1 | FileCheck %s
// RUN: not %clang_cc1 -triple amdgcn -target-cpu gfx900 -target-feature +wavefrontsize32 -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=GFX9
// RUN: not %clang_cc1 -triple amdgcn -target-cpu gfx1250 -target-feature +wavefrontsize64 -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=GFX1250

// CHECK: error: invalid feature combination: 'wavefrontsize32' and 'wavefrontsize64' are mutually exclusive
// GFX9: error: option 'wavefrontsize32' cannot be specified on this target
// GFX1250: error: option 'wavefrontsize64' cannot be specified on this target

kernel void test() {}
15 changes: 6 additions & 9 deletions flang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,15 @@ getExplicitAndImplicitAMDGPUTargetFeatures(clang::DiagnosticsEngine &diags,
const TargetOptions &targetOpts,
const llvm::Triple triple) {
llvm::StringRef cpu = targetOpts.cpu;
llvm::StringMap<bool> implicitFeaturesMap;
// Get the set of implicit target features
llvm::AMDGPU::fillAMDGPUFeatureMap(cpu, triple, implicitFeaturesMap);
llvm::StringMap<bool> FeaturesMap;

// Add target features specified by the user
for (auto &userFeature : targetOpts.featuresAsWritten) {
std::string userKeyString = userFeature.substr(1);
implicitFeaturesMap[userKeyString] = (userFeature[0] == '+');
FeaturesMap[userKeyString] = (userFeature[0] == '+');
}

auto HasError =
llvm::AMDGPU::insertWaveSizeFeature(cpu, triple, implicitFeaturesMap);
auto HasError = llvm::AMDGPU::fillAMDGPUFeatureMap(cpu, triple, FeaturesMap);
if (HasError.first) {
unsigned diagID = diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
"Unsupported feature ID: %0");
Expand All @@ -273,9 +270,9 @@ getExplicitAndImplicitAMDGPUTargetFeatures(clang::DiagnosticsEngine &diags,
}

llvm::SmallVector<std::string> featuresVec;
for (auto &implicitFeatureItem : implicitFeaturesMap) {
featuresVec.push_back((llvm::Twine(implicitFeatureItem.second ? "+" : "-") +
implicitFeatureItem.first().str())
for (auto &FeatureItem : FeaturesMap) {
featuresVec.push_back((llvm::Twine(FeatureItem.second ? "+" : "-") +
FeatureItem.first().str())
.str());
}
llvm::sort(featuresVec);
Expand Down
12 changes: 4 additions & 8 deletions llvm/include/llvm/TargetParser/TargetParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,11 @@ LLVM_ABI void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);

LLVM_ABI IsaVersion getIsaVersion(StringRef GPU);

/// Fills Features map with default values for given target GPU
LLVM_ABI void fillAMDGPUFeatureMap(StringRef GPU, const Triple &T,
StringMap<bool> &Features);

/// Inserts wave size feature for given GPU into features map
/// Fills Features map with default values for given target GPU.
/// \p Features contains overriding target features and this function returns
/// default target features with entries overridden by \p Features.
LLVM_ABI std::pair<FeatureError, StringRef>
insertWaveSizeFeature(StringRef GPU, const Triple &T,
StringMap<bool> &Features);

fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, StringMap<bool> &Features);
} // namespace AMDGPU

struct BasicSubtargetFeatureKV {
Expand Down
Loading