LLDB mainline
ArchSpec.cpp
Go to the documentation of this file.
1//===-- ArchSpec.cpp ------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12#include "lldb/Utility/Log.h"
14#include "lldb/lldb-defines.h"
15#include "llvm/ADT/STLExtras.h"
16#include "llvm/BinaryFormat/COFF.h"
17#include "llvm/BinaryFormat/ELF.h"
18#include "llvm/BinaryFormat/MachO.h"
19#include "llvm/BinaryFormat/XCOFF.h"
20#include "llvm/Support/Compiler.h"
21#include "llvm/TargetParser/ARMTargetParser.h"
22
23using namespace lldb;
24using namespace lldb_private;
25
26static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2,
27 bool try_inverse, bool enforce_exact_match);
28
29namespace lldb_private {
30
36 llvm::Triple::ArchType machine;
38 const char *const name;
39};
40
41} // namespace lldb_private
42
43// This core information can be looked using the ArchSpec::Core as the index
44static constexpr const CoreDefinition g_core_definitions[] = {
45 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_generic,
46 "arm"},
47 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv4,
48 "armv4"},
49 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv4t,
50 "armv4t"},
51 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv5,
52 "armv5"},
53 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv5e,
54 "armv5e"},
55 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv5t,
56 "armv5t"},
57 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv6,
58 "armv6"},
59 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv6m,
60 "armv6m"},
61 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7,
62 "armv7"},
63 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7a,
64 "armv7a"},
65 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7l,
66 "armv7l"},
67 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7f,
68 "armv7f"},
69 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7s,
70 "armv7s"},
71 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7k,
72 "armv7k"},
73 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7m,
74 "armv7m"},
75 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7em,
76 "armv7em"},
77 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_xscale,
78 "xscale"},
79 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumb,
80 "thumb"},
81 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv4t,
82 "thumbv4t"},
83 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv5,
84 "thumbv5"},
85 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv5e,
86 "thumbv5e"},
87 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv6,
88 "thumbv6"},
89 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv6m,
90 "thumbv6m"},
91 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7,
92 "thumbv7"},
93 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7s,
94 "thumbv7s"},
95 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7k,
96 "thumbv7k"},
97 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7f,
98 "thumbv7f"},
99 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7m,
100 "thumbv7m"},
101 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7em,
102 "thumbv7em"},
103 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
105 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
107 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
109 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv8l,
110 "armv8l"},
111 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
113 {eByteOrderLittle, 4, 4, 4, llvm::Triple::aarch64_32,
114 ArchSpec::eCore_arm_arm64_32, "arm64_32"},
115 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
116 ArchSpec::eCore_arm_aarch64, "aarch64"},
117
118 // mips32, mips32r2, mips32r3, mips32r5, mips32r6
119 {eByteOrderBig, 4, 2, 4, llvm::Triple::mips, ArchSpec::eCore_mips32,
120 "mips"},
121 {eByteOrderBig, 4, 2, 4, llvm::Triple::mips, ArchSpec::eCore_mips32r2,
122 "mipsr2"},
123 {eByteOrderBig, 4, 2, 4, llvm::Triple::mips, ArchSpec::eCore_mips32r3,
124 "mipsr3"},
125 {eByteOrderBig, 4, 2, 4, llvm::Triple::mips, ArchSpec::eCore_mips32r5,
126 "mipsr5"},
127 {eByteOrderBig, 4, 2, 4, llvm::Triple::mips, ArchSpec::eCore_mips32r6,
128 "mipsr6"},
129 {eByteOrderLittle, 4, 2, 4, llvm::Triple::mipsel, ArchSpec::eCore_mips32el,
130 "mipsel"},
131 {eByteOrderLittle, 4, 2, 4, llvm::Triple::mipsel,
132 ArchSpec::eCore_mips32r2el, "mipsr2el"},
133 {eByteOrderLittle, 4, 2, 4, llvm::Triple::mipsel,
134 ArchSpec::eCore_mips32r3el, "mipsr3el"},
135 {eByteOrderLittle, 4, 2, 4, llvm::Triple::mipsel,
136 ArchSpec::eCore_mips32r5el, "mipsr5el"},
137 {eByteOrderLittle, 4, 2, 4, llvm::Triple::mipsel,
138 ArchSpec::eCore_mips32r6el, "mipsr6el"},
139
140 // mips64, mips64r2, mips64r3, mips64r5, mips64r6
141 {eByteOrderBig, 8, 2, 4, llvm::Triple::mips64, ArchSpec::eCore_mips64,
142 "mips64"},
143 {eByteOrderBig, 8, 2, 4, llvm::Triple::mips64, ArchSpec::eCore_mips64r2,
144 "mips64r2"},
145 {eByteOrderBig, 8, 2, 4, llvm::Triple::mips64, ArchSpec::eCore_mips64r3,
146 "mips64r3"},
147 {eByteOrderBig, 8, 2, 4, llvm::Triple::mips64, ArchSpec::eCore_mips64r5,
148 "mips64r5"},
149 {eByteOrderBig, 8, 2, 4, llvm::Triple::mips64, ArchSpec::eCore_mips64r6,
150 "mips64r6"},
151 {eByteOrderLittle, 8, 2, 4, llvm::Triple::mips64el,
152 ArchSpec::eCore_mips64el, "mips64el"},
153 {eByteOrderLittle, 8, 2, 4, llvm::Triple::mips64el,
154 ArchSpec::eCore_mips64r2el, "mips64r2el"},
155 {eByteOrderLittle, 8, 2, 4, llvm::Triple::mips64el,
156 ArchSpec::eCore_mips64r3el, "mips64r3el"},
157 {eByteOrderLittle, 8, 2, 4, llvm::Triple::mips64el,
158 ArchSpec::eCore_mips64r5el, "mips64r5el"},
159 {eByteOrderLittle, 8, 2, 4, llvm::Triple::mips64el,
160 ArchSpec::eCore_mips64r6el, "mips64r6el"},
161
162 // MSP430
163 {eByteOrderLittle, 2, 2, 4, llvm::Triple::msp430, ArchSpec::eCore_msp430,
164 "msp430"},
165
166 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_generic,
167 "powerpc"},
168 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc601,
169 "ppc601"},
170 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc602,
171 "ppc602"},
172 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc603,
173 "ppc603"},
174 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc603e,
175 "ppc603e"},
176 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc603ev,
177 "ppc603ev"},
178 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc604,
179 "ppc604"},
180 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc604e,
181 "ppc604e"},
182 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc620,
183 "ppc620"},
184 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc750,
185 "ppc750"},
186 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc7400,
187 "ppc7400"},
188 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc7450,
189 "ppc7450"},
190 {eByteOrderBig, 4, 4, 4, llvm::Triple::ppc, ArchSpec::eCore_ppc_ppc970,
191 "ppc970"},
192
193 {eByteOrderLittle, 8, 4, 4, llvm::Triple::ppc64le,
194 ArchSpec::eCore_ppc64le_generic, "powerpc64le"},
195 {eByteOrderBig, 8, 4, 4, llvm::Triple::ppc64, ArchSpec::eCore_ppc64_generic,
196 "powerpc64"},
197 {eByteOrderBig, 8, 4, 4, llvm::Triple::ppc64,
199
200 {eByteOrderBig, 8, 2, 6, llvm::Triple::systemz,
202
203 {eByteOrderLittle, 4, 4, 4, llvm::Triple::sparc,
205 {eByteOrderLittle, 8, 4, 4, llvm::Triple::sparcv9,
207
208 {eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, ArchSpec::eCore_x86_32_i386,
209 "i386"},
210 {eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, ArchSpec::eCore_x86_32_i486,
211 "i486"},
212 {eByteOrderLittle, 4, 1, 15, llvm::Triple::x86,
214 {eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, ArchSpec::eCore_x86_32_i686,
215 "i686"},
216
217 {eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64,
219 {eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64,
221 {eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64,
223
224 {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon,
226 {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon,
228 {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon,
230
231 {eByteOrderLittle, 4, 2, 8, llvm::Triple::riscv32, ArchSpec::eCore_riscv32,
232 "riscv32"},
233 {eByteOrderLittle, 8, 2, 8, llvm::Triple::riscv64, ArchSpec::eCore_riscv64,
234 "riscv64"},
235
236 {eByteOrderLittle, 4, 4, 4, llvm::Triple::loongarch32,
237 ArchSpec::eCore_loongarch32, "loongarch32"},
238 {eByteOrderLittle, 8, 4, 4, llvm::Triple::loongarch64,
239 ArchSpec::eCore_loongarch64, "loongarch64"},
240
241 {eByteOrderLittle, 4, 4, 4, llvm::Triple::UnknownArch,
242 ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
243 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
244 ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
245 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"},
246
247 {eByteOrderLittle, 2, 2, 4, llvm::Triple::avr, ArchSpec::eCore_avr, "avr"},
248
249 {eByteOrderLittle, 4, 1, 4, llvm::Triple::wasm32, ArchSpec::eCore_wasm32,
250 "wasm32"},
251};
252
253// Ensure that we have an entry in the g_core_definitions for each core. If you
254// comment out an entry above, you will need to comment out the corresponding
255// ArchSpec::Core enumeration.
256static_assert(sizeof(g_core_definitions) / sizeof(CoreDefinition) ==
258 "make sure we have one core definition for each core");
259
260template <int I> struct ArchSpecValidator : ArchSpecValidator<I + 1> {
261 static_assert(g_core_definitions[I].core == I,
262 "g_core_definitions order doesn't match Core enumeration");
263};
264
265template <> struct ArchSpecValidator<ArchSpec::kNumCores> {};
266
268
276
283
285 for (const auto &def : g_core_definitions)
286 list.AppendString(def.name);
287}
288
290 for (const auto &def : g_core_definitions)
291 request.TryCompleteCurrentArg(def.name);
292}
293
294#define CPU_ANY (UINT32_MAX)
295
296//===----------------------------------------------------------------------===//
297// A table that gets searched linearly for matches. This table is used to
298// convert cpu type and subtypes to architecture names, and to convert
299// architecture names to cpu types and subtypes. The ordering is important and
300// allows the precedence to be set when the table is built.
301#define SUBTYPE_MASK 0x00FFFFFFu
302
303// clang-format off
305 {ArchSpec::eCore_arm_generic, llvm::MachO::CPU_TYPE_ARM, CPU_ANY, UINT32_MAX, UINT32_MAX},
306 {ArchSpec::eCore_arm_generic, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_ALL, UINT32_MAX, SUBTYPE_MASK},
307 {ArchSpec::eCore_arm_armv4, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
308 {ArchSpec::eCore_arm_armv4t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
309 {ArchSpec::eCore_arm_armv6, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6, UINT32_MAX, SUBTYPE_MASK},
310 {ArchSpec::eCore_arm_armv6m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6M, UINT32_MAX, SUBTYPE_MASK},
311 {ArchSpec::eCore_arm_armv5, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
312 {ArchSpec::eCore_arm_armv5e, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
313 {ArchSpec::eCore_arm_armv5t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
314 {ArchSpec::eCore_arm_xscale, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_XSCALE, UINT32_MAX, SUBTYPE_MASK},
315 {ArchSpec::eCore_arm_armv7, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7, UINT32_MAX, SUBTYPE_MASK},
316 {ArchSpec::eCore_arm_armv7f, llvm::MachO::CPU_TYPE_ARM, 10, UINT32_MAX, SUBTYPE_MASK},
317 {ArchSpec::eCore_arm_armv7s, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7S, UINT32_MAX, SUBTYPE_MASK},
318 {ArchSpec::eCore_arm_armv7k, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7K, UINT32_MAX, SUBTYPE_MASK},
319 {ArchSpec::eCore_arm_armv7m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7M, UINT32_MAX, SUBTYPE_MASK},
320 {ArchSpec::eCore_arm_armv7em, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7EM, UINT32_MAX, SUBTYPE_MASK},
321 {ArchSpec::eCore_arm_arm64e, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64E, UINT32_MAX, SUBTYPE_MASK},
322 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_ALL, UINT32_MAX, SUBTYPE_MASK},
323 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_V8, UINT32_MAX, SUBTYPE_MASK},
324 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, 13, UINT32_MAX, SUBTYPE_MASK},
325 {ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 0, UINT32_MAX, SUBTYPE_MASK},
326 {ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 1, UINT32_MAX, SUBTYPE_MASK},
327 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
328 {ArchSpec::eCore_thumb, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_ALL, UINT32_MAX, SUBTYPE_MASK},
329 {ArchSpec::eCore_thumbv4t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
330 {ArchSpec::eCore_thumbv5, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5, UINT32_MAX, SUBTYPE_MASK},
331 {ArchSpec::eCore_thumbv5e, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5, UINT32_MAX, SUBTYPE_MASK},
332 {ArchSpec::eCore_thumbv6, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6, UINT32_MAX, SUBTYPE_MASK},
333 {ArchSpec::eCore_thumbv6m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6M, UINT32_MAX, SUBTYPE_MASK},
334 {ArchSpec::eCore_thumbv7, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7, UINT32_MAX, SUBTYPE_MASK},
335 {ArchSpec::eCore_thumbv7f, llvm::MachO::CPU_TYPE_ARM, 10, UINT32_MAX, SUBTYPE_MASK},
336 {ArchSpec::eCore_thumbv7s, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7S, UINT32_MAX, SUBTYPE_MASK},
337 {ArchSpec::eCore_thumbv7k, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7K, UINT32_MAX, SUBTYPE_MASK},
338 {ArchSpec::eCore_thumbv7m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7M, UINT32_MAX, SUBTYPE_MASK},
339 {ArchSpec::eCore_thumbv7em, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7EM, UINT32_MAX, SUBTYPE_MASK},
340 {ArchSpec::eCore_ppc_generic, llvm::MachO::CPU_TYPE_POWERPC, CPU_ANY, UINT32_MAX, UINT32_MAX},
341 {ArchSpec::eCore_ppc_generic, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_ALL, UINT32_MAX, SUBTYPE_MASK},
342 {ArchSpec::eCore_ppc_ppc601, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_601, UINT32_MAX, SUBTYPE_MASK},
343 {ArchSpec::eCore_ppc_ppc602, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_602, UINT32_MAX, SUBTYPE_MASK},
344 {ArchSpec::eCore_ppc_ppc603, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603, UINT32_MAX, SUBTYPE_MASK},
345 {ArchSpec::eCore_ppc_ppc603e, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603e, UINT32_MAX, SUBTYPE_MASK},
346 {ArchSpec::eCore_ppc_ppc603ev, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603ev, UINT32_MAX, SUBTYPE_MASK},
347 {ArchSpec::eCore_ppc_ppc604, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_604, UINT32_MAX, SUBTYPE_MASK},
348 {ArchSpec::eCore_ppc_ppc604e, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_604e, UINT32_MAX, SUBTYPE_MASK},
349 {ArchSpec::eCore_ppc_ppc620, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_620, UINT32_MAX, SUBTYPE_MASK},
350 {ArchSpec::eCore_ppc_ppc750, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_750, UINT32_MAX, SUBTYPE_MASK},
351 {ArchSpec::eCore_ppc_ppc7400, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_7400, UINT32_MAX, SUBTYPE_MASK},
352 {ArchSpec::eCore_ppc_ppc7450, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_7450, UINT32_MAX, SUBTYPE_MASK},
353 {ArchSpec::eCore_ppc_ppc970, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_970, UINT32_MAX, SUBTYPE_MASK},
354 {ArchSpec::eCore_ppc64_generic, llvm::MachO::CPU_TYPE_POWERPC64, llvm::MachO::CPU_SUBTYPE_POWERPC_ALL, UINT32_MAX, SUBTYPE_MASK},
355 {ArchSpec::eCore_ppc64le_generic, llvm::MachO::CPU_TYPE_POWERPC64, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
356 {ArchSpec::eCore_ppc64_ppc970_64, llvm::MachO::CPU_TYPE_POWERPC64, 100, UINT32_MAX, SUBTYPE_MASK},
357 {ArchSpec::eCore_x86_32_i386, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_I386_ALL, UINT32_MAX, SUBTYPE_MASK},
358 {ArchSpec::eCore_x86_32_i486, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_486, UINT32_MAX, SUBTYPE_MASK},
359 {ArchSpec::eCore_x86_32_i486sx, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_486SX, UINT32_MAX, SUBTYPE_MASK},
360 {ArchSpec::eCore_x86_32_i386, llvm::MachO::CPU_TYPE_I386, CPU_ANY, UINT32_MAX, UINT32_MAX},
361 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_64_ALL, UINT32_MAX, SUBTYPE_MASK},
362 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_ARCH1, UINT32_MAX, SUBTYPE_MASK},
363 {ArchSpec::eCore_x86_64_x86_64h, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_64_H, UINT32_MAX, SUBTYPE_MASK},
364 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, CPU_ANY, UINT32_MAX, UINT32_MAX},
365 {ArchSpec::eCore_riscv32, llvm::MachO::CPU_TYPE_RISCV, llvm::MachO::CPU_SUBTYPE_RISCV_ALL, UINT32_MAX, SUBTYPE_MASK},
366 {ArchSpec::eCore_riscv32, llvm::MachO::CPU_TYPE_RISCV, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
367 // Catch any unknown mach architectures so we can always use the object and symbol mach-o files
368 {ArchSpec::eCore_uknownMach32, 0, 0, 0xFF000000u, 0x00000000u},
369 {ArchSpec::eCore_uknownMach64, llvm::MachO::CPU_ARCH_ABI64, 0, 0xFF000000u, 0x00000000u}
370};
371// clang-format on
372
376
377//===----------------------------------------------------------------------===//
378// A table that gets searched linearly for matches. This table is used to
379// convert cpu type and subtypes to architecture names, and to convert
380// architecture names to cpu types and subtypes. The ordering is important and
381// allows the precedence to be set when the table is built.
382// clang-format off
384 {ArchSpec::eCore_sparc_generic, llvm::ELF::EM_SPARC }, // Sparc
385 {ArchSpec::eCore_x86_32_i386, llvm::ELF::EM_386 }, // Intel 80386
386 {ArchSpec::eCore_x86_32_i486, llvm::ELF::EM_IAMCU }, // Intel MCU // FIXME: is this correct?
387 {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC }, // PowerPC
388 {ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, ArchSpec::eCore_ppc64le_generic}, // PowerPC64le
389 {ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, ArchSpec::eCore_ppc64_generic}, // PowerPC64
390 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM }, // ARM
391 {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64 }, // ARM64
392 {ArchSpec::eCore_s390x_generic, llvm::ELF::EM_S390 }, // SystemZ
393 {ArchSpec::eCore_sparc9_generic, llvm::ELF::EM_SPARCV9 }, // SPARC V9
394 {ArchSpec::eCore_x86_64_x86_64, llvm::ELF::EM_X86_64 }, // AMD64
395 {ArchSpec::eCore_mips32, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32}, // mips32
396 {ArchSpec::eCore_mips32r2, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r2}, // mips32r2
397 {ArchSpec::eCore_mips32r6, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r6}, // mips32r6
398 {ArchSpec::eCore_mips32el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32el}, // mips32el
399 {ArchSpec::eCore_mips32r2el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r2el}, // mips32r2el
400 {ArchSpec::eCore_mips32r6el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r6el}, // mips32r6el
402 {ArchSpec::eCore_mips64r2, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r2}, // mips64r2
403 {ArchSpec::eCore_mips64r6, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r6}, // mips64r6
404 {ArchSpec::eCore_mips64el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64el}, // mips64el
405 {ArchSpec::eCore_mips64r2el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r2el}, // mips64r2el
406 {ArchSpec::eCore_mips64r6el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r6el}, // mips64r6el
407 {ArchSpec::eCore_msp430, llvm::ELF::EM_MSP430 }, // MSP430
408 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON }, // HEXAGON
409 {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2}, // ARC
410 {ArchSpec::eCore_avr, llvm::ELF::EM_AVR }, // AVR
411 {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32}, // riscv32
412 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv64}, // riscv64
413 {ArchSpec::eCore_loongarch32, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch32}, // loongarch32
414 {ArchSpec::eCore_loongarch64, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch64}, // loongarch64
415};
416// clang-format on
417
420 std::size(g_elf_arch_entries),
422 "elf",
423};
424// clang-format off
426 {ArchSpec::eCore_x86_32_i386, llvm::COFF::IMAGE_FILE_MACHINE_I386}, // Intel 80x86
427 {ArchSpec::eCore_ppc_generic, llvm::COFF::IMAGE_FILE_MACHINE_POWERPC}, // PowerPC
428 {ArchSpec::eCore_ppc_generic, llvm::COFF::IMAGE_FILE_MACHINE_POWERPCFP}, // PowerPC (with FPU)
429 {ArchSpec::eCore_arm_generic, llvm::COFF::IMAGE_FILE_MACHINE_ARM}, // ARM
430 {ArchSpec::eCore_arm_armv7, llvm::COFF::IMAGE_FILE_MACHINE_ARMNT}, // ARMv7
431 {ArchSpec::eCore_thumb, llvm::COFF::IMAGE_FILE_MACHINE_THUMB}, // ARMv7
432 {ArchSpec::eCore_x86_64_x86_64, llvm::COFF::IMAGE_FILE_MACHINE_AMD64}, // AMD64
433 {ArchSpec::eCore_arm_arm64, llvm::COFF::IMAGE_FILE_MACHINE_ARM64} // ARM64
434};
435// clang-format on
436
439 std::size(g_coff_arch_entries),
441 "pe-coff",
442};
443
444// clang-format off
446 {ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM},
447 {ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64}
448};
449// clang-format on
450
453 std::size(g_xcoff_arch_entries),
455 "xcoff",
456};
457
458//===----------------------------------------------------------------------===//
459// Table of all ArchDefinitions
462
463//===----------------------------------------------------------------------===//
464// Static helper functions.
465
466// Get the architecture definition for a given object type.
468 for (const ArchDefinition *def : g_arch_definitions) {
469 if (def->type == arch_type)
470 return def;
471 }
472 return nullptr;
473}
474
475// Get an architecture definition by name.
476static const CoreDefinition *FindCoreDefinition(llvm::StringRef name) {
477 for (const auto &def : g_core_definitions) {
478 if (name.equals_insensitive(def.name))
479 return &def;
480 }
481 return nullptr;
482}
483
485 if (core < std::size(g_core_definitions))
486 return &g_core_definitions[core];
487 return nullptr;
488}
489
490// Get a definition entry by cpu type and subtype.
491static const ArchDefinitionEntry *
492FindArchDefinitionEntry(const ArchDefinition *def, uint32_t cpu, uint32_t sub) {
493 if (def == nullptr)
494 return nullptr;
495
496 const ArchDefinitionEntry *entries = def->entries;
497 for (size_t i = 0; i < def->num_entries; ++i) {
498 if (entries[i].cpu == (cpu & entries[i].cpu_mask))
499 if (entries[i].sub == (sub & entries[i].sub_mask))
500 return &entries[i];
501 }
502 return nullptr;
503}
504
505static const ArchDefinitionEntry *
507 if (def == nullptr)
508 return nullptr;
509
510 const ArchDefinitionEntry *entries = def->entries;
511 for (size_t i = 0; i < def->num_entries; ++i) {
512 if (entries[i].core == core)
513 return &entries[i];
514 }
515 return nullptr;
516}
517
518//===----------------------------------------------------------------------===//
519// Constructors and destructors.
520
521ArchSpec::ArchSpec() = default;
522
523ArchSpec::ArchSpec(const char *triple_cstr) {
524 if (triple_cstr)
525 SetTriple(triple_cstr);
526}
527
528ArchSpec::ArchSpec(llvm::StringRef triple_str) { SetTriple(triple_str); }
529
530ArchSpec::ArchSpec(const llvm::Triple &triple) { SetTriple(triple); }
531
532ArchSpec::ArchSpec(ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) {
533 SetArchitecture(arch_type, cpu, subtype);
534}
535
536ArchSpec::~ArchSpec() = default;
537
539 m_triple = llvm::Triple();
542 m_flags = 0;
543}
544
545//===----------------------------------------------------------------------===//
546// Predicates.
547
548const char *ArchSpec::GetArchitectureName() const {
549 const CoreDefinition *core_def = FindCoreDefinition(m_core);
550 if (core_def)
551 return core_def->name;
552 return "unknown";
553}
554
555bool ArchSpec::IsMIPS() const { return GetTriple().isMIPS(); }
556
557bool ArchSpec::IsNVPTX() const { return GetTriple().isNVPTX(); }
558
559std::string ArchSpec::GetTargetABI() const {
560
561 std::string abi;
562
563 if (IsMIPS()) {
564 switch (GetFlags() & ArchSpec::eMIPSABI_mask) {
566 abi = "n64";
567 return abi;
569 abi = "n32";
570 return abi;
572 abi = "o32";
573 return abi;
574 default:
575 return abi;
576 }
577 }
578 return abi;
579}
580
581void ArchSpec::SetFlags(const std::string &elf_abi) {
582
583 uint32_t flag = GetFlags();
584 if (IsMIPS()) {
585 if (elf_abi == "n64")
587 else if (elf_abi == "n32")
589 else if (elf_abi == "o32")
591 }
592 SetFlags(flag);
593}
594
595std::string ArchSpec::GetClangTargetCPU() const {
596 std::string cpu;
597 if (IsMIPS()) {
598 switch (m_core) {
601 cpu = "mips32";
602 break;
605 cpu = "mips32r2";
606 break;
609 cpu = "mips32r3";
610 break;
613 cpu = "mips32r5";
614 break;
617 cpu = "mips32r6";
618 break;
621 cpu = "mips64";
622 break;
625 cpu = "mips64r2";
626 break;
629 cpu = "mips64r3";
630 break;
633 cpu = "mips64r5";
634 break;
637 cpu = "mips64r6";
638 break;
639 default:
640 break;
641 }
642 }
643
644 if (GetTriple().isARM())
645 cpu = llvm::ARM::getARMCPUForArch(GetTriple(), "").str();
646 return cpu;
647}
648
650 const CoreDefinition *core_def = FindCoreDefinition(m_core);
651 if (core_def) {
652 const ArchDefinitionEntry *arch_def =
654 if (arch_def) {
655 return arch_def->cpu;
656 }
657 }
659}
660
662 const CoreDefinition *core_def = FindCoreDefinition(m_core);
663 if (core_def) {
664 const ArchDefinitionEntry *arch_def =
666 if (arch_def) {
667 return arch_def->sub;
668 }
669 }
671}
672
673llvm::Triple::ArchType ArchSpec::GetMachine() const {
674 const CoreDefinition *core_def = FindCoreDefinition(m_core);
675 if (core_def)
676 return core_def->machine;
677
678 return llvm::Triple::UnknownArch;
679}
680
682 const CoreDefinition *core_def = FindCoreDefinition(m_core);
683 if (core_def) {
684 if (core_def->machine == llvm::Triple::mips64 ||
685 core_def->machine == llvm::Triple::mips64el) {
686 // For N32/O32 applications Address size is 4 bytes.
688 return 4;
689 }
690 return core_def->addr_byte_size;
691 }
692 return 0;
693}
694
696 const CoreDefinition *core_def = FindCoreDefinition(m_core);
697 if (core_def)
698 return core_def->default_byte_order;
699 return eByteOrderInvalid;
700}
701
703 switch (m_triple.getArch()) {
704 default:
705 return true;
706
707 case llvm::Triple::aarch64:
708 case llvm::Triple::aarch64_32:
709 case llvm::Triple::aarch64_be:
710 case llvm::Triple::arm:
711 case llvm::Triple::armeb:
712 case llvm::Triple::thumb:
713 case llvm::Triple::thumbeb:
714 return m_triple.isOSDarwin() || m_triple.isOSWindows();
715
716 case llvm::Triple::ppc:
717 case llvm::Triple::ppc64:
718 return m_triple.isOSDarwin();
719
720 case llvm::Triple::riscv64:
721 case llvm::Triple::riscv32:
722 case llvm::Triple::ppc64le:
723 case llvm::Triple::systemz:
724 case llvm::Triple::xcore:
725 case llvm::Triple::arc:
726 return false;
727 }
728}
729
735
736//===----------------------------------------------------------------------===//
737// Mutators.
738
739bool ArchSpec::SetTriple(const llvm::Triple &triple) {
740 m_triple = triple;
741 UpdateCore();
742 return IsValid();
743}
744
745bool lldb_private::ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str,
746 ArchSpec &arch) {
747 // Accept "12-10" or "12.10" as cpu type/subtype
748 if (triple_str.empty())
749 return false;
750
751 size_t pos = triple_str.find_first_of("-.");
752 if (pos == llvm::StringRef::npos)
753 return false;
754
755 llvm::StringRef cpu_str = triple_str.substr(0, pos);
756 llvm::StringRef remainder = triple_str.substr(pos + 1);
757 if (cpu_str.empty() || remainder.empty())
758 return false;
759
760 llvm::StringRef sub_str;
761 llvm::StringRef vendor;
762 llvm::StringRef os;
763 std::tie(sub_str, remainder) = remainder.split('-');
764 std::tie(vendor, os) = remainder.split('-');
765
766 uint32_t cpu = 0;
767 uint32_t sub = 0;
768 if (cpu_str.getAsInteger(10, cpu) || sub_str.getAsInteger(10, sub))
769 return false;
770
771 if (!arch.SetArchitecture(eArchTypeMachO, cpu, sub))
772 return false;
773 if (!vendor.empty() && !os.empty()) {
774 arch.GetTriple().setVendorName(vendor);
775 arch.GetTriple().setOSName(os);
776 }
777
778 return true;
779}
780
781bool ArchSpec::SetTriple(llvm::StringRef triple) {
782 if (triple.empty()) {
783 Clear();
784 return false;
785 }
786
787 if (ParseMachCPUDashSubtypeTriple(triple, *this))
788 return true;
789
790 SetTriple(llvm::Triple(llvm::Triple::normalize(triple)));
791 return IsValid();
792}
793
794bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) {
795 return !normalized_triple.getArchName().empty() &&
796 normalized_triple.getOSName().empty() &&
797 normalized_triple.getVendorName().empty() &&
798 normalized_triple.getEnvironmentName().empty();
799}
800
801void ArchSpec::MergeFrom(const ArchSpec &other) {
802 // ios-macabi always wins over macosx.
803 if ((GetTriple().getOS() == llvm::Triple::MacOSX ||
804 GetTriple().getOS() == llvm::Triple::UnknownOS) &&
805 other.GetTriple().getOS() == llvm::Triple::IOS &&
806 other.GetTriple().getEnvironment() == llvm::Triple::MacABI) {
807 (*this) = other;
808 return;
809 }
810
812 GetTriple().setVendor(other.GetTriple().getVendor());
814 GetTriple().setOS(other.GetTriple().getOS());
815 if (GetTriple().getArch() == llvm::Triple::UnknownArch) {
816 GetTriple().setArch(other.GetTriple().getArch());
817
818 // MachO unknown64 isn't really invalid as the debugger can still obtain
819 // information from the binary, e.g. line tables. As such, we don't update
820 // the core here.
821 if (other.GetCore() != eCore_uknownMach64)
822 UpdateCore();
823 }
826 GetTriple().setEnvironment(other.GetTriple().getEnvironment());
827 }
828 // If this and other are both arm ArchSpecs and this ArchSpec is a generic
829 // "some kind of arm" spec but the other ArchSpec is a specific arm core,
830 // adopt the specific arm core.
831 if (GetTriple().getArch() == llvm::Triple::arm &&
832 other.GetTriple().getArch() == llvm::Triple::arm &&
835 m_core = other.GetCore();
836 CoreUpdated(false);
837 }
838 if (GetFlags() == 0) {
839 SetFlags(other.GetFlags());
840 }
841}
842
843bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
844 uint32_t sub, uint32_t os) {
846 bool update_triple = true;
847 const ArchDefinition *arch_def = FindArchDefinition(arch_type);
848 if (arch_def) {
849 const ArchDefinitionEntry *arch_def_entry =
850 FindArchDefinitionEntry(arch_def, cpu, sub);
851 if (arch_def_entry) {
852 const CoreDefinition *core_def = FindCoreDefinition(arch_def_entry->core);
853 if (core_def) {
854 m_core = core_def->core;
855 update_triple = false;
856 // Always use the architecture name because it might be more
857 // descriptive than the architecture enum ("armv7" ->
858 // llvm::Triple::arm).
859 m_triple.setArchName(llvm::StringRef(core_def->name));
860 if (arch_type == eArchTypeMachO) {
861 m_triple.setVendor(llvm::Triple::Apple);
862
863 // Don't set the OS. It could be simulator, macosx, ios, watchos,
864 // tvos, bridgeos. We could get close with the cpu type - but we
865 // can't get it right all of the time. Better to leave this unset
866 // so other sections of code will set it when they have more
867 // information. NB: don't call m_triple.setOS
868 // (llvm::Triple::UnknownOS). That sets the OSName to "unknown" and
869 // the ArchSpec::TripleVendorWasSpecified() method says that any
870 // OSName setting means it was specified.
871 } else if (arch_type == eArchTypeELF) {
872 switch (os) {
873 case llvm::ELF::ELFOSABI_AIX:
874 m_triple.setOS(llvm::Triple::OSType::AIX);
875 break;
876 case llvm::ELF::ELFOSABI_FREEBSD:
877 m_triple.setOS(llvm::Triple::OSType::FreeBSD);
878 break;
879 case llvm::ELF::ELFOSABI_GNU:
880 m_triple.setOS(llvm::Triple::OSType::Linux);
881 break;
882 case llvm::ELF::ELFOSABI_NETBSD:
883 m_triple.setOS(llvm::Triple::OSType::NetBSD);
884 break;
885 case llvm::ELF::ELFOSABI_OPENBSD:
886 m_triple.setOS(llvm::Triple::OSType::OpenBSD);
887 break;
888 case llvm::ELF::ELFOSABI_SOLARIS:
889 m_triple.setOS(llvm::Triple::OSType::Solaris);
890 break;
891 case llvm::ELF::ELFOSABI_STANDALONE:
892 m_triple.setOS(llvm::Triple::OSType::UnknownOS);
893 break;
894 }
895 } else if (arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
896 m_triple.setVendor(llvm::Triple::PC);
897 m_triple.setOS(llvm::Triple::Win32);
898 } else if (arch_type == eArchTypeXCOFF && os == llvm::Triple::AIX) {
899 m_triple.setVendor(llvm::Triple::IBM);
900 m_triple.setOS(llvm::Triple::AIX);
901 } else {
902 m_triple.setVendor(llvm::Triple::UnknownVendor);
903 m_triple.setOS(llvm::Triple::UnknownOS);
904 }
905 // Fall back onto setting the machine type if the arch by name
906 // failed...
907 if (m_triple.getArch() == llvm::Triple::UnknownArch)
908 m_triple.setArch(core_def->machine);
909 }
910 } else {
912 LLDB_LOGF(log,
913 "Unable to find a core definition for cpu 0x%" PRIx32
914 " sub %" PRId32,
915 cpu, sub);
916 }
917 }
918 CoreUpdated(update_triple);
919 return IsValid();
920}
921
923 const CoreDefinition *core_def = FindCoreDefinition(m_core);
924 if (core_def)
925 return core_def->min_opcode_byte_size;
926 return 0;
927}
928
930 const CoreDefinition *core_def = FindCoreDefinition(m_core);
931 if (core_def)
932 return core_def->max_opcode_byte_size;
933 return 0;
934}
935
936static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs,
937 llvm::Triple::EnvironmentType rhs) {
938 if (lhs == rhs)
939 return true;
940
941 // Apple simulators are a different platform than what they simulate.
942 // As the environments are different at this point, if one of them is a
943 // simulator, then they are different.
944 if (lhs == llvm::Triple::Simulator || rhs == llvm::Triple::Simulator)
945 return false;
946
947 // If any of the environment is unknown then they are compatible
948 if (lhs == llvm::Triple::UnknownEnvironment ||
949 rhs == llvm::Triple::UnknownEnvironment)
950 return true;
951
952 // If one of the environment is Android and the other one is EABI then they
953 // are considered to be compatible. This is required as a workaround for
954 // shared libraries compiled for Android without the NOTE section indicating
955 // that they are using the Android ABI.
956 if ((lhs == llvm::Triple::Android && rhs == llvm::Triple::EABI) ||
957 (rhs == llvm::Triple::Android && lhs == llvm::Triple::EABI) ||
958 (lhs == llvm::Triple::GNUEABI && rhs == llvm::Triple::EABI) ||
959 (rhs == llvm::Triple::GNUEABI && lhs == llvm::Triple::EABI) ||
960 (lhs == llvm::Triple::GNUEABIHF && rhs == llvm::Triple::EABIHF) ||
961 (rhs == llvm::Triple::GNUEABIHF && lhs == llvm::Triple::EABIHF))
962 return true;
963
964 return false;
965}
966
967bool ArchSpec::IsMatch(const ArchSpec &rhs, MatchType match) const {
968 if (GetByteOrder() != rhs.GetByteOrder() ||
969 !cores_match(GetCore(), rhs.GetCore(), true, match == ExactMatch))
970 return false;
971
972 const llvm::Triple &lhs_triple = GetTriple();
973 const llvm::Triple &rhs_triple = rhs.GetTriple();
974
975 const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
976 const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
977
978 const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
979 const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
980
981 bool both_windows = lhs_triple.isOSWindows() && rhs_triple.isOSWindows();
982
983 // On Windows, the vendor field doesn't have any practical effect, but
984 // it is often set to either "pc" or "w64".
985 if ((lhs_triple_vendor != rhs_triple_vendor) &&
986 (match == ExactMatch || !both_windows)) {
987 const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
988 const bool lhs_vendor_specified = TripleVendorWasSpecified();
989 // Both architectures had the vendor specified, so if they aren't equal
990 // then we return false
991 if (rhs_vendor_specified && lhs_vendor_specified)
992 return false;
993
994 // Only fail if both vendor types are not unknown
995 if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
996 rhs_triple_vendor != llvm::Triple::UnknownVendor)
997 return false;
998 }
999
1000 const llvm::Triple::EnvironmentType lhs_triple_env =
1001 lhs_triple.getEnvironment();
1002 const llvm::Triple::EnvironmentType rhs_triple_env =
1003 rhs_triple.getEnvironment();
1004
1005 if (match == CompatibleMatch) {
1006 // x86_64-apple-ios-macabi, x86_64-apple-macosx are compatible, no match.
1007 if ((lhs_triple_os == llvm::Triple::IOS &&
1008 lhs_triple_env == llvm::Triple::MacABI &&
1009 rhs_triple_os == llvm::Triple::MacOSX) ||
1010 (lhs_triple_os == llvm::Triple::MacOSX &&
1011 rhs_triple_os == llvm::Triple::IOS &&
1012 rhs_triple_env == llvm::Triple::MacABI))
1013 return true;
1014 // x86_64-apple-driverkit, x86_64-apple-macosx are compatible, no match.
1015 if ((lhs_triple_os == llvm::Triple::DriverKit &&
1016 rhs_triple_os == llvm::Triple::MacOSX) ||
1017 (lhs_triple_os == llvm::Triple::MacOSX &&
1018 rhs_triple_os == llvm::Triple::DriverKit))
1019 return true;
1020 }
1021
1022 // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
1023 if (lhs_triple_os == llvm::Triple::IOS &&
1024 rhs_triple_os == llvm::Triple::IOS &&
1025 (lhs_triple_env == llvm::Triple::MacABI ||
1026 rhs_triple_env == llvm::Triple::MacABI) &&
1027 lhs_triple_env != rhs_triple_env)
1028 return false;
1029
1030 if (lhs_triple_os != rhs_triple_os) {
1031 const bool lhs_os_specified = TripleOSWasSpecified();
1032 const bool rhs_os_specified = rhs.TripleOSWasSpecified();
1033 // If both OS types are specified and different, fail.
1034 if (lhs_os_specified && rhs_os_specified)
1035 return false;
1036
1037 // If the pair of os+env is both unspecified, match any other os+env combo.
1038 if (match == CompatibleMatch &&
1039 ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
1040 (!rhs_os_specified && !rhs_triple.hasEnvironment())))
1041 return true;
1042 }
1043
1044 if (match == CompatibleMatch && both_windows)
1045 return true; // The Windows environments (MSVC vs GNU) are compatible
1046
1047 return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
1048}
1049
1051 llvm::StringRef arch_name(m_triple.getArchName());
1052 const CoreDefinition *core_def = FindCoreDefinition(arch_name);
1053 if (core_def) {
1054 m_core = core_def->core;
1055 // Set the byte order to the default byte order for an architecture. This
1056 // can be modified if needed for cases when cores handle both big and
1057 // little endian
1058 m_byte_order = core_def->default_byte_order;
1059 } else {
1060 Clear();
1061 }
1062}
1063
1064//===----------------------------------------------------------------------===//
1065// Helper methods.
1066
1067void ArchSpec::CoreUpdated(bool update_triple) {
1068 const CoreDefinition *core_def = FindCoreDefinition(m_core);
1069 if (core_def) {
1070 if (update_triple)
1071 m_triple = llvm::Triple(core_def->name, "unknown", "unknown");
1072 m_byte_order = core_def->default_byte_order;
1073 } else {
1074 if (update_triple)
1075 m_triple = llvm::Triple();
1077 }
1078}
1079
1080//===----------------------------------------------------------------------===//
1081// Operators.
1082
1083static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2,
1084 bool try_inverse, bool enforce_exact_match) {
1085 if (core1 == core2)
1086 return true;
1087
1088 switch (core1) {
1090 return true;
1091
1093 if (enforce_exact_match)
1094 break;
1095 [[fallthrough]];
1097 if (core2 >= ArchSpec::kCore_arm_first && core2 <= ArchSpec::kCore_arm_last)
1098 return true;
1099 if (core2 >= ArchSpec::kCore_thumb_first &&
1101 return true;
1102 if (core2 == ArchSpec::kCore_arm_any)
1103 return true;
1104 break;
1105
1107 if ((core2 >= ArchSpec::kCore_x86_32_first &&
1108 core2 <= ArchSpec::kCore_x86_32_last) ||
1109 (core2 == ArchSpec::kCore_x86_32_any))
1110 return true;
1111 break;
1112
1114 if ((core2 >= ArchSpec::kCore_x86_64_first &&
1115 core2 <= ArchSpec::kCore_x86_64_last) ||
1116 (core2 == ArchSpec::kCore_x86_64_any))
1117 return true;
1118 break;
1119
1121 if ((core2 >= ArchSpec::kCore_ppc_first &&
1122 core2 <= ArchSpec::kCore_ppc_last) ||
1123 (core2 == ArchSpec::kCore_ppc_any))
1124 return true;
1125 break;
1126
1128 if ((core2 >= ArchSpec::kCore_ppc64_first &&
1129 core2 <= ArchSpec::kCore_ppc64_last) ||
1130 (core2 == ArchSpec::kCore_ppc64_any))
1131 return true;
1132 break;
1133
1135 if ((core2 >= ArchSpec::kCore_hexagon_first &&
1136 core2 <= ArchSpec::kCore_hexagon_last) ||
1137 (core2 == ArchSpec::kCore_hexagon_any))
1138 return true;
1139 break;
1140
1141 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1142 // Cortex-M0 - ARMv6-M - armv6m
1143 // Cortex-M3 - ARMv7-M - armv7m
1144 // Cortex-M4 - ARMv7E-M - armv7em
1146 if (!enforce_exact_match) {
1147 if (core2 == ArchSpec::eCore_arm_generic)
1148 return true;
1149 if (core2 == ArchSpec::eCore_arm_armv7m)
1150 return true;
1151 if (core2 == ArchSpec::eCore_arm_armv6m)
1152 return true;
1153 if (core2 == ArchSpec::eCore_arm_armv7)
1154 return true;
1155 try_inverse = true;
1156 }
1157 break;
1158
1159 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1160 // Cortex-M0 - ARMv6-M - armv6m
1161 // Cortex-M3 - ARMv7-M - armv7m
1162 // Cortex-M4 - ARMv7E-M - armv7em
1164 if (!enforce_exact_match) {
1165 if (core2 == ArchSpec::eCore_arm_generic)
1166 return true;
1167 if (core2 == ArchSpec::eCore_arm_armv6m)
1168 return true;
1169 if (core2 == ArchSpec::eCore_arm_armv7)
1170 return true;
1171 if (core2 == ArchSpec::eCore_arm_armv7em)
1172 return true;
1173 try_inverse = true;
1174 }
1175 break;
1176
1177 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1178 // Cortex-M0 - ARMv6-M - armv6m
1179 // Cortex-M3 - ARMv7-M - armv7m
1180 // Cortex-M4 - ARMv7E-M - armv7em
1182 if (!enforce_exact_match) {
1183 if (core2 == ArchSpec::eCore_arm_generic)
1184 return true;
1185 if (core2 == ArchSpec::eCore_arm_armv7em)
1186 return true;
1187 if (core2 == ArchSpec::eCore_arm_armv7)
1188 return true;
1189 if (core2 == ArchSpec::eCore_arm_armv6m)
1190 return true;
1191 try_inverse = false;
1192 }
1193 break;
1194
1200 if (!enforce_exact_match) {
1201 if (core2 == ArchSpec::eCore_arm_generic)
1202 return true;
1203 if (core2 == ArchSpec::eCore_arm_armv7)
1204 return true;
1205 try_inverse = false;
1206 }
1207 break;
1208
1211 if (!enforce_exact_match) {
1212 try_inverse = false;
1213 if (core2 == ArchSpec::eCore_x86_64_x86_64)
1214 return true;
1215 }
1216 break;
1217
1219 if (!enforce_exact_match) {
1220 if (core2 == ArchSpec::eCore_arm_arm64)
1221 return true;
1222 if (core2 == ArchSpec::eCore_arm_aarch64)
1223 return true;
1224 if (core2 == ArchSpec::eCore_arm_arm64e)
1225 return true;
1226 try_inverse = false;
1227 }
1228 break;
1229
1231 if (!enforce_exact_match) {
1232 if (core2 == ArchSpec::eCore_arm_arm64)
1233 return true;
1234 if (core2 == ArchSpec::eCore_arm_aarch64)
1235 return true;
1236 if (core2 == ArchSpec::eCore_arm_armv8)
1237 return true;
1238 try_inverse = false;
1239 }
1240 break;
1242 if (!enforce_exact_match) {
1243 if (core2 == ArchSpec::eCore_arm_arm64)
1244 return true;
1245 if (core2 == ArchSpec::eCore_arm_armv8)
1246 return true;
1247 if (core2 == ArchSpec::eCore_arm_arm64e)
1248 return true;
1249 try_inverse = false;
1250 }
1251 break;
1252
1254 if (!enforce_exact_match) {
1255 if (core2 == ArchSpec::eCore_arm_aarch64)
1256 return true;
1257 if (core2 == ArchSpec::eCore_arm_armv8)
1258 return true;
1259 if (core2 == ArchSpec::eCore_arm_arm64e)
1260 return true;
1261 try_inverse = false;
1262 }
1263 break;
1264
1266 if (!enforce_exact_match) {
1267 if (core2 == ArchSpec::eCore_arm_generic)
1268 return true;
1269 try_inverse = false;
1270 }
1271 break;
1272
1274 if (!enforce_exact_match) {
1275 if (core2 >= ArchSpec::kCore_mips32_first &&
1277 return true;
1278 try_inverse = false;
1279 }
1280 break;
1281
1283 if (!enforce_exact_match) {
1284 if (core2 >= ArchSpec::kCore_mips32el_first &&
1286 return true;
1287 try_inverse = true;
1288 }
1289 break;
1290
1292 if (!enforce_exact_match) {
1293 if (core2 >= ArchSpec::kCore_mips32_first &&
1295 return true;
1296 if (core2 >= ArchSpec::kCore_mips64_first &&
1298 return true;
1299 try_inverse = false;
1300 }
1301 break;
1302
1304 if (!enforce_exact_match) {
1305 if (core2 >= ArchSpec::kCore_mips32el_first &&
1307 return true;
1308 if (core2 >= ArchSpec::kCore_mips64el_first &&
1310 return true;
1311 try_inverse = false;
1312 }
1313 break;
1314
1318 if (!enforce_exact_match) {
1319 if (core2 >= ArchSpec::kCore_mips32_first && core2 <= (core1 - 10))
1320 return true;
1321 if (core2 >= ArchSpec::kCore_mips64_first && core2 <= (core1 - 1))
1322 return true;
1323 try_inverse = false;
1324 }
1325 break;
1326
1330 if (!enforce_exact_match) {
1331 if (core2 >= ArchSpec::kCore_mips32el_first && core2 <= (core1 - 10))
1332 return true;
1333 if (core2 >= ArchSpec::kCore_mips64el_first && core2 <= (core1 - 1))
1334 return true;
1335 try_inverse = false;
1336 }
1337 break;
1338
1342 if (!enforce_exact_match) {
1343 if (core2 >= ArchSpec::kCore_mips32_first && core2 <= core1)
1344 return true;
1345 }
1346 break;
1347
1351 if (!enforce_exact_match) {
1352 if (core2 >= ArchSpec::kCore_mips32el_first && core2 <= core1)
1353 return true;
1354 }
1355 break;
1356
1358 if (!enforce_exact_match) {
1359 if (core2 == ArchSpec::eCore_mips32 || core2 == ArchSpec::eCore_mips32r6)
1360 return true;
1361 }
1362 break;
1363
1365 if (!enforce_exact_match) {
1366 if (core2 == ArchSpec::eCore_mips32el ||
1368 return true;
1369 }
1370 break;
1371
1373 if (!enforce_exact_match) {
1374 if (core2 == ArchSpec::eCore_mips32 || core2 == ArchSpec::eCore_mips32r6)
1375 return true;
1376 if (core2 == ArchSpec::eCore_mips64 || core2 == ArchSpec::eCore_mips64r6)
1377 return true;
1378 }
1379 break;
1380
1382 if (!enforce_exact_match) {
1383 if (core2 == ArchSpec::eCore_mips32el ||
1385 return true;
1386 if (core2 == ArchSpec::eCore_mips64el ||
1388 return true;
1389 }
1390 break;
1391
1392 default:
1393 break;
1394 }
1395 if (try_inverse)
1396 return cores_match(core2, core1, false, enforce_exact_match);
1397 return false;
1398}
1399
1400bool lldb_private::operator<(const ArchSpec &lhs, const ArchSpec &rhs) {
1401 const ArchSpec::Core lhs_core = lhs.GetCore();
1402 const ArchSpec::Core rhs_core = rhs.GetCore();
1403 return lhs_core < rhs_core;
1404}
1405
1406bool lldb_private::operator==(const ArchSpec &lhs, const ArchSpec &rhs) {
1407 return lhs.GetCore() == rhs.GetCore();
1408}
1409
1410bool lldb_private::operator!=(const ArchSpec &lhs, const ArchSpec &rhs) {
1411 return !(lhs == rhs);
1412}
1413
1415 if (!TripleOSWasSpecified())
1416 return false;
1417
1419 return false;
1420
1421 const unsigned unspecified = 0;
1422 const llvm::Triple &triple = GetTriple();
1423 if (triple.isOSDarwin() && triple.getOSMajorVersion() == unspecified)
1424 return false;
1425
1426 return true;
1427}
1428
1430 if (GetTriple().getArch() == llvm::Triple::arm ||
1431 GetTriple().getArch() == llvm::Triple::thumb) {
1432 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M
1433 //
1434 // Cortex-M0 through Cortex-M7 are ARM processor cores which can only
1435 // execute thumb instructions. We map the cores to arch names like this:
1436 //
1437 // Cortex-M0, Cortex-M0+, Cortex-M1: armv6m Cortex-M3: armv7m Cortex-M4,
1438 // Cortex-M7: armv7em
1439
1446 return true;
1447 }
1448 // Windows on ARM is always thumb.
1449 if (GetTriple().isOSWindows())
1450 return true;
1451 }
1452 return false;
1453}
1454
1455void ArchSpec::DumpTriple(llvm::raw_ostream &s) const {
1456 const llvm::Triple &triple = GetTriple();
1457 llvm::StringRef arch_str = triple.getArchName();
1458 llvm::StringRef vendor_str = triple.getVendorName();
1459 llvm::StringRef os_str = triple.getOSName();
1460 llvm::StringRef environ_str = triple.getEnvironmentName();
1461
1462 s << llvm::formatv("{0}-{1}-{2}", arch_str.empty() ? "*" : arch_str,
1463 vendor_str.empty() ? "*" : vendor_str,
1464 os_str.empty() ? "*" : os_str);
1465
1466 if (!environ_str.empty())
1467 s << "-" << environ_str;
1468}
#define SUBTYPE_MASK
Definition ArchSpec.cpp:301
static const ArchDefinition g_elf_arch_def
Definition ArchSpec.cpp:418
static const CoreDefinition * FindCoreDefinition(llvm::StringRef name)
Definition ArchSpec.cpp:476
static const ArchDefinitionEntry * FindArchDefinitionEntry(const ArchDefinition *def, uint32_t cpu, uint32_t sub)
Definition ArchSpec.cpp:492
static const ArchDefinitionEntry g_macho_arch_entries[]
Definition ArchSpec.cpp:304
static const ArchDefinitionEntry g_xcoff_arch_entries[]
Definition ArchSpec.cpp:445
static const ArchDefinitionEntry g_coff_arch_entries[]
Definition ArchSpec.cpp:425
static const ArchDefinitionEntry g_elf_arch_entries[]
Definition ArchSpec.cpp:383
static const ArchDefinition * FindArchDefinition(ArchitectureType arch_type)
Definition ArchSpec.cpp:467
static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse, bool enforce_exact_match)
#define CPU_ANY
Definition ArchSpec.cpp:294
static const ArchDefinition g_xcoff_arch_def
Definition ArchSpec.cpp:451
static constexpr const CoreDefinition g_core_definitions[]
Definition ArchSpec.cpp:44
static const ArchDefinition * g_arch_definitions[]
Definition ArchSpec.cpp:460
static const ArchDefinition g_coff_arch_def
Definition ArchSpec.cpp:437
static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, llvm::Triple::EnvironmentType rhs)
Definition ArchSpec.cpp:936
static const ArchDefinition g_macho_arch_def
Definition ArchSpec.cpp:373
#define LLDB_LOGF(log,...)
Definition Log.h:376
An architecture specification class.
Definition ArchSpec.h:32
static void ListSupportedArchNames(StringList &list)
Definition ArchSpec.cpp:284
bool IsFullySpecifiedTriple() const
bool IsNVPTX() const
If NVPTX architecture return true.
Definition ArchSpec.cpp:557
static void AutoComplete(CompletionRequest &request)
Definition ArchSpec.cpp:289
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition ArchSpec.cpp:681
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:367
void Clear()
Clears the object state.
Definition ArchSpec.cpp:538
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:457
void SetFlags(uint32_t flags)
Definition ArchSpec.h:530
bool IsAlwaysThumbInstructions() const
Detect whether this architecture uses thumb code exclusively.
bool TripleEnvironmentWasSpecified() const
Definition ArchSpec.h:378
bool IsMatch(const ArchSpec &rhs, MatchType match) const
Compare this ArchSpec to another ArchSpec.
Definition ArchSpec.cpp:967
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition ArchSpec.cpp:739
llvm::Triple m_triple
Definition ArchSpec.h:545
lldb::ByteOrder GetDefaultEndian() const
Returns the default endianness of the architecture.
Definition ArchSpec.cpp:695
lldb::ByteOrder m_byte_order
Definition ArchSpec.h:547
~ArchSpec()
Destructor.
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os=0)
Change the architecture object type, CPU type and OS type.
Definition ArchSpec.cpp:843
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
Definition ArchSpec.cpp:801
void DumpTriple(llvm::raw_ostream &s) const
uint32_t GetMachOCPUSubType() const
Definition ArchSpec.cpp:661
void CoreUpdated(bool update_triple)
bool IsMIPS() const
if MIPS architecture return true.
Definition ArchSpec.cpp:555
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition ArchSpec.h:509
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Definition ArchSpec.cpp:702
ArchSpec()
Default constructor.
uint32_t GetMachOCPUType() const
Definition ArchSpec.cpp:649
std::string GetTargetABI() const
Return a string representing target application ABI.
Definition ArchSpec.cpp:559
uint32_t GetMinimumOpcodeByteSize() const
Definition ArchSpec.cpp:922
uint32_t GetFlags() const
Definition ArchSpec.h:528
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition ArchSpec.cpp:730
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:673
std::string GetClangTargetCPU() const
Returns a string representing current architecture as a target CPU for tools like compiler,...
Definition ArchSpec.cpp:595
uint32_t GetMaximumOpcodeByteSize() const
Definition ArchSpec.cpp:929
bool TripleVendorWasSpecified() const
Definition ArchSpec.h:372
Core GetCore() const
Definition ArchSpec.h:448
bool TripleOSWasSpecified() const
Definition ArchSpec.h:376
static bool ContainsOnlyArch(const llvm::Triple &normalized_triple)
Returns true if the OS, vendor and environment fields of the triple are unset.
Definition ArchSpec.cpp:794
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:548
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
void AppendString(const std::string &s)
#define LLDB_INVALID_CPUTYPE
#define UINT32_MAX
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch)
Definition ArchSpec.cpp:745
bool operator!=(const Address &lhs, const Address &rhs)
Definition Address.cpp:1017
TableValidator< 0 > validator
bool operator==(const Address &lhs, const Address &rhs)
Definition Address.cpp:1011
bool operator<(const Address &lhs, const Address &rhs)
Definition Address.cpp:980
ByteOrder
Byte ordering definitions.
ArchSpec::Core core
Definition ArchSpec.cpp:270
ArchitectureType type
Definition ArchSpec.cpp:278
const ArchDefinitionEntry * entries
Definition ArchSpec.cpp:280
size_t num_entries
Definition ArchSpec.cpp:279
const char * name
Definition ArchSpec.cpp:281
llvm::Triple::ArchType machine
Definition ArchSpec.cpp:36
const char *const name
Definition ArchSpec.cpp:38