Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
71 changes: 0 additions & 71 deletions clang/lib/Basic/Targets/LoongArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,73 +393,6 @@ bool LoongArchTargetInfo::handleTargetFeatures(
return true;
}

enum class AttrFeatureKind { Arch, Tune, NoFeature, Feature };

static std::pair<AttrFeatureKind, llvm::StringRef>
getAttrFeatureTypeAndValue(llvm::StringRef AttrFeature) {
if (auto Split = AttrFeature.split("="); !Split.second.empty()) {
if (Split.first.trim() == "arch")
return {AttrFeatureKind::Arch, Split.second.trim()};
if (Split.first.trim() == "tune")
return {AttrFeatureKind::Tune, Split.second.trim()};
}
if (AttrFeature.starts_with("no-"))
return {AttrFeatureKind::NoFeature, AttrFeature.drop_front(3)};
return {AttrFeatureKind::Feature, AttrFeature};
}

ParsedTargetAttr
LoongArchTargetInfo::parseTargetAttr(StringRef Features) const {
ParsedTargetAttr Ret;
if (Features == "default")
return Ret;
SmallVector<StringRef, 1> AttrFeatures;
Features.split(AttrFeatures, ",");

for (auto &Feature : AttrFeatures) {
auto [Kind, Value] = getAttrFeatureTypeAndValue(Feature.trim());

switch (Kind) {
case AttrFeatureKind::Arch: {
if (llvm::LoongArch::isValidArchName(Value) || Value == "la64v1.0" ||
Value == "la64v1.1") {
std::vector<llvm::StringRef> ArchFeatures;
if (llvm::LoongArch::getArchFeatures(Value, ArchFeatures)) {
Ret.Features.insert(Ret.Features.end(), ArchFeatures.begin(),
ArchFeatures.end());
}

if (!Ret.CPU.empty())
Ret.Duplicate = "arch=";
else if (Value == "la64v1.0" || Value == "la64v1.1")
Ret.CPU = "loongarch64";
else
Ret.CPU = Value;
} else {
Ret.Features.push_back("!arch=" + Value.str());
}
break;
}

case AttrFeatureKind::Tune:
if (!Ret.Tune.empty())
Ret.Duplicate = "tune=";
else
Ret.Tune = Value;
break;

case AttrFeatureKind::NoFeature:
Ret.Features.push_back("-" + Value.str());
break;

case AttrFeatureKind::Feature:
Ret.Features.push_back("+" + Value.str());
break;
}
}
return Ret;
}

bool LoongArchTargetInfo::isValidCPUName(StringRef Name) const {
return llvm::LoongArch::isValidCPUName(Name);
}
Expand All @@ -468,7 +401,3 @@ void LoongArchTargetInfo::fillValidCPUList(
SmallVectorImpl<StringRef> &Values) const {
llvm::LoongArch::fillValidCPUList(Values);
}

bool LoongArchTargetInfo::isValidFeatureName(StringRef Name) const {
return llvm::LoongArch::isValidFeatureName(Name);
}
4 changes: 0 additions & 4 deletions clang/lib/Basic/Targets/LoongArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override;

ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
bool supportsTargetAttributeTune() const override { return true; }

bool
initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
Expand All @@ -113,7 +110,6 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {

bool isValidCPUName(StringRef Name) const override;
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
bool isValidFeatureName(StringRef Name) const override;
};

class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
Expand Down
11 changes: 0 additions & 11 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3195,17 +3195,6 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
}
}

if (Context.getTargetInfo().getTriple().isLoongArch()) {
for (const auto &Feature : ParsedAttrs.Features) {
StringRef CurFeature = Feature;
if (CurFeature.starts_with("!arch=")) {
StringRef ArchValue = CurFeature.split("=").second.trim();
return Diag(LiteralLoc, diag::err_attribute_unsupported)
<< "target(arch=..)" << ArchValue;
}
}
}

if (ParsedAttrs.Duplicate != "")
return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Duplicate << None << ParsedAttrs.Duplicate << Target;
Expand Down
92 changes: 0 additions & 92 deletions clang/test/CodeGen/LoongArch/targetattr.c

This file was deleted.

25 changes: 0 additions & 25 deletions clang/test/Sema/attr-target-loongarch.c

This file was deleted.

1 change: 0 additions & 1 deletion llvm/include/llvm/TargetParser/LoongArchTargetParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ struct ArchInfo {
};

bool isValidArchName(StringRef Arch);
bool isValidFeatureName(StringRef Feature);
bool getArchFeatures(StringRef Arch, std::vector<StringRef> &Features);
bool isValidCPUName(StringRef TuneCPU);
void fillValidCPUList(SmallVectorImpl<StringRef> &Values);
Expand Down
12 changes: 0 additions & 12 deletions llvm/lib/TargetParser/LoongArchTargetParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ bool LoongArch::isValidArchName(StringRef Arch) {
return false;
}

bool LoongArch::isValidFeatureName(StringRef Feature) {
if (Feature.starts_with("+") || Feature.starts_with("-"))
return false;
for (const auto &F : AllFeatures) {
StringRef CanonicalName =
F.Name.starts_with("+") ? F.Name.drop_front() : F.Name;
if (CanonicalName == Feature)
return true;
}
return false;
}

bool LoongArch::getArchFeatures(StringRef Arch,
std::vector<StringRef> &Features) {
for (const auto A : AllArchs) {
Expand Down
Loading