/usr/lib/llvm-3.4/include/lldb/Core/ArchSpec.h is in liblldb-3.4-dev 1:3.4.2-13.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | //===-- ArchSpec.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ArchSpec_h_
#define liblldb_ArchSpec_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
struct CoreDefinition;
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
/// @brief An architecture specification class.
///
/// A class designed to be created from a cpu type and subtype, a
/// string representation, or an llvm::Triple. Keeping all of the
/// conversions of strings to architecture enumeration values confined
/// to this class allows new architecture support to be added easily.
//----------------------------------------------------------------------
class ArchSpec
{
public:
enum Core
{
eCore_arm_generic,
eCore_arm_armv4,
eCore_arm_armv4t,
eCore_arm_armv5,
eCore_arm_armv5e,
eCore_arm_armv5t,
eCore_arm_armv6,
eCore_arm_armv6m,
eCore_arm_armv7,
eCore_arm_armv7f,
eCore_arm_armv7s,
eCore_arm_armv7k,
eCore_arm_armv7m,
eCore_arm_armv7em,
eCore_arm_xscale,
eCore_thumb,
eCore_thumbv4t,
eCore_thumbv5,
eCore_thumbv5e,
eCore_thumbv6,
eCore_thumbv6m,
eCore_thumbv7,
eCore_thumbv7f,
eCore_thumbv7s,
eCore_thumbv7k,
eCore_thumbv7m,
eCore_thumbv7em,
eCore_mips64,
eCore_ppc_generic,
eCore_ppc_ppc601,
eCore_ppc_ppc602,
eCore_ppc_ppc603,
eCore_ppc_ppc603e,
eCore_ppc_ppc603ev,
eCore_ppc_ppc604,
eCore_ppc_ppc604e,
eCore_ppc_ppc620,
eCore_ppc_ppc750,
eCore_ppc_ppc7400,
eCore_ppc_ppc7450,
eCore_ppc_ppc970,
eCore_ppc64_generic,
eCore_ppc64_ppc970_64,
eCore_sparc_generic,
eCore_sparc9_generic,
eCore_x86_32_i386,
eCore_x86_32_i486,
eCore_x86_32_i486sx,
eCore_x86_64_x86_64,
eCore_uknownMach32,
eCore_uknownMach64,
kNumCores,
kCore_invalid,
// The following constants are used for wildcard matching only
kCore_any,
kCore_arm_any,
kCore_ppc_any,
kCore_ppc64_any,
kCore_x86_32_any,
kCore_arm_first = eCore_arm_generic,
kCore_arm_last = eCore_arm_xscale,
kCore_thumb_first = eCore_thumb,
kCore_thumb_last = eCore_thumbv7em,
kCore_ppc_first = eCore_ppc_generic,
kCore_ppc_last = eCore_ppc_ppc970,
kCore_ppc64_first = eCore_ppc64_generic,
kCore_ppc64_last = eCore_ppc64_ppc970_64,
kCore_x86_32_first = eCore_x86_32_i386,
kCore_x86_32_last = eCore_x86_32_i486sx
};
//------------------------------------------------------------------
/// Default constructor.
///
/// Default constructor that initializes the object with invalid
/// cpu type and subtype values.
//------------------------------------------------------------------
ArchSpec ();
//------------------------------------------------------------------
/// Constructor over triple.
///
/// Constructs an ArchSpec with properties consistent with the given
/// Triple.
//------------------------------------------------------------------
explicit
ArchSpec (const llvm::Triple &triple);
explicit
ArchSpec (const char *triple_cstr);
explicit
ArchSpec (const char *triple_cstr, Platform *platform);
//------------------------------------------------------------------
/// Constructor over architecture name.
///
/// Constructs an ArchSpec with properties consistent with the given
/// object type and architecture name.
//------------------------------------------------------------------
explicit
ArchSpec (ArchitectureType arch_type,
uint32_t cpu_type,
uint32_t cpu_subtype);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~ArchSpec ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// @param[in] rhs another ArchSpec object to copy.
///
/// @return A const reference to this object.
//------------------------------------------------------------------
const ArchSpec&
operator= (const ArchSpec& rhs);
static size_t
AutoComplete (const char *name,
StringList &matches);
//------------------------------------------------------------------
/// Returns a static string representing the current architecture.
///
/// @return A static string correcponding to the current
/// architecture.
//------------------------------------------------------------------
const char *
GetArchitectureName () const;
//------------------------------------------------------------------
/// Clears the object state.
///
/// Clears the object state back to a default invalid state.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Returns the size in bytes of an address of the current
/// architecture.
///
/// @return The byte size of an address of the current architecture.
//------------------------------------------------------------------
uint32_t
GetAddressByteSize () const;
//------------------------------------------------------------------
/// Returns a machine family for the current architecture.
///
/// @return An LLVM arch type.
//------------------------------------------------------------------
llvm::Triple::ArchType
GetMachine () const;
//------------------------------------------------------------------
/// Tests if this ArchSpec is valid.
///
/// @return True if the current architecture is valid, false
/// otherwise.
//------------------------------------------------------------------
bool
IsValid () const
{
return m_core >= eCore_arm_generic && m_core < kNumCores;
}
bool
TripleVendorWasSpecified() const
{
return !m_triple.getVendorName().empty();
}
bool
TripleOSWasSpecified() const
{
return !m_triple.getOSName().empty();
}
//------------------------------------------------------------------
/// Sets this ArchSpec according to the given architecture name.
///
/// The architecture name can be one of the generic system default
/// values:
///
/// @li \c LLDB_ARCH_DEFAULT - The arch the current system defaults
/// to when a program is launched without any extra
/// attributes or settings.
/// @li \c LLDB_ARCH_DEFAULT_32BIT - The default host architecture
/// for 32 bit (if any).
/// @li \c LLDB_ARCH_DEFAULT_64BIT - The default host architecture
/// for 64 bit (if any).
///
/// Alternatively, if the object type of this ArchSpec has been
/// configured, a concrete architecture can be specified to set
/// the CPU type ("x86_64" for example).
///
/// Finally, an encoded object and archetecture format is accepted.
/// The format contains an object type (like "macho" or "elf"),
/// followed by a platform dependent encoding of CPU type and
/// subtype. For example:
///
/// "macho" : Specifies an object type of MachO.
/// "macho-16-6" : MachO specific encoding for ARMv6.
/// "elf-43 : ELF specific encoding for Sparc V9.
///
/// @param[in] arch_name The name of an architecture.
///
/// @return True if @p arch_name was successfully translated, false
/// otherwise.
//------------------------------------------------------------------
// bool
// SetArchitecture (const llvm::StringRef& arch_name);
//
// bool
// SetArchitecture (const char *arch_name);
//------------------------------------------------------------------
/// Change the architecture object type and CPU type.
///
/// @param[in] arch_type The object type of this ArchSpec.
///
/// @param[in] cpu The required CPU type.
///
/// @return True if the object and CPU type were sucessfully set.
//------------------------------------------------------------------
bool
SetArchitecture (ArchitectureType arch_type,
uint32_t cpu,
uint32_t sub);
//------------------------------------------------------------------
/// Returns the byte order for the architecture specification.
///
/// @return The endian enumeration for the current endianness of
/// the architecture specification
//------------------------------------------------------------------
lldb::ByteOrder
GetByteOrder () const;
//------------------------------------------------------------------
/// Sets this ArchSpec's byte order.
///
/// In the common case there is no need to call this method as the
/// byte order can almost always be determined by the architecture.
/// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
/// and the default/assumed byte order may be incorrect.
//------------------------------------------------------------------
void
SetByteOrder (lldb::ByteOrder byte_order)
{
m_byte_order = byte_order;
}
uint32_t
GetMinimumOpcodeByteSize() const;
uint32_t
GetMaximumOpcodeByteSize() const;
Core
GetCore () const
{
return m_core;
}
uint32_t
GetMachOCPUType () const;
uint32_t
GetMachOCPUSubType () const;
//------------------------------------------------------------------
/// Architecture tripple accessor.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
llvm::Triple &
GetTriple ()
{
return m_triple;
}
//------------------------------------------------------------------
/// Architecture tripple accessor.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
const llvm::Triple &
GetTriple () const
{
return m_triple;
}
//------------------------------------------------------------------
/// Architecture tripple setter.
///
/// Configures this ArchSpec according to the given triple. If the
/// triple has unknown components in all of the vendor, OS, and
/// the optional environment field (i.e. "i386-unknown-unknown")
/// then default values are taken from the host. Architecture and
/// environment components are used to further resolve the CPU type
/// and subtype, endian characteristics, etc.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
bool
SetTriple (const llvm::Triple &triple);
bool
SetTriple (const char *triple_cstr);
bool
SetTriple (const char *triple_cstr,
Platform *platform);
//------------------------------------------------------------------
/// Returns the default endianness of the architecture.
///
/// @return The endian enumeration for the default endianness of
/// the architecture.
//------------------------------------------------------------------
lldb::ByteOrder
GetDefaultEndian () const;
//------------------------------------------------------------------
/// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
/// type match between them.
/// e.g. armv7s is not an exact match with armv7 - this would return false
///
/// @return true if the two ArchSpecs match.
//------------------------------------------------------------------
bool
IsExactMatch (const ArchSpec& rhs) const;
//------------------------------------------------------------------
/// Compare an ArchSpec to another ArchSpec, requiring a compatible
/// cpu type match between them.
/// e.g. armv7s is compatible with armv7 - this method would return true
///
/// @return true if the two ArchSpecs are compatible
//------------------------------------------------------------------
bool
IsCompatibleMatch (const ArchSpec& rhs) const;
protected:
bool
IsEqualTo (const ArchSpec& rhs, bool exact_match) const;
llvm::Triple m_triple;
Core m_core;
lldb::ByteOrder m_byte_order;
// Called when m_def or m_entry are changed. Fills in all remaining
// members with default values.
void
CoreUpdated (bool update_triple);
};
//------------------------------------------------------------------
/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs)
/// @brief Less than operator.
///
/// Tests two ArchSpec objects to see if \a lhs is less than \a
/// rhs.
///
/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
///
/// @return true if \a lhs is less than \a rhs
//------------------------------------------------------------------
bool operator< (const ArchSpec& lhs, const ArchSpec& rhs);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // #ifndef liblldb_ArchSpec_h_
|