1f5f373fcSRenato Golin //===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
2f5f373fcSRenato Golin //
3f5f373fcSRenato Golin //                     The LLVM Compiler Infrastructure
4f5f373fcSRenato Golin //
5f5f373fcSRenato Golin // This file is distributed under the University of Illinois Open Source
6f5f373fcSRenato Golin // License. See LICENSE.TXT for details.
7f5f373fcSRenato Golin //
8f5f373fcSRenato Golin //===----------------------------------------------------------------------===//
9f5f373fcSRenato Golin //
10f5f373fcSRenato Golin // This file implements a target parser to recognise hardware features such as
11f5f373fcSRenato Golin // FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
12f5f373fcSRenato Golin //
13f5f373fcSRenato Golin //===----------------------------------------------------------------------===//
14f5f373fcSRenato Golin 
15f5f373fcSRenato Golin #include "llvm/Support/ARMBuildAttributes.h"
16f5f373fcSRenato Golin #include "llvm/Support/TargetParser.h"
17f5f373fcSRenato Golin #include "llvm/ADT/StringExtras.h"
18f5f373fcSRenato Golin #include "llvm/ADT/StringSwitch.h"
19ebdd12cbSRenato Golin #include <cctype>
20f5f373fcSRenato Golin 
21f5f373fcSRenato Golin using namespace llvm;
22f5f373fcSRenato Golin 
23f5f373fcSRenato Golin namespace {
24f5f373fcSRenato Golin 
25d03d2292SJohn Brawn // List of canonical FPU names (use getFPUSynonym) and which architectural
26d03d2292SJohn Brawn // features they correspond to (use getFPUFeatures).
27f5f373fcSRenato Golin // FIXME: TableGen this.
28*d5526303SJaved Absar // The entries must appear in the order listed in ARM::FPUKind for correct indexing
29f5f373fcSRenato Golin struct {
30f5f373fcSRenato Golin   const char * Name;
31f5f373fcSRenato Golin   ARM::FPUKind ID;
32*d5526303SJaved Absar   ARM::FPUVersion FPUVersion;
33d03d2292SJohn Brawn   ARM::NeonSupportLevel NeonSupport;
34d03d2292SJohn Brawn   ARM::FPURestriction Restriction;
35f5f373fcSRenato Golin } FPUNames[] = {
36*d5526303SJaved Absar   { "invalid",        ARM::FK_INVALID,        ARM::FV_NONE,       ARM::NS_None,   ARM::FR_None},
37*d5526303SJaved Absar   { "none",           ARM::FK_NONE,           ARM::FV_NONE,       ARM::NS_None,   ARM::FR_None},
38*d5526303SJaved Absar   { "vfp",            ARM::FK_VFP,            ARM::FV_VFPV2,      ARM::NS_None,   ARM::FR_None},
39*d5526303SJaved Absar   { "vfpv2",          ARM::FK_VFPV2,          ARM::FV_VFPV2,      ARM::NS_None,   ARM::FR_None},
40*d5526303SJaved Absar   { "vfpv3",          ARM::FK_VFPV3,          ARM::FV_VFPV3,      ARM::NS_None,   ARM::FR_None},
41*d5526303SJaved Absar   { "vfpv3-fp16",     ARM::FK_VFPV3_FP16,     ARM::FV_VFPV3_FP16, ARM::NS_None,   ARM::FR_None},
42*d5526303SJaved Absar   { "vfpv3-d16",      ARM::FK_VFPV3_D16,      ARM::FV_VFPV3,      ARM::NS_None,   ARM::FR_D16},
43*d5526303SJaved Absar   { "vfpv3-d16-fp16", ARM::FK_VFPV3_D16_FP16, ARM::FV_VFPV3_FP16, ARM::NS_None,   ARM::FR_D16},
44*d5526303SJaved Absar   { "vfpv3xd",        ARM::FK_VFPV3XD,        ARM::FV_VFPV3,      ARM::NS_None,   ARM::FR_SP_D16},
45*d5526303SJaved Absar   { "vfpv3xd-fp16",   ARM::FK_VFPV3XD_FP16,   ARM::FV_VFPV3_FP16, ARM::NS_None,   ARM::FR_SP_D16},
46*d5526303SJaved Absar   { "vfpv4",          ARM::FK_VFPV4,          ARM::FV_VFPV4,      ARM::NS_None,   ARM::FR_None},
47*d5526303SJaved Absar   { "vfpv4-d16",      ARM::FK_VFPV4_D16,      ARM::FV_VFPV4,      ARM::NS_None,   ARM::FR_D16},
48*d5526303SJaved Absar   { "fpv4-sp-d16",    ARM::FK_FPV4_SP_D16,    ARM::FV_VFPV4,      ARM::NS_None,   ARM::FR_SP_D16},
49*d5526303SJaved Absar   { "fpv5-d16",       ARM::FK_FPV5_D16,       ARM::FV_VFPV5,      ARM::NS_None,   ARM::FR_D16},
50*d5526303SJaved Absar   { "fpv5-sp-d16",    ARM::FK_FPV5_SP_D16,    ARM::FV_VFPV5,      ARM::NS_None,   ARM::FR_SP_D16},
51*d5526303SJaved Absar   { "fp-armv8",       ARM::FK_FP_ARMV8,       ARM::FV_VFPV5,      ARM::NS_None,   ARM::FR_None},
52*d5526303SJaved Absar   { "neon",           ARM::FK_NEON,           ARM::FV_VFPV3,      ARM::NS_Neon,   ARM::FR_None},
53*d5526303SJaved Absar   { "neon-fp16",      ARM::FK_NEON_FP16,      ARM::FV_VFPV3_FP16, ARM::NS_Neon,   ARM::FR_None},
54*d5526303SJaved Absar   { "neon-vfpv4",     ARM::FK_NEON_VFPV4,     ARM::FV_VFPV4,      ARM::NS_Neon,   ARM::FR_None},
55*d5526303SJaved Absar   { "neon-fp-armv8",  ARM::FK_NEON_FP_ARMV8,  ARM::FV_VFPV5,      ARM::NS_Neon,   ARM::FR_None},
56d03d2292SJohn Brawn   { "crypto-neon-fp-armv8",
57*d5526303SJaved Absar                ARM::FK_CRYPTO_NEON_FP_ARMV8,  ARM::FV_VFPV5,      ARM::NS_Crypto, ARM::FR_None},
58*d5526303SJaved Absar   { "softvfp",        ARM::FK_SOFTVFP,        ARM::FV_NONE,       ARM::NS_None,   ARM::FR_None},
59f5f373fcSRenato Golin };
60d03d2292SJohn Brawn 
61f7c0d5f2SRenato Golin // List of canonical arch names (use getArchSynonym).
62f7c0d5f2SRenato Golin // This table also provides the build attribute fields for CPU arch
63f7c0d5f2SRenato Golin // and Arch ID, according to the Addenda to the ARM ABI, chapters
64f7c0d5f2SRenato Golin // 2.4 and 2.3.5.2 respectively.
6542dad647SRenato Golin // FIXME: SubArch values were simplified to fit into the expectations
6642dad647SRenato Golin // of the triples and are not conforming with their official names.
6742dad647SRenato Golin // Check to see if the expectation should be changed.
68f5f373fcSRenato Golin // FIXME: TableGen this.
69f5f373fcSRenato Golin struct {
70f5f373fcSRenato Golin   const char *Name;
71f5f373fcSRenato Golin   ARM::ArchKind ID;
72f7c0d5f2SRenato Golin   const char *CPUAttr; // CPU class in build attributes.
7342dad647SRenato Golin   const char *SubArch; // Sub-Arch name.
74f7c0d5f2SRenato Golin   ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes.
75f5f373fcSRenato Golin } ARCHNames[] = {
7642dad647SRenato Golin   { "invalid",   ARM::AK_INVALID,  nullptr,   nullptr, ARMBuildAttrs::CPUArch::Pre_v4 },
7742dad647SRenato Golin   { "armv2",     ARM::AK_ARMV2,    "2",       "v2",    ARMBuildAttrs::CPUArch::Pre_v4 },
7842dad647SRenato Golin   { "armv2a",    ARM::AK_ARMV2A,   "2A",      "v2a",   ARMBuildAttrs::CPUArch::Pre_v4 },
7942dad647SRenato Golin   { "armv3",     ARM::AK_ARMV3,    "3",       "v3",    ARMBuildAttrs::CPUArch::Pre_v4 },
8042dad647SRenato Golin   { "armv3m",    ARM::AK_ARMV3M,   "3M",      "v3m",   ARMBuildAttrs::CPUArch::Pre_v4 },
8142dad647SRenato Golin   { "armv4",     ARM::AK_ARMV4,    "4",       "v4",    ARMBuildAttrs::CPUArch::v4 },
8242dad647SRenato Golin   { "armv4t",    ARM::AK_ARMV4T,   "4T",      "v4t",   ARMBuildAttrs::CPUArch::v4T },
8342dad647SRenato Golin   { "armv5t",    ARM::AK_ARMV5T,   "5T",      "v5",    ARMBuildAttrs::CPUArch::v5T },
8442dad647SRenato Golin   { "armv5te",   ARM::AK_ARMV5TE,  "5TE",     "v5e",   ARMBuildAttrs::CPUArch::v5TE },
8542dad647SRenato Golin   { "armv5tej",  ARM::AK_ARMV5TEJ, "5TEJ",    "v5e",   ARMBuildAttrs::CPUArch::v5TEJ },
8642dad647SRenato Golin   { "armv6",     ARM::AK_ARMV6,    "6",       "v6",    ARMBuildAttrs::CPUArch::v6 },
8742dad647SRenato Golin   { "armv6k",    ARM::AK_ARMV6K,   "6K",      "v6k",   ARMBuildAttrs::CPUArch::v6K },
8842dad647SRenato Golin   { "armv6t2",   ARM::AK_ARMV6T2,  "6T2",     "v6t2",  ARMBuildAttrs::CPUArch::v6T2 },
8942dad647SRenato Golin   { "armv6z",    ARM::AK_ARMV6Z,   "6Z",      "v6z",   ARMBuildAttrs::CPUArch::v6KZ },
9042dad647SRenato Golin   { "armv6zk",   ARM::AK_ARMV6ZK,  "6ZK",     "v6zk",  ARMBuildAttrs::CPUArch::v6KZ },
9142dad647SRenato Golin   { "armv6-m",   ARM::AK_ARMV6M,   "6-M",     "v6m",   ARMBuildAttrs::CPUArch::v6_M },
9242dad647SRenato Golin   { "armv6s-m",  ARM::AK_ARMV6SM,  "6S-M",    "v6sm",  ARMBuildAttrs::CPUArch::v6S_M },
9342dad647SRenato Golin   { "armv7-a",   ARM::AK_ARMV7A,   "7-A",     "v7",    ARMBuildAttrs::CPUArch::v7 },
9442dad647SRenato Golin   { "armv7-r",   ARM::AK_ARMV7R,   "7-R",     "v7r",   ARMBuildAttrs::CPUArch::v7 },
9542dad647SRenato Golin   { "armv7-m",   ARM::AK_ARMV7M,   "7-M",     "v7m",   ARMBuildAttrs::CPUArch::v7 },
9642dad647SRenato Golin   { "armv7e-m",  ARM::AK_ARMV7EM,  "7E-M",    "v7em",  ARMBuildAttrs::CPUArch::v7E_M },
9742dad647SRenato Golin   { "armv8-a",   ARM::AK_ARMV8A,   "8-A",     "v8",    ARMBuildAttrs::CPUArch::v8 },
9842dad647SRenato Golin   { "armv8.1-a", ARM::AK_ARMV8_1A, "8.1-A",   "v8.1a", ARMBuildAttrs::CPUArch::v8 },
99e8048f0dSRenato Golin   // Non-standard Arch names.
10042dad647SRenato Golin   { "iwmmxt",    ARM::AK_IWMMXT,   "iwmmxt",  "",      ARMBuildAttrs::CPUArch::v5TE },
10142dad647SRenato Golin   { "iwmmxt2",   ARM::AK_IWMMXT2,  "iwmmxt2", "",      ARMBuildAttrs::CPUArch::v5TE },
10242dad647SRenato Golin   { "xscale",    ARM::AK_XSCALE,   "xscale",  "",      ARMBuildAttrs::CPUArch::v5TE },
10342dad647SRenato Golin   { "armv5",     ARM::AK_ARMV5,    "5T",      "v5",    ARMBuildAttrs::CPUArch::v5T },
10442dad647SRenato Golin   { "armv5e",    ARM::AK_ARMV5E,   "5TE",     "v5e",   ARMBuildAttrs::CPUArch::v5TE },
10542dad647SRenato Golin   { "armv6j",    ARM::AK_ARMV6J,   "6J",      "v6",    ARMBuildAttrs::CPUArch::v6 },
10642dad647SRenato Golin   { "armv6hl",   ARM::AK_ARMV6HL,  "6-M",     "v6hl",  ARMBuildAttrs::CPUArch::v6_M },
10742dad647SRenato Golin   { "armv7",     ARM::AK_ARMV7,    "7",       "v7",    ARMBuildAttrs::CPUArch::v7 },
10842dad647SRenato Golin   { "armv7l",    ARM::AK_ARMV7L,   "7-L",     "v7l",   ARMBuildAttrs::CPUArch::v7 },
10942dad647SRenato Golin   { "armv7hl",   ARM::AK_ARMV7HL,  "7-L",     "v7hl",  ARMBuildAttrs::CPUArch::v7 },
11042dad647SRenato Golin   { "armv7s",    ARM::AK_ARMV7S,   "7-S",     "v7s",   ARMBuildAttrs::CPUArch::v7 }
111f5f373fcSRenato Golin };
112e1326cadSRenato Golin // List of Arch Extension names.
113f5f373fcSRenato Golin // FIXME: TableGen this.
114f5f373fcSRenato Golin struct {
115f5f373fcSRenato Golin   const char *Name;
116f5f373fcSRenato Golin   ARM::ArchExtKind ID;
117f5f373fcSRenato Golin } ARCHExtNames[] = {
11835de35d0SRenato Golin   { "invalid",  ARM::AEK_INVALID },
11935de35d0SRenato Golin   { "crc",      ARM::AEK_CRC },
12035de35d0SRenato Golin   { "crypto",   ARM::AEK_CRYPTO },
12135de35d0SRenato Golin   { "fp",       ARM::AEK_FP },
12235de35d0SRenato Golin   { "idiv",     ARM::AEK_HWDIV },
12335de35d0SRenato Golin   { "mp",       ARM::AEK_MP },
124230d2983SRenato Golin   { "simd",     ARM::AEK_SIMD },
12535de35d0SRenato Golin   { "sec",      ARM::AEK_SEC },
126230d2983SRenato Golin   { "virt",     ARM::AEK_VIRT },
127230d2983SRenato Golin   { "os",       ARM::AEK_OS },
128230d2983SRenato Golin   { "iwmmxt",   ARM::AEK_IWMMXT },
129230d2983SRenato Golin   { "iwmmxt2",  ARM::AEK_IWMMXT2 },
130230d2983SRenato Golin   { "maverick", ARM::AEK_MAVERICK },
131230d2983SRenato Golin   { "xscale",   ARM::AEK_XSCALE }
132f5f373fcSRenato Golin };
133e8048f0dSRenato Golin // List of CPU names and their arches.
134e8048f0dSRenato Golin // The same CPU can have multiple arches and can be default on multiple arches.
135e8048f0dSRenato Golin // When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
1367374fcdbSRenato Golin // When this becomes table-generated, we'd probably need two tables.
137e8048f0dSRenato Golin // FIXME: TableGen this.
138e8048f0dSRenato Golin struct {
139e8048f0dSRenato Golin   const char *Name;
140e8048f0dSRenato Golin   ARM::ArchKind ArchID;
141e8048f0dSRenato Golin   bool Default;
142e8048f0dSRenato Golin } CPUNames[] = {
143e8048f0dSRenato Golin   { "arm2",          ARM::AK_ARMV2,    true },
1447374fcdbSRenato Golin   { "arm3",          ARM::AK_ARMV2A,   true },
145e8048f0dSRenato Golin   { "arm6",          ARM::AK_ARMV3,    true },
146e8048f0dSRenato Golin   { "arm7m",         ARM::AK_ARMV3M,   true },
1477374fcdbSRenato Golin   { "arm8",          ARM::AK_ARMV4,    false },
1487374fcdbSRenato Golin   { "arm810",        ARM::AK_ARMV4,    false },
149e8048f0dSRenato Golin   { "strongarm",     ARM::AK_ARMV4,    true },
1507374fcdbSRenato Golin   { "strongarm110",  ARM::AK_ARMV4,    false },
1517374fcdbSRenato Golin   { "strongarm1100", ARM::AK_ARMV4,    false },
1527374fcdbSRenato Golin   { "strongarm1110", ARM::AK_ARMV4,    false },
153e8048f0dSRenato Golin   { "arm7tdmi",      ARM::AK_ARMV4T,   true },
154e8048f0dSRenato Golin   { "arm7tdmi-s",    ARM::AK_ARMV4T,   false },
155e8048f0dSRenato Golin   { "arm710t",       ARM::AK_ARMV4T,   false },
156e8048f0dSRenato Golin   { "arm720t",       ARM::AK_ARMV4T,   false },
157e8048f0dSRenato Golin   { "arm9",          ARM::AK_ARMV4T,   false },
158e8048f0dSRenato Golin   { "arm9tdmi",      ARM::AK_ARMV4T,   false },
159e8048f0dSRenato Golin   { "arm920",        ARM::AK_ARMV4T,   false },
160e8048f0dSRenato Golin   { "arm920t",       ARM::AK_ARMV4T,   false },
161e8048f0dSRenato Golin   { "arm922t",       ARM::AK_ARMV4T,   false },
162e8048f0dSRenato Golin   { "arm9312",       ARM::AK_ARMV4T,   false },
163e8048f0dSRenato Golin   { "arm940t",       ARM::AK_ARMV4T,   false },
164e8048f0dSRenato Golin   { "ep9312",        ARM::AK_ARMV4T,   false },
165e8048f0dSRenato Golin   { "arm10tdmi",     ARM::AK_ARMV5T,   true },
166e8048f0dSRenato Golin   { "arm1020t",      ARM::AK_ARMV5T,   false },
167e8048f0dSRenato Golin   { "arm9e",         ARM::AK_ARMV5TE,  false },
1687374fcdbSRenato Golin   { "arm946e-s",     ARM::AK_ARMV5TE,  false },
169e8048f0dSRenato Golin   { "arm966e-s",     ARM::AK_ARMV5TE,  false },
170e8048f0dSRenato Golin   { "arm968e-s",     ARM::AK_ARMV5TE,  false },
1717374fcdbSRenato Golin   { "arm10e",        ARM::AK_ARMV5TE,  false },
172e8048f0dSRenato Golin   { "arm1020e",      ARM::AK_ARMV5TE,  false },
173e8048f0dSRenato Golin   { "arm1022e",      ARM::AK_ARMV5TE,  true },
174e8048f0dSRenato Golin   { "iwmmxt",        ARM::AK_ARMV5TE,  false },
1757374fcdbSRenato Golin   { "xscale",        ARM::AK_ARMV5TE,  false },
1767374fcdbSRenato Golin   { "arm926ej-s",    ARM::AK_ARMV5TEJ, true },
177e8048f0dSRenato Golin   { "arm1136jf-s",   ARM::AK_ARMV6,    true },
178e8048f0dSRenato Golin   { "arm1176j-s",    ARM::AK_ARMV6K,   false },
1797374fcdbSRenato Golin   { "arm1176jz-s",   ARM::AK_ARMV6K,   false },
180e8048f0dSRenato Golin   { "mpcore",        ARM::AK_ARMV6K,   false },
181e8048f0dSRenato Golin   { "mpcorenovfp",   ARM::AK_ARMV6K,   false },
182e8048f0dSRenato Golin   { "arm1176jzf-s",  ARM::AK_ARMV6K,   true },
183e8048f0dSRenato Golin   { "arm1176jzf-s",  ARM::AK_ARMV6Z,   true },
184e8048f0dSRenato Golin   { "arm1176jzf-s",  ARM::AK_ARMV6ZK,  true },
185e8048f0dSRenato Golin   { "arm1156t2-s",   ARM::AK_ARMV6T2,  true },
186e8048f0dSRenato Golin   { "arm1156t2f-s",  ARM::AK_ARMV6T2,  false },
187e8048f0dSRenato Golin   { "cortex-m0",     ARM::AK_ARMV6M,   true },
188e8048f0dSRenato Golin   { "cortex-m0plus", ARM::AK_ARMV6M,   false },
189e8048f0dSRenato Golin   { "cortex-m1",     ARM::AK_ARMV6M,   false },
190e8048f0dSRenato Golin   { "sc000",         ARM::AK_ARMV6M,   false },
191e8048f0dSRenato Golin   { "cortex-a5",     ARM::AK_ARMV7A,   false },
192e8048f0dSRenato Golin   { "cortex-a7",     ARM::AK_ARMV7A,   false },
193e8048f0dSRenato Golin   { "cortex-a8",     ARM::AK_ARMV7A,   true },
194e8048f0dSRenato Golin   { "cortex-a9",     ARM::AK_ARMV7A,   false },
195e8048f0dSRenato Golin   { "cortex-a12",    ARM::AK_ARMV7A,   false },
196e8048f0dSRenato Golin   { "cortex-a15",    ARM::AK_ARMV7A,   false },
197e8048f0dSRenato Golin   { "cortex-a17",    ARM::AK_ARMV7A,   false },
198e8048f0dSRenato Golin   { "krait",         ARM::AK_ARMV7A,   false },
199e8048f0dSRenato Golin   { "cortex-r4",     ARM::AK_ARMV7R,   true },
200e8048f0dSRenato Golin   { "cortex-r4f",    ARM::AK_ARMV7R,   false },
201e8048f0dSRenato Golin   { "cortex-r5",     ARM::AK_ARMV7R,   false },
202e8048f0dSRenato Golin   { "cortex-r7",     ARM::AK_ARMV7R,   false },
203e8048f0dSRenato Golin   { "sc300",         ARM::AK_ARMV7M,   false },
204e8048f0dSRenato Golin   { "cortex-m3",     ARM::AK_ARMV7M,   true },
2057374fcdbSRenato Golin   { "cortex-m4",     ARM::AK_ARMV7EM,  true },
2067374fcdbSRenato Golin   { "cortex-m7",     ARM::AK_ARMV7EM,  false },
207e8048f0dSRenato Golin   { "cortex-a53",    ARM::AK_ARMV8A,   true },
208e8048f0dSRenato Golin   { "cortex-a57",    ARM::AK_ARMV8A,   false },
209e8048f0dSRenato Golin   { "cortex-a72",    ARM::AK_ARMV8A,   false },
210e8048f0dSRenato Golin   { "cyclone",       ARM::AK_ARMV8A,   false },
211e8048f0dSRenato Golin   { "generic",       ARM::AK_ARMV8_1A, true },
212e8048f0dSRenato Golin   // Non-standard Arch names.
2137374fcdbSRenato Golin   { "iwmmxt",        ARM::AK_IWMMXT,   true },
2147374fcdbSRenato Golin   { "xscale",        ARM::AK_XSCALE,   true },
2157374fcdbSRenato Golin   { "arm10tdmi",     ARM::AK_ARMV5,    true },
216e8048f0dSRenato Golin   { "arm1022e",      ARM::AK_ARMV5E,   true },
2177374fcdbSRenato Golin   { "arm1136j-s",    ARM::AK_ARMV6J,   true },
2187374fcdbSRenato Golin   { "arm1136jz-s",   ARM::AK_ARMV6J,   false },
219e8048f0dSRenato Golin   { "cortex-m0",     ARM::AK_ARMV6SM,  true },
220b6b9e056SRenato Golin   { "arm1176jzf-s",  ARM::AK_ARMV6HL,  true },
2217374fcdbSRenato Golin   { "cortex-a8",     ARM::AK_ARMV7,    true },
222e8048f0dSRenato Golin   { "cortex-a8",     ARM::AK_ARMV7L,   true },
223b6b9e056SRenato Golin   { "cortex-a8",     ARM::AK_ARMV7HL,  true },
224e8048f0dSRenato Golin   { "cortex-m4",     ARM::AK_ARMV7EM,  true },
225e8048f0dSRenato Golin   { "swift",         ARM::AK_ARMV7S,   true },
226e8048f0dSRenato Golin   // Invalid CPU
227e8048f0dSRenato Golin   { "invalid",       ARM::AK_INVALID,  true }
228e8048f0dSRenato Golin };
229f5f373fcSRenato Golin 
230f5f373fcSRenato Golin } // namespace
231f5f373fcSRenato Golin 
232f5f373fcSRenato Golin // ======================================================= //
233f5f373fcSRenato Golin // Information by ID
234f5f373fcSRenato Golin // ======================================================= //
235f5f373fcSRenato Golin 
236e8048f0dSRenato Golin const char *ARMTargetParser::getFPUName(unsigned FPUKind) {
237e8048f0dSRenato Golin   if (FPUKind >= ARM::FK_LAST)
238f5f373fcSRenato Golin     return nullptr;
239e8048f0dSRenato Golin   return FPUNames[FPUKind].Name;
240f5f373fcSRenato Golin }
241f5f373fcSRenato Golin 
242d03d2292SJohn Brawn unsigned ARMTargetParser::getFPUVersion(unsigned FPUKind) {
243d03d2292SJohn Brawn   if (FPUKind >= ARM::FK_LAST)
244d03d2292SJohn Brawn     return 0;
245d03d2292SJohn Brawn   return FPUNames[FPUKind].FPUVersion;
246d03d2292SJohn Brawn }
247d03d2292SJohn Brawn 
248f2d06a57SBenjamin Kramer unsigned ARMTargetParser::getFPUNeonSupportLevel(unsigned FPUKind) {
249d03d2292SJohn Brawn   if (FPUKind >= ARM::FK_LAST)
250d03d2292SJohn Brawn     return 0;
251d03d2292SJohn Brawn   return FPUNames[FPUKind].NeonSupport;
252d03d2292SJohn Brawn }
253d03d2292SJohn Brawn 
254f2d06a57SBenjamin Kramer unsigned ARMTargetParser::getFPURestriction(unsigned FPUKind) {
255d03d2292SJohn Brawn   if (FPUKind >= ARM::FK_LAST)
256d03d2292SJohn Brawn     return 0;
257d03d2292SJohn Brawn   return FPUNames[FPUKind].Restriction;
258d03d2292SJohn Brawn }
259d03d2292SJohn Brawn 
260d03d2292SJohn Brawn bool ARMTargetParser::getFPUFeatures(unsigned FPUKind,
261d03d2292SJohn Brawn                                      std::vector<const char *> &Features) {
262d03d2292SJohn Brawn 
263d03d2292SJohn Brawn   if (FPUKind >= ARM::FK_LAST || FPUKind == ARM::FK_INVALID)
264d03d2292SJohn Brawn     return false;
265d03d2292SJohn Brawn 
266d03d2292SJohn Brawn   // fp-only-sp and d16 subtarget features are independent of each other, so we
267d03d2292SJohn Brawn   // must enable/disable both.
268d03d2292SJohn Brawn   switch (FPUNames[FPUKind].Restriction) {
269d03d2292SJohn Brawn   case ARM::FR_SP_D16:
270d03d2292SJohn Brawn     Features.push_back("+fp-only-sp");
271d03d2292SJohn Brawn     Features.push_back("+d16");
272d03d2292SJohn Brawn     break;
273d03d2292SJohn Brawn   case ARM::FR_D16:
274d03d2292SJohn Brawn     Features.push_back("-fp-only-sp");
275d03d2292SJohn Brawn     Features.push_back("+d16");
276d03d2292SJohn Brawn     break;
277d03d2292SJohn Brawn   case ARM::FR_None:
278d03d2292SJohn Brawn     Features.push_back("-fp-only-sp");
279d03d2292SJohn Brawn     Features.push_back("-d16");
280d03d2292SJohn Brawn     break;
281d03d2292SJohn Brawn   }
282d03d2292SJohn Brawn 
283d03d2292SJohn Brawn   // FPU version subtarget features are inclusive of lower-numbered ones, so
284d03d2292SJohn Brawn   // enable the one corresponding to this version and disable all that are
285d9e39d53SJohn Brawn   // higher. We also have to make sure to disable fp16 when vfp4 is disabled,
286d9e39d53SJohn Brawn   // as +vfp4 implies +fp16 but -vfp4 does not imply -fp16.
287d03d2292SJohn Brawn   switch (FPUNames[FPUKind].FPUVersion) {
288*d5526303SJaved Absar   case ARM::FV_VFPV5:
289d03d2292SJohn Brawn     Features.push_back("+fp-armv8");
290d03d2292SJohn Brawn     break;
291*d5526303SJaved Absar   case ARM::FV_VFPV4:
292d03d2292SJohn Brawn     Features.push_back("+vfp4");
293d03d2292SJohn Brawn     Features.push_back("-fp-armv8");
294d03d2292SJohn Brawn     break;
295*d5526303SJaved Absar   case ARM::FV_VFPV3_FP16:
296*d5526303SJaved Absar     Features.push_back("+vfp3");
297*d5526303SJaved Absar     Features.push_back("+fp16");
298*d5526303SJaved Absar     Features.push_back("-vfp4");
299*d5526303SJaved Absar     Features.push_back("-fp-armv8");
300*d5526303SJaved Absar     break;
301*d5526303SJaved Absar   case ARM::FV_VFPV3:
302d03d2292SJohn Brawn     Features.push_back("+vfp3");
303d9e39d53SJohn Brawn     Features.push_back("-fp16");
304d03d2292SJohn Brawn     Features.push_back("-vfp4");
305d03d2292SJohn Brawn     Features.push_back("-fp-armv8");
306d03d2292SJohn Brawn     break;
307*d5526303SJaved Absar   case ARM::FV_VFPV2:
308d03d2292SJohn Brawn     Features.push_back("+vfp2");
309d03d2292SJohn Brawn     Features.push_back("-vfp3");
310d9e39d53SJohn Brawn     Features.push_back("-fp16");
311d03d2292SJohn Brawn     Features.push_back("-vfp4");
312d03d2292SJohn Brawn     Features.push_back("-fp-armv8");
313d03d2292SJohn Brawn     break;
314*d5526303SJaved Absar   case ARM::FV_NONE:
315d03d2292SJohn Brawn     Features.push_back("-vfp2");
316d03d2292SJohn Brawn     Features.push_back("-vfp3");
317d9e39d53SJohn Brawn     Features.push_back("-fp16");
318d03d2292SJohn Brawn     Features.push_back("-vfp4");
319d03d2292SJohn Brawn     Features.push_back("-fp-armv8");
320d03d2292SJohn Brawn     break;
321*d5526303SJaved Absar   default:
322*d5526303SJaved Absar     return false;
323d03d2292SJohn Brawn   }
324d03d2292SJohn Brawn 
325d03d2292SJohn Brawn   // crypto includes neon, so we handle this similarly to FPU version.
326d03d2292SJohn Brawn   switch (FPUNames[FPUKind].NeonSupport) {
327d03d2292SJohn Brawn   case ARM::NS_Crypto:
328d03d2292SJohn Brawn     Features.push_back("+crypto");
329d03d2292SJohn Brawn     break;
330d03d2292SJohn Brawn   case ARM::NS_Neon:
331d03d2292SJohn Brawn     Features.push_back("+neon");
332d03d2292SJohn Brawn     Features.push_back("-crypto");
333d03d2292SJohn Brawn     break;
334d03d2292SJohn Brawn   case ARM::NS_None:
335d03d2292SJohn Brawn     Features.push_back("-neon");
336d03d2292SJohn Brawn     Features.push_back("-crypto");
337d03d2292SJohn Brawn     break;
338d03d2292SJohn Brawn   }
339d03d2292SJohn Brawn 
340d03d2292SJohn Brawn   return true;
341d03d2292SJohn Brawn }
342d03d2292SJohn Brawn 
343e8048f0dSRenato Golin const char *ARMTargetParser::getArchName(unsigned ArchKind) {
344e8048f0dSRenato Golin   if (ArchKind >= ARM::AK_LAST)
345f5f373fcSRenato Golin     return nullptr;
346e8048f0dSRenato Golin   return ARCHNames[ArchKind].Name;
347f5f373fcSRenato Golin }
348f5f373fcSRenato Golin 
349f7c0d5f2SRenato Golin const char *ARMTargetParser::getCPUAttr(unsigned ArchKind) {
350e8048f0dSRenato Golin   if (ArchKind >= ARM::AK_LAST)
351f5f373fcSRenato Golin     return nullptr;
352f7c0d5f2SRenato Golin   return ARCHNames[ArchKind].CPUAttr;
353f5f373fcSRenato Golin }
354f5f373fcSRenato Golin 
35542dad647SRenato Golin const char *ARMTargetParser::getSubArch(unsigned ArchKind) {
35642dad647SRenato Golin   if (ArchKind >= ARM::AK_LAST)
35742dad647SRenato Golin     return nullptr;
35842dad647SRenato Golin   return ARCHNames[ArchKind].SubArch;
35942dad647SRenato Golin }
36042dad647SRenato Golin 
361f7c0d5f2SRenato Golin unsigned ARMTargetParser::getArchAttr(unsigned ArchKind) {
362e8048f0dSRenato Golin   if (ArchKind >= ARM::AK_LAST)
363e8048f0dSRenato Golin     return ARMBuildAttrs::CPUArch::Pre_v4;
364f7c0d5f2SRenato Golin   return ARCHNames[ArchKind].ArchAttr;
365f5f373fcSRenato Golin }
366f5f373fcSRenato Golin 
367e8048f0dSRenato Golin const char *ARMTargetParser::getArchExtName(unsigned ArchExtKind) {
368e8048f0dSRenato Golin   if (ArchExtKind >= ARM::AEK_LAST)
369f5f373fcSRenato Golin     return nullptr;
370e8048f0dSRenato Golin   return ARCHExtNames[ArchExtKind].Name;
371e8048f0dSRenato Golin }
372e8048f0dSRenato Golin 
373e8048f0dSRenato Golin const char *ARMTargetParser::getDefaultCPU(StringRef Arch) {
374e8048f0dSRenato Golin   unsigned AK = parseArch(Arch);
375e8048f0dSRenato Golin   if (AK == ARM::AK_INVALID)
376e8048f0dSRenato Golin     return nullptr;
377e8048f0dSRenato Golin 
378e8048f0dSRenato Golin   // Look for multiple AKs to find the default for pair AK+Name.
379e8048f0dSRenato Golin   for (const auto CPU : CPUNames) {
380e8048f0dSRenato Golin     if (CPU.ArchID == AK && CPU.Default)
381e8048f0dSRenato Golin       return CPU.Name;
382e8048f0dSRenato Golin   }
383e8048f0dSRenato Golin   return nullptr;
384f5f373fcSRenato Golin }
385f5f373fcSRenato Golin 
386f5f373fcSRenato Golin // ======================================================= //
387f5f373fcSRenato Golin // Parsers
388f5f373fcSRenato Golin // ======================================================= //
389f5f373fcSRenato Golin 
390f5f373fcSRenato Golin StringRef ARMTargetParser::getFPUSynonym(StringRef FPU) {
391f5f373fcSRenato Golin   return StringSwitch<StringRef>(FPU)
392f5f373fcSRenato Golin     .Cases("fpa", "fpe2", "fpe3", "maverick", "invalid") // Unsupported
393f5f373fcSRenato Golin     .Case("vfp2", "vfpv2")
394f5f373fcSRenato Golin     .Case("vfp3", "vfpv3")
395f5f373fcSRenato Golin     .Case("vfp4", "vfpv4")
396f5f373fcSRenato Golin     .Case("vfp3-d16", "vfpv3-d16")
397f5f373fcSRenato Golin     .Case("vfp4-d16", "vfpv4-d16")
398985c04e8SJohn Brawn     .Cases("fp4-sp-d16", "vfpv4-sp-d16", "fpv4-sp-d16")
399f5f373fcSRenato Golin     .Cases("fp4-dp-d16", "fpv4-dp-d16", "vfpv4-d16")
400985c04e8SJohn Brawn     .Case("fp5-sp-d16", "fpv5-sp-d16")
401f5f373fcSRenato Golin     .Cases("fp5-dp-d16", "fpv5-dp-d16", "fpv5-d16")
402f5f373fcSRenato Golin     // FIXME: Clang uses it, but it's bogus, since neon defaults to vfpv3.
403f5f373fcSRenato Golin     .Case("neon-vfpv3", "neon")
404f5f373fcSRenato Golin     .Default(FPU);
405f5f373fcSRenato Golin }
406f5f373fcSRenato Golin 
407f5f373fcSRenato Golin StringRef ARMTargetParser::getArchSynonym(StringRef Arch) {
408f5f373fcSRenato Golin   return StringSwitch<StringRef>(Arch)
40985aebc8cSArtyom Skrobov     .Case("v6sm", "v6s-m")
41085aebc8cSArtyom Skrobov     .Case("v6m", "v6-m")
41185aebc8cSArtyom Skrobov     .Case("v7a", "v7-a")
41285aebc8cSArtyom Skrobov     .Case("v7r", "v7-r")
41385aebc8cSArtyom Skrobov     .Case("v7m", "v7-m")
41485aebc8cSArtyom Skrobov     .Case("v7em", "v7e-m")
415acd1cd66SArtyom Skrobov     .Cases("v8", "v8a", "aarch64", "arm64", "v8-a")
41685aebc8cSArtyom Skrobov     .Case("v8.1a", "v8.1-a")
417f5f373fcSRenato Golin     .Default(Arch);
418f5f373fcSRenato Golin }
419f5f373fcSRenato Golin 
420e8048f0dSRenato Golin // MArch is expected to be of the form (arm|thumb)?(eb)?(v.+)?(eb)?, but
421e8048f0dSRenato Golin // (iwmmxt|xscale)(eb)? is also permitted. If the former, return
422ebdd12cbSRenato Golin // "v.+", if the latter, return unmodified string, minus 'eb'.
423ebdd12cbSRenato Golin // If invalid, return empty string.
424e8048f0dSRenato Golin StringRef ARMTargetParser::getCanonicalArchName(StringRef Arch) {
425e8048f0dSRenato Golin   size_t offset = StringRef::npos;
426e8048f0dSRenato Golin   StringRef A = Arch;
427b6b9e056SRenato Golin   StringRef Error = "";
428e8048f0dSRenato Golin 
429e8048f0dSRenato Golin   // Begins with "arm" / "thumb", move past it.
430ebdd12cbSRenato Golin   if (A.startswith("arm64"))
431ebdd12cbSRenato Golin     offset = 5;
432ebdd12cbSRenato Golin   else if (A.startswith("arm"))
433e8048f0dSRenato Golin     offset = 3;
434e8048f0dSRenato Golin   else if (A.startswith("thumb"))
435e8048f0dSRenato Golin     offset = 5;
436b6b9e056SRenato Golin   else if (A.startswith("aarch64")) {
437b6b9e056SRenato Golin     offset = 7;
438b6b9e056SRenato Golin     // AArch64 uses "_be", not "eb" suffix.
439b6b9e056SRenato Golin     if (A.find("eb") != StringRef::npos)
440b6b9e056SRenato Golin       return Error;
441b6b9e056SRenato Golin     if (A.substr(offset,3) == "_be")
442b6b9e056SRenato Golin       offset += 3;
443b6b9e056SRenato Golin   }
444b6b9e056SRenato Golin 
445e8048f0dSRenato Golin   // Ex. "armebv7", move past the "eb".
446e8048f0dSRenato Golin   if (offset != StringRef::npos && A.substr(offset, 2) == "eb")
447e8048f0dSRenato Golin     offset += 2;
448e8048f0dSRenato Golin   // Or, if it ends with eb ("armv7eb"), chop it off.
449e8048f0dSRenato Golin   else if (A.endswith("eb"))
450e8048f0dSRenato Golin     A = A.substr(0, A.size() - 2);
451ebdd12cbSRenato Golin   // Trim the head
452ebdd12cbSRenato Golin   if (offset != StringRef::npos)
453e8048f0dSRenato Golin     A = A.substr(offset);
454e8048f0dSRenato Golin 
455ebdd12cbSRenato Golin   // Empty string means offset reached the end, which means it's valid.
456e8048f0dSRenato Golin   if (A.empty())
457e8048f0dSRenato Golin     return Arch;
458e8048f0dSRenato Golin 
459ebdd12cbSRenato Golin   // Only match non-marketing names
460ebdd12cbSRenato Golin   if (offset != StringRef::npos) {
461ebdd12cbSRenato Golin   // Must start with 'vN'.
462ebdd12cbSRenato Golin     if (A[0] != 'v' || !std::isdigit(A[1]))
463b6b9e056SRenato Golin       return Error;
464ebdd12cbSRenato Golin     // Can't have an extra 'eb'.
465ebdd12cbSRenato Golin     if (A.find("eb") != StringRef::npos)
466ebdd12cbSRenato Golin       return Error;
467ebdd12cbSRenato Golin   }
468e8048f0dSRenato Golin 
469ebdd12cbSRenato Golin   // Arch will either be a 'v' name (v7a) or a marketing name (xscale).
470e8048f0dSRenato Golin   return A;
471e8048f0dSRenato Golin }
472e8048f0dSRenato Golin 
473f5f373fcSRenato Golin unsigned ARMTargetParser::parseFPU(StringRef FPU) {
474f5f373fcSRenato Golin   StringRef Syn = getFPUSynonym(FPU);
475f5f373fcSRenato Golin   for (const auto F : FPUNames) {
476f5f373fcSRenato Golin     if (Syn == F.Name)
477f5f373fcSRenato Golin       return F.ID;
478f5f373fcSRenato Golin   }
47935de35d0SRenato Golin   return ARM::FK_INVALID;
480f5f373fcSRenato Golin }
481f5f373fcSRenato Golin 
482e8048f0dSRenato Golin // Allows partial match, ex. "v7a" matches "armv7a".
483f5f373fcSRenato Golin unsigned ARMTargetParser::parseArch(StringRef Arch) {
48485aebc8cSArtyom Skrobov   Arch = getCanonicalArchName(Arch);
485f5f373fcSRenato Golin   StringRef Syn = getArchSynonym(Arch);
486f5f373fcSRenato Golin   for (const auto A : ARCHNames) {
487e8048f0dSRenato Golin     if (StringRef(A.Name).endswith(Syn))
488f5f373fcSRenato Golin       return A.ID;
489f5f373fcSRenato Golin   }
49035de35d0SRenato Golin   return ARM::AK_INVALID;
491f5f373fcSRenato Golin }
492f5f373fcSRenato Golin 
493f5f373fcSRenato Golin unsigned ARMTargetParser::parseArchExt(StringRef ArchExt) {
494f5f373fcSRenato Golin   for (const auto A : ARCHExtNames) {
495f5f373fcSRenato Golin     if (ArchExt == A.Name)
496f5f373fcSRenato Golin       return A.ID;
497f5f373fcSRenato Golin   }
49835de35d0SRenato Golin   return ARM::AEK_INVALID;
499f5f373fcSRenato Golin }
500f5f373fcSRenato Golin 
501e8048f0dSRenato Golin unsigned ARMTargetParser::parseCPUArch(StringRef CPU) {
502e8048f0dSRenato Golin   for (const auto C : CPUNames) {
503e8048f0dSRenato Golin     if (CPU == C.Name)
504e8048f0dSRenato Golin       return C.ArchID;
505e8048f0dSRenato Golin   }
506e8048f0dSRenato Golin   return ARM::AK_INVALID;
507e8048f0dSRenato Golin }
508e8048f0dSRenato Golin 
509b6b9e056SRenato Golin // ARM, Thumb, AArch64
510b6b9e056SRenato Golin unsigned ARMTargetParser::parseArchISA(StringRef Arch) {
511b6b9e056SRenato Golin   return StringSwitch<unsigned>(Arch)
512b6b9e056SRenato Golin       .StartsWith("aarch64", ARM::IK_AARCH64)
513b6b9e056SRenato Golin       .StartsWith("arm64",   ARM::IK_AARCH64)
514b6b9e056SRenato Golin       .StartsWith("thumb",   ARM::IK_THUMB)
515b6b9e056SRenato Golin       .StartsWith("arm",     ARM::IK_ARM)
516b6b9e056SRenato Golin       .Default(ARM::EK_INVALID);
517b6b9e056SRenato Golin }
518b6b9e056SRenato Golin 
519b6b9e056SRenato Golin // Little/Big endian
520b6b9e056SRenato Golin unsigned ARMTargetParser::parseArchEndian(StringRef Arch) {
521b6b9e056SRenato Golin   if (Arch.startswith("armeb") ||
522b6b9e056SRenato Golin       Arch.startswith("thumbeb") ||
523b6b9e056SRenato Golin       Arch.startswith("aarch64_be"))
524b6b9e056SRenato Golin     return ARM::EK_BIG;
525b6b9e056SRenato Golin 
526b6b9e056SRenato Golin   if (Arch.startswith("arm") || Arch.startswith("thumb")) {
527b6b9e056SRenato Golin     if (Arch.endswith("eb"))
528b6b9e056SRenato Golin       return ARM::EK_BIG;
529b6b9e056SRenato Golin     else
530b6b9e056SRenato Golin       return ARM::EK_LITTLE;
531b6b9e056SRenato Golin   }
532b6b9e056SRenato Golin 
533b6b9e056SRenato Golin   if (Arch.startswith("aarch64"))
534b6b9e056SRenato Golin     return ARM::EK_LITTLE;
535b6b9e056SRenato Golin 
536b6b9e056SRenato Golin   return ARM::EK_INVALID;
537b6b9e056SRenato Golin }
538b6b9e056SRenato Golin 
539fadc2108SRenato Golin // Profile A/R/M
540fadc2108SRenato Golin unsigned ARMTargetParser::parseArchProfile(StringRef Arch) {
541fadc2108SRenato Golin   Arch = getCanonicalArchName(Arch);
542fadc2108SRenato Golin   switch(parseArch(Arch)) {
543fadc2108SRenato Golin   case ARM::AK_ARMV6M:
544fadc2108SRenato Golin   case ARM::AK_ARMV7M:
545fadc2108SRenato Golin   case ARM::AK_ARMV6SM:
546fadc2108SRenato Golin   case ARM::AK_ARMV7EM:
547fadc2108SRenato Golin     return ARM::PK_M;
548fadc2108SRenato Golin   case ARM::AK_ARMV7R:
549fadc2108SRenato Golin     return ARM::PK_R;
550fadc2108SRenato Golin   case ARM::AK_ARMV7:
551fadc2108SRenato Golin   case ARM::AK_ARMV7A:
552fadc2108SRenato Golin   case ARM::AK_ARMV8A:
553fadc2108SRenato Golin   case ARM::AK_ARMV8_1A:
554fadc2108SRenato Golin     return ARM::PK_A;
555fadc2108SRenato Golin   }
556fadc2108SRenato Golin   return ARM::PK_INVALID;
557fadc2108SRenato Golin }
558fadc2108SRenato Golin 
559ebdd12cbSRenato Golin // Version number (ex. v7 = 7).
560fadc2108SRenato Golin unsigned ARMTargetParser::parseArchVersion(StringRef Arch) {
561fadc2108SRenato Golin   Arch = getCanonicalArchName(Arch);
562fadc2108SRenato Golin   switch(parseArch(Arch)) {
563fadc2108SRenato Golin   case ARM::AK_ARMV2:
564fadc2108SRenato Golin   case ARM::AK_ARMV2A:
565fadc2108SRenato Golin     return 2;
566fadc2108SRenato Golin   case ARM::AK_ARMV3:
567fadc2108SRenato Golin   case ARM::AK_ARMV3M:
568fadc2108SRenato Golin     return 3;
569fadc2108SRenato Golin   case ARM::AK_ARMV4:
570fadc2108SRenato Golin   case ARM::AK_ARMV4T:
571fadc2108SRenato Golin     return 4;
572fadc2108SRenato Golin   case ARM::AK_ARMV5:
573fadc2108SRenato Golin   case ARM::AK_ARMV5T:
574fadc2108SRenato Golin   case ARM::AK_ARMV5TE:
575fadc2108SRenato Golin   case ARM::AK_IWMMXT:
576fadc2108SRenato Golin   case ARM::AK_IWMMXT2:
577fadc2108SRenato Golin   case ARM::AK_XSCALE:
578fadc2108SRenato Golin   case ARM::AK_ARMV5E:
579fadc2108SRenato Golin   case ARM::AK_ARMV5TEJ:
580fadc2108SRenato Golin     return 5;
581fadc2108SRenato Golin   case ARM::AK_ARMV6:
582fadc2108SRenato Golin   case ARM::AK_ARMV6J:
583fadc2108SRenato Golin   case ARM::AK_ARMV6K:
584fadc2108SRenato Golin   case ARM::AK_ARMV6T2:
585fadc2108SRenato Golin   case ARM::AK_ARMV6Z:
586fadc2108SRenato Golin   case ARM::AK_ARMV6ZK:
587fadc2108SRenato Golin   case ARM::AK_ARMV6M:
588fadc2108SRenato Golin   case ARM::AK_ARMV6SM:
589fadc2108SRenato Golin   case ARM::AK_ARMV6HL:
590fadc2108SRenato Golin     return 6;
591fadc2108SRenato Golin   case ARM::AK_ARMV7:
592fadc2108SRenato Golin   case ARM::AK_ARMV7A:
593fadc2108SRenato Golin   case ARM::AK_ARMV7R:
594fadc2108SRenato Golin   case ARM::AK_ARMV7M:
595fadc2108SRenato Golin   case ARM::AK_ARMV7L:
596fadc2108SRenato Golin   case ARM::AK_ARMV7HL:
597fadc2108SRenato Golin   case ARM::AK_ARMV7S:
598fadc2108SRenato Golin   case ARM::AK_ARMV7EM:
599fadc2108SRenato Golin     return 7;
600fadc2108SRenato Golin   case ARM::AK_ARMV8A:
601fadc2108SRenato Golin   case ARM::AK_ARMV8_1A:
602fadc2108SRenato Golin     return 8;
603fadc2108SRenato Golin   }
604fadc2108SRenato Golin   return 0;
605fadc2108SRenato Golin }
606