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