blob: 912dff0f1d0cd245febf2e9edc2098c473ebde1a [file] [log] [blame]
Arnold Schwaighofer1f0da1f2007-10-12 21:30:57 +00001//===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
Michael J. Spencerb88784c2011-04-14 14:33:36 +00002//
John Criswell29265fe2003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Michael J. Spencerb88784c2011-04-14 14:33:36 +00007//
John Criswell29265fe2003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +00009//
10// This is a target description file for the Intel i386 architecture, refered to
11// here as the "X86" architecture.
12//
13//===----------------------------------------------------------------------===//
14
Chris Lattner25510802003-08-04 04:59:56 +000015// Get the target-independent interfaces which we are implementing...
Chris Lattner5da8e802003-08-03 15:47:49 +000016//
Evan Cheng977e7be2008-11-24 07:34:46 +000017include "llvm/Target/Target.td"
Chris Lattner5da8e802003-08-03 15:47:49 +000018
19//===----------------------------------------------------------------------===//
Evan Chengff1beda2006-10-06 09:17:41 +000020// X86 Subtarget features.
Bill Wendlinge6182262007-05-04 20:38:40 +000021//===----------------------------------------------------------------------===//
Chris Lattnercc8c5812009-09-02 05:53:04 +000022
23def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
24 "Enable conditional move instructions">;
25
Benjamin Kramer2f489232010-12-04 20:32:23 +000026def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
27 "Support POPCNT instruction">;
28
David Greene206351a2010-01-11 16:29:42 +000029
Bill Wendlinge6182262007-05-04 20:38:40 +000030def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
31 "Enable MMX instructions">;
32def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
33 "Enable SSE instructions",
Chris Lattnercc8c5812009-09-02 05:53:04 +000034 // SSE codegen depends on cmovs, and all
Michael J. Spencerb88784c2011-04-14 14:33:36 +000035 // SSE1+ processors support them.
Chris Lattnercc8c5812009-09-02 05:53:04 +000036 [FeatureMMX, FeatureCMOV]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000037def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
38 "Enable SSE2 instructions",
39 [FeatureSSE1]>;
40def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
41 "Enable SSE3 instructions",
42 [FeatureSSE2]>;
43def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
44 "Enable SSSE3 instructions",
45 [FeatureSSE3]>;
Nate Begemane14fdfa2008-02-03 07:18:54 +000046def FeatureSSE41 : SubtargetFeature<"sse41", "X86SSELevel", "SSE41",
47 "Enable SSE 4.1 instructions",
48 [FeatureSSSE3]>;
49def FeatureSSE42 : SubtargetFeature<"sse42", "X86SSELevel", "SSE42",
50 "Enable SSE 4.2 instructions",
Benjamin Kramer2f489232010-12-04 20:32:23 +000051 [FeatureSSE41, FeaturePOPCNT]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000052def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
Michael J. Spencer30088ba2011-04-15 00:32:41 +000053 "Enable 3DNow! instructions",
54 [FeatureMMX]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000055def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
Bill Wendlingf985c492007-05-06 07:56:19 +000056 "Enable 3DNow! Athlon instructions",
57 [Feature3DNow]>;
Dan Gohman74037512009-02-03 00:04:43 +000058// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
59// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
60// without disabling 64-bit mode.
Bill Wendlingf985c492007-05-06 07:56:19 +000061def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Chris Lattner77f7dba2010-03-14 22:24:34 +000062 "Support 64-bit instructions",
63 [FeatureCMOV]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +000064def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
65 "Bit testing of memory is slow">;
Evan Cheng738b0f92010-04-01 05:58:17 +000066def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
67 "IsUAMemFast", "true",
68 "Fast unaligned memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +000069def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
Benjamin Kramer2f489232010-12-04 20:32:23 +000070 "Support SSE 4a instructions",
71 [FeaturePOPCNT]>;
Evan Chengff1beda2006-10-06 09:17:41 +000072
David Greene8f6f72c2009-06-26 22:46:54 +000073def FeatureAVX : SubtargetFeature<"avx", "HasAVX", "true",
74 "Enable AVX instructions">;
Bruno Cardoso Lopesd618c8a2010-07-23 01:22:45 +000075def FeatureCLMUL : SubtargetFeature<"clmul", "HasCLMUL", "true",
76 "Enable carry-less multiplication instructions">;
David Greene8f6f72c2009-06-26 22:46:54 +000077def FeatureFMA3 : SubtargetFeature<"fma3", "HasFMA3", "true",
Sean Callanan04d8cb72009-12-18 00:01:26 +000078 "Enable three-operand fused multiple-add">;
David Greene8f6f72c2009-06-26 22:46:54 +000079def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
80 "Enable four-operand fused multiple-add">;
David Greene206351a2010-01-11 16:29:42 +000081def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
82 "HasVectorUAMem", "true",
83 "Allow unaligned memory operands on vector/SIMD instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +000084def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
85 "Enable AES instructions">;
David Greene8f6f72c2009-06-26 22:46:54 +000086
Evan Chengff1beda2006-10-06 09:17:41 +000087//===----------------------------------------------------------------------===//
88// X86 processors supported.
89//===----------------------------------------------------------------------===//
90
91class Proc<string Name, list<SubtargetFeature> Features>
92 : Processor<Name, NoItineraries, Features>;
93
94def : Proc<"generic", []>;
95def : Proc<"i386", []>;
96def : Proc<"i486", []>;
Dale Johannesen28106752008-10-14 22:06:33 +000097def : Proc<"i586", []>;
Evan Chengff1beda2006-10-06 09:17:41 +000098def : Proc<"pentium", []>;
99def : Proc<"pentium-mmx", [FeatureMMX]>;
100def : Proc<"i686", []>;
Chris Lattnercc8c5812009-09-02 05:53:04 +0000101def : Proc<"pentiumpro", [FeatureCMOV]>;
102def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000103def : Proc<"pentium3", [FeatureSSE1]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000104def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000105def : Proc<"pentium4", [FeatureSSE2]>;
Evan Cheng71d7eaa2009-12-22 17:47:23 +0000106def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>;
107def : Proc<"yonah", [FeatureSSE3, FeatureSlowBTMem]>;
108def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
109def : Proc<"nocona", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
110def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>;
111def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>;
112def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000113// "Arrandale" along with corei3 and corei5
Evan Cheng738b0f92010-04-01 05:58:17 +0000114def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
Eric Christopher2ef63182010-04-02 21:54:27 +0000115 FeatureFastUAMem, FeatureAES]>;
Evan Cheng738b0f92010-04-01 05:58:17 +0000116def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
117 FeatureFastUAMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000118// Westmere is a similar machine to nehalem with some additional features.
119// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Nate Begeman8b08f522010-12-10 00:26:57 +0000120def : Proc<"westmere", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
121 FeatureFastUAMem, FeatureAES, FeatureCLMUL]>;
122// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
123// rather than a superset.
Evan Chengf8b4c002010-12-13 04:23:53 +0000124// FIXME: Disabling AVX for now since it's not ready.
125def : Proc<"sandybridge", [FeatureSSE42, Feature64Bit,
126 FeatureAES, FeatureCLMUL]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000127
128def : Proc<"k6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000129def : Proc<"k6-2", [Feature3DNow]>;
130def : Proc<"k6-3", [Feature3DNow]>;
131def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem]>;
132def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000133def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
134def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
135def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
Dan Gohman74037512009-02-03 00:04:43 +0000136def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
137 FeatureSlowBTMem]>;
138def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
139 FeatureSlowBTMem]>;
140def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
141 FeatureSlowBTMem]>;
142def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
143 FeatureSlowBTMem]>;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000144def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
145 FeatureSlowBTMem]>;
146def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
147 FeatureSlowBTMem]>;
148def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
149 FeatureSlowBTMem]>;
150def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A,
151 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
152def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A,
153 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
David Greene46b56ff2009-06-29 16:54:06 +0000154def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
155 Feature3DNowA]>;
156def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
157 Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000158
159def : Proc<"winchip-c6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000160def : Proc<"winchip2", [Feature3DNow]>;
161def : Proc<"c3", [Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000162def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000163
164//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000165// Register File Description
166//===----------------------------------------------------------------------===//
167
168include "X86RegisterInfo.td"
169
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000170//===----------------------------------------------------------------------===//
171// Instruction Descriptions
172//===----------------------------------------------------------------------===//
173
Chris Lattner59a4a912003-08-03 21:54:21 +0000174include "X86InstrInfo.td"
175
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000176def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000177
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000178//===----------------------------------------------------------------------===//
179// Calling Conventions
180//===----------------------------------------------------------------------===//
181
182include "X86CallingConv.td"
183
184
185//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000186// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000187//===----------------------------------------------------------------------===//
188
Daniel Dunbar00331992009-07-29 00:02:19 +0000189// Currently the X86 assembly parser only supports ATT syntax.
190def ATTAsmParser : AsmParser {
Daniel Dunbar9b816a12010-05-04 16:12:42 +0000191 string AsmParserClassName = "ATTAsmParser";
Daniel Dunbar00331992009-07-29 00:02:19 +0000192 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000193
194 // Discard comments in assembly strings.
195 string CommentDelimiter = "#";
196
197 // Recognize hard coded registers.
198 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000199}
200
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000201//===----------------------------------------------------------------------===//
202// Assembly Printers
203//===----------------------------------------------------------------------===//
204
Chris Lattner56832602004-10-03 20:36:57 +0000205// The X86 target supports two different syntaxes for emitting machine code.
206// This is controlled by the -x86-asm-syntax={att|intel}
207def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000208 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000209 int Variant = 0;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000210 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000211}
212def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000213 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000214 int Variant = 1;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000215 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000216}
217
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000218def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000219 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000220 let InstructionSet = X86InstrInfo;
Chris Lattner56832602004-10-03 20:36:57 +0000221
Daniel Dunbar00331992009-07-29 00:02:19 +0000222 let AssemblyParsers = [ATTAsmParser];
223
Chris Lattner56832602004-10-03 20:36:57 +0000224 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000225}