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
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_thumbv7f,
94 "thumbv7f"},
95 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7s,
96 "thumbv7s"},
97 {eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7k,
98 "thumbv7k"},
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
267
274
276 for (const auto &def : g_core_definitions)
277 list.AppendString(def.name);
278}
279
281 for (const auto &def : g_core_definitions)
282 request.TryCompleteCurrentArg(def.name);
283}
284
285#define CPU_ANY (UINT32_MAX)
286
287//===----------------------------------------------------------------------===//
288// A table that gets searched linearly for matches. This table is used to
289// convert cpu type and subtypes to architecture names, and to convert
290// architecture names to cpu types and subtypes. The ordering is important and
291// allows the precedence to be set when the table is built.
292#define SUBTYPE_MASK 0x00FFFFFFu
293
294// clang-format off
296 {ArchSpec::eCore_arm_generic, llvm::MachO::CPU_TYPE_ARM, CPU_ANY, UINT32_MAX, UINT32_MAX},
297 {ArchSpec::eCore_arm_generic, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_ALL, UINT32_MAX, SUBTYPE_MASK},
298 {ArchSpec::eCore_arm_armv4, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
299 {ArchSpec::eCore_arm_armv4t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
300 {ArchSpec::eCore_arm_armv6, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6, UINT32_MAX, SUBTYPE_MASK},
301 {ArchSpec::eCore_arm_armv6m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6M, UINT32_MAX, SUBTYPE_MASK},
302 {ArchSpec::eCore_arm_armv5, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
303 {ArchSpec::eCore_arm_armv5e, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
304 {ArchSpec::eCore_arm_armv5t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5TEJ, UINT32_MAX, SUBTYPE_MASK},
305 {ArchSpec::eCore_arm_xscale, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_XSCALE, UINT32_MAX, SUBTYPE_MASK},
306 {ArchSpec::eCore_arm_armv7, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7, UINT32_MAX, SUBTYPE_MASK},
307 {ArchSpec::eCore_arm_armv7f, llvm::MachO::CPU_TYPE_ARM, 10, UINT32_MAX, SUBTYPE_MASK},
308 {ArchSpec::eCore_arm_armv7s, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7S, UINT32_MAX, SUBTYPE_MASK},
309 {ArchSpec::eCore_arm_armv7k, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7K, UINT32_MAX, SUBTYPE_MASK},
310 {ArchSpec::eCore_arm_armv7m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7M, UINT32_MAX, SUBTYPE_MASK},
311 {ArchSpec::eCore_arm_armv7em, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7EM, UINT32_MAX, SUBTYPE_MASK},
312 {ArchSpec::eCore_arm_arm64e, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64E, UINT32_MAX, SUBTYPE_MASK},
313 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_ALL, UINT32_MAX, SUBTYPE_MASK},
314 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_V8, UINT32_MAX, SUBTYPE_MASK},
315 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, 13, UINT32_MAX, SUBTYPE_MASK},
316 {ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 0, UINT32_MAX, SUBTYPE_MASK},
317 {ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 1, UINT32_MAX, SUBTYPE_MASK},
318 {ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
319 {ArchSpec::eCore_thumb, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_ALL, UINT32_MAX, SUBTYPE_MASK},
320 {ArchSpec::eCore_thumbv4t, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V4T, UINT32_MAX, SUBTYPE_MASK},
321 {ArchSpec::eCore_thumbv5, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5, UINT32_MAX, SUBTYPE_MASK},
322 {ArchSpec::eCore_thumbv5e, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V5, UINT32_MAX, SUBTYPE_MASK},
323 {ArchSpec::eCore_thumbv6, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6, UINT32_MAX, SUBTYPE_MASK},
324 {ArchSpec::eCore_thumbv6m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V6M, UINT32_MAX, SUBTYPE_MASK},
325 {ArchSpec::eCore_thumbv7, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7, UINT32_MAX, SUBTYPE_MASK},
326 {ArchSpec::eCore_thumbv7f, llvm::MachO::CPU_TYPE_ARM, 10, UINT32_MAX, SUBTYPE_MASK},
327 {ArchSpec::eCore_thumbv7s, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7S, UINT32_MAX, SUBTYPE_MASK},
328 {ArchSpec::eCore_thumbv7k, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7K, UINT32_MAX, SUBTYPE_MASK},
329 {ArchSpec::eCore_thumbv7m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7M, UINT32_MAX, SUBTYPE_MASK},
330 {ArchSpec::eCore_thumbv7em, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7EM, UINT32_MAX, SUBTYPE_MASK},
331 {ArchSpec::eCore_ppc_generic, llvm::MachO::CPU_TYPE_POWERPC, CPU_ANY, UINT32_MAX, UINT32_MAX},
332 {ArchSpec::eCore_ppc_generic, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_ALL, UINT32_MAX, SUBTYPE_MASK},
333 {ArchSpec::eCore_ppc_ppc601, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_601, UINT32_MAX, SUBTYPE_MASK},
334 {ArchSpec::eCore_ppc_ppc602, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_602, UINT32_MAX, SUBTYPE_MASK},
335 {ArchSpec::eCore_ppc_ppc603, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603, UINT32_MAX, SUBTYPE_MASK},
336 {ArchSpec::eCore_ppc_ppc603e, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603e, UINT32_MAX, SUBTYPE_MASK},
337 {ArchSpec::eCore_ppc_ppc603ev, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_603ev, UINT32_MAX, SUBTYPE_MASK},
338 {ArchSpec::eCore_ppc_ppc604, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_604, UINT32_MAX, SUBTYPE_MASK},
339 {ArchSpec::eCore_ppc_ppc604e, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_604e, UINT32_MAX, SUBTYPE_MASK},
340 {ArchSpec::eCore_ppc_ppc620, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_620, UINT32_MAX, SUBTYPE_MASK},
341 {ArchSpec::eCore_ppc_ppc750, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_750, UINT32_MAX, SUBTYPE_MASK},
342 {ArchSpec::eCore_ppc_ppc7400, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_7400, UINT32_MAX, SUBTYPE_MASK},
343 {ArchSpec::eCore_ppc_ppc7450, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_7450, UINT32_MAX, SUBTYPE_MASK},
344 {ArchSpec::eCore_ppc_ppc970, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_SUBTYPE_POWERPC_970, UINT32_MAX, SUBTYPE_MASK},
345 {ArchSpec::eCore_ppc64_generic, llvm::MachO::CPU_TYPE_POWERPC64, llvm::MachO::CPU_SUBTYPE_POWERPC_ALL, UINT32_MAX, SUBTYPE_MASK},
346 {ArchSpec::eCore_ppc64le_generic, llvm::MachO::CPU_TYPE_POWERPC64, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
347 {ArchSpec::eCore_ppc64_ppc970_64, llvm::MachO::CPU_TYPE_POWERPC64, 100, UINT32_MAX, SUBTYPE_MASK},
348 {ArchSpec::eCore_x86_32_i386, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_I386_ALL, UINT32_MAX, SUBTYPE_MASK},
349 {ArchSpec::eCore_x86_32_i486, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_486, UINT32_MAX, SUBTYPE_MASK},
350 {ArchSpec::eCore_x86_32_i486sx, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_SUBTYPE_486SX, UINT32_MAX, SUBTYPE_MASK},
351 {ArchSpec::eCore_x86_32_i386, llvm::MachO::CPU_TYPE_I386, CPU_ANY, UINT32_MAX, UINT32_MAX},
352 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_64_ALL, UINT32_MAX, SUBTYPE_MASK},
353 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_ARCH1, UINT32_MAX, SUBTYPE_MASK},
354 {ArchSpec::eCore_x86_64_x86_64h, llvm::MachO::CPU_TYPE_X86_64, llvm::MachO::CPU_SUBTYPE_X86_64_H, UINT32_MAX, SUBTYPE_MASK},
355 {ArchSpec::eCore_x86_64_x86_64, llvm::MachO::CPU_TYPE_X86_64, CPU_ANY, UINT32_MAX, UINT32_MAX},
356 {ArchSpec::eCore_riscv32, llvm::MachO::CPU_TYPE_RISCV, llvm::MachO::CPU_SUBTYPE_RISCV_ALL, UINT32_MAX, SUBTYPE_MASK},
357 {ArchSpec::eCore_riscv32, llvm::MachO::CPU_TYPE_RISCV, CPU_ANY, UINT32_MAX, SUBTYPE_MASK},
358 // Catch any unknown mach architectures so we can always use the object and symbol mach-o files
359 {ArchSpec::eCore_uknownMach32, 0, 0, 0xFF000000u, 0x00000000u},
360 {ArchSpec::eCore_uknownMach64, llvm::MachO::CPU_ARCH_ABI64, 0, 0xFF000000u, 0x00000000u}
361};
362// clang-format on
363
367
368//===----------------------------------------------------------------------===//
369// A table that gets searched linearly for matches. This table is used to
370// convert cpu type and subtypes to architecture names, and to convert
371// architecture names to cpu types and subtypes. The ordering is important and
372// allows the precedence to be set when the table is built.
373// clang-format off
375 {ArchSpec::eCore_sparc_generic, llvm::ELF::EM_SPARC }, // Sparc
376 {ArchSpec::eCore_x86_32_i386, llvm::ELF::EM_386 }, // Intel 80386
377 {ArchSpec::eCore_x86_32_i486, llvm::ELF::EM_IAMCU }, // Intel MCU // FIXME: is this correct?
378 {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC }, // PowerPC
379 {ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, ArchSpec::eCore_ppc64le_generic}, // PowerPC64le
380 {ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, ArchSpec::eCore_ppc64_generic}, // PowerPC64
381 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM }, // ARM
382 {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64 }, // ARM64
383 {ArchSpec::eCore_s390x_generic, llvm::ELF::EM_S390 }, // SystemZ
384 {ArchSpec::eCore_sparc9_generic, llvm::ELF::EM_SPARCV9 }, // SPARC V9
385 {ArchSpec::eCore_x86_64_x86_64, llvm::ELF::EM_X86_64 }, // AMD64
386 {ArchSpec::eCore_mips32, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32}, // mips32
387 {ArchSpec::eCore_mips32r2, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r2}, // mips32r2
388 {ArchSpec::eCore_mips32r6, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r6}, // mips32r6
389 {ArchSpec::eCore_mips32el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32el}, // mips32el
390 {ArchSpec::eCore_mips32r2el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r2el}, // mips32r2el
391 {ArchSpec::eCore_mips32r6el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32r6el}, // mips32r6el
393 {ArchSpec::eCore_mips64r2, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r2}, // mips64r2
394 {ArchSpec::eCore_mips64r6, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r6}, // mips64r6
395 {ArchSpec::eCore_mips64el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64el}, // mips64el
396 {ArchSpec::eCore_mips64r2el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r2el}, // mips64r2el
397 {ArchSpec::eCore_mips64r6el, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64r6el}, // mips64r6el
398 {ArchSpec::eCore_msp430, llvm::ELF::EM_MSP430 }, // MSP430
399 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON }, // HEXAGON
400 {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2}, // ARC
401 {ArchSpec::eCore_avr, llvm::ELF::EM_AVR }, // AVR
402 {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32}, // riscv32
403 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv64}, // riscv64
404 {ArchSpec::eCore_loongarch32, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch32}, // loongarch32
405 {ArchSpec::eCore_loongarch64, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch64}, // loongarch64
406};
407// clang-format on
408
411 std::size(g_elf_arch_entries),
413 "elf",
414};
415// clang-format off
417 {ArchSpec::eCore_x86_32_i386, llvm::COFF::IMAGE_FILE_MACHINE_I386}, // Intel 80x86
418 {ArchSpec::eCore_ppc_generic, llvm::COFF::IMAGE_FILE_MACHINE_POWERPC}, // PowerPC
419 {ArchSpec::eCore_ppc_generic, llvm::COFF::IMAGE_FILE_MACHINE_POWERPCFP}, // PowerPC (with FPU)
420 {ArchSpec::eCore_arm_generic, llvm::COFF::IMAGE_FILE_MACHINE_ARM}, // ARM
421 {ArchSpec::eCore_arm_armv7, llvm::COFF::IMAGE_FILE_MACHINE_ARMNT}, // ARMv7
422 {ArchSpec::eCore_thumb, llvm::COFF::IMAGE_FILE_MACHINE_THUMB}, // ARMv7
423 {ArchSpec::eCore_x86_64_x86_64, llvm::COFF::IMAGE_FILE_MACHINE_AMD64}, // AMD64
424 {ArchSpec::eCore_arm_arm64, llvm::COFF::IMAGE_FILE_MACHINE_ARM64} // ARM64
425};
426// clang-format on
427
430 std::size(g_coff_arch_entries),
432 "pe-coff",
433};
434
435// clang-format off
437 {ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM},
438 {ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64}
439};
440// clang-format on
441
444 std::size(g_xcoff_arch_entries),
446 "xcoff",
447};
448
449//===----------------------------------------------------------------------===//
450// Table of all ArchDefinitions
453
454//===----------------------------------------------------------------------===//
455// Static helper functions.
456
457// Get the architecture definition for a given object type.
459 for (const ArchDefinition *def : g_arch_definitions) {
460 if (def->type == arch_type)
461 return def;
462 }
463 return nullptr;
464}
465
466// Get an architecture definition by name.
467static const CoreDefinition *FindCoreDefinition(llvm::StringRef name) {
468 for (const auto &def : g_core_definitions) {
469 if (name.equals_insensitive(def.name))
470 return &def;
471 }
472 return nullptr;
473}
474
476 if (core < std::size(g_core_definitions))
477 return &g_core_definitions[core];
478 return nullptr;
479}
480
481// Get a definition entry by cpu type and subtype.
482static const ArchDefinitionEntry *
483FindArchDefinitionEntry(const ArchDefinition *def, uint32_t cpu, uint32_t sub) {
484 if (def == nullptr)
485 return nullptr;
486
487 const ArchDefinitionEntry *entries = def->entries;
488 for (size_t i = 0; i < def->num_entries; ++i) {
489 if (entries[i].cpu == (cpu & entries[i].cpu_mask))
490 if (entries[i].sub == (sub & entries[i].sub_mask))
491 return &entries[i];
492 }
493 return nullptr;
494}
495
496static const ArchDefinitionEntry *
498 if (def == nullptr)
499 return nullptr;
500
501 const ArchDefinitionEntry *entries = def->entries;
502 for (size_t i = 0; i < def->num_entries; ++i) {
503 if (entries[i].core == core)
504 return &entries[i];
505 }
506 return nullptr;
507}
508
509//===----------------------------------------------------------------------===//
510// Constructors and destructors.
511
512ArchSpec::ArchSpec() = default;
513
514ArchSpec::ArchSpec(const char *triple_cstr) {
515 if (triple_cstr)
516 SetTriple(triple_cstr);
517}
518
519ArchSpec::ArchSpec(llvm::StringRef triple_str) { SetTriple(triple_str); }
520
521ArchSpec::ArchSpec(const llvm::Triple &triple) { SetTriple(triple); }
522
523ArchSpec::ArchSpec(ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) {
524 SetArchitecture(arch_type, cpu, subtype);
525}
526
527ArchSpec::~ArchSpec() = default;
528
530 m_triple = llvm::Triple();
533 m_flags = 0;
534}
535
536//===----------------------------------------------------------------------===//
537// Predicates.
538
539const char *ArchSpec::GetArchitectureName() const {
540 const CoreDefinition *core_def = FindCoreDefinition(m_core);
541 if (core_def)
542 return core_def->name;
543 return "unknown";
544}
545
546bool ArchSpec::IsMIPS() const { return GetTriple().isMIPS(); }
547
548bool ArchSpec::IsNVPTX() const { return GetTriple().isNVPTX(); }
549
550std::string ArchSpec::GetTargetABI() const {
551
552 std::string abi;
553
554 if (IsMIPS()) {
555 switch (GetFlags() & ArchSpec::eMIPSABI_mask) {
557 abi = "n64";
558 return abi;
560 abi = "n32";
561 return abi;
563 abi = "o32";
564 return abi;
565 default:
566 return abi;
567 }
568 }
569 return abi;
570}
571
572void ArchSpec::SetFlags(const std::string &elf_abi) {
573
574 uint32_t flag = GetFlags();
575 if (IsMIPS()) {
576 if (elf_abi == "n64")
578 else if (elf_abi == "n32")
580 else if (elf_abi == "o32")
582 }
583 SetFlags(flag);
584}
585
586std::string ArchSpec::GetClangTargetCPU() const {
587 std::string cpu;
588 if (IsMIPS()) {
589 switch (m_core) {
592 cpu = "mips32";
593 break;
596 cpu = "mips32r2";
597 break;
600 cpu = "mips32r3";
601 break;
604 cpu = "mips32r5";
605 break;
608 cpu = "mips32r6";
609 break;
612 cpu = "mips64";
613 break;
616 cpu = "mips64r2";
617 break;
620 cpu = "mips64r3";
621 break;
624 cpu = "mips64r5";
625 break;
628 cpu = "mips64r6";
629 break;
630 default:
631 break;
632 }
633 }
634
635 if (GetTriple().isARM())
636 cpu = llvm::ARM::getARMCPUForArch(GetTriple(), "").str();
637 return cpu;
638}
639
641 const CoreDefinition *core_def = FindCoreDefinition(m_core);
642 if (core_def) {
643 const ArchDefinitionEntry *arch_def =
645 if (arch_def) {
646 return arch_def->cpu;
647 }
648 }
650}
651
653 const CoreDefinition *core_def = FindCoreDefinition(m_core);
654 if (core_def) {
655 const ArchDefinitionEntry *arch_def =
657 if (arch_def) {
658 return arch_def->sub;
659 }
660 }
662}
663
664uint32_t ArchSpec::GetDataByteSize() const { return 1; }
665
666uint32_t ArchSpec::GetCodeByteSize() const { return 1; }
667
668llvm::Triple::ArchType ArchSpec::GetMachine() const {
669 const CoreDefinition *core_def = FindCoreDefinition(m_core);
670 if (core_def)
671 return core_def->machine;
672
673 return llvm::Triple::UnknownArch;
674}
675
677 const CoreDefinition *core_def = FindCoreDefinition(m_core);
678 if (core_def) {
679 if (core_def->machine == llvm::Triple::mips64 ||
680 core_def->machine == llvm::Triple::mips64el) {
681 // For N32/O32 applications Address size is 4 bytes.
683 return 4;
684 }
685 return core_def->addr_byte_size;
686 }
687 return 0;
688}
689
691 const CoreDefinition *core_def = FindCoreDefinition(m_core);
692 if (core_def)
693 return core_def->default_byte_order;
694 return eByteOrderInvalid;
695}
696
698 switch (m_triple.getArch()) {
699 default:
700 return true;
701
702 case llvm::Triple::aarch64:
703 case llvm::Triple::aarch64_32:
704 case llvm::Triple::aarch64_be:
705 case llvm::Triple::arm:
706 case llvm::Triple::armeb:
707 case llvm::Triple::thumb:
708 case llvm::Triple::thumbeb:
709 return m_triple.isOSDarwin() || m_triple.isOSWindows();
710
711 case llvm::Triple::ppc:
712 case llvm::Triple::ppc64:
713 return m_triple.isOSDarwin();
714
715 case llvm::Triple::ppc64le:
716 case llvm::Triple::systemz:
717 case llvm::Triple::xcore:
718 case llvm::Triple::arc:
719 return false;
720 }
721}
722
728
729//===----------------------------------------------------------------------===//
730// Mutators.
731
732bool ArchSpec::SetTriple(const llvm::Triple &triple) {
733 m_triple = triple;
734 UpdateCore();
735 return IsValid();
736}
737
738bool lldb_private::ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str,
739 ArchSpec &arch) {
740 // Accept "12-10" or "12.10" as cpu type/subtype
741 if (triple_str.empty())
742 return false;
743
744 size_t pos = triple_str.find_first_of("-.");
745 if (pos == llvm::StringRef::npos)
746 return false;
747
748 llvm::StringRef cpu_str = triple_str.substr(0, pos);
749 llvm::StringRef remainder = triple_str.substr(pos + 1);
750 if (cpu_str.empty() || remainder.empty())
751 return false;
752
753 llvm::StringRef sub_str;
754 llvm::StringRef vendor;
755 llvm::StringRef os;
756 std::tie(sub_str, remainder) = remainder.split('-');
757 std::tie(vendor, os) = remainder.split('-');
758
759 uint32_t cpu = 0;
760 uint32_t sub = 0;
761 if (cpu_str.getAsInteger(10, cpu) || sub_str.getAsInteger(10, sub))
762 return false;
763
764 if (!arch.SetArchitecture(eArchTypeMachO, cpu, sub))
765 return false;
766 if (!vendor.empty() && !os.empty()) {
767 arch.GetTriple().setVendorName(vendor);
768 arch.GetTriple().setOSName(os);
769 }
770
771 return true;
772}
773
774bool ArchSpec::SetTriple(llvm::StringRef triple) {
775 if (triple.empty()) {
776 Clear();
777 return false;
778 }
779
780 if (ParseMachCPUDashSubtypeTriple(triple, *this))
781 return true;
782
783 SetTriple(llvm::Triple(llvm::Triple::normalize(triple)));
784 return IsValid();
785}
786
787bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) {
788 return !normalized_triple.getArchName().empty() &&
789 normalized_triple.getOSName().empty() &&
790 normalized_triple.getVendorName().empty() &&
791 normalized_triple.getEnvironmentName().empty();
792}
793
794void ArchSpec::MergeFrom(const ArchSpec &other) {
795 // ios-macabi always wins over macosx.
796 if ((GetTriple().getOS() == llvm::Triple::MacOSX ||
797 GetTriple().getOS() == llvm::Triple::UnknownOS) &&
798 other.GetTriple().getOS() == llvm::Triple::IOS &&
799 other.GetTriple().getEnvironment() == llvm::Triple::MacABI) {
800 (*this) = other;
801 return;
802 }
803
805 GetTriple().setVendor(other.GetTriple().getVendor());
807 GetTriple().setOS(other.GetTriple().getOS());
808 if (GetTriple().getArch() == llvm::Triple::UnknownArch) {
809 GetTriple().setArch(other.GetTriple().getArch());
810
811 // MachO unknown64 isn't really invalid as the debugger can still obtain
812 // information from the binary, e.g. line tables. As such, we don't update
813 // the core here.
814 if (other.GetCore() != eCore_uknownMach64)
815 UpdateCore();
816 }
819 GetTriple().setEnvironment(other.GetTriple().getEnvironment());
820 }
821 // If this and other are both arm ArchSpecs and this ArchSpec is a generic
822 // "some kind of arm" spec but the other ArchSpec is a specific arm core,
823 // adopt the specific arm core.
824 if (GetTriple().getArch() == llvm::Triple::arm &&
825 other.GetTriple().getArch() == llvm::Triple::arm &&
828 m_core = other.GetCore();
829 CoreUpdated(false);
830 }
831 if (GetFlags() == 0) {
832 SetFlags(other.GetFlags());
833 }
834}
835
836bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
837 uint32_t sub, uint32_t os) {
839 bool update_triple = true;
840 const ArchDefinition *arch_def = FindArchDefinition(arch_type);
841 if (arch_def) {
842 const ArchDefinitionEntry *arch_def_entry =
843 FindArchDefinitionEntry(arch_def, cpu, sub);
844 if (arch_def_entry) {
845 const CoreDefinition *core_def = FindCoreDefinition(arch_def_entry->core);
846 if (core_def) {
847 m_core = core_def->core;
848 update_triple = false;
849 // Always use the architecture name because it might be more
850 // descriptive than the architecture enum ("armv7" ->
851 // llvm::Triple::arm).
852 m_triple.setArchName(llvm::StringRef(core_def->name));
853 if (arch_type == eArchTypeMachO) {
854 m_triple.setVendor(llvm::Triple::Apple);
855
856 // Don't set the OS. It could be simulator, macosx, ios, watchos,
857 // tvos, bridgeos. We could get close with the cpu type - but we
858 // can't get it right all of the time. Better to leave this unset
859 // so other sections of code will set it when they have more
860 // information. NB: don't call m_triple.setOS
861 // (llvm::Triple::UnknownOS). That sets the OSName to "unknown" and
862 // the ArchSpec::TripleVendorWasSpecified() method says that any
863 // OSName setting means it was specified.
864 } else if (arch_type == eArchTypeELF) {
865 switch (os) {
866 case llvm::ELF::ELFOSABI_AIX:
867 m_triple.setOS(llvm::Triple::OSType::AIX);
868 break;
869 case llvm::ELF::ELFOSABI_FREEBSD:
870 m_triple.setOS(llvm::Triple::OSType::FreeBSD);
871 break;
872 case llvm::ELF::ELFOSABI_GNU:
873 m_triple.setOS(llvm::Triple::OSType::Linux);
874 break;
875 case llvm::ELF::ELFOSABI_NETBSD:
876 m_triple.setOS(llvm::Triple::OSType::NetBSD);
877 break;
878 case llvm::ELF::ELFOSABI_OPENBSD:
879 m_triple.setOS(llvm::Triple::OSType::OpenBSD);
880 break;
881 case llvm::ELF::ELFOSABI_SOLARIS:
882 m_triple.setOS(llvm::Triple::OSType::Solaris);
883 break;
884 case llvm::ELF::ELFOSABI_STANDALONE:
885 m_triple.setOS(llvm::Triple::OSType::UnknownOS);
886 break;
887 }
888 } else if (arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
889 m_triple.setVendor(llvm::Triple::PC);
890 m_triple.setOS(llvm::Triple::Win32);
891 } else if (arch_type == eArchTypeXCOFF && os == llvm::Triple::AIX) {
892 m_triple.setVendor(llvm::Triple::IBM);
893 m_triple.setOS(llvm::Triple::AIX);
894 } else {
895 m_triple.setVendor(llvm::Triple::UnknownVendor);
896 m_triple.setOS(llvm::Triple::UnknownOS);
897 }
898 // Fall back onto setting the machine type if the arch by name
899 // failed...
900 if (m_triple.getArch() == llvm::Triple::UnknownArch)
901 m_triple.setArch(core_def->machine);
902 }
903 } else {
905 LLDB_LOGF(log,
906 "Unable to find a core definition for cpu 0x%" PRIx32
907 " sub %" PRId32,
908 cpu, sub);
909 }
910 }
911 CoreUpdated(update_triple);
912 return IsValid();
913}
914
916 const CoreDefinition *core_def = FindCoreDefinition(m_core);
917 if (core_def)
918 return core_def->min_opcode_byte_size;
919 return 0;
920}
921
923 const CoreDefinition *core_def = FindCoreDefinition(m_core);
924 if (core_def)
925 return core_def->max_opcode_byte_size;
926 return 0;
927}
928
929static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs,
930 llvm::Triple::EnvironmentType rhs) {
931 if (lhs == rhs)
932 return true;
933
934 // Apple simulators are a different platform than what they simulate.
935 // As the environments are different at this point, if one of them is a
936 // simulator, then they are different.
937 if (lhs == llvm::Triple::Simulator || rhs == llvm::Triple::Simulator)
938 return false;
939
940 // If any of the environment is unknown then they are compatible
941 if (lhs == llvm::Triple::UnknownEnvironment ||
942 rhs == llvm::Triple::UnknownEnvironment)
943 return true;
944
945 // If one of the environment is Android and the other one is EABI then they
946 // are considered to be compatible. This is required as a workaround for
947 // shared libraries compiled for Android without the NOTE section indicating
948 // that they are using the Android ABI.
949 if ((lhs == llvm::Triple::Android && rhs == llvm::Triple::EABI) ||
950 (rhs == llvm::Triple::Android && lhs == llvm::Triple::EABI) ||
951 (lhs == llvm::Triple::GNUEABI && rhs == llvm::Triple::EABI) ||
952 (rhs == llvm::Triple::GNUEABI && lhs == llvm::Triple::EABI) ||
953 (lhs == llvm::Triple::GNUEABIHF && rhs == llvm::Triple::EABIHF) ||
954 (rhs == llvm::Triple::GNUEABIHF && lhs == llvm::Triple::EABIHF))
955 return true;
956
957 return false;
958}
959
960bool ArchSpec::IsMatch(const ArchSpec &rhs, MatchType match) const {
961 if (GetByteOrder() != rhs.GetByteOrder() ||
962 !cores_match(GetCore(), rhs.GetCore(), true, match == ExactMatch))
963 return false;
964
965 const llvm::Triple &lhs_triple = GetTriple();
966 const llvm::Triple &rhs_triple = rhs.GetTriple();
967
968 const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
969 const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
970
971 const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
972 const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
973
974 bool both_windows = lhs_triple.isOSWindows() && rhs_triple.isOSWindows();
975
976 // On Windows, the vendor field doesn't have any practical effect, but
977 // it is often set to either "pc" or "w64".
978 if ((lhs_triple_vendor != rhs_triple_vendor) &&
979 (match == ExactMatch || !both_windows)) {
980 const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
981 const bool lhs_vendor_specified = TripleVendorWasSpecified();
982 // Both architectures had the vendor specified, so if they aren't equal
983 // then we return false
984 if (rhs_vendor_specified && lhs_vendor_specified)
985 return false;
986
987 // Only fail if both vendor types are not unknown
988 if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
989 rhs_triple_vendor != llvm::Triple::UnknownVendor)
990 return false;
991 }
992
993 const llvm::Triple::EnvironmentType lhs_triple_env =
994 lhs_triple.getEnvironment();
995 const llvm::Triple::EnvironmentType rhs_triple_env =
996 rhs_triple.getEnvironment();
997
998 if (match == CompatibleMatch) {
999 // x86_64-apple-ios-macabi, x86_64-apple-macosx are compatible, no match.
1000 if ((lhs_triple_os == llvm::Triple::IOS &&
1001 lhs_triple_env == llvm::Triple::MacABI &&
1002 rhs_triple_os == llvm::Triple::MacOSX) ||
1003 (lhs_triple_os == llvm::Triple::MacOSX &&
1004 rhs_triple_os == llvm::Triple::IOS &&
1005 rhs_triple_env == llvm::Triple::MacABI))
1006 return true;
1007 // x86_64-apple-driverkit, x86_64-apple-macosx are compatible, no match.
1008 if ((lhs_triple_os == llvm::Triple::DriverKit &&
1009 rhs_triple_os == llvm::Triple::MacOSX) ||
1010 (lhs_triple_os == llvm::Triple::MacOSX &&
1011 rhs_triple_os == llvm::Triple::DriverKit))
1012 return true;
1013 }
1014
1015 // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
1016 if (lhs_triple_os == llvm::Triple::IOS &&
1017 rhs_triple_os == llvm::Triple::IOS &&
1018 (lhs_triple_env == llvm::Triple::MacABI ||
1019 rhs_triple_env == llvm::Triple::MacABI) &&
1020 lhs_triple_env != rhs_triple_env)
1021 return false;
1022
1023 if (lhs_triple_os != rhs_triple_os) {
1024 const bool lhs_os_specified = TripleOSWasSpecified();
1025 const bool rhs_os_specified = rhs.TripleOSWasSpecified();
1026 // If both OS types are specified and different, fail.
1027 if (lhs_os_specified && rhs_os_specified)
1028 return false;
1029
1030 // If the pair of os+env is both unspecified, match any other os+env combo.
1031 if (match == CompatibleMatch &&
1032 ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
1033 (!rhs_os_specified && !rhs_triple.hasEnvironment())))
1034 return true;
1035 }
1036
1037 if (match == CompatibleMatch && both_windows)
1038 return true; // The Windows environments (MSVC vs GNU) are compatible
1039
1040 return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
1041}
1042
1044 llvm::StringRef arch_name(m_triple.getArchName());
1045 const CoreDefinition *core_def = FindCoreDefinition(arch_name);
1046 if (core_def) {
1047 m_core = core_def->core;
1048 // Set the byte order to the default byte order for an architecture. This
1049 // can be modified if needed for cases when cores handle both big and
1050 // little endian
1051 m_byte_order = core_def->default_byte_order;
1052 } else {
1053 Clear();
1054 }
1055}
1056
1057//===----------------------------------------------------------------------===//
1058// Helper methods.
1059
1060void ArchSpec::CoreUpdated(bool update_triple) {
1061 const CoreDefinition *core_def = FindCoreDefinition(m_core);
1062 if (core_def) {
1063 if (update_triple)
1064 m_triple = llvm::Triple(core_def->name, "unknown", "unknown");
1065 m_byte_order = core_def->default_byte_order;
1066 } else {
1067 if (update_triple)
1068 m_triple = llvm::Triple();
1070 }
1071}
1072
1073//===----------------------------------------------------------------------===//
1074// Operators.
1075
1076static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2,
1077 bool try_inverse, bool enforce_exact_match) {
1078 if (core1 == core2)
1079 return true;
1080
1081 switch (core1) {
1083 return true;
1084
1086 if (enforce_exact_match)
1087 break;
1088 [[fallthrough]];
1090 if (core2 >= ArchSpec::kCore_arm_first && core2 <= ArchSpec::kCore_arm_last)
1091 return true;
1092 if (core2 >= ArchSpec::kCore_thumb_first &&
1094 return true;
1095 if (core2 == ArchSpec::kCore_arm_any)
1096 return true;
1097 break;
1098
1100 if ((core2 >= ArchSpec::kCore_x86_32_first &&
1101 core2 <= ArchSpec::kCore_x86_32_last) ||
1102 (core2 == ArchSpec::kCore_x86_32_any))
1103 return true;
1104 break;
1105
1107 if ((core2 >= ArchSpec::kCore_x86_64_first &&
1108 core2 <= ArchSpec::kCore_x86_64_last) ||
1109 (core2 == ArchSpec::kCore_x86_64_any))
1110 return true;
1111 break;
1112
1114 if ((core2 >= ArchSpec::kCore_ppc_first &&
1115 core2 <= ArchSpec::kCore_ppc_last) ||
1116 (core2 == ArchSpec::kCore_ppc_any))
1117 return true;
1118 break;
1119
1121 if ((core2 >= ArchSpec::kCore_ppc64_first &&
1122 core2 <= ArchSpec::kCore_ppc64_last) ||
1123 (core2 == ArchSpec::kCore_ppc64_any))
1124 return true;
1125 break;
1126
1128 if ((core2 >= ArchSpec::kCore_hexagon_first &&
1129 core2 <= ArchSpec::kCore_hexagon_last) ||
1130 (core2 == ArchSpec::kCore_hexagon_any))
1131 return true;
1132 break;
1133
1134 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1135 // Cortex-M0 - ARMv6-M - armv6m
1136 // Cortex-M3 - ARMv7-M - armv7m
1137 // Cortex-M4 - ARMv7E-M - armv7em
1139 if (!enforce_exact_match) {
1140 if (core2 == ArchSpec::eCore_arm_generic)
1141 return true;
1142 if (core2 == ArchSpec::eCore_arm_armv7m)
1143 return true;
1144 if (core2 == ArchSpec::eCore_arm_armv6m)
1145 return true;
1146 if (core2 == ArchSpec::eCore_arm_armv7)
1147 return true;
1148 try_inverse = true;
1149 }
1150 break;
1151
1152 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1153 // Cortex-M0 - ARMv6-M - armv6m
1154 // Cortex-M3 - ARMv7-M - armv7m
1155 // Cortex-M4 - ARMv7E-M - armv7em
1157 if (!enforce_exact_match) {
1158 if (core2 == ArchSpec::eCore_arm_generic)
1159 return true;
1160 if (core2 == ArchSpec::eCore_arm_armv6m)
1161 return true;
1162 if (core2 == ArchSpec::eCore_arm_armv7)
1163 return true;
1164 if (core2 == ArchSpec::eCore_arm_armv7em)
1165 return true;
1166 try_inverse = true;
1167 }
1168 break;
1169
1170 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
1171 // Cortex-M0 - ARMv6-M - armv6m
1172 // Cortex-M3 - ARMv7-M - armv7m
1173 // Cortex-M4 - ARMv7E-M - armv7em
1175 if (!enforce_exact_match) {
1176 if (core2 == ArchSpec::eCore_arm_generic)
1177 return true;
1178 if (core2 == ArchSpec::eCore_arm_armv7em)
1179 return true;
1180 if (core2 == ArchSpec::eCore_arm_armv7)
1181 return true;
1182 if (core2 == ArchSpec::eCore_arm_armv6m)
1183 return true;
1184 try_inverse = false;
1185 }
1186 break;
1187
1193 if (!enforce_exact_match) {
1194 if (core2 == ArchSpec::eCore_arm_generic)
1195 return true;
1196 if (core2 == ArchSpec::eCore_arm_armv7)
1197 return true;
1198 try_inverse = false;
1199 }
1200 break;
1201
1204 if (!enforce_exact_match) {
1205 try_inverse = false;
1206 if (core2 == ArchSpec::eCore_x86_64_x86_64)
1207 return true;
1208 }
1209 break;
1210
1212 if (!enforce_exact_match) {
1213 if (core2 == ArchSpec::eCore_arm_arm64)
1214 return true;
1215 if (core2 == ArchSpec::eCore_arm_aarch64)
1216 return true;
1217 if (core2 == ArchSpec::eCore_arm_arm64e)
1218 return true;
1219 try_inverse = false;
1220 }
1221 break;
1222
1224 if (!enforce_exact_match) {
1225 if (core2 == ArchSpec::eCore_arm_arm64)
1226 return true;
1227 if (core2 == ArchSpec::eCore_arm_aarch64)
1228 return true;
1229 if (core2 == ArchSpec::eCore_arm_armv8)
1230 return true;
1231 try_inverse = false;
1232 }
1233 break;
1235 if (!enforce_exact_match) {
1236 if (core2 == ArchSpec::eCore_arm_arm64)
1237 return true;
1238 if (core2 == ArchSpec::eCore_arm_armv8)
1239 return true;
1240 if (core2 == ArchSpec::eCore_arm_arm64e)
1241 return true;
1242 try_inverse = false;
1243 }
1244 break;
1245
1247 if (!enforce_exact_match) {
1248 if (core2 == ArchSpec::eCore_arm_aarch64)
1249 return true;
1250 if (core2 == ArchSpec::eCore_arm_armv8)
1251 return true;
1252 if (core2 == ArchSpec::eCore_arm_arm64e)
1253 return true;
1254 try_inverse = false;
1255 }
1256 break;
1257
1259 if (!enforce_exact_match) {
1260 if (core2 == ArchSpec::eCore_arm_generic)
1261 return true;
1262 try_inverse = false;
1263 }
1264 break;
1265
1267 if (!enforce_exact_match) {
1268 if (core2 >= ArchSpec::kCore_mips32_first &&
1270 return true;
1271 try_inverse = false;
1272 }
1273 break;
1274
1276 if (!enforce_exact_match) {
1277 if (core2 >= ArchSpec::kCore_mips32el_first &&
1279 return true;
1280 try_inverse = true;
1281 }
1282 break;
1283
1285 if (!enforce_exact_match) {
1286 if (core2 >= ArchSpec::kCore_mips32_first &&
1288 return true;
1289 if (core2 >= ArchSpec::kCore_mips64_first &&
1291 return true;
1292 try_inverse = false;
1293 }
1294 break;
1295
1297 if (!enforce_exact_match) {
1298 if (core2 >= ArchSpec::kCore_mips32el_first &&
1300 return true;
1301 if (core2 >= ArchSpec::kCore_mips64el_first &&
1303 return true;
1304 try_inverse = false;
1305 }
1306 break;
1307
1311 if (!enforce_exact_match) {
1312 if (core2 >= ArchSpec::kCore_mips32_first && core2 <= (core1 - 10))
1313 return true;
1314 if (core2 >= ArchSpec::kCore_mips64_first && core2 <= (core1 - 1))
1315 return true;
1316 try_inverse = false;
1317 }
1318 break;
1319
1323 if (!enforce_exact_match) {
1324 if (core2 >= ArchSpec::kCore_mips32el_first && core2 <= (core1 - 10))
1325 return true;
1326 if (core2 >= ArchSpec::kCore_mips64el_first && core2 <= (core1 - 1))
1327 return true;
1328 try_inverse = false;
1329 }
1330 break;
1331
1335 if (!enforce_exact_match) {
1336 if (core2 >= ArchSpec::kCore_mips32_first && core2 <= core1)
1337 return true;
1338 }
1339 break;
1340
1344 if (!enforce_exact_match) {
1345 if (core2 >= ArchSpec::kCore_mips32el_first && core2 <= core1)
1346 return true;
1347 }
1348 break;
1349
1351 if (!enforce_exact_match) {
1352 if (core2 == ArchSpec::eCore_mips32 || core2 == ArchSpec::eCore_mips32r6)
1353 return true;
1354 }
1355 break;
1356
1358 if (!enforce_exact_match) {
1359 if (core2 == ArchSpec::eCore_mips32el ||
1361 return true;
1362 }
1363 break;
1364
1366 if (!enforce_exact_match) {
1367 if (core2 == ArchSpec::eCore_mips32 || core2 == ArchSpec::eCore_mips32r6)
1368 return true;
1369 if (core2 == ArchSpec::eCore_mips64 || core2 == ArchSpec::eCore_mips64r6)
1370 return true;
1371 }
1372 break;
1373
1375 if (!enforce_exact_match) {
1376 if (core2 == ArchSpec::eCore_mips32el ||
1378 return true;
1379 if (core2 == ArchSpec::eCore_mips64el ||
1381 return true;
1382 }
1383 break;
1384
1385 default:
1386 break;
1387 }
1388 if (try_inverse)
1389 return cores_match(core2, core1, false, enforce_exact_match);
1390 return false;
1391}
1392
1393bool lldb_private::operator<(const ArchSpec &lhs, const ArchSpec &rhs) {
1394 const ArchSpec::Core lhs_core = lhs.GetCore();
1395 const ArchSpec::Core rhs_core = rhs.GetCore();
1396 return lhs_core < rhs_core;
1397}
1398
1399bool lldb_private::operator==(const ArchSpec &lhs, const ArchSpec &rhs) {
1400 return lhs.GetCore() == rhs.GetCore();
1401}
1402
1403bool lldb_private::operator!=(const ArchSpec &lhs, const ArchSpec &rhs) {
1404 return !(lhs == rhs);
1405}
1406
1408 if (!TripleOSWasSpecified())
1409 return false;
1410
1412 return false;
1413
1414 const unsigned unspecified = 0;
1415 const llvm::Triple &triple = GetTriple();
1416 if (triple.isOSDarwin() && triple.getOSMajorVersion() == unspecified)
1417 return false;
1418
1419 return true;
1420}
1421
1423 if (GetTriple().getArch() == llvm::Triple::arm ||
1424 GetTriple().getArch() == llvm::Triple::thumb) {
1425 // v. https://en.wikipedia.org/wiki/ARM_Cortex-M
1426 //
1427 // Cortex-M0 through Cortex-M7 are ARM processor cores which can only
1428 // execute thumb instructions. We map the cores to arch names like this:
1429 //
1430 // Cortex-M0, Cortex-M0+, Cortex-M1: armv6m Cortex-M3: armv7m Cortex-M4,
1431 // Cortex-M7: armv7em
1432
1439 return true;
1440 }
1441 // Windows on ARM is always thumb.
1442 if (GetTriple().isOSWindows())
1443 return true;
1444 }
1445 return false;
1446}
1447
1448void ArchSpec::DumpTriple(llvm::raw_ostream &s) const {
1449 const llvm::Triple &triple = GetTriple();
1450 llvm::StringRef arch_str = triple.getArchName();
1451 llvm::StringRef vendor_str = triple.getVendorName();
1452 llvm::StringRef os_str = triple.getOSName();
1453 llvm::StringRef environ_str = triple.getEnvironmentName();
1454
1455 s << llvm::formatv("{0}-{1}-{2}", arch_str.empty() ? "*" : arch_str,
1456 vendor_str.empty() ? "*" : vendor_str,
1457 os_str.empty() ? "*" : os_str);
1458
1459 if (!environ_str.empty())
1460 s << "-" << environ_str;
1461}
#define SUBTYPE_MASK
Definition ArchSpec.cpp:292
static const ArchDefinition g_elf_arch_def
Definition ArchSpec.cpp:409
static const CoreDefinition * FindCoreDefinition(llvm::StringRef name)
Definition ArchSpec.cpp:467
static const ArchDefinitionEntry * FindArchDefinitionEntry(const ArchDefinition *def, uint32_t cpu, uint32_t sub)
Definition ArchSpec.cpp:483
static const ArchDefinitionEntry g_macho_arch_entries[]
Definition ArchSpec.cpp:295
static const ArchDefinitionEntry g_xcoff_arch_entries[]
Definition ArchSpec.cpp:436
static const ArchDefinitionEntry g_coff_arch_entries[]
Definition ArchSpec.cpp:416
static const ArchDefinitionEntry g_elf_arch_entries[]
Definition ArchSpec.cpp:374
static const ArchDefinition * FindArchDefinition(ArchitectureType arch_type)
Definition ArchSpec.cpp:458
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:285
static const ArchDefinition g_xcoff_arch_def
Definition ArchSpec.cpp:442
static const CoreDefinition g_core_definitions[]
Definition ArchSpec.cpp:44
static const ArchDefinition * g_arch_definitions[]
Definition ArchSpec.cpp:451
static const ArchDefinition g_coff_arch_def
Definition ArchSpec.cpp:428
static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, llvm::Triple::EnvironmentType rhs)
Definition ArchSpec.cpp:929
static const ArchDefinition g_macho_arch_def
Definition ArchSpec.cpp:364
#define LLDB_LOGF(log,...)
Definition Log.h:376
An architecture specification class.
Definition ArchSpec.h:31
static void ListSupportedArchNames(StringList &list)
Definition ArchSpec.cpp:275
bool IsFullySpecifiedTriple() const
bool IsNVPTX() const
If NVPTX architecture return true.
Definition ArchSpec.cpp:548
static void AutoComplete(CompletionRequest &request)
Definition ArchSpec.cpp:280
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition ArchSpec.cpp:676
uint32_t GetCodeByteSize() const
Architecture code byte width accessor.
Definition ArchSpec.cpp:666
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:366
void Clear()
Clears the object state.
Definition ArchSpec.cpp:529
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:468
void SetFlags(uint32_t flags)
Definition ArchSpec.h:541
bool IsAlwaysThumbInstructions() const
Detect whether this architecture uses thumb code exclusively.
bool TripleEnvironmentWasSpecified() const
Definition ArchSpec.h:377
bool IsMatch(const ArchSpec &rhs, MatchType match) const
Compare this ArchSpec to another ArchSpec.
Definition ArchSpec.cpp:960
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition ArchSpec.cpp:732
llvm::Triple m_triple
Definition ArchSpec.h:548
lldb::ByteOrder GetDefaultEndian() const
Returns the default endianness of the architecture.
Definition ArchSpec.cpp:690
lldb::ByteOrder m_byte_order
Definition ArchSpec.h:550
~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:836
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
Definition ArchSpec.cpp:794
void DumpTriple(llvm::raw_ostream &s) const
uint32_t GetMachOCPUSubType() const
Definition ArchSpec.cpp:652
void CoreUpdated(bool update_triple)
bool IsMIPS() const
if MIPS architecture return true.
Definition ArchSpec.cpp:546
uint32_t GetDataByteSize() const
Architecture data byte width accessor.
Definition ArchSpec.cpp:664
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition ArchSpec.h:520
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Definition ArchSpec.cpp:697
ArchSpec()
Default constructor.
uint32_t GetMachOCPUType() const
Definition ArchSpec.cpp:640
std::string GetTargetABI() const
Return a string representing target application ABI.
Definition ArchSpec.cpp:550
uint32_t GetMinimumOpcodeByteSize() const
Definition ArchSpec.cpp:915
uint32_t GetFlags() const
Definition ArchSpec.h:539
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition ArchSpec.cpp:723
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:668
std::string GetClangTargetCPU() const
Returns a string representing current architecture as a target CPU for tools like compiler,...
Definition ArchSpec.cpp:586
uint32_t GetMaximumOpcodeByteSize() const
Definition ArchSpec.cpp:922
bool TripleVendorWasSpecified() const
Definition ArchSpec.h:371
Core GetCore() const
Definition ArchSpec.h:447
bool TripleOSWasSpecified() const
Definition ArchSpec.h:375
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:787
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:539
"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:738
bool operator!=(const Address &lhs, const Address &rhs)
Definition Address.cpp:1017
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:261
ArchitectureType type
Definition ArchSpec.cpp:269
const ArchDefinitionEntry * entries
Definition ArchSpec.cpp:271
size_t num_entries
Definition ArchSpec.cpp:270
const char * name
Definition ArchSpec.cpp:272
llvm::Triple::ArchType machine
Definition ArchSpec.cpp:36
const char *const name
Definition ArchSpec.cpp:38