Skip to content

Commit d1d85f5

Browse files
author
Erich Keane
committedFeb 8, 2018
Add X86 Support to ValidCPUList (enabling march notes)
A followup to: https://reviews.llvm.org/D42978 This patch adds X86 and X86_64 support for enabling the march notes. Differential Revision: https://reviews.llvm.org/D43041 llvm-svn: 324674
1 parent 3ec1743 commit d1d85f5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎clang/lib/Basic/Targets/X86.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Basic/Builtins.h"
1616
#include "clang/Basic/Diagnostic.h"
1717
#include "clang/Basic/TargetBuiltins.h"
18+
#include "llvm/ADT/StringExtras.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/ADT/StringSwitch.h"
2021
#include "llvm/Support/TargetParser.h"
@@ -1648,8 +1649,6 @@ std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
16481649
bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
16491650
// Perform any per-CPU checks necessary to determine if this CPU is
16501651
// acceptable.
1651-
// FIXME: This results in terrible diagnostics. Clang just says the CPU is
1652-
// invalid without explaining *why*.
16531652
switch (Kind) {
16541653
case CK_Generic:
16551654
// No processor selected!
@@ -1662,6 +1661,18 @@ bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
16621661
llvm_unreachable("Unhandled CPU kind");
16631662
}
16641663

1664+
void X86TargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
1665+
#define PROC(ENUM, STRING, IS64BIT) \
1666+
if (IS64BIT || getTriple().getArch() == llvm::Triple::x86) \
1667+
Values.emplace_back(STRING);
1668+
// Go through CPUKind checking to ensure that the alias is de-aliased and
1669+
// 64 bit-ness is checked.
1670+
#define PROC_ALIAS(ENUM, ALIAS) \
1671+
if (checkCPUKind(getCPUKind(ALIAS))) \
1672+
Values.emplace_back(ALIAS);
1673+
#include "clang/Basic/X86Target.def"
1674+
}
1675+
16651676
X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
16661677
return llvm::StringSwitch<CPUKind>(CPU)
16671678
#define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)

‎clang/lib/Basic/Targets/X86.h

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
264264
return checkCPUKind(getCPUKind(Name));
265265
}
266266

267+
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
268+
267269
bool setCPU(const std::string &Name) override {
268270
return checkCPUKind(CPU = getCPUKind(Name));
269271
}

0 commit comments

Comments
 (0)
Please sign in to comment.