ARM: diagnose ARM/Thumb assembly switches on CPUs only supporting one.
[oota-llvm.git] / lib / Target / ARM / ARM.td
1 //===-- ARM.td - Describe the ARM Target Machine -----------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 //===----------------------------------------------------------------------===//
14 // Target-independent interfaces which we are implementing
15 //===----------------------------------------------------------------------===//
16
17 include "llvm/Target/Target.td"
18
19 //===----------------------------------------------------------------------===//
20 // ARM Subtarget state.
21 //
22
23 def ModeThumb  : SubtargetFeature<"thumb-mode", "InThumbMode", "true",
24                                   "Thumb mode">;
25
26 //===----------------------------------------------------------------------===//
27 // ARM Subtarget features.
28 //
29
30 def FeatureVFP2 : SubtargetFeature<"vfp2", "HasVFPv2", "true",
31                                    "Enable VFP2 instructions">;
32 def FeatureVFP3 : SubtargetFeature<"vfp3", "HasVFPv3", "true",
33                                    "Enable VFP3 instructions",
34                                    [FeatureVFP2]>;
35 def FeatureNEON : SubtargetFeature<"neon", "HasNEON", "true",
36                                    "Enable NEON instructions",
37                                    [FeatureVFP3]>;
38 def FeatureThumb2 : SubtargetFeature<"thumb2", "HasThumb2", "true",
39                                      "Enable Thumb2 instructions">;
40 def FeatureNoARM  : SubtargetFeature<"noarm", "NoARM", "true",
41                                      "Does not support ARM mode execution",
42                                      [ModeThumb]>;
43 def FeatureFP16   : SubtargetFeature<"fp16", "HasFP16", "true",
44                                      "Enable half-precision floating point">;
45 def FeatureVFP4   : SubtargetFeature<"vfp4", "HasVFPv4", "true",
46                                      "Enable VFP4 instructions",
47                                      [FeatureVFP3, FeatureFP16]>;
48 def FeatureD16    : SubtargetFeature<"d16", "HasD16", "true",
49                                      "Restrict VFP3 to 16 double registers">;
50 def FeatureHWDiv  : SubtargetFeature<"hwdiv", "HasHardwareDivide", "true",
51                                      "Enable divide instructions">;
52 def FeatureHWDivARM  : SubtargetFeature<"hwdiv-arm",
53                                         "HasHardwareDivideInARM", "true",
54                                       "Enable divide instructions in ARM mode">;
55 def FeatureT2XtPk : SubtargetFeature<"t2xtpk", "HasT2ExtractPack", "true",
56                                  "Enable Thumb2 extract and pack instructions">;
57 def FeatureDB     : SubtargetFeature<"db", "HasDataBarrier", "true",
58                                    "Has data barrier (dmb / dsb) instructions">;
59 def FeatureSlowFPBrcc : SubtargetFeature<"slow-fp-brcc", "SlowFPBrcc", "true",
60                                          "FP compare + branch is slow">;
61 def FeatureVFPOnlySP : SubtargetFeature<"fp-only-sp", "FPOnlySP", "true",
62                           "Floating point unit supports single precision only">;
63 def FeaturePerfMon : SubtargetFeature<"perfmon", "HasPerfMon", "true",
64                            "Enable support for Performance Monitor extensions">;
65 def FeatureTrustZone : SubtargetFeature<"trustzone", "HasTrustZone", "true",
66                           "Enable support for TrustZone security extensions">;
67
68 // Some processors have FP multiply-accumulate instructions that don't
69 // play nicely with other VFP / NEON instructions, and it's generally better
70 // to just not use them.
71 def FeatureHasSlowFPVMLx : SubtargetFeature<"slowfpvmlx", "SlowFPVMLx", "true",
72                                          "Disable VFP / NEON MAC instructions">;
73
74 // Cortex-A8 / A9 Advanced SIMD has multiplier accumulator forwarding.
75 def FeatureVMLxForwarding : SubtargetFeature<"vmlx-forwarding",
76                                        "HasVMLxForwarding", "true",
77                                        "Has multiplier accumulator forwarding">;
78
79 // Some processors benefit from using NEON instructions for scalar
80 // single-precision FP operations.
81 def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP",
82                                         "true",
83                                         "Use NEON for single precision FP">;
84
85 // Disable 32-bit to 16-bit narrowing for experimentation.
86 def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Pref32BitThumb", "true",
87                                              "Prefer 32-bit Thumb instrs">;
88
89 /// Some instructions update CPSR partially, which can add false dependency for
90 /// out-of-order implementation, e.g. Cortex-A9, unless each individual bit is
91 /// mapped to a separate physical register. Avoid partial CPSR update for these
92 /// processors.
93 def FeatureAvoidPartialCPSR : SubtargetFeature<"avoid-partial-cpsr",
94                                                "AvoidCPSRPartialUpdate", "true",
95                                  "Avoid CPSR partial update for OOO execution">;
96
97 def FeatureAvoidMOVsShOp : SubtargetFeature<"avoid-movs-shop",
98                                             "AvoidMOVsShifterOperand", "true",
99                                 "Avoid movs instructions with shifter operand">;
100
101 // Some processors perform return stack prediction. CodeGen should avoid issue
102 // "normal" call instructions to callees which do not return.
103 def FeatureHasRAS : SubtargetFeature<"ras", "HasRAS", "true",
104                                      "Has return address stack">;
105
106 /// Some M architectures don't have the DSP extension (v7E-M vs. v7M)
107 def FeatureDSPThumb2 : SubtargetFeature<"t2dsp", "Thumb2DSP", "true",
108                                  "Supports v7 DSP instructions in Thumb2">;
109
110 // Multiprocessing extension.
111 def FeatureMP : SubtargetFeature<"mp", "HasMPExtension", "true",
112                                  "Supports Multiprocessing extension">;
113
114 // M-series ISA?
115 def FeatureMClass : SubtargetFeature<"mclass", "IsMClass", "true",
116                                      "Is microcontroller profile ('M' series)">;
117
118 // Special TRAP encoding for NaCl, which looks like a TRAP in Thumb too.
119 // See ARMInstrInfo.td for details.
120 def FeatureNaClTrap : SubtargetFeature<"nacl-trap", "UseNaClTrap", "true",
121                                        "NaCl trap">;
122
123 // ARM ISAs.
124 def HasV4TOps   : SubtargetFeature<"v4t", "HasV4TOps", "true",
125                                    "Support ARM v4T instructions">;
126 def HasV5TOps   : SubtargetFeature<"v5t", "HasV5TOps", "true",
127                                    "Support ARM v5T instructions",
128                                    [HasV4TOps]>;
129 def HasV5TEOps  : SubtargetFeature<"v5te", "HasV5TEOps", "true",
130                              "Support ARM v5TE, v5TEj, and v5TExp instructions",
131                                    [HasV5TOps]>;
132 def HasV6Ops    : SubtargetFeature<"v6", "HasV6Ops", "true",
133                                    "Support ARM v6 instructions",
134                                    [HasV5TEOps]>;
135 def HasV6T2Ops  : SubtargetFeature<"v6t2", "HasV6T2Ops", "true",
136                                    "Support ARM v6t2 instructions",
137                                    [HasV6Ops, FeatureThumb2]>;
138 def HasV7Ops    : SubtargetFeature<"v7", "HasV7Ops", "true",
139                                    "Support ARM v7 instructions",
140                                    [HasV6T2Ops, FeaturePerfMon]>;
141
142 //===----------------------------------------------------------------------===//
143 // ARM Processors supported.
144 //
145
146 include "ARMSchedule.td"
147
148 // ARM processor families.
149 def ProcA5      : SubtargetFeature<"a5", "ARMProcFamily", "CortexA5",
150                                    "Cortex-A5 ARM processors",
151                                    [FeatureSlowFPBrcc, FeatureHasSlowFPVMLx,
152                                     FeatureVMLxForwarding, FeatureT2XtPk,
153                                     FeatureTrustZone]>;
154 def ProcA8      : SubtargetFeature<"a8", "ARMProcFamily", "CortexA8",
155                                    "Cortex-A8 ARM processors",
156                                    [FeatureSlowFPBrcc, FeatureHasSlowFPVMLx,
157                                     FeatureVMLxForwarding, FeatureT2XtPk,
158                                     FeatureTrustZone]>;
159 def ProcA9      : SubtargetFeature<"a9", "ARMProcFamily", "CortexA9",
160                                    "Cortex-A9 ARM processors",
161                                    [FeatureVMLxForwarding,
162                                     FeatureT2XtPk, FeatureFP16,
163                                     FeatureAvoidPartialCPSR,
164                                     FeatureTrustZone]>;
165 def ProcSwift   : SubtargetFeature<"swift", "ARMProcFamily", "Swift",
166                                    "Swift ARM processors",
167                                    [FeatureNEONForFP, FeatureT2XtPk,
168                                     FeatureVFP4, FeatureMP, FeatureHWDiv,
169                                     FeatureHWDivARM, FeatureAvoidPartialCPSR,
170                                     FeatureAvoidMOVsShOp,
171                                     FeatureHasSlowFPVMLx, FeatureTrustZone]>;
172
173 // FIXME: It has not been determined if A15 has these features.
174 def ProcA15      : SubtargetFeature<"a15", "ARMProcFamily", "CortexA15",
175                                    "Cortex-A15 ARM processors",
176                                    [FeatureT2XtPk, FeatureFP16,
177                                     FeatureAvoidPartialCPSR,
178                                     FeatureTrustZone]>;
179 def ProcR5      : SubtargetFeature<"r5", "ARMProcFamily", "CortexR5",
180                                    "Cortex-R5 ARM processors",
181                                    [FeatureSlowFPBrcc,
182                                     FeatureHWDiv, FeatureHWDivARM,
183                                     FeatureHasSlowFPVMLx,
184                                     FeatureAvoidPartialCPSR,
185                                     FeatureT2XtPk]>;
186
187 class ProcNoItin<string Name, list<SubtargetFeature> Features>
188  : Processor<Name, NoItineraries, Features>;
189
190 // V4 Processors.
191 def : ProcNoItin<"generic",         []>;
192 def : ProcNoItin<"arm8",            []>;
193 def : ProcNoItin<"arm810",          []>;
194 def : ProcNoItin<"strongarm",       []>;
195 def : ProcNoItin<"strongarm110",    []>;
196 def : ProcNoItin<"strongarm1100",   []>;
197 def : ProcNoItin<"strongarm1110",   []>;
198
199 // V4T Processors.
200 def : ProcNoItin<"arm7tdmi",        [HasV4TOps]>;
201 def : ProcNoItin<"arm7tdmi-s",      [HasV4TOps]>;
202 def : ProcNoItin<"arm710t",         [HasV4TOps]>;
203 def : ProcNoItin<"arm720t",         [HasV4TOps]>;
204 def : ProcNoItin<"arm9",            [HasV4TOps]>;
205 def : ProcNoItin<"arm9tdmi",        [HasV4TOps]>;
206 def : ProcNoItin<"arm920",          [HasV4TOps]>;
207 def : ProcNoItin<"arm920t",         [HasV4TOps]>;
208 def : ProcNoItin<"arm922t",         [HasV4TOps]>;
209 def : ProcNoItin<"arm940t",         [HasV4TOps]>;
210 def : ProcNoItin<"ep9312",          [HasV4TOps]>;
211
212 // V5T Processors.
213 def : ProcNoItin<"arm10tdmi",       [HasV5TOps]>;
214 def : ProcNoItin<"arm1020t",        [HasV5TOps]>;
215
216 // V5TE Processors.
217 def : ProcNoItin<"arm9e",           [HasV5TEOps]>;
218 def : ProcNoItin<"arm926ej-s",      [HasV5TEOps]>;
219 def : ProcNoItin<"arm946e-s",       [HasV5TEOps]>;
220 def : ProcNoItin<"arm966e-s",       [HasV5TEOps]>;
221 def : ProcNoItin<"arm968e-s",       [HasV5TEOps]>;
222 def : ProcNoItin<"arm10e",          [HasV5TEOps]>;
223 def : ProcNoItin<"arm1020e",        [HasV5TEOps]>;
224 def : ProcNoItin<"arm1022e",        [HasV5TEOps]>;
225 def : ProcNoItin<"xscale",          [HasV5TEOps]>;
226 def : ProcNoItin<"iwmmxt",          [HasV5TEOps]>;
227
228 // V6 Processors.
229 def : Processor<"arm1136j-s",       ARMV6Itineraries, [HasV6Ops]>;
230 def : Processor<"arm1136jf-s",      ARMV6Itineraries, [HasV6Ops, FeatureVFP2,
231                                                        FeatureHasSlowFPVMLx]>;
232 def : Processor<"arm1176jz-s",      ARMV6Itineraries, [HasV6Ops]>;
233 def : Processor<"arm1176jzf-s",     ARMV6Itineraries, [HasV6Ops, FeatureVFP2,
234                                                        FeatureHasSlowFPVMLx]>;
235 def : Processor<"mpcorenovfp",      ARMV6Itineraries, [HasV6Ops]>;
236 def : Processor<"mpcore",           ARMV6Itineraries, [HasV6Ops, FeatureVFP2,
237                                                        FeatureHasSlowFPVMLx]>;
238
239 // V6M Processors.
240 def : Processor<"cortex-m0",        ARMV6Itineraries, [HasV6Ops, FeatureNoARM,
241                                                        FeatureDB, FeatureMClass]>;
242
243 // V6T2 Processors.
244 def : Processor<"arm1156t2-s",      ARMV6Itineraries, [HasV6T2Ops,
245                                                        FeatureDSPThumb2]>;
246 def : Processor<"arm1156t2f-s",     ARMV6Itineraries, [HasV6T2Ops, FeatureVFP2,
247                                                        FeatureHasSlowFPVMLx,
248                                                        FeatureDSPThumb2]>;
249
250 // V7a Processors.
251 // FIXME: A5 has currently the same Schedule model as A8
252 def : ProcessorModel<"cortex-a5",   CortexA8Model,
253                                     [ProcA5, HasV7Ops, FeatureNEON, FeatureDB,
254                                      FeatureVFP4, FeatureDSPThumb2,
255                                      FeatureHasRAS]>;
256 def : ProcessorModel<"cortex-a8",   CortexA8Model,
257                                     [ProcA8, HasV7Ops, FeatureNEON, FeatureDB,
258                                      FeatureDSPThumb2, FeatureHasRAS]>;
259 def : ProcessorModel<"cortex-a9",   CortexA9Model,
260                                     [ProcA9, HasV7Ops, FeatureNEON, FeatureDB,
261                                      FeatureDSPThumb2, FeatureHasRAS]>;
262 def : ProcessorModel<"cortex-a9-mp", CortexA9Model,
263                                     [ProcA9, HasV7Ops, FeatureNEON, FeatureDB,
264                                      FeatureDSPThumb2, FeatureMP,
265                                      FeatureHasRAS]>;
266 // FIXME: A15 has currently the same ProcessorModel as A9.
267 def : ProcessorModel<"cortex-a15",   CortexA9Model,
268                                     [ProcA15, HasV7Ops, FeatureNEON, FeatureDB,
269                                      FeatureDSPThumb2, FeatureHasRAS]>;
270 // FIXME: R5 has currently the same ProcessorModel as A8.
271 def : ProcessorModel<"cortex-r5",   CortexA8Model,
272                                     [ProcR5, HasV7Ops, FeatureDB,
273                                      FeatureVFP3, FeatureDSPThumb2,
274                                      FeatureHasRAS]>;
275
276 // V7M Processors.
277 def : ProcNoItin<"cortex-m3",       [HasV7Ops,
278                                      FeatureThumb2, FeatureNoARM, FeatureDB,
279                                      FeatureHWDiv, FeatureMClass]>;
280
281 // V7EM Processors.
282 def : ProcNoItin<"cortex-m4",       [HasV7Ops,
283                                      FeatureThumb2, FeatureNoARM, FeatureDB,
284                                      FeatureHWDiv, FeatureDSPThumb2,
285                                      FeatureT2XtPk, FeatureVFP4,
286                                      FeatureVFPOnlySP, FeatureMClass]>;
287
288 // Swift uArch Processors.
289 def : ProcessorModel<"swift",       SwiftModel,
290                                     [ProcSwift, HasV7Ops, FeatureNEON,
291                                      FeatureDB, FeatureDSPThumb2,
292                                      FeatureHasRAS]>;
293
294 //===----------------------------------------------------------------------===//
295 // Register File Description
296 //===----------------------------------------------------------------------===//
297
298 include "ARMRegisterInfo.td"
299
300 include "ARMCallingConv.td"
301
302 //===----------------------------------------------------------------------===//
303 // Instruction Descriptions
304 //===----------------------------------------------------------------------===//
305
306 include "ARMInstrInfo.td"
307
308 def ARMInstrInfo : InstrInfo;
309
310
311 //===----------------------------------------------------------------------===//
312 // Assembly printer
313 //===----------------------------------------------------------------------===//
314 // ARM Uses the MC printer for asm output, so make sure the TableGen
315 // AsmWriter bits get associated with the correct class.
316 def ARMAsmWriter : AsmWriter {
317   string AsmWriterClassName  = "InstPrinter";
318   bit isMCAsmWriter = 1;
319 }
320
321 //===----------------------------------------------------------------------===//
322 // Declare the target which we are implementing
323 //===----------------------------------------------------------------------===//
324
325 def ARM : Target {
326   // Pull in Instruction Info:
327   let InstructionSet = ARMInstrInfo;
328
329   let AssemblyWriters = [ARMAsmWriter];
330 }