1 //===-- ARM.td - Describe the ARM Target Machine -----------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // Target-independent interfaces which we are implementing
15 //===----------------------------------------------------------------------===//
17 include "llvm/Target/Target.td"
19 //===----------------------------------------------------------------------===//
20 // ARM Helper classes.
23 class ProcNoItin<string Name, list<SubtargetFeature> Features>
24 : Processor<Name, NoItineraries, Features>;
26 class Architecture<string fname, string aname, list<SubtargetFeature> features >
27 : SubtargetFeature<fname, "ARMArch", aname,
28 !strconcat(aname, " architecture"), features>;
30 //===----------------------------------------------------------------------===//
31 // ARM Subtarget state.
34 def ModeThumb : SubtargetFeature<"thumb-mode", "InThumbMode", "true",
37 def ModeSoftFloat : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
38 "Use software floating point features.">;
40 //===----------------------------------------------------------------------===//
41 // ARM Subtarget features.
44 def FeatureVFP2 : SubtargetFeature<"vfp2", "HasVFPv2", "true",
45 "Enable VFP2 instructions">;
46 def FeatureVFP3 : SubtargetFeature<"vfp3", "HasVFPv3", "true",
47 "Enable VFP3 instructions",
49 def FeatureNEON : SubtargetFeature<"neon", "HasNEON", "true",
50 "Enable NEON instructions",
52 def FeatureThumb2 : SubtargetFeature<"thumb2", "HasThumb2", "true",
53 "Enable Thumb2 instructions">;
54 def FeatureNoARM : SubtargetFeature<"noarm", "NoARM", "true",
55 "Does not support ARM mode execution",
57 def FeatureFP16 : SubtargetFeature<"fp16", "HasFP16", "true",
58 "Enable half-precision floating point">;
59 def FeatureVFP4 : SubtargetFeature<"vfp4", "HasVFPv4", "true",
60 "Enable VFP4 instructions",
61 [FeatureVFP3, FeatureFP16]>;
62 def FeatureFPARMv8 : SubtargetFeature<"fp-armv8", "HasFPARMv8",
63 "true", "Enable ARMv8 FP",
65 def FeatureD16 : SubtargetFeature<"d16", "HasD16", "true",
66 "Restrict FP to 16 double registers">;
67 def FeatureHWDiv : SubtargetFeature<"hwdiv", "HasHardwareDivide", "true",
68 "Enable divide instructions">;
69 def FeatureHWDivARM : SubtargetFeature<"hwdiv-arm",
70 "HasHardwareDivideInARM", "true",
71 "Enable divide instructions in ARM mode">;
72 def FeatureT2XtPk : SubtargetFeature<"t2xtpk", "HasT2ExtractPack", "true",
73 "Enable Thumb2 extract and pack instructions">;
74 def FeatureDB : SubtargetFeature<"db", "HasDataBarrier", "true",
75 "Has data barrier (dmb / dsb) instructions">;
76 def FeatureSlowFPBrcc : SubtargetFeature<"slow-fp-brcc", "SlowFPBrcc", "true",
77 "FP compare + branch is slow">;
78 def FeatureVFPOnlySP : SubtargetFeature<"fp-only-sp", "FPOnlySP", "true",
79 "Floating point unit supports single precision only">;
80 def FeaturePerfMon : SubtargetFeature<"perfmon", "HasPerfMon", "true",
81 "Enable support for Performance Monitor extensions">;
82 def FeatureTrustZone : SubtargetFeature<"trustzone", "HasTrustZone", "true",
83 "Enable support for TrustZone security extensions">;
84 def FeatureCrypto : SubtargetFeature<"crypto", "HasCrypto", "true",
85 "Enable support for Cryptography extensions",
87 def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true",
88 "Enable support for CRC instructions">;
90 // Cyclone has preferred instructions for zeroing VFP registers, which can
91 // execute in 0 cycles.
92 def FeatureZCZeroing : SubtargetFeature<"zcz", "HasZeroCycleZeroing", "true",
93 "Has zero-cycle zeroing instructions">;
95 // Some processors have FP multiply-accumulate instructions that don't
96 // play nicely with other VFP / NEON instructions, and it's generally better
97 // to just not use them.
98 def FeatureHasSlowFPVMLx : SubtargetFeature<"slowfpvmlx", "SlowFPVMLx", "true",
99 "Disable VFP / NEON MAC instructions">;
101 // Cortex-A8 / A9 Advanced SIMD has multiplier accumulator forwarding.
102 def FeatureVMLxForwarding : SubtargetFeature<"vmlx-forwarding",
103 "HasVMLxForwarding", "true",
104 "Has multiplier accumulator forwarding">;
106 // Some processors benefit from using NEON instructions for scalar
107 // single-precision FP operations.
108 def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP",
110 "Use NEON for single precision FP">;
112 // Disable 32-bit to 16-bit narrowing for experimentation.
113 def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Pref32BitThumb", "true",
114 "Prefer 32-bit Thumb instrs">;
116 /// Some instructions update CPSR partially, which can add false dependency for
117 /// out-of-order implementation, e.g. Cortex-A9, unless each individual bit is
118 /// mapped to a separate physical register. Avoid partial CPSR update for these
120 def FeatureAvoidPartialCPSR : SubtargetFeature<"avoid-partial-cpsr",
121 "AvoidCPSRPartialUpdate", "true",
122 "Avoid CPSR partial update for OOO execution">;
124 def FeatureAvoidMOVsShOp : SubtargetFeature<"avoid-movs-shop",
125 "AvoidMOVsShifterOperand", "true",
126 "Avoid movs instructions with shifter operand">;
128 // Some processors perform return stack prediction. CodeGen should avoid issue
129 // "normal" call instructions to callees which do not return.
130 def FeatureHasRAS : SubtargetFeature<"ras", "HasRAS", "true",
131 "Has return address stack">;
134 def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true",
135 "Supports DSP instructions in ARM and/or Thumb2">;
137 // Multiprocessing extension.
138 def FeatureMP : SubtargetFeature<"mp", "HasMPExtension", "true",
139 "Supports Multiprocessing extension">;
141 // Virtualization extension - requires HW divide (ARMv7-AR ARMARM - 4.4.8).
142 def FeatureVirtualization : SubtargetFeature<"virtualization",
143 "HasVirtualization", "true",
144 "Supports Virtualization extension",
145 [FeatureHWDiv, FeatureHWDivARM]>;
148 def FeatureMClass : SubtargetFeature<"mclass", "ARMProcClass", "MClass",
149 "Is microcontroller profile ('M' series)">;
152 def FeatureRClass : SubtargetFeature<"rclass", "ARMProcClass", "RClass",
153 "Is realtime profile ('R' series)">;
156 def FeatureAClass : SubtargetFeature<"aclass", "ARMProcClass", "AClass",
157 "Is application profile ('A' series)">;
159 // Special TRAP encoding for NaCl, which looks like a TRAP in Thumb too.
160 // See ARMInstrInfo.td for details.
161 def FeatureNaClTrap : SubtargetFeature<"nacl-trap", "UseNaClTrap", "true",
164 def FeatureStrictAlign : SubtargetFeature<"strict-align",
165 "StrictAlign", "true",
166 "Disallow all unaligned memory "
169 def FeatureLongCalls : SubtargetFeature<"long-calls", "GenLongCalls", "true",
170 "Generate calls via indirect call "
173 def FeatureReserveR9 : SubtargetFeature<"reserve-r9", "ReserveR9", "true",
174 "Reserve R9, making it unavailable as "
177 def FeatureNoMovt : SubtargetFeature<"no-movt", "NoMovt", "true",
178 "Don't use movt/movw pairs for 32-bit "
182 //===----------------------------------------------------------------------===//
186 def HasV4TOps : SubtargetFeature<"v4t", "HasV4TOps", "true",
187 "Support ARM v4T instructions">;
188 def HasV5TOps : SubtargetFeature<"v5t", "HasV5TOps", "true",
189 "Support ARM v5T instructions",
191 def HasV5TEOps : SubtargetFeature<"v5te", "HasV5TEOps", "true",
192 "Support ARM v5TE, v5TEj, and v5TExp instructions",
194 def HasV6Ops : SubtargetFeature<"v6", "HasV6Ops", "true",
195 "Support ARM v6 instructions",
197 def HasV6MOps : SubtargetFeature<"v6m", "HasV6MOps", "true",
198 "Support ARM v6M instructions",
200 def HasV6KOps : SubtargetFeature<"v6k", "HasV6KOps", "true",
201 "Support ARM v6k instructions",
203 def HasV6T2Ops : SubtargetFeature<"v6t2", "HasV6T2Ops", "true",
204 "Support ARM v6t2 instructions",
205 [HasV6MOps, HasV6KOps, FeatureThumb2]>;
206 def HasV7Ops : SubtargetFeature<"v7", "HasV7Ops", "true",
207 "Support ARM v7 instructions",
208 [HasV6T2Ops, FeaturePerfMon]>;
209 def HasV8Ops : SubtargetFeature<"v8", "HasV8Ops", "true",
210 "Support ARM v8 instructions",
212 def HasV8_1aOps : SubtargetFeature<"v8.1a", "HasV8_1aOps", "true",
213 "Support ARM v8.1a instructions",
217 //===----------------------------------------------------------------------===//
218 // ARM Processor subtarget features.
221 def ProcA5 : SubtargetFeature<"a5", "ARMProcFamily", "CortexA5",
222 "Cortex-A5 ARM processors", []>;
223 def ProcA7 : SubtargetFeature<"a7", "ARMProcFamily", "CortexA7",
224 "Cortex-A7 ARM processors", []>;
225 def ProcA8 : SubtargetFeature<"a8", "ARMProcFamily", "CortexA8",
226 "Cortex-A8 ARM processors", []>;
227 def ProcA9 : SubtargetFeature<"a9", "ARMProcFamily", "CortexA9",
228 "Cortex-A9 ARM processors", []>;
229 def ProcA12 : SubtargetFeature<"a12", "ARMProcFamily", "CortexA12",
230 "Cortex-A12 ARM processors", []>;
231 def ProcA15 : SubtargetFeature<"a15", "ARMProcFamily", "CortexA15",
232 "Cortex-A15 ARM processors", []>;
233 def ProcA17 : SubtargetFeature<"a17", "ARMProcFamily", "CortexA17",
234 "Cortex-A17 ARM processors", []>;
235 def ProcA53 : SubtargetFeature<"a53", "ARMProcFamily", "CortexA53",
236 "Cortex-A53 ARM processors", []>;
237 def ProcA57 : SubtargetFeature<"a57", "ARMProcFamily", "CortexA57",
238 "Cortex-A57 ARM processors", []>;
239 def ProcA72 : SubtargetFeature<"a72", "ARMProcFamily", "CortexA72",
240 "Cortex-A72 ARM processors", []>;
242 def ProcKrait : SubtargetFeature<"krait", "ARMProcFamily", "Krait",
243 "Qualcomm ARM processors", []>;
244 def ProcSwift : SubtargetFeature<"swift", "ARMProcFamily", "Swift",
245 "Swift ARM processors", []>;
248 def ProcR4 : SubtargetFeature<"r4", "ARMProcFamily", "CortexR4",
249 "Cortex-R4 ARM processors", []>;
250 def ProcR5 : SubtargetFeature<"r5", "ARMProcFamily", "CortexR5",
251 "Cortex-R5 ARM processors", []>;
252 def ProcR7 : SubtargetFeature<"r7", "ARMProcFamily", "CortexR7",
253 "Cortex-R7 ARM processors", []>;
256 //===----------------------------------------------------------------------===//
260 include "ARMSchedule.td"
263 //===----------------------------------------------------------------------===//
267 def ARMv2 : Architecture<"armv2", "ARMv2", []>;
269 def ARMv2a : Architecture<"armv2a", "ARMv2a", []>;
271 def ARMv3 : Architecture<"armv3", "ARMv3", []>;
273 def ARMv3m : Architecture<"armv3m", "ARMv3m", []>;
275 def ARMv4 : Architecture<"armv4", "ARMv4", []>;
277 def ARMv4t : Architecture<"armv4t", "ARMv4t", [HasV4TOps]>;
279 def ARMv5t : Architecture<"armv5t", "ARMv5t", [HasV5TOps]>;
281 def ARMv5te : Architecture<"armv5te", "ARMv5te", [HasV5TEOps]>;
283 def ARMv5tej : Architecture<"armv5tej", "ARMv5tej", [HasV5TEOps]>;
285 def ARMv6 : Architecture<"armv6", "ARMv6", [HasV6Ops]>;
287 def ARMv6t2 : Architecture<"armv6t2", "ARMv6t2", [HasV6T2Ops,
290 def ARMv6k : Architecture<"armv6k", "ARMv6k", [HasV6KOps]>;
292 def ARMv6kz : Architecture<"armv6kz", "ARMv6kz", [HasV6KOps,
295 def ARMv6m : Architecture<"armv6-m", "ARMv6m", [HasV6MOps,
300 def ARMv6sm : Architecture<"armv6s-m", "ARMv6sm", [HasV6MOps,
305 def ARMv7a : Architecture<"armv7-a", "ARMv7a", [HasV7Ops,
311 def ARMv7r : Architecture<"armv7-r", "ARMv7r", [HasV7Ops,
317 def ARMv7m : Architecture<"armv7-m", "ARMv7m", [HasV7Ops,
324 def ARMv7em : Architecture<"armv7e-m", "ARMv7em", [HasV7Ops,
333 def ARMv8a : Architecture<"armv8-a", "ARMv8a", [HasV8Ops,
341 FeatureVirtualization,
345 def ARMv81a : Architecture<"armv8.1-a", "ARMv81a", [HasV8_1aOps,
353 FeatureVirtualization,
358 def IWMMXT : Architecture<"iwmmxt", "ARMv5te", [ARMv5te]>;
359 def IWMMXT2 : Architecture<"iwmmxt2", "ARMv5te", [ARMv5te]>;
360 def XScale : Architecture<"xscale", "ARMv5te", [ARMv5te]>;
361 def ARMv6j : Architecture<"armv6j", "ARMv7a", [ARMv6]>;
362 def ARMv7k : Architecture<"armv7k", "ARMv7a", [ARMv7a]>;
363 def ARMv7s : Architecture<"armv7s", "ARMv7a", [ARMv7a]>;
366 //===----------------------------------------------------------------------===//
370 // Dummy CPU, used to target architectures
371 def : ProcNoItin<"generic", []>;
373 def : ProcNoItin<"arm8", [ARMv4]>;
374 def : ProcNoItin<"arm810", [ARMv4]>;
375 def : ProcNoItin<"strongarm", [ARMv4]>;
376 def : ProcNoItin<"strongarm110", [ARMv4]>;
377 def : ProcNoItin<"strongarm1100", [ARMv4]>;
378 def : ProcNoItin<"strongarm1110", [ARMv4]>;
380 def : ProcNoItin<"arm7tdmi", [ARMv4t]>;
381 def : ProcNoItin<"arm7tdmi-s", [ARMv4t]>;
382 def : ProcNoItin<"arm710t", [ARMv4t]>;
383 def : ProcNoItin<"arm720t", [ARMv4t]>;
384 def : ProcNoItin<"arm9", [ARMv4t]>;
385 def : ProcNoItin<"arm9tdmi", [ARMv4t]>;
386 def : ProcNoItin<"arm920", [ARMv4t]>;
387 def : ProcNoItin<"arm920t", [ARMv4t]>;
388 def : ProcNoItin<"arm922t", [ARMv4t]>;
389 def : ProcNoItin<"arm940t", [ARMv4t]>;
390 def : ProcNoItin<"ep9312", [ARMv4t]>;
392 def : ProcNoItin<"arm10tdmi", [ARMv5t]>;
393 def : ProcNoItin<"arm1020t", [ARMv5t]>;
395 def : ProcNoItin<"arm9e", [ARMv5te]>;
396 def : ProcNoItin<"arm926ej-s", [ARMv5te]>;
397 def : ProcNoItin<"arm946e-s", [ARMv5te]>;
398 def : ProcNoItin<"arm966e-s", [ARMv5te]>;
399 def : ProcNoItin<"arm968e-s", [ARMv5te]>;
400 def : ProcNoItin<"arm10e", [ARMv5te]>;
401 def : ProcNoItin<"arm1020e", [ARMv5te]>;
402 def : ProcNoItin<"arm1022e", [ARMv5te]>;
403 def : ProcNoItin<"xscale", [ARMv5te]>;
404 def : ProcNoItin<"iwmmxt", [ARMv5te]>;
406 def : Processor<"arm1136j-s", ARMV6Itineraries, [ARMv6]>;
407 def : Processor<"arm1136jf-s", ARMV6Itineraries, [ARMv6,
409 FeatureHasSlowFPVMLx]>;
411 def : Processor<"cortex-m0", ARMV6Itineraries, [ARMv6m]>;
412 def : Processor<"cortex-m0plus", ARMV6Itineraries, [ARMv6m]>;
413 def : Processor<"cortex-m1", ARMV6Itineraries, [ARMv6m]>;
414 def : Processor<"sc000", ARMV6Itineraries, [ARMv6m]>;
416 def : Processor<"arm1176jz-s", ARMV6Itineraries, [ARMv6kz]>;
417 def : Processor<"arm1176jzf-s", ARMV6Itineraries, [ARMv6kz,
419 FeatureHasSlowFPVMLx]>;
421 def : Processor<"mpcorenovfp", ARMV6Itineraries, [ARMv6k]>;
422 def : Processor<"mpcore", ARMV6Itineraries, [ARMv6k,
424 FeatureHasSlowFPVMLx]>;
426 def : Processor<"arm1156t2-s", ARMV6Itineraries, [ARMv6t2]>;
427 def : Processor<"arm1156t2f-s", ARMV6Itineraries, [ARMv6t2,
429 FeatureHasSlowFPVMLx]>;
431 // FIXME: A5 has currently the same Schedule model as A8
432 def : ProcessorModel<"cortex-a5", CortexA8Model, [ARMv7a, ProcA5,
436 FeatureHasSlowFPVMLx,
437 FeatureVMLxForwarding,
442 def : ProcessorModel<"cortex-a7", CortexA8Model, [ARMv7a, ProcA7,
446 FeatureHasSlowFPVMLx,
447 FeatureVMLxForwarding,
453 FeatureVirtualization]>;
455 def : ProcessorModel<"cortex-a8", CortexA8Model, [ARMv7a, ProcA8,
459 FeatureHasSlowFPVMLx,
460 FeatureVMLxForwarding,
463 def : ProcessorModel<"cortex-a9", CortexA9Model, [ARMv7a, ProcA9,
466 FeatureVMLxForwarding,
469 FeatureAvoidPartialCPSR,
472 // FIXME: A12 has currently the same Schedule model as A9
473 def : ProcessorModel<"cortex-a12", CortexA9Model, [ARMv7a, ProcA12,
476 FeatureVMLxForwarding,
481 FeatureAvoidPartialCPSR,
482 FeatureVirtualization,
485 // FIXME: A15 has currently the same Schedule model as A9.
486 def : ProcessorModel<"cortex-a15", CortexA9Model, [ARMv7a, ProcA15,
494 FeatureAvoidPartialCPSR,
495 FeatureVirtualization]>;
497 // FIXME: A17 has currently the same Schedule model as A9
498 def : ProcessorModel<"cortex-a17", CortexA9Model, [ARMv7a, ProcA17,
502 FeatureVMLxForwarding,
507 FeatureAvoidPartialCPSR,
508 FeatureVirtualization]>;
510 // FIXME: krait has currently the same Schedule model as A9
511 // FIXME: krait has currently the same features as A9 plus VFP4 and hardware
512 // division features.
513 def : ProcessorModel<"krait", CortexA9Model, [ARMv7a, ProcKrait,
515 FeatureVMLxForwarding,
518 FeatureAvoidPartialCPSR,
523 def : ProcessorModel<"swift", SwiftModel, [ARMv7a, ProcSwift,
531 FeatureAvoidPartialCPSR,
532 FeatureAvoidMOVsShOp,
533 FeatureHasSlowFPVMLx]>;
535 // FIXME: R4 has currently the same ProcessorModel as A8.
536 def : ProcessorModel<"cortex-r4", CortexA8Model, [ARMv7r, ProcR4,
538 FeatureAvoidPartialCPSR,
541 // FIXME: R4F has currently the same ProcessorModel as A8.
542 def : ProcessorModel<"cortex-r4f", CortexA8Model, [ARMv7r, ProcR4,
545 FeatureHasSlowFPVMLx,
548 FeatureAvoidPartialCPSR,
551 // FIXME: R5 has currently the same ProcessorModel as A8.
552 def : ProcessorModel<"cortex-r5", CortexA8Model, [ARMv7r, ProcR5,
558 FeatureHasSlowFPVMLx,
559 FeatureAvoidPartialCPSR,
562 // FIXME: R7 has currently the same ProcessorModel as A8 and is modelled as R5.
563 def : ProcessorModel<"cortex-r7", CortexA8Model, [ARMv7r, ProcR7,
571 FeatureHasSlowFPVMLx,
572 FeatureAvoidPartialCPSR,
575 def : ProcNoItin<"cortex-m3", [ARMv7m]>;
576 def : ProcNoItin<"sc300", [ARMv7m]>;
578 def : ProcNoItin<"cortex-m4", [ARMv7em,
583 def : ProcNoItin<"cortex-m7", [ARMv7em,
588 def : ProcNoItin<"cortex-a53", [ARMv8a, ProcA53,
595 def : ProcNoItin<"cortex-a57", [ARMv8a, ProcA57,
602 def : ProcNoItin<"cortex-a72", [ARMv8a, ProcA72,
609 // Cyclone is very similar to swift
610 def : ProcessorModel<"cyclone", SwiftModel, [ARMv8a, ProcSwift,
618 FeatureAvoidPartialCPSR,
619 FeatureAvoidMOVsShOp,
620 FeatureHasSlowFPVMLx,
625 //===----------------------------------------------------------------------===//
626 // Register File Description
627 //===----------------------------------------------------------------------===//
629 include "ARMRegisterInfo.td"
631 include "ARMCallingConv.td"
633 //===----------------------------------------------------------------------===//
634 // Instruction Descriptions
635 //===----------------------------------------------------------------------===//
637 include "ARMInstrInfo.td"
639 def ARMInstrInfo : InstrInfo;
641 //===----------------------------------------------------------------------===//
642 // Declare the target which we are implementing
643 //===----------------------------------------------------------------------===//
645 def ARMAsmWriter : AsmWriter {
646 string AsmWriterClassName = "InstPrinter";
647 int PassSubtarget = 1;
649 bit isMCAsmWriter = 1;
652 def ARMAsmParserVariant : AsmParserVariant {
655 string BreakCharacters = ".";
659 // Pull in Instruction Info:
660 let InstructionSet = ARMInstrInfo;
661 let AssemblyWriters = [ARMAsmWriter];
662 let AssemblyParserVariants = [ARMAsmParserVariant];