blob: 7919559058b1c8f280bf7156c581d3595c4cb3b9 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This is a target description file for the Intel i386 architecture, refered to
11// here as the "X86" architecture.
12//
13//===----------------------------------------------------------------------===//
14
15// Get the target-independent interfaces which we are implementing...
16//
Evan Cheng301aaf52008-11-24 07:34:46 +000017include "llvm/Target/Target.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018
19//===----------------------------------------------------------------------===//
20// X86 Subtarget features.
21//===----------------------------------------------------------------------===//
Chris Lattner556464f2009-09-02 05:53:04 +000022
23def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
24 "Enable conditional move instructions">;
25
David Greene5235d412010-01-11 16:29:42 +000026
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
28 "Enable MMX instructions">;
29def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
30 "Enable SSE instructions",
Chris Lattner556464f2009-09-02 05:53:04 +000031 // SSE codegen depends on cmovs, and all
32 // SSE1+ processors support them.
33 [FeatureMMX, FeatureCMOV]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
35 "Enable SSE2 instructions",
36 [FeatureSSE1]>;
37def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
38 "Enable SSE3 instructions",
39 [FeatureSSE2]>;
40def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
41 "Enable SSSE3 instructions",
42 [FeatureSSE3]>;
Nate Begemanb2975562008-02-03 07:18:54 +000043def FeatureSSE41 : SubtargetFeature<"sse41", "X86SSELevel", "SSE41",
44 "Enable SSE 4.1 instructions",
45 [FeatureSSSE3]>;
46def FeatureSSE42 : SubtargetFeature<"sse42", "X86SSELevel", "SSE42",
47 "Enable SSE 4.2 instructions",
48 [FeatureSSE41]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
50 "Enable 3DNow! instructions">;
51def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
52 "Enable 3DNow! Athlon instructions",
53 [Feature3DNow]>;
Dan Gohman4092bbc2009-02-03 00:04:43 +000054// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
55// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
56// without disabling 64-bit mode.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Dan Gohman4092bbc2009-02-03 00:04:43 +000058 "Support 64-bit instructions">;
Evan Cheng95a77fd2009-01-02 05:35:45 +000059def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
60 "Bit testing of memory is slow">;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +000061def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
62 "Support SSE 4a instructions">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063
David Greene8bf22bc2009-06-26 22:46:54 +000064def FeatureAVX : SubtargetFeature<"avx", "HasAVX", "true",
65 "Enable AVX instructions">;
66def FeatureFMA3 : SubtargetFeature<"fma3", "HasFMA3", "true",
Sean Callanan2c48df22009-12-18 00:01:26 +000067 "Enable three-operand fused multiple-add">;
David Greene8bf22bc2009-06-26 22:46:54 +000068def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
69 "Enable four-operand fused multiple-add">;
David Greene5235d412010-01-11 16:29:42 +000070def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
71 "HasVectorUAMem", "true",
72 "Allow unaligned memory operands on vector/SIMD instructions">;
David Greene8bf22bc2009-06-26 22:46:54 +000073
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074//===----------------------------------------------------------------------===//
75// X86 processors supported.
76//===----------------------------------------------------------------------===//
77
78class Proc<string Name, list<SubtargetFeature> Features>
79 : Processor<Name, NoItineraries, Features>;
80
81def : Proc<"generic", []>;
82def : Proc<"i386", []>;
83def : Proc<"i486", []>;
Dale Johannesen68a99ca2008-10-14 22:06:33 +000084def : Proc<"i586", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085def : Proc<"pentium", []>;
86def : Proc<"pentium-mmx", [FeatureMMX]>;
87def : Proc<"i686", []>;
Chris Lattner556464f2009-09-02 05:53:04 +000088def : Proc<"pentiumpro", [FeatureCMOV]>;
89def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090def : Proc<"pentium3", [FeatureSSE1]>;
Evan Cheng95a77fd2009-01-02 05:35:45 +000091def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092def : Proc<"pentium4", [FeatureSSE2]>;
Evan Chengd53fca12009-12-22 17:47:23 +000093def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>;
94def : Proc<"yonah", [FeatureSSE3, FeatureSlowBTMem]>;
95def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
96def : Proc<"nocona", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
97def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>;
98def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>;
99def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
100def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>;
101def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>;
David Greene8bf22bc2009-06-26 22:46:54 +0000102// Sandy Bridge does not have FMA
Evan Chengd53fca12009-12-22 17:47:23 +0000103def : Proc<"sandybridge", [FeatureSSE42, FeatureAVX, Feature64Bit]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
105def : Proc<"k6", [FeatureMMX]>;
106def : Proc<"k6-2", [FeatureMMX, Feature3DNow]>;
107def : Proc<"k6-3", [FeatureMMX, Feature3DNow]>;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000108def : Proc<"athlon", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
109def : Proc<"athlon-tbird", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
110def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
111def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
112def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
Dan Gohman4092bbc2009-02-03 00:04:43 +0000113def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
114 FeatureSlowBTMem]>;
115def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
116 FeatureSlowBTMem]>;
117def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
118 FeatureSlowBTMem]>;
119def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
120 FeatureSlowBTMem]>;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000121def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
122 FeatureSlowBTMem]>;
123def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
124 FeatureSlowBTMem]>;
125def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
126 FeatureSlowBTMem]>;
127def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A,
128 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
129def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A,
130 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
David Greene7f4cb852009-06-29 16:54:06 +0000131def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
132 Feature3DNowA]>;
133def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
134 Feature3DNowA]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def : Proc<"winchip-c6", [FeatureMMX]>;
137def : Proc<"winchip2", [FeatureMMX, Feature3DNow]>;
138def : Proc<"c3", [FeatureMMX, Feature3DNow]>;
139def : Proc<"c3-2", [FeatureSSE1]>;
140
141//===----------------------------------------------------------------------===//
142// Register File Description
143//===----------------------------------------------------------------------===//
144
145include "X86RegisterInfo.td"
146
147//===----------------------------------------------------------------------===//
148// Instruction Descriptions
149//===----------------------------------------------------------------------===//
150
151include "X86InstrInfo.td"
152
153def X86InstrInfo : InstrInfo {
154
155 // Define how we want to layout our TargetSpecific information field... This
156 // should be kept up-to-date with the fields in the X86InstrInfo.h file.
157 let TSFlagsFields = ["FormBits",
158 "hasOpSizePrefix",
159 "hasAdSizePrefix",
160 "Prefix",
161 "hasREX_WPrefix",
162 "ImmTypeBits",
163 "FPFormBits",
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +0000164 "hasLockPrefix",
Anton Korobeynikov975e1472008-10-11 19:09:15 +0000165 "SegOvrBits",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 "Opcode"];
167 let TSFlagsShifts = [0,
168 6,
169 7,
170 8,
Chris Lattnerd262f502010-02-12 01:55:31 +0000171 12,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 13,
Chris Lattnerd262f502010-02-12 01:55:31 +0000173 16,
174 19,
Anton Korobeynikov975e1472008-10-11 19:09:15 +0000175 20,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 24];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177}
178
179//===----------------------------------------------------------------------===//
180// Calling Conventions
181//===----------------------------------------------------------------------===//
182
183include "X86CallingConv.td"
184
185
186//===----------------------------------------------------------------------===//
187// Assembly Printers
188//===----------------------------------------------------------------------===//
189
Daniel Dunbar85f1b392009-07-29 00:02:19 +0000190// Currently the X86 assembly parser only supports ATT syntax.
191def ATTAsmParser : AsmParser {
192 string AsmParserClassName = "ATTAsmParser";
193 int Variant = 0;
Daniel Dunbara6d04732009-08-11 20:59:47 +0000194
195 // Discard comments in assembly strings.
196 string CommentDelimiter = "#";
197
198 // Recognize hard coded registers.
199 string RegisterPrefix = "%";
Daniel Dunbar85f1b392009-07-29 00:02:19 +0000200}
201
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202// The X86 target supports two different syntaxes for emitting machine code.
203// This is controlled by the -x86-asm-syntax={att|intel}
204def ATTAsmWriter : AsmWriter {
Chris Lattner59a6e612009-09-13 19:30:11 +0000205 string AsmWriterClassName = "ATTInstPrinter";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 int Variant = 0;
207}
208def IntelAsmWriter : AsmWriter {
Chris Lattnerf0544b62009-09-20 07:47:59 +0000209 string AsmWriterClassName = "IntelInstPrinter";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 int Variant = 1;
211}
212
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213def X86 : Target {
214 // Information about the instructions...
215 let InstructionSet = X86InstrInfo;
216
Daniel Dunbar85f1b392009-07-29 00:02:19 +0000217 let AssemblyParsers = [ATTAsmParser];
218
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
220}