Skip to content

Commit 6da1108

Browse files
author
Erich Keane
committed
Split x86 "Processor" info into its own def file. [NFC]
A first step toward removing the repetition of features/CPU info in the x86 target info, this patch pulls all the processor information out into its own .def file. Differential Revision: https://reviews.llvm.org/D40093 llvm-svn: 318343
1 parent 4b65ee6 commit 6da1108

File tree

2 files changed

+9
-281
lines changed

2 files changed

+9
-281
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 7 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,121 +1504,19 @@ bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
15041504
case CK_Generic:
15051505
// No processor selected!
15061506
return false;
1507-
1508-
case CK_i386:
1509-
case CK_i486:
1510-
case CK_WinChipC6:
1511-
case CK_WinChip2:
1512-
case CK_C3:
1513-
case CK_i586:
1514-
case CK_Pentium:
1515-
case CK_PentiumMMX:
1516-
case CK_PentiumPro:
1517-
case CK_Pentium2:
1518-
case CK_Pentium3:
1519-
case CK_PentiumM:
1520-
case CK_Yonah:
1521-
case CK_C3_2:
1522-
case CK_Pentium4:
1523-
case CK_Lakemont:
1524-
case CK_Prescott:
1525-
case CK_K6:
1526-
case CK_K6_2:
1527-
case CK_K6_3:
1528-
case CK_Athlon:
1529-
case CK_AthlonXP:
1530-
case CK_Geode:
1531-
// Only accept certain architectures when compiling in 32-bit mode.
1532-
if (getTriple().getArch() != llvm::Triple::x86)
1533-
return false;
1534-
1535-
LLVM_FALLTHROUGH;
1536-
case CK_Nocona:
1537-
case CK_Core2:
1538-
case CK_Penryn:
1539-
case CK_Bonnell:
1540-
case CK_Silvermont:
1541-
case CK_Goldmont:
1542-
case CK_Nehalem:
1543-
case CK_Westmere:
1544-
case CK_SandyBridge:
1545-
case CK_IvyBridge:
1546-
case CK_Haswell:
1547-
case CK_Broadwell:
1548-
case CK_SkylakeClient:
1549-
case CK_SkylakeServer:
1550-
case CK_Cannonlake:
1551-
case CK_KNL:
1552-
case CK_KNM:
1553-
case CK_K8:
1554-
case CK_K8SSE3:
1555-
case CK_AMDFAM10:
1556-
case CK_BTVER1:
1557-
case CK_BTVER2:
1558-
case CK_BDVER1:
1559-
case CK_BDVER2:
1560-
case CK_BDVER3:
1561-
case CK_BDVER4:
1562-
case CK_ZNVER1:
1563-
case CK_x86_64:
1564-
return true;
1507+
#define PROC(ENUM, STRING, IS64BIT) \
1508+
case CK_##ENUM: \
1509+
return IS64BIT || getTriple().getArch() == llvm::Triple::x86;
1510+
#include "clang/Basic/X86Target.def"
15651511
}
15661512
llvm_unreachable("Unhandled CPU kind");
15671513
}
15681514

15691515
X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
15701516
return llvm::StringSwitch<CPUKind>(CPU)
1571-
.Case("i386", CK_i386)
1572-
.Case("i486", CK_i486)
1573-
.Case("winchip-c6", CK_WinChipC6)
1574-
.Case("winchip2", CK_WinChip2)
1575-
.Case("c3", CK_C3)
1576-
.Case("i586", CK_i586)
1577-
.Case("pentium", CK_Pentium)
1578-
.Case("pentium-mmx", CK_PentiumMMX)
1579-
.Cases("i686", "pentiumpro", CK_PentiumPro)
1580-
.Case("pentium2", CK_Pentium2)
1581-
.Cases("pentium3", "pentium3m", CK_Pentium3)
1582-
.Case("pentium-m", CK_PentiumM)
1583-
.Case("c3-2", CK_C3_2)
1584-
.Case("yonah", CK_Yonah)
1585-
.Cases("pentium4", "pentium4m", CK_Pentium4)
1586-
.Case("prescott", CK_Prescott)
1587-
.Case("nocona", CK_Nocona)
1588-
.Case("core2", CK_Core2)
1589-
.Case("penryn", CK_Penryn)
1590-
.Cases("bonnell", "atom", CK_Bonnell)
1591-
.Cases("silvermont", "slm", CK_Silvermont)
1592-
.Case("goldmont", CK_Goldmont)
1593-
.Cases("nehalem", "corei7", CK_Nehalem)
1594-
.Case("westmere", CK_Westmere)
1595-
.Cases("sandybridge", "corei7-avx", CK_SandyBridge)
1596-
.Cases("ivybridge", "core-avx-i", CK_IvyBridge)
1597-
.Cases("haswell", "core-avx2", CK_Haswell)
1598-
.Case("broadwell", CK_Broadwell)
1599-
.Case("skylake", CK_SkylakeClient)
1600-
.Cases("skylake-avx512", "skx", CK_SkylakeServer)
1601-
.Case("cannonlake", CK_Cannonlake)
1602-
.Case("knl", CK_KNL)
1603-
.Case("knm", CK_KNM)
1604-
.Case("lakemont", CK_Lakemont)
1605-
.Case("k6", CK_K6)
1606-
.Case("k6-2", CK_K6_2)
1607-
.Case("k6-3", CK_K6_3)
1608-
.Cases("athlon", "athlon-tbird", CK_Athlon)
1609-
.Cases("athlon-xp", "athlon-mp", "athlon-4", CK_AthlonXP)
1610-
.Cases("k8", "athlon64", "athlon-fx", "opteron", CK_K8)
1611-
.Cases("k8-sse3", "athlon64-sse3", "opteron-sse3", CK_K8SSE3)
1612-
.Cases("amdfam10", "barcelona", CK_AMDFAM10)
1613-
.Case("btver1", CK_BTVER1)
1614-
.Case("btver2", CK_BTVER2)
1615-
.Case("bdver1", CK_BDVER1)
1616-
.Case("bdver2", CK_BDVER2)
1617-
.Case("bdver3", CK_BDVER3)
1618-
.Case("bdver4", CK_BDVER4)
1619-
.Case("znver1", CK_ZNVER1)
1620-
.Case("x86-64", CK_x86_64)
1621-
.Case("geode", CK_Geode)
1517+
#define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)
1518+
#define PROC_ALIAS(ENUM, ALIAS) .Case(ALIAS, CK_##ENUM)
1519+
#include "clang/Basic/X86Target.def"
16221520
.Default(CK_Generic);
16231521
}
16241522

clang/lib/Basic/Targets/X86.h

Lines changed: 2 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -95,178 +95,8 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
9595
/// loosely correspond to the options passed to '-march' or '-mtune' flags.
9696
enum CPUKind {
9797
CK_Generic,
98-
99-
/// \name i386
100-
/// i386-generation processors.
101-
//@{
102-
CK_i386,
103-
//@}
104-
105-
/// \name i486
106-
/// i486-generation processors.
107-
//@{
108-
CK_i486,
109-
CK_WinChipC6,
110-
CK_WinChip2,
111-
CK_C3,
112-
//@}
113-
114-
/// \name i586
115-
/// i586-generation processors, P5 microarchitecture based.
116-
//@{
117-
CK_i586,
118-
CK_Pentium,
119-
CK_PentiumMMX,
120-
//@}
121-
122-
/// \name i686
123-
/// i686-generation processors, P6 / Pentium M microarchitecture based.
124-
//@{
125-
CK_PentiumPro,
126-
CK_Pentium2,
127-
CK_Pentium3,
128-
CK_PentiumM,
129-
CK_C3_2,
130-
131-
/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
132-
/// Clang however has some logic to support this.
133-
// FIXME: Warn, deprecate, and potentially remove this.
134-
CK_Yonah,
135-
//@}
136-
137-
/// \name Netburst
138-
/// Netburst microarchitecture based processors.
139-
//@{
140-
CK_Pentium4,
141-
CK_Prescott,
142-
CK_Nocona,
143-
//@}
144-
145-
/// \name Core
146-
/// Core microarchitecture based processors.
147-
//@{
148-
CK_Core2,
149-
150-
/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
151-
/// codename which GCC no longer accepts as an option to -march, but Clang
152-
/// has some logic for recognizing it.
153-
// FIXME: Warn, deprecate, and potentially remove this.
154-
CK_Penryn,
155-
//@}
156-
157-
/// \name Atom
158-
/// Atom processors
159-
//@{
160-
CK_Bonnell,
161-
CK_Silvermont,
162-
CK_Goldmont,
163-
//@}
164-
165-
/// \name Nehalem
166-
/// Nehalem microarchitecture based processors.
167-
CK_Nehalem,
168-
169-
/// \name Westmere
170-
/// Westmere microarchitecture based processors.
171-
CK_Westmere,
172-
173-
/// \name Sandy Bridge
174-
/// Sandy Bridge microarchitecture based processors.
175-
CK_SandyBridge,
176-
177-
/// \name Ivy Bridge
178-
/// Ivy Bridge microarchitecture based processors.
179-
CK_IvyBridge,
180-
181-
/// \name Haswell
182-
/// Haswell microarchitecture based processors.
183-
CK_Haswell,
184-
185-
/// \name Broadwell
186-
/// Broadwell microarchitecture based processors.
187-
CK_Broadwell,
188-
189-
/// \name Skylake Client
190-
/// Skylake client microarchitecture based processors.
191-
CK_SkylakeClient,
192-
193-
/// \name Skylake Server
194-
/// Skylake server microarchitecture based processors.
195-
CK_SkylakeServer,
196-
197-
/// \name Cannonlake Client
198-
/// Cannonlake client microarchitecture based processors.
199-
CK_Cannonlake,
200-
201-
/// \name Knights Landing
202-
/// Knights Landing processor.
203-
CK_KNL,
204-
205-
/// \name Knights Mill
206-
/// Knights Mill processor.
207-
CK_KNM,
208-
209-
/// \name Lakemont
210-
/// Lakemont microarchitecture based processors.
211-
CK_Lakemont,
212-
213-
/// \name K6
214-
/// K6 architecture processors.
215-
//@{
216-
CK_K6,
217-
CK_K6_2,
218-
CK_K6_3,
219-
//@}
220-
221-
/// \name K7
222-
/// K7 architecture processors.
223-
//@{
224-
CK_Athlon,
225-
CK_AthlonXP,
226-
//@}
227-
228-
/// \name K8
229-
/// K8 architecture processors.
230-
//@{
231-
CK_K8,
232-
CK_K8SSE3,
233-
CK_AMDFAM10,
234-
//@}
235-
236-
/// \name Bobcat
237-
/// Bobcat architecture processors.
238-
//@{
239-
CK_BTVER1,
240-
CK_BTVER2,
241-
//@}
242-
243-
/// \name Bulldozer
244-
/// Bulldozer architecture processors.
245-
//@{
246-
CK_BDVER1,
247-
CK_BDVER2,
248-
CK_BDVER3,
249-
CK_BDVER4,
250-
//@}
251-
252-
/// \name zen
253-
/// Zen architecture processors.
254-
//@{
255-
CK_ZNVER1,
256-
//@}
257-
258-
/// This specification is deprecated and will be removed in the future.
259-
/// Users should prefer \see CK_K8.
260-
// FIXME: Warn on this when the CPU is set to it.
261-
//@{
262-
CK_x86_64,
263-
//@}
264-
265-
/// \name Geode
266-
/// Geode processors.
267-
//@{
268-
CK_Geode
269-
//@}
98+
#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
99+
#include "clang/Basic/X86Target.def"
270100
} CPU = CK_Generic;
271101

272102
bool checkCPUKind(CPUKind Kind) const;

0 commit comments

Comments
 (0)