Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 1 | //===-- TargetParser - Parser for target features ---------------*- C++ -*-===// |
| 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 | // This file implements a target parser to recognise hardware features such as |
| 11 | // FPU/CPU/ARCH names as well as specific support such as HDIV, etc. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/Support/ARMBuildAttributes.h" |
| 16 | #include "llvm/Support/TargetParser.h" |
| 17 | #include "llvm/ADT/StringExtras.h" |
| 18 | #include "llvm/ADT/StringSwitch.h" |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 19 | #include <cctype> |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 22 | using namespace ARM; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 23 | |
| 24 | namespace { |
| 25 | |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 26 | // List of canonical FPU names (use getFPUSynonym) and which architectural |
| 27 | // features they correspond to (use getFPUFeatures). |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 28 | // FIXME: TableGen this. |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 29 | // The entries must appear in the order listed in ARM::FPUKind for correct indexing |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 30 | struct { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 31 | const char *NameCStr; |
| 32 | size_t NameLength; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 33 | ARM::FPUKind ID; |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 34 | ARM::FPUVersion FPUVersion; |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 35 | ARM::NeonSupportLevel NeonSupport; |
| 36 | ARM::FPURestriction Restriction; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 37 | |
| 38 | StringRef getName() const { return StringRef(NameCStr, NameLength); } |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 39 | } FPUNames[] = { |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 40 | #define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) \ |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 41 | { NAME, sizeof(NAME) - 1, KIND, VERSION, NEON_SUPPORT, RESTRICTION }, |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 42 | #include "llvm/Support/ARMTargetParser.def" |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 43 | }; |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 44 | |
Renato Golin | f7c0d5f | 2015-05-27 18:15:37 +0000 | [diff] [blame] | 45 | // List of canonical arch names (use getArchSynonym). |
| 46 | // This table also provides the build attribute fields for CPU arch |
| 47 | // and Arch ID, according to the Addenda to the ARM ABI, chapters |
| 48 | // 2.4 and 2.3.5.2 respectively. |
Renato Golin | 42dad64 | 2015-05-28 15:05:18 +0000 | [diff] [blame] | 49 | // FIXME: SubArch values were simplified to fit into the expectations |
| 50 | // of the triples and are not conforming with their official names. |
| 51 | // Check to see if the expectation should be changed. |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 52 | // FIXME: TableGen this. |
| 53 | struct { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 54 | const char *NameCStr; |
| 55 | size_t NameLength; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 56 | ARM::ArchKind ID; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 57 | const char *CPUAttrCStr; |
| 58 | size_t CPUAttrLength; |
| 59 | const char *SubArchCStr; |
| 60 | size_t SubArchLength; |
Renato Golin | f7c0d5f | 2015-05-27 18:15:37 +0000 | [diff] [blame] | 61 | ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes. |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 62 | |
| 63 | StringRef getName() const { return StringRef(NameCStr, NameLength); } |
| 64 | |
| 65 | // CPU class in build attributes. |
| 66 | StringRef getCPUAttr() const { return StringRef(CPUAttrCStr, CPUAttrLength); } |
| 67 | |
| 68 | // Sub-Arch name. |
| 69 | StringRef getSubArch() const { return StringRef(SubArchCStr, SubArchLength); } |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 70 | } ARCHNames[] = { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 71 | #define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR) \ |
| 72 | {NAME, sizeof(NAME) - 1, ID, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH, \ |
| 73 | sizeof(SUB_ARCH) - 1, ARCH_ATTR}, |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 74 | #include "llvm/Support/ARMTargetParser.def" |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 75 | }; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 76 | |
Renato Golin | e1326ca | 2015-05-28 08:59:03 +0000 | [diff] [blame] | 77 | // List of Arch Extension names. |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 78 | // FIXME: TableGen this. |
| 79 | struct { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 80 | const char *NameCStr; |
| 81 | size_t NameLength; |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 82 | unsigned ID; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 83 | |
| 84 | StringRef getName() const { return StringRef(NameCStr, NameLength); } |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 85 | } ARCHExtNames[] = { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 86 | #define ARM_ARCH_EXT_NAME(NAME, ID) { NAME, sizeof(NAME) - 1, ID }, |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 87 | #include "llvm/Support/ARMTargetParser.def" |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 88 | }; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 89 | |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 90 | // List of HWDiv names (use getHWDivSynonym) and which architectural |
| 91 | // features they correspond to (use getHWDivFeatures). |
| 92 | // FIXME: TableGen this. |
| 93 | struct { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 94 | const char *NameCStr; |
| 95 | size_t NameLength; |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 96 | unsigned ID; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 97 | |
| 98 | StringRef getName() const { return StringRef(NameCStr, NameLength); } |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 99 | } HWDivNames[] = { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 100 | #define ARM_HW_DIV_NAME(NAME, ID) { NAME, sizeof(NAME) - 1, ID }, |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 101 | #include "llvm/Support/ARMTargetParser.def" |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 102 | }; |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 103 | |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 104 | // List of CPU names and their arches. |
| 105 | // The same CPU can have multiple arches and can be default on multiple arches. |
| 106 | // When finding the Arch for a CPU, first-found prevails. Sort them accordingly. |
Renato Golin | 7374fcd | 2015-05-28 12:10:37 +0000 | [diff] [blame] | 107 | // When this becomes table-generated, we'd probably need two tables. |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 108 | // FIXME: TableGen this. |
| 109 | struct { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 110 | const char *NameCStr; |
| 111 | size_t NameLength; |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 112 | ARM::ArchKind ArchID; |
Alexandros Lamprineas | fcd93d5 | 2015-07-15 10:46:21 +0000 | [diff] [blame] | 113 | ARM::FPUKind DefaultFPU; |
| 114 | bool Default; // is $Name the default CPU for $ArchID ? |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 115 | |
| 116 | StringRef getName() const { return StringRef(NameCStr, NameLength); } |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 117 | } CPUNames[] = { |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 118 | #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT) \ |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 119 | { NAME, sizeof(NAME) - 1, ID, DEFAULT_FPU, IS_DEFAULT }, |
Chandler Carruth | 799e880 | 2015-08-30 05:27:31 +0000 | [diff] [blame] | 120 | #include "llvm/Support/ARMTargetParser.def" |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 121 | }; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 122 | |
| 123 | } // namespace |
| 124 | |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 125 | // ======================================================= // |
| 126 | // Information by ID |
| 127 | // ======================================================= // |
| 128 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 129 | StringRef llvm::ARM::getFPUName(unsigned FPUKind) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 130 | if (FPUKind >= ARM::FK_LAST) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 131 | return StringRef(); |
| 132 | return FPUNames[FPUKind].getName(); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 135 | unsigned llvm::ARM::getFPUVersion(unsigned FPUKind) { |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 136 | if (FPUKind >= ARM::FK_LAST) |
| 137 | return 0; |
| 138 | return FPUNames[FPUKind].FPUVersion; |
| 139 | } |
| 140 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 141 | unsigned llvm::ARM::getFPUNeonSupportLevel(unsigned FPUKind) { |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 142 | if (FPUKind >= ARM::FK_LAST) |
| 143 | return 0; |
| 144 | return FPUNames[FPUKind].NeonSupport; |
| 145 | } |
| 146 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 147 | unsigned llvm::ARM::getFPURestriction(unsigned FPUKind) { |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 148 | if (FPUKind >= ARM::FK_LAST) |
| 149 | return 0; |
| 150 | return FPUNames[FPUKind].Restriction; |
| 151 | } |
| 152 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 153 | unsigned llvm::ARM::getDefaultFPU(StringRef CPU) { |
Alexandros Lamprineas | fcd93d5 | 2015-07-15 10:46:21 +0000 | [diff] [blame] | 154 | for (const auto C : CPUNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 155 | if (CPU == C.getName()) |
Alexandros Lamprineas | fcd93d5 | 2015-07-15 10:46:21 +0000 | [diff] [blame] | 156 | return C.DefaultFPU; |
| 157 | } |
| 158 | return ARM::FK_INVALID; |
| 159 | } |
| 160 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 161 | bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind, |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 162 | std::vector<const char *> &Features) { |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 163 | |
| 164 | if (HWDivKind == ARM::AEK_INVALID) |
| 165 | return false; |
| 166 | |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 167 | if (HWDivKind & ARM::AEK_HWDIVARM) |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 168 | Features.push_back("+hwdiv-arm"); |
| 169 | else |
| 170 | Features.push_back("-hwdiv-arm"); |
| 171 | |
| 172 | if (HWDivKind & ARM::AEK_HWDIV) |
| 173 | Features.push_back("+hwdiv"); |
| 174 | else |
| 175 | Features.push_back("-hwdiv"); |
| 176 | |
| 177 | return true; |
| 178 | } |
| 179 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 180 | bool llvm::ARM::getFPUFeatures(unsigned FPUKind, |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 181 | std::vector<const char *> &Features) { |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 182 | |
| 183 | if (FPUKind >= ARM::FK_LAST || FPUKind == ARM::FK_INVALID) |
| 184 | return false; |
| 185 | |
| 186 | // fp-only-sp and d16 subtarget features are independent of each other, so we |
| 187 | // must enable/disable both. |
| 188 | switch (FPUNames[FPUKind].Restriction) { |
| 189 | case ARM::FR_SP_D16: |
| 190 | Features.push_back("+fp-only-sp"); |
| 191 | Features.push_back("+d16"); |
| 192 | break; |
| 193 | case ARM::FR_D16: |
| 194 | Features.push_back("-fp-only-sp"); |
| 195 | Features.push_back("+d16"); |
| 196 | break; |
| 197 | case ARM::FR_None: |
| 198 | Features.push_back("-fp-only-sp"); |
| 199 | Features.push_back("-d16"); |
| 200 | break; |
| 201 | } |
| 202 | |
| 203 | // FPU version subtarget features are inclusive of lower-numbered ones, so |
| 204 | // enable the one corresponding to this version and disable all that are |
John Brawn | d9e39d5 | 2015-06-12 09:38:51 +0000 | [diff] [blame] | 205 | // higher. We also have to make sure to disable fp16 when vfp4 is disabled, |
| 206 | // as +vfp4 implies +fp16 but -vfp4 does not imply -fp16. |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 207 | switch (FPUNames[FPUKind].FPUVersion) { |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 208 | case ARM::FV_VFPV5: |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 209 | Features.push_back("+fp-armv8"); |
| 210 | break; |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 211 | case ARM::FV_VFPV4: |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 212 | Features.push_back("+vfp4"); |
| 213 | Features.push_back("-fp-armv8"); |
| 214 | break; |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 215 | case ARM::FV_VFPV3_FP16: |
| 216 | Features.push_back("+vfp3"); |
| 217 | Features.push_back("+fp16"); |
| 218 | Features.push_back("-vfp4"); |
| 219 | Features.push_back("-fp-armv8"); |
| 220 | break; |
| 221 | case ARM::FV_VFPV3: |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 222 | Features.push_back("+vfp3"); |
John Brawn | d9e39d5 | 2015-06-12 09:38:51 +0000 | [diff] [blame] | 223 | Features.push_back("-fp16"); |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 224 | Features.push_back("-vfp4"); |
| 225 | Features.push_back("-fp-armv8"); |
| 226 | break; |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 227 | case ARM::FV_VFPV2: |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 228 | Features.push_back("+vfp2"); |
| 229 | Features.push_back("-vfp3"); |
John Brawn | d9e39d5 | 2015-06-12 09:38:51 +0000 | [diff] [blame] | 230 | Features.push_back("-fp16"); |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 231 | Features.push_back("-vfp4"); |
| 232 | Features.push_back("-fp-armv8"); |
| 233 | break; |
Javed Absar | d552630 | 2015-06-29 09:32:29 +0000 | [diff] [blame] | 234 | case ARM::FV_NONE: |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 235 | Features.push_back("-vfp2"); |
| 236 | Features.push_back("-vfp3"); |
John Brawn | d9e39d5 | 2015-06-12 09:38:51 +0000 | [diff] [blame] | 237 | Features.push_back("-fp16"); |
John Brawn | d03d229 | 2015-06-05 13:29:24 +0000 | [diff] [blame] | 238 | Features.push_back("-vfp4"); |
| 239 | Features.push_back("-fp-armv8"); |
| 240 | break; |
| 241 | } |
| 242 | |
| 243 | // crypto includes neon, so we handle this similarly to FPU version. |
| 244 | switch (FPUNames[FPUKind].NeonSupport) { |
| 245 | case ARM::NS_Crypto: |
| 246 | Features.push_back("+crypto"); |
| 247 | break; |
| 248 | case ARM::NS_Neon: |
| 249 | Features.push_back("+neon"); |
| 250 | Features.push_back("-crypto"); |
| 251 | break; |
| 252 | case ARM::NS_None: |
| 253 | Features.push_back("-neon"); |
| 254 | Features.push_back("-crypto"); |
| 255 | break; |
| 256 | } |
| 257 | |
| 258 | return true; |
| 259 | } |
| 260 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 261 | StringRef llvm::ARM::getArchName(unsigned ArchKind) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 262 | if (ArchKind >= ARM::AK_LAST) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 263 | return StringRef(); |
| 264 | return ARCHNames[ArchKind].getName(); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 267 | StringRef llvm::ARM::getCPUAttr(unsigned ArchKind) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 268 | if (ArchKind >= ARM::AK_LAST) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 269 | return StringRef(); |
| 270 | return ARCHNames[ArchKind].getCPUAttr(); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 273 | StringRef llvm::ARM::getSubArch(unsigned ArchKind) { |
Renato Golin | 42dad64 | 2015-05-28 15:05:18 +0000 | [diff] [blame] | 274 | if (ArchKind >= ARM::AK_LAST) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 275 | return StringRef(); |
| 276 | return ARCHNames[ArchKind].getSubArch(); |
Renato Golin | 42dad64 | 2015-05-28 15:05:18 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 279 | unsigned llvm::ARM::getArchAttr(unsigned ArchKind) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 280 | if (ArchKind >= ARM::AK_LAST) |
| 281 | return ARMBuildAttrs::CPUArch::Pre_v4; |
Renato Golin | f7c0d5f | 2015-05-27 18:15:37 +0000 | [diff] [blame] | 282 | return ARCHNames[ArchKind].ArchAttr; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 285 | StringRef llvm::ARM::getArchExtName(unsigned ArchExtKind) { |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 286 | for (const auto AE : ARCHExtNames) { |
| 287 | if (ArchExtKind == AE.ID) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 288 | return AE.getName(); |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 289 | } |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 290 | return StringRef(); |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 293 | StringRef llvm::ARM::getHWDivName(unsigned HWDivKind) { |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 294 | for (const auto D : HWDivNames) { |
| 295 | if (HWDivKind == D.ID) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 296 | return D.getName(); |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 297 | } |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 298 | return StringRef(); |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 301 | StringRef llvm::ARM::getDefaultCPU(StringRef Arch) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 302 | unsigned AK = parseArch(Arch); |
| 303 | if (AK == ARM::AK_INVALID) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 304 | return StringRef(); |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 305 | |
| 306 | // Look for multiple AKs to find the default for pair AK+Name. |
| 307 | for (const auto CPU : CPUNames) { |
| 308 | if (CPU.ArchID == AK && CPU.Default) |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 309 | return CPU.getName(); |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 310 | } |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 311 | return StringRef(); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | // ======================================================= // |
| 315 | // Parsers |
| 316 | // ======================================================= // |
| 317 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 318 | static StringRef getHWDivSynonym(StringRef HWDiv) { |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 319 | return StringSwitch<StringRef>(HWDiv) |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 320 | .Case("thumb,arm", "arm,thumb") |
| 321 | .Default(HWDiv); |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 324 | static StringRef getFPUSynonym(StringRef FPU) { |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 325 | return StringSwitch<StringRef>(FPU) |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 326 | .Cases("fpa", "fpe2", "fpe3", "maverick", "invalid") // Unsupported |
| 327 | .Case("vfp2", "vfpv2") |
| 328 | .Case("vfp3", "vfpv3") |
| 329 | .Case("vfp4", "vfpv4") |
| 330 | .Case("vfp3-d16", "vfpv3-d16") |
| 331 | .Case("vfp4-d16", "vfpv4-d16") |
| 332 | .Cases("fp4-sp-d16", "vfpv4-sp-d16", "fpv4-sp-d16") |
| 333 | .Cases("fp4-dp-d16", "fpv4-dp-d16", "vfpv4-d16") |
| 334 | .Case("fp5-sp-d16", "fpv5-sp-d16") |
| 335 | .Cases("fp5-dp-d16", "fpv5-dp-d16", "fpv5-d16") |
| 336 | // FIXME: Clang uses it, but it's bogus, since neon defaults to vfpv3. |
| 337 | .Case("neon-vfpv3", "neon") |
| 338 | .Default(FPU); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 341 | static StringRef getArchSynonym(StringRef Arch) { |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 342 | return StringSwitch<StringRef>(Arch) |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 343 | .Case("v6sm", "v6s-m") |
| 344 | .Case("v6m", "v6-m") |
| 345 | .Case("v7a", "v7-a") |
| 346 | .Case("v7r", "v7-r") |
| 347 | .Case("v7m", "v7-m") |
| 348 | .Case("v7em", "v7e-m") |
| 349 | .Cases("v8", "v8a", "aarch64", "arm64", "v8-a") |
| 350 | .Case("v8.1a", "v8.1-a") |
| 351 | .Default(Arch); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 354 | // MArch is expected to be of the form (arm|thumb)?(eb)?(v.+)?(eb)?, but |
| 355 | // (iwmmxt|xscale)(eb)? is also permitted. If the former, return |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 356 | // "v.+", if the latter, return unmodified string, minus 'eb'. |
| 357 | // If invalid, return empty string. |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 358 | StringRef llvm::ARM::getCanonicalArchName(StringRef Arch) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 359 | size_t offset = StringRef::npos; |
| 360 | StringRef A = Arch; |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 361 | StringRef Error = ""; |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 362 | |
| 363 | // Begins with "arm" / "thumb", move past it. |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 364 | if (A.startswith("arm64")) |
| 365 | offset = 5; |
| 366 | else if (A.startswith("arm")) |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 367 | offset = 3; |
| 368 | else if (A.startswith("thumb")) |
| 369 | offset = 5; |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 370 | else if (A.startswith("aarch64")) { |
| 371 | offset = 7; |
| 372 | // AArch64 uses "_be", not "eb" suffix. |
| 373 | if (A.find("eb") != StringRef::npos) |
| 374 | return Error; |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 375 | if (A.substr(offset, 3) == "_be") |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 376 | offset += 3; |
| 377 | } |
| 378 | |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 379 | // Ex. "armebv7", move past the "eb". |
| 380 | if (offset != StringRef::npos && A.substr(offset, 2) == "eb") |
| 381 | offset += 2; |
| 382 | // Or, if it ends with eb ("armv7eb"), chop it off. |
| 383 | else if (A.endswith("eb")) |
| 384 | A = A.substr(0, A.size() - 2); |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 385 | // Trim the head |
| 386 | if (offset != StringRef::npos) |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 387 | A = A.substr(offset); |
| 388 | |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 389 | // Empty string means offset reached the end, which means it's valid. |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 390 | if (A.empty()) |
| 391 | return Arch; |
| 392 | |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 393 | // Only match non-marketing names |
| 394 | if (offset != StringRef::npos) { |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 395 | // Must start with 'vN'. |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 396 | if (A[0] != 'v' || !std::isdigit(A[1])) |
| 397 | return Error; |
| 398 | // Can't have an extra 'eb'. |
| 399 | if (A.find("eb") != StringRef::npos) |
| 400 | return Error; |
| 401 | } |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 402 | |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 403 | // Arch will either be a 'v' name (v7a) or a marketing name (xscale). |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 404 | return A; |
| 405 | } |
| 406 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 407 | unsigned llvm::ARM::parseHWDiv(StringRef HWDiv) { |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 408 | StringRef Syn = getHWDivSynonym(HWDiv); |
| 409 | for (const auto D : HWDivNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 410 | if (Syn == D.getName()) |
Alexandros Lamprineas | 4ea7075 | 2015-07-27 22:26:59 +0000 | [diff] [blame] | 411 | return D.ID; |
| 412 | } |
| 413 | return ARM::AEK_INVALID; |
| 414 | } |
| 415 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 416 | unsigned llvm::ARM::parseFPU(StringRef FPU) { |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 417 | StringRef Syn = getFPUSynonym(FPU); |
| 418 | for (const auto F : FPUNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 419 | if (Syn == F.getName()) |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 420 | return F.ID; |
| 421 | } |
Renato Golin | 35de35d | 2015-05-12 10:33:58 +0000 | [diff] [blame] | 422 | return ARM::FK_INVALID; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 425 | // Allows partial match, ex. "v7a" matches "armv7a". |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 426 | unsigned llvm::ARM::parseArch(StringRef Arch) { |
Artyom Skrobov | 85aebc8 | 2015-06-04 21:26:58 +0000 | [diff] [blame] | 427 | Arch = getCanonicalArchName(Arch); |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 428 | StringRef Syn = getArchSynonym(Arch); |
| 429 | for (const auto A : ARCHNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 430 | if (A.getName().endswith(Syn)) |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 431 | return A.ID; |
| 432 | } |
Renato Golin | 35de35d | 2015-05-12 10:33:58 +0000 | [diff] [blame] | 433 | return ARM::AK_INVALID; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 434 | } |
| 435 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 436 | unsigned llvm::ARM::parseArchExt(StringRef ArchExt) { |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 437 | for (const auto A : ARCHExtNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 438 | if (ArchExt == A.getName()) |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 439 | return A.ID; |
| 440 | } |
Renato Golin | 35de35d | 2015-05-12 10:33:58 +0000 | [diff] [blame] | 441 | return ARM::AEK_INVALID; |
Renato Golin | f5f373f | 2015-05-08 21:04:27 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 444 | unsigned llvm::ARM::parseCPUArch(StringRef CPU) { |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 445 | for (const auto C : CPUNames) { |
Chandler Carruth | 3309ef6 | 2015-08-30 07:51:04 +0000 | [diff] [blame^] | 446 | if (CPU == C.getName()) |
Renato Golin | e8048f0 | 2015-05-20 15:05:07 +0000 | [diff] [blame] | 447 | return C.ArchID; |
| 448 | } |
| 449 | return ARM::AK_INVALID; |
| 450 | } |
| 451 | |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 452 | // ARM, Thumb, AArch64 |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 453 | unsigned llvm::ARM::parseArchISA(StringRef Arch) { |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 454 | return StringSwitch<unsigned>(Arch) |
| 455 | .StartsWith("aarch64", ARM::IK_AARCH64) |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 456 | .StartsWith("arm64", ARM::IK_AARCH64) |
| 457 | .StartsWith("thumb", ARM::IK_THUMB) |
| 458 | .StartsWith("arm", ARM::IK_ARM) |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 459 | .Default(ARM::EK_INVALID); |
| 460 | } |
| 461 | |
| 462 | // Little/Big endian |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 463 | unsigned llvm::ARM::parseArchEndian(StringRef Arch) { |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 464 | if (Arch.startswith("armeb") || Arch.startswith("thumbeb") || |
Renato Golin | b6b9e05 | 2015-05-21 13:52:20 +0000 | [diff] [blame] | 465 | Arch.startswith("aarch64_be")) |
| 466 | return ARM::EK_BIG; |
| 467 | |
| 468 | if (Arch.startswith("arm") || Arch.startswith("thumb")) { |
| 469 | if (Arch.endswith("eb")) |
| 470 | return ARM::EK_BIG; |
| 471 | else |
| 472 | return ARM::EK_LITTLE; |
| 473 | } |
| 474 | |
| 475 | if (Arch.startswith("aarch64")) |
| 476 | return ARM::EK_LITTLE; |
| 477 | |
| 478 | return ARM::EK_INVALID; |
| 479 | } |
| 480 | |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 481 | // Profile A/R/M |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 482 | unsigned llvm::ARM::parseArchProfile(StringRef Arch) { |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 483 | Arch = getCanonicalArchName(Arch); |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 484 | switch (parseArch(Arch)) { |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 485 | case ARM::AK_ARMV6M: |
| 486 | case ARM::AK_ARMV7M: |
| 487 | case ARM::AK_ARMV6SM: |
| 488 | case ARM::AK_ARMV7EM: |
| 489 | return ARM::PK_M; |
| 490 | case ARM::AK_ARMV7R: |
| 491 | return ARM::PK_R; |
| 492 | case ARM::AK_ARMV7: |
| 493 | case ARM::AK_ARMV7A: |
Alexandros Lamprineas | 0e20b8d | 2015-07-16 14:54:41 +0000 | [diff] [blame] | 494 | case ARM::AK_ARMV7L: |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 495 | case ARM::AK_ARMV8A: |
| 496 | case ARM::AK_ARMV8_1A: |
| 497 | return ARM::PK_A; |
| 498 | } |
| 499 | return ARM::PK_INVALID; |
| 500 | } |
| 501 | |
Renato Golin | ebdd12c | 2015-05-22 20:43:30 +0000 | [diff] [blame] | 502 | // Version number (ex. v7 = 7). |
Chandler Carruth | bb47b9a | 2015-08-30 02:09:48 +0000 | [diff] [blame] | 503 | unsigned llvm::ARM::parseArchVersion(StringRef Arch) { |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 504 | Arch = getCanonicalArchName(Arch); |
Chandler Carruth | 4fc3a98 | 2015-08-30 02:17:15 +0000 | [diff] [blame] | 505 | switch (parseArch(Arch)) { |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 506 | case ARM::AK_ARMV2: |
| 507 | case ARM::AK_ARMV2A: |
| 508 | return 2; |
| 509 | case ARM::AK_ARMV3: |
| 510 | case ARM::AK_ARMV3M: |
| 511 | return 3; |
| 512 | case ARM::AK_ARMV4: |
| 513 | case ARM::AK_ARMV4T: |
| 514 | return 4; |
| 515 | case ARM::AK_ARMV5: |
| 516 | case ARM::AK_ARMV5T: |
| 517 | case ARM::AK_ARMV5TE: |
| 518 | case ARM::AK_IWMMXT: |
| 519 | case ARM::AK_IWMMXT2: |
| 520 | case ARM::AK_XSCALE: |
| 521 | case ARM::AK_ARMV5E: |
| 522 | case ARM::AK_ARMV5TEJ: |
| 523 | return 5; |
| 524 | case ARM::AK_ARMV6: |
| 525 | case ARM::AK_ARMV6J: |
| 526 | case ARM::AK_ARMV6K: |
| 527 | case ARM::AK_ARMV6T2: |
| 528 | case ARM::AK_ARMV6Z: |
| 529 | case ARM::AK_ARMV6ZK: |
| 530 | case ARM::AK_ARMV6M: |
| 531 | case ARM::AK_ARMV6SM: |
| 532 | case ARM::AK_ARMV6HL: |
| 533 | return 6; |
| 534 | case ARM::AK_ARMV7: |
| 535 | case ARM::AK_ARMV7A: |
| 536 | case ARM::AK_ARMV7R: |
| 537 | case ARM::AK_ARMV7M: |
| 538 | case ARM::AK_ARMV7L: |
| 539 | case ARM::AK_ARMV7HL: |
| 540 | case ARM::AK_ARMV7S: |
| 541 | case ARM::AK_ARMV7EM: |
Vedant Kumar | 366dd9fd | 2015-08-21 21:52:48 +0000 | [diff] [blame] | 542 | case ARM::AK_ARMV7K: |
Renato Golin | fadc210 | 2015-05-22 18:17:55 +0000 | [diff] [blame] | 543 | return 7; |
| 544 | case ARM::AK_ARMV8A: |
| 545 | case ARM::AK_ARMV8_1A: |
| 546 | return 8; |
| 547 | } |
| 548 | return 0; |
| 549 | } |