blob: 1e1497b446ccaa244be9305c086758dcf5f09b64 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ArchSpec.cpp --------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Core/ArchSpec.h"
11
Eli Friedman50fac2f2010-06-11 04:26:08 +000012#include <stdio.h>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000013
14#include <string>
15
Greg Clayton41f92322010-06-11 03:25:34 +000016#include "llvm/Support/ELF.h"
Stephen Wilsonfacebfc2011-02-24 19:13:58 +000017#include "llvm/Support/Host.h"
Greg Clayton41f92322010-06-11 03:25:34 +000018#include "llvm/Support/MachO.h"
Greg Clayton514487e2011-02-15 21:59:32 +000019#include "lldb/Host/Endian.h"
20#include "lldb/Host/Host.h"
Greg Claytoneb0103f2011-04-07 22:46:35 +000021#include "lldb/Target/Platform.h"
Greg Clayton41f92322010-06-11 03:25:34 +000022
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023using namespace lldb;
24using namespace lldb_private;
25
Greg Clayton64195a22011-02-23 00:35:02 +000026#define ARCH_SPEC_SEPARATOR_CHAR '-'
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027
Greg Clayton64195a22011-02-23 00:35:02 +000028namespace lldb_private {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029
Greg Clayton64195a22011-02-23 00:35:02 +000030 struct CoreDefinition
31 {
32 ByteOrder default_byte_order;
33 uint32_t addr_byte_size;
Greg Clayton357132e2011-03-26 19:14:58 +000034 uint32_t min_opcode_byte_size;
35 uint32_t max_opcode_byte_size;
Greg Clayton64195a22011-02-23 00:35:02 +000036 llvm::Triple::ArchType machine;
37 ArchSpec::Core core;
38 const char *name;
39 };
40
41}
42
43// This core information can be looked using the ArchSpec::Core as the index
44static const CoreDefinition g_core_definitions[ArchSpec::kNumCores] =
Chris Lattner30fdc8d2010-06-08 16:52:24 +000045{
Greg Clayton357132e2011-03-26 19:14:58 +000046 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_generic , "arm" },
47 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4 , "armv4" },
48 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4t , "armv4t" },
49 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5 , "armv5" },
Greg Claytonb5c39fe2011-12-16 18:15:52 +000050 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5e , "armv5e" },
Greg Clayton357132e2011-03-26 19:14:58 +000051 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5t , "armv5t" },
52 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv6 , "armv6" },
53 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7 , "armv7" },
54 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7f , "armv7f" },
55 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7k , "armv7k" },
56 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7s , "armv7s" },
57 { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_xscale , "xscale" },
Greg Claytonb5c39fe2011-12-16 18:15:52 +000058 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumb , "thumb" },
59 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv4t , "thumbv4t" },
60 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv5 , "thumbv5" },
61 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv5e , "thumbv5e" },
62 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv6 , "thumbv6" },
63 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7 , "thumbv7" },
64 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7f , "thumbv7f" },
65 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7k , "thumbv7k" },
66 { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7s , "thumbv7s" },
67
Greg Clayton64195a22011-02-23 00:35:02 +000068
Greg Clayton357132e2011-03-26 19:14:58 +000069 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_generic , "ppc" },
70 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc601 , "ppc601" },
71 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc602 , "ppc602" },
72 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603 , "ppc603" },
73 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603e , "ppc603e" },
74 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603ev , "ppc603ev" },
75 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc604 , "ppc604" },
76 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc604e , "ppc604e" },
77 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc620 , "ppc620" },
78 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc750 , "ppc750" },
79 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc7400 , "ppc7400" },
80 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc7450 , "ppc7450" },
81 { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc970 , "ppc970" },
Greg Clayton64195a22011-02-23 00:35:02 +000082
Greg Clayton357132e2011-03-26 19:14:58 +000083 { eByteOrderLittle, 8, 4, 4, llvm::Triple::ppc64 , ArchSpec::eCore_ppc64_generic , "ppc64" },
84 { eByteOrderLittle, 8, 4, 4, llvm::Triple::ppc64 , ArchSpec::eCore_ppc64_ppc970_64 , "ppc970-64" },
Greg Clayton64195a22011-02-23 00:35:02 +000085
Greg Clayton357132e2011-03-26 19:14:58 +000086 { eByteOrderLittle, 4, 4, 4, llvm::Triple::sparc , ArchSpec::eCore_sparc_generic , "sparc" },
87 { eByteOrderLittle, 8, 4, 4, llvm::Triple::sparcv9, ArchSpec::eCore_sparc9_generic , "sparcv9" },
Greg Clayton64195a22011-02-23 00:35:02 +000088
Greg Claytonab65b342011-04-13 22:47:15 +000089 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" },
90 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" },
91 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" },
Greg Clayton64195a22011-02-23 00:35:02 +000092
Greg Claytonab65b342011-04-13 22:47:15 +000093 { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" }
Greg Clayton64195a22011-02-23 00:35:02 +000094};
95
96struct ArchDefinitionEntry
97{
98 ArchSpec::Core core;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099 uint32_t cpu;
100 uint32_t sub;
Greg Clayton64195a22011-02-23 00:35:02 +0000101};
102
103struct ArchDefinition
104{
105 ArchitectureType type;
106 size_t num_entries;
107 const ArchDefinitionEntry *entries;
108 uint32_t cpu_mask;
109 uint32_t sub_mask;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000110 const char *name;
111};
112
Greg Clayton41f92322010-06-11 03:25:34 +0000113
Greg Claytonab65b342011-04-13 22:47:15 +0000114uint32_t
115ArchSpec::AutoComplete (const char *name, StringList &matches)
116{
117 uint32_t i;
118 if (name && name[0])
119 {
120 for (i = 0; i < ArchSpec::kNumCores; ++i)
121 {
122 if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
123 matches.AppendString (g_core_definitions[i].name);
124 }
125 }
126 else
127 {
128 for (i = 0; i < ArchSpec::kNumCores; ++i)
129 matches.AppendString (g_core_definitions[i].name);
130 }
131 return matches.GetSize();
132}
133
134
135
Greg Clayton64195a22011-02-23 00:35:02 +0000136#define CPU_ANY (UINT32_MAX)
137
138//===----------------------------------------------------------------------===//
139// A table that gets searched linearly for matches. This table is used to
140// convert cpu type and subtypes to architecture names, and to convert
141// architecture names to cpu types and subtypes. The ordering is important and
142// allows the precedence to be set when the table is built.
143static const ArchDefinitionEntry g_macho_arch_entries[] =
Greg Clayton41f92322010-06-11 03:25:34 +0000144{
Greg Clayton64195a22011-02-23 00:35:02 +0000145 { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , CPU_ANY },
146 { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , 0 },
147 { ArchSpec::eCore_arm_armv4 , llvm::MachO::CPUTypeARM , 5 },
Greg Claytonb5c39fe2011-12-16 18:15:52 +0000148 { ArchSpec::eCore_arm_armv4t , llvm::MachO::CPUTypeARM , 5 },
Greg Clayton64195a22011-02-23 00:35:02 +0000149 { ArchSpec::eCore_arm_armv6 , llvm::MachO::CPUTypeARM , 6 },
150 { ArchSpec::eCore_arm_armv5 , llvm::MachO::CPUTypeARM , 7 },
Greg Claytonb5c39fe2011-12-16 18:15:52 +0000151 { ArchSpec::eCore_arm_armv5e , llvm::MachO::CPUTypeARM , 7 },
152 { ArchSpec::eCore_arm_armv5t , llvm::MachO::CPUTypeARM , 7 },
Greg Clayton64195a22011-02-23 00:35:02 +0000153 { ArchSpec::eCore_arm_xscale , llvm::MachO::CPUTypeARM , 8 },
154 { ArchSpec::eCore_arm_armv7 , llvm::MachO::CPUTypeARM , 9 },
Greg Claytonded470d2011-03-19 01:12:21 +0000155 { ArchSpec::eCore_arm_armv7f , llvm::MachO::CPUTypeARM , 10 },
156 { ArchSpec::eCore_arm_armv7k , llvm::MachO::CPUTypeARM , 12 },
157 { ArchSpec::eCore_arm_armv7s , llvm::MachO::CPUTypeARM , 11 },
Greg Claytonb5c39fe2011-12-16 18:15:52 +0000158 { ArchSpec::eCore_thumb , llvm::MachO::CPUTypeARM , 0 },
159 { ArchSpec::eCore_thumbv4t , llvm::MachO::CPUTypeARM , 5 },
160 { ArchSpec::eCore_thumbv5 , llvm::MachO::CPUTypeARM , 7 },
161 { ArchSpec::eCore_thumbv5e , llvm::MachO::CPUTypeARM , 7 },
162 { ArchSpec::eCore_thumbv6 , llvm::MachO::CPUTypeARM , 6 },
163 { ArchSpec::eCore_thumbv7 , llvm::MachO::CPUTypeARM , 9 },
164 { ArchSpec::eCore_thumbv7f , llvm::MachO::CPUTypeARM , 10 },
165 { ArchSpec::eCore_thumbv7k , llvm::MachO::CPUTypeARM , 12 },
166 { ArchSpec::eCore_thumbv7s , llvm::MachO::CPUTypeARM , 11 },
Greg Clayton64195a22011-02-23 00:35:02 +0000167 { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , CPU_ANY },
168 { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , 0 },
169 { ArchSpec::eCore_ppc_ppc601 , llvm::MachO::CPUTypePowerPC , 1 },
170 { ArchSpec::eCore_ppc_ppc602 , llvm::MachO::CPUTypePowerPC , 2 },
171 { ArchSpec::eCore_ppc_ppc603 , llvm::MachO::CPUTypePowerPC , 3 },
172 { ArchSpec::eCore_ppc_ppc603e , llvm::MachO::CPUTypePowerPC , 4 },
173 { ArchSpec::eCore_ppc_ppc603ev , llvm::MachO::CPUTypePowerPC , 5 },
174 { ArchSpec::eCore_ppc_ppc604 , llvm::MachO::CPUTypePowerPC , 6 },
175 { ArchSpec::eCore_ppc_ppc604e , llvm::MachO::CPUTypePowerPC , 7 },
176 { ArchSpec::eCore_ppc_ppc620 , llvm::MachO::CPUTypePowerPC , 8 },
177 { ArchSpec::eCore_ppc_ppc750 , llvm::MachO::CPUTypePowerPC , 9 },
178 { ArchSpec::eCore_ppc_ppc7400 , llvm::MachO::CPUTypePowerPC , 10 },
179 { ArchSpec::eCore_ppc_ppc7450 , llvm::MachO::CPUTypePowerPC , 11 },
180 { ArchSpec::eCore_ppc_ppc970 , llvm::MachO::CPUTypePowerPC , 100 },
181 { ArchSpec::eCore_ppc64_generic , llvm::MachO::CPUTypePowerPC64 , 0 },
182 { ArchSpec::eCore_ppc64_ppc970_64 , llvm::MachO::CPUTypePowerPC64 , 100 },
183 { ArchSpec::eCore_x86_32_i386 , llvm::MachO::CPUTypeI386 , 3 },
184 { ArchSpec::eCore_x86_32_i486 , llvm::MachO::CPUTypeI386 , 4 },
185 { ArchSpec::eCore_x86_32_i486sx , llvm::MachO::CPUTypeI386 , 0x84 },
186 { ArchSpec::eCore_x86_32_i386 , llvm::MachO::CPUTypeI386 , CPU_ANY },
187 { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , 3 },
Jason Molenda311186a2011-08-16 01:23:22 +0000188 { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , 4 },
Greg Clayton64195a22011-02-23 00:35:02 +0000189 { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , CPU_ANY }
190};
191static const ArchDefinition g_macho_arch_def = {
192 eArchTypeMachO,
193 sizeof(g_macho_arch_entries)/sizeof(g_macho_arch_entries[0]),
194 g_macho_arch_entries,
195 UINT32_MAX, // CPU type mask
196 0x00FFFFFFu, // CPU subtype mask
197 "mach-o"
Greg Clayton41f92322010-06-11 03:25:34 +0000198};
199
Greg Clayton64195a22011-02-23 00:35:02 +0000200//===----------------------------------------------------------------------===//
201// A table that gets searched linearly for matches. This table is used to
202// convert cpu type and subtypes to architecture names, and to convert
203// architecture names to cpu types and subtypes. The ordering is important and
204// allows the precedence to be set when the table is built.
205static const ArchDefinitionEntry g_elf_arch_entries[] =
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000206{
Greg Clayton64195a22011-02-23 00:35:02 +0000207 { ArchSpec::eCore_sparc_generic , llvm::ELF::EM_SPARC , LLDB_INVALID_CPUTYPE }, // Sparc
208 { ArchSpec::eCore_x86_32_i386 , llvm::ELF::EM_386 , LLDB_INVALID_CPUTYPE }, // Intel 80386
209 { ArchSpec::eCore_x86_32_i486 , llvm::ELF::EM_486 , LLDB_INVALID_CPUTYPE }, // Intel 486 (deprecated)
210 { ArchSpec::eCore_ppc_generic , llvm::ELF::EM_PPC , LLDB_INVALID_CPUTYPE }, // PowerPC
211 { ArchSpec::eCore_ppc64_generic , llvm::ELF::EM_PPC64 , LLDB_INVALID_CPUTYPE }, // PowerPC64
212 { ArchSpec::eCore_arm_generic , llvm::ELF::EM_ARM , LLDB_INVALID_CPUTYPE }, // ARM
Greg Clayton64195a22011-02-23 00:35:02 +0000213 { ArchSpec::eCore_sparc9_generic , llvm::ELF::EM_SPARCV9, LLDB_INVALID_CPUTYPE }, // SPARC V9
214 { ArchSpec::eCore_x86_64_x86_64 , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE }, // AMD64
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000215};
216
Greg Clayton64195a22011-02-23 00:35:02 +0000217static const ArchDefinition g_elf_arch_def = {
218 eArchTypeELF,
219 sizeof(g_elf_arch_entries)/sizeof(g_elf_arch_entries[0]),
220 g_elf_arch_entries,
221 UINT32_MAX, // CPU type mask
222 UINT32_MAX, // CPU subtype mask
223 "elf",
Greg Clayton41f92322010-06-11 03:25:34 +0000224};
225
Greg Clayton64195a22011-02-23 00:35:02 +0000226//===----------------------------------------------------------------------===//
227// Table of all ArchDefinitions
228static const ArchDefinition *g_arch_definitions[] = {
229 &g_macho_arch_def,
230 &g_elf_arch_def,
231};
Greg Clayton41f92322010-06-11 03:25:34 +0000232
Greg Clayton64195a22011-02-23 00:35:02 +0000233static const size_t k_num_arch_definitions =
234 sizeof(g_arch_definitions) / sizeof(g_arch_definitions[0]);
235
236//===----------------------------------------------------------------------===//
237// Static helper functions.
238
239
240// Get the architecture definition for a given object type.
241static const ArchDefinition *
242FindArchDefinition (ArchitectureType arch_type)
243{
244 for (unsigned int i = 0; i < k_num_arch_definitions; ++i)
245 {
246 const ArchDefinition *def = g_arch_definitions[i];
247 if (def->type == arch_type)
248 return def;
249 }
250 return NULL;
251}
252
253// Get an architecture definition by name.
254static const CoreDefinition *
255FindCoreDefinition (llvm::StringRef name)
256{
257 for (unsigned int i = 0; i < ArchSpec::kNumCores; ++i)
258 {
259 if (name.equals_lower(g_core_definitions[i].name))
260 return &g_core_definitions[i];
261 }
262 return NULL;
263}
264
265static inline const CoreDefinition *
266FindCoreDefinition (ArchSpec::Core core)
267{
268 if (core >= 0 && core < ArchSpec::kNumCores)
269 return &g_core_definitions[core];
270 return NULL;
271}
272
273// Get a definition entry by cpu type and subtype.
274static const ArchDefinitionEntry *
275FindArchDefinitionEntry (const ArchDefinition *def, uint32_t cpu, uint32_t sub)
276{
277 if (def == NULL)
278 return NULL;
279
280 const uint32_t cpu_mask = def->cpu_mask;
281 const uint32_t sub_mask = def->sub_mask;
282 const ArchDefinitionEntry *entries = def->entries;
283 for (size_t i = 0; i < def->num_entries; ++i)
284 {
285 if ((entries[i].cpu == (cpu_mask & cpu)) &&
286 (entries[i].sub == (sub_mask & sub)))
287 return &entries[i];
288 }
289 return NULL;
290}
291
292static const ArchDefinitionEntry *
293FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
294{
295 if (def == NULL)
296 return NULL;
297
298 const ArchDefinitionEntry *entries = def->entries;
299 for (size_t i = 0; i < def->num_entries; ++i)
300 {
301 if (entries[i].core == core)
302 return &entries[i];
303 }
304 return NULL;
305}
306
307//===----------------------------------------------------------------------===//
308// Constructors and destructors.
309
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000310ArchSpec::ArchSpec() :
Greg Clayton514487e2011-02-15 21:59:32 +0000311 m_triple (),
Greg Clayton64195a22011-02-23 00:35:02 +0000312 m_core (kCore_invalid),
313 m_byte_order (eByteOrderInvalid)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000314{
315}
316
Greg Claytoneb0103f2011-04-07 22:46:35 +0000317ArchSpec::ArchSpec (const char *triple_cstr, Platform *platform) :
Greg Clayton514487e2011-02-15 21:59:32 +0000318 m_triple (),
Greg Clayton64195a22011-02-23 00:35:02 +0000319 m_core (kCore_invalid),
320 m_byte_order (eByteOrderInvalid)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000321{
Greg Clayton64195a22011-02-23 00:35:02 +0000322 if (triple_cstr)
Greg Claytoneb0103f2011-04-07 22:46:35 +0000323 SetTriple(triple_cstr, platform);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000324}
325
Greg Clayton70512312012-05-08 01:45:38 +0000326
327ArchSpec::ArchSpec (const char *triple_cstr) :
328 m_triple (),
329 m_core (kCore_invalid),
330 m_byte_order (eByteOrderInvalid)
331{
332 if (triple_cstr)
333 SetTriple(triple_cstr);
334}
335
Greg Clayton64195a22011-02-23 00:35:02 +0000336ArchSpec::ArchSpec(const llvm::Triple &triple) :
Greg Clayton514487e2011-02-15 21:59:32 +0000337 m_triple (),
Greg Clayton64195a22011-02-23 00:35:02 +0000338 m_core (kCore_invalid),
339 m_byte_order (eByteOrderInvalid)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000340{
Greg Clayton64195a22011-02-23 00:35:02 +0000341 SetTriple(triple);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342}
343
Greg Claytone0d378b2011-03-24 21:19:54 +0000344ArchSpec::ArchSpec (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) :
Greg Clayton64195a22011-02-23 00:35:02 +0000345 m_triple (),
346 m_core (kCore_invalid),
347 m_byte_order (eByteOrderInvalid)
348{
349 SetArchitecture (arch_type, cpu, subtype);
350}
351
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000352ArchSpec::~ArchSpec()
353{
354}
355
Greg Clayton64195a22011-02-23 00:35:02 +0000356//===----------------------------------------------------------------------===//
357// Assignment and initialization.
358
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000359const ArchSpec&
360ArchSpec::operator= (const ArchSpec& rhs)
361{
362 if (this != &rhs)
363 {
Greg Clayton514487e2011-02-15 21:59:32 +0000364 m_triple = rhs.m_triple;
Greg Clayton64195a22011-02-23 00:35:02 +0000365 m_core = rhs.m_core;
Greg Clayton514487e2011-02-15 21:59:32 +0000366 m_byte_order = rhs.m_byte_order;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000367 }
368 return *this;
369}
370
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000371void
372ArchSpec::Clear()
373{
Greg Clayton514487e2011-02-15 21:59:32 +0000374 m_triple = llvm::Triple();
Greg Clayton64195a22011-02-23 00:35:02 +0000375 m_core = kCore_invalid;
376 m_byte_order = eByteOrderInvalid;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377}
378
Greg Clayton64195a22011-02-23 00:35:02 +0000379//===----------------------------------------------------------------------===//
380// Predicates.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000381
Greg Clayton41f92322010-06-11 03:25:34 +0000382
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000383const char *
Greg Clayton64195a22011-02-23 00:35:02 +0000384ArchSpec::GetArchitectureName () const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000385{
Greg Clayton64195a22011-02-23 00:35:02 +0000386 const CoreDefinition *core_def = FindCoreDefinition (m_core);
387 if (core_def)
388 return core_def->name;
389 return "unknown";
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000390}
391
Greg Clayton64195a22011-02-23 00:35:02 +0000392uint32_t
393ArchSpec::GetMachOCPUType () const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000394{
Greg Clayton64195a22011-02-23 00:35:02 +0000395 const CoreDefinition *core_def = FindCoreDefinition (m_core);
396 if (core_def)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000397 {
Greg Clayton64195a22011-02-23 00:35:02 +0000398 const ArchDefinitionEntry *arch_def = FindArchDefinitionEntry (&g_macho_arch_def, core_def->core);
399 if (arch_def)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000400 {
Greg Clayton64195a22011-02-23 00:35:02 +0000401 return arch_def->cpu;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000402 }
403 }
Greg Clayton64195a22011-02-23 00:35:02 +0000404 return LLDB_INVALID_CPUTYPE;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000405}
406
Greg Clayton64195a22011-02-23 00:35:02 +0000407uint32_t
408ArchSpec::GetMachOCPUSubType () const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000409{
Greg Clayton64195a22011-02-23 00:35:02 +0000410 const CoreDefinition *core_def = FindCoreDefinition (m_core);
411 if (core_def)
412 {
413 const ArchDefinitionEntry *arch_def = FindArchDefinitionEntry (&g_macho_arch_def, core_def->core);
414 if (arch_def)
415 {
Greg Clayton1cb64962011-03-24 04:28:38 +0000416 return arch_def->sub;
Greg Clayton64195a22011-02-23 00:35:02 +0000417 }
418 }
419 return LLDB_INVALID_CPUTYPE;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000420}
421
Greg Clayton64195a22011-02-23 00:35:02 +0000422llvm::Triple::ArchType
423ArchSpec::GetMachine () const
424{
425 const CoreDefinition *core_def = FindCoreDefinition (m_core);
426 if (core_def)
427 return core_def->machine;
428
429 return llvm::Triple::UnknownArch;
430}
431
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000432uint32_t
433ArchSpec::GetAddressByteSize() const
434{
Greg Clayton64195a22011-02-23 00:35:02 +0000435 const CoreDefinition *core_def = FindCoreDefinition (m_core);
436 if (core_def)
437 return core_def->addr_byte_size;
Greg Clayton41f92322010-06-11 03:25:34 +0000438 return 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000439}
440
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000441ByteOrder
442ArchSpec::GetDefaultEndian () const
443{
Greg Clayton64195a22011-02-23 00:35:02 +0000444 const CoreDefinition *core_def = FindCoreDefinition (m_core);
445 if (core_def)
446 return core_def->default_byte_order;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000447 return eByteOrderInvalid;
448}
449
Greg Clayton64195a22011-02-23 00:35:02 +0000450lldb::ByteOrder
451ArchSpec::GetByteOrder () const
452{
453 if (m_byte_order == eByteOrderInvalid)
454 return GetDefaultEndian();
455 return m_byte_order;
456}
457
458//===----------------------------------------------------------------------===//
459// Mutators.
460
461bool
462ArchSpec::SetTriple (const llvm::Triple &triple)
463{
464 m_triple = triple;
465
466 llvm::StringRef arch_name (m_triple.getArchName());
467 const CoreDefinition *core_def = FindCoreDefinition (arch_name);
468 if (core_def)
469 {
470 m_core = core_def->core;
Greg Claytoneb0103f2011-04-07 22:46:35 +0000471 // Set the byte order to the default byte order for an architecture.
472 // This can be modified if needed for cases when cores handle both
473 // big and little endian
474 m_byte_order = core_def->default_byte_order;
Greg Clayton64195a22011-02-23 00:35:02 +0000475 }
476 else
477 {
478 Clear();
479 }
480
481
482 return IsValid();
483}
484
485bool
Greg Clayton70512312012-05-08 01:45:38 +0000486ArchSpec::SetTriple (const char *triple_cstr)
Greg Clayton64195a22011-02-23 00:35:02 +0000487{
Greg Clayton23aca092011-08-12 23:32:52 +0000488 if (triple_cstr && triple_cstr[0])
Greg Clayton64195a22011-02-23 00:35:02 +0000489 {
490 llvm::StringRef triple_stref (triple_cstr);
491 if (triple_stref.startswith (LLDB_ARCH_DEFAULT))
492 {
493 // Special case for the current host default architectures...
494 if (triple_stref.equals (LLDB_ARCH_DEFAULT_32BIT))
495 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
496 else if (triple_stref.equals (LLDB_ARCH_DEFAULT_64BIT))
497 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
498 else if (triple_stref.equals (LLDB_ARCH_DEFAULT))
499 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
500 }
501 else
502 {
503 std::string normalized_triple_sstr (llvm::Triple::normalize(triple_stref));
504 triple_stref = normalized_triple_sstr;
Greg Clayton70512312012-05-08 01:45:38 +0000505 SetTriple (llvm::Triple (triple_stref));
506 }
507 }
508 else
509 Clear();
510 return IsValid();
511}
512
513bool
514ArchSpec::SetTriple (const char *triple_cstr, Platform *platform)
515{
516 if (triple_cstr && triple_cstr[0])
517 {
518 llvm::StringRef triple_stref (triple_cstr);
519 if (triple_stref.startswith (LLDB_ARCH_DEFAULT))
520 {
521 // Special case for the current host default architectures...
522 if (triple_stref.equals (LLDB_ARCH_DEFAULT_32BIT))
523 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
524 else if (triple_stref.equals (LLDB_ARCH_DEFAULT_64BIT))
525 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
526 else if (triple_stref.equals (LLDB_ARCH_DEFAULT))
527 *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
528 }
529 else
530 {
531 ArchSpec raw_arch (triple_cstr);
532
533 std::string normalized_triple_sstr (llvm::Triple::normalize(triple_stref));
534 triple_stref = normalized_triple_sstr;
Greg Claytoneb0103f2011-04-07 22:46:35 +0000535 llvm::Triple normalized_triple (triple_stref);
536
537 const bool os_specified = normalized_triple.getOSName().size() > 0;
538 const bool vendor_specified = normalized_triple.getVendorName().size() > 0;
539 const bool env_specified = normalized_triple.getEnvironmentName().size() > 0;
540
541 // If we got an arch only, then default the vendor, os, environment
542 // to match the platform if one is supplied
543 if (!(os_specified || vendor_specified || env_specified))
544 {
545 if (platform)
546 {
547 // If we were given a platform, use the platform's system
548 // architecture. If this is not available (might not be
549 // connected) use the first supported architecture.
Greg Clayton70512312012-05-08 01:45:38 +0000550 ArchSpec compatible_arch;
551 if (platform->IsCompatibleArchitecture (raw_arch, &compatible_arch))
Greg Claytoneb0103f2011-04-07 22:46:35 +0000552 {
Greg Clayton70512312012-05-08 01:45:38 +0000553 if (compatible_arch.IsValid())
554 {
555 const llvm::Triple &compatible_triple = compatible_arch.GetTriple();
556 if (!vendor_specified)
557 normalized_triple.setVendor(compatible_triple.getVendor());
558 if (!os_specified)
559 normalized_triple.setOS(compatible_triple.getOS());
560 if (!env_specified && compatible_triple.getEnvironmentName().size())
561 normalized_triple.setEnvironment(compatible_triple.getEnvironment());
562 }
Greg Claytoneb0103f2011-04-07 22:46:35 +0000563 }
Greg Clayton70512312012-05-08 01:45:38 +0000564 else
Greg Claytoneb0103f2011-04-07 22:46:35 +0000565 {
Greg Clayton70512312012-05-08 01:45:38 +0000566 *this = raw_arch;
567 return IsValid();
Greg Claytoneb0103f2011-04-07 22:46:35 +0000568 }
569 }
570 else
571 {
572 // No platform specified, fall back to the host system for
573 // the default vendor, os, and environment.
Sean Callananbfb237bc2011-11-04 22:46:46 +0000574 llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
Greg Clayton70512312012-05-08 01:45:38 +0000575 if (!vendor_specified)
576 normalized_triple.setVendor(host_triple.getVendor());
577 if (!vendor_specified)
578 normalized_triple.setOS(host_triple.getOS());
579 if (!env_specified && host_triple.getEnvironmentName().size())
580 normalized_triple.setEnvironment(host_triple.getEnvironment());
Greg Claytoneb0103f2011-04-07 22:46:35 +0000581 }
582 }
583 SetTriple (normalized_triple);
Greg Clayton64195a22011-02-23 00:35:02 +0000584 }
585 }
586 else
587 Clear();
588 return IsValid();
589}
590
Greg Clayton64195a22011-02-23 00:35:02 +0000591bool
Greg Claytone0d378b2011-03-24 21:19:54 +0000592ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t sub)
Greg Clayton64195a22011-02-23 00:35:02 +0000593{
594 m_core = kCore_invalid;
595 bool update_triple = true;
596 const ArchDefinition *arch_def = FindArchDefinition(arch_type);
597 if (arch_def)
598 {
599 const ArchDefinitionEntry *arch_def_entry = FindArchDefinitionEntry (arch_def, cpu, sub);
600 if (arch_def_entry)
601 {
602 const CoreDefinition *core_def = FindCoreDefinition (arch_def_entry->core);
603 if (core_def)
604 {
605 m_core = core_def->core;
606 update_triple = false;
Greg Clayton593577a2011-09-21 03:57:31 +0000607 // Always use the architecture name because it might be more descriptive
608 // than the architecture enum ("armv7" -> llvm::Triple::arm).
609 m_triple.setArchName(llvm::StringRef(core_def->name));
Greg Clayton64195a22011-02-23 00:35:02 +0000610 if (arch_type == eArchTypeMachO)
611 {
612 m_triple.setVendor (llvm::Triple::Apple);
Greg Clayton70512312012-05-08 01:45:38 +0000613
614 switch (core_def->machine)
615 {
616 case llvm::Triple::arm:
617 case llvm::Triple::thumb:
618 m_triple.setOS (llvm::Triple::IOS);
619 break;
620
621 case llvm::Triple::x86:
622 case llvm::Triple::x86_64:
623 default:
624 m_triple.setOS (llvm::Triple::MacOSX);
625 break;
626 }
Greg Clayton64195a22011-02-23 00:35:02 +0000627 }
628 else
629 {
630 m_triple.setVendor (llvm::Triple::UnknownVendor);
631 m_triple.setOS (llvm::Triple::UnknownOS);
632 }
Greg Clayton593577a2011-09-21 03:57:31 +0000633 // Fall back onto setting the machine type if the arch by name failed...
634 if (m_triple.getArch () == llvm::Triple::UnknownArch)
635 m_triple.setArch (core_def->machine);
Greg Clayton64195a22011-02-23 00:35:02 +0000636 }
637 }
638 }
639 CoreUpdated(update_triple);
640 return IsValid();
641}
642
Greg Clayton357132e2011-03-26 19:14:58 +0000643uint32_t
644ArchSpec::GetMinimumOpcodeByteSize() const
Greg Clayton64195a22011-02-23 00:35:02 +0000645{
Greg Clayton357132e2011-03-26 19:14:58 +0000646 const CoreDefinition *core_def = FindCoreDefinition (m_core);
647 if (core_def)
648 return core_def->min_opcode_byte_size;
649 return 0;
650}
651
652uint32_t
653ArchSpec::GetMaximumOpcodeByteSize() const
654{
655 const CoreDefinition *core_def = FindCoreDefinition (m_core);
656 if (core_def)
657 return core_def->max_opcode_byte_size;
658 return 0;
Greg Clayton64195a22011-02-23 00:35:02 +0000659}
660
661//===----------------------------------------------------------------------===//
662// Helper methods.
663
664void
665ArchSpec::CoreUpdated (bool update_triple)
666{
667 const CoreDefinition *core_def = FindCoreDefinition (m_core);
668 if (core_def)
669 {
670 if (update_triple)
671 m_triple = llvm::Triple(core_def->name, "unknown", "unknown");
672 m_byte_order = core_def->default_byte_order;
673 }
674 else
675 {
676 if (update_triple)
677 m_triple = llvm::Triple();
678 m_byte_order = eByteOrderInvalid;
679 }
680}
681
682//===----------------------------------------------------------------------===//
683// Operators.
684
Greg Clayton70512312012-05-08 01:45:38 +0000685static bool
686cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse)
687{
688 switch (core1)
689 {
690// case ArchSpec::eCore_arm_armv4:
691// try_inverse = false;
692// if (core2 == ArchSpec::eCore_thumb)
693// return true;
694// break;
695//
696// case ArchSpec::eCore_arm_armv4t:
697// try_inverse = false;
698// if (core2 == ArchSpec::eCore_thumbv4t)
699// return true;
700// break;
701//
702// case ArchSpec::eCore_arm_armv5:
703// try_inverse = false;
704// if (core2 == ArchSpec::eCore_thumbv5)
705// return true;
706// break;
707//
708// case ArchSpec::eCore_arm_armv5t:
709// case ArchSpec::eCore_arm_armv5e:
710// try_inverse = false;
711// if (core2 == ArchSpec::eCore_thumbv5e)
712// return true;
713// break;
714//
715// case ArchSpec::eCore_arm_armv6:
716// try_inverse = false;
717// if (core2 == ArchSpec::eCore_thumbv6)
718// return true;
719// break;
720//
721// case ArchSpec::eCore_arm_armv7:
722// try_inverse = false;
723// if (core2 == ArchSpec::eCore_thumbv7)
724// return true;
725// break;
726//
727// case ArchSpec::eCore_arm_armv7f:
728// try_inverse = false;
729// if (core2 == ArchSpec::eCore_thumbv7f)
730// return true;
731// break;
732//
733// case ArchSpec::eCore_arm_armv7k:
734// try_inverse = false;
735// if (core2 == ArchSpec::eCore_thumbv7k)
736// return true;
737// break;
738//
739// case ArchSpec::eCore_arm_armv7s:
740// try_inverse = false;
741// if (core2 == ArchSpec::eCore_thumbv7s)
742// return true;
743// break;
744//
745// case ArchSpec::eCore_thumb:
746// try_inverse = false;
747// if (core2 == ArchSpec::eCore_arm_armv4)
748// return true;
749// break;
750//
751// case ArchSpec::eCore_thumbv4t:
752// try_inverse = false;
753// if (core2 == ArchSpec::eCore_arm_armv4t)
754// return true;
755// break;
756//
757// case ArchSpec::eCore_thumbv5:
758// try_inverse = false;
759// if (core2 == ArchSpec::eCore_arm_armv5)
760// return true;
761// break;
762//
763// case ArchSpec::eCore_thumbv5e:
764// try_inverse = false;
765// if (core2 == ArchSpec::eCore_arm_armv5t || core2 == ArchSpec::eCore_arm_armv5e)
766// return true;
767// break;
768//
769// case ArchSpec::eCore_thumbv6:
770// try_inverse = false;
771// if (core2 == ArchSpec::eCore_arm_armv6)
772// return true;
773// break;
774//
775// case ArchSpec::eCore_thumbv7:
776// try_inverse = false;
777// if (core2 == ArchSpec::eCore_arm_armv7)
778// return true;
779// break;
780//
781// case ArchSpec::eCore_thumbv7f:
782// try_inverse = false;
783// if (core2 == ArchSpec::eCore_arm_armv7f)
784// return true;
785// break;
786//
787// case ArchSpec::eCore_thumbv7k:
788// try_inverse = false;
789// if (core2 == ArchSpec::eCore_arm_armv7k)
790// return true;
791// break;
792//
793// case ArchSpec::eCore_thumbv7s:
794// try_inverse = false;
795// if (core2 == ArchSpec::eCore_arm_armv7s)
796// return true;
797// break;
798
799 case ArchSpec::kCore_any:
800 return true;
801
802 case ArchSpec::kCore_arm_any:
803 if (core2 >= ArchSpec::kCore_arm_first && core2 <= ArchSpec::kCore_arm_last)
804 return true;
805 if (core2 >= ArchSpec::kCore_thumb_first && core2 <= ArchSpec::kCore_thumb_last)
806 return true;
807 if (core2 == ArchSpec::kCore_arm_any)
808 return true;
809 break;
810
811 case ArchSpec::kCore_x86_32_any:
812 if ((core2 >= ArchSpec::kCore_x86_32_first && core2 <= ArchSpec::kCore_x86_32_last) || (core2 == ArchSpec::kCore_x86_32_any))
813 return true;
814 break;
815
816 case ArchSpec::kCore_ppc_any:
817 if ((core2 >= ArchSpec::kCore_ppc_first && core2 <= ArchSpec::kCore_ppc_last) || (core2 == ArchSpec::kCore_ppc_any))
818 return true;
819 break;
820
821 case ArchSpec::kCore_ppc64_any:
822 if ((core2 >= ArchSpec::kCore_ppc64_first && core2 <= ArchSpec::kCore_ppc64_last) || (core2 == ArchSpec::kCore_ppc64_any))
823 return true;
824 break;
825
826 default:
827 break;
828 }
829 if (try_inverse)
830 return cores_match (core2, core1, false);
831 return false;
832}
833
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000834bool
835lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs)
836{
Jim Ingham4d9695a2011-09-15 01:07:30 +0000837 if (lhs.GetByteOrder() != rhs.GetByteOrder())
838 return false;
839
Greg Clayton64195a22011-02-23 00:35:02 +0000840 const ArchSpec::Core lhs_core = lhs.GetCore ();
841 const ArchSpec::Core rhs_core = rhs.GetCore ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000842
Greg Clayton70512312012-05-08 01:45:38 +0000843 // Check if the cores match, or check a little closer watching for wildcard
844 // and equivalent cores
845 const bool core_match = (lhs_core == rhs_core) || cores_match (lhs_core, rhs_core, true);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000846
Greg Clayton70512312012-05-08 01:45:38 +0000847 if (core_match)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000848 {
Jim Ingham4d9695a2011-09-15 01:07:30 +0000849 const llvm::Triple &lhs_triple = lhs.GetTriple();
850 const llvm::Triple &rhs_triple = rhs.GetTriple();
Greg Clayton593577a2011-09-21 03:57:31 +0000851
852 const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
853 const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
854 if (lhs_triple_vendor != rhs_triple_vendor)
855 {
Greg Clayton70512312012-05-08 01:45:38 +0000856 const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
857 const bool lhs_vendor_specified = lhs.TripleVendorWasSpecified();
858 // Both architectures had the vendor specified, so if they aren't
859 // equal then we return false
860 if (rhs_vendor_specified && lhs_vendor_specified)
861 return false;
862
Greg Clayton593577a2011-09-21 03:57:31 +0000863 // Only fail if both vendor types are not unknown
864 if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
865 rhs_triple_vendor != llvm::Triple::UnknownVendor)
866 return false;
867 }
868
869 const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
870 const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
871 if (lhs_triple_os != rhs_triple_os)
872 {
Greg Clayton70512312012-05-08 01:45:38 +0000873 const bool rhs_os_specified = rhs.TripleOSWasSpecified();
874 const bool lhs_os_specified = lhs.TripleOSWasSpecified();
875 // Both architectures had the OS specified, so if they aren't
876 // equal then we return false
877 if (rhs_os_specified && lhs_os_specified)
878 return false;
Greg Clayton593577a2011-09-21 03:57:31 +0000879 // Only fail if both os types are not unknown
880 if (lhs_triple_os != llvm::Triple::UnknownOS &&
881 rhs_triple_os != llvm::Triple::UnknownOS)
882 return false;
883 }
884
885 const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment();
886 const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment();
887
888 if (lhs_triple_env != rhs_triple_env)
889 {
890 // Only fail if both environment types are not unknown
891 if (lhs_triple_env != llvm::Triple::UnknownEnvironment &&
892 rhs_triple_env != llvm::Triple::UnknownEnvironment)
893 return false;
894 }
895 return true;
Greg Clayton64195a22011-02-23 00:35:02 +0000896 }
Greg Clayton70512312012-05-08 01:45:38 +0000897 return false;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000898}
899
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000900bool
901lldb_private::operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
902{
903 return !(lhs == rhs);
904}
905
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000906bool
907lldb_private::operator<(const ArchSpec& lhs, const ArchSpec& rhs)
908{
Greg Clayton64195a22011-02-23 00:35:02 +0000909 const ArchSpec::Core lhs_core = lhs.GetCore ();
910 const ArchSpec::Core rhs_core = rhs.GetCore ();
911 return lhs_core < rhs_core;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000912}