9#ifndef LLVM_OBJECT_STACKMAPPARSER_H 
   10#define LLVM_OBJECT_STACKMAPPARSER_H 
   26  template <
typename AccessorT>
 
   39      return A.P == 
Other.A.P;
 
 
   43      return !(*
this == 
Other);
 
 
 
   54  class FunctionAccessor {
 
   60      return read<uint64_t>(P);
 
 
   65      return read<uint64_t>(P + 
sizeof(
uint64_t));
 
 
   70      return read<uint64_t>(P + (2 * 
sizeof(
uint64_t)));
 
 
   76    const static int FunctionAccessorSize = 3 * 
sizeof(
uint64_t);
 
   78    FunctionAccessor next()
 const {
 
   79      return FunctionAccessor(
P + FunctionAccessorSize);
 
 
   86  class ConstantAccessor {
 
   96    const static int ConstantAccessorSize = 
sizeof(
uint64_t);
 
   98    ConstantAccessor next()
 const {
 
   99      return ConstantAccessor(
P + ConstantAccessorSize);
 
 
  110  class LocationAccessor {
 
  122        return read<uint16_t>(P + SizeOffset);
 
 
  128      return read<uint16_t>(P + DwarfRegNumOffset);
 
 
  134      return read<uint32_t>(P + SmallConstantOffset);
 
 
  140             "Not a constant-index.");
 
  141      return read<uint32_t>(P + SmallConstantOffset);
 
 
  148             "Not direct or indirect.");
 
  149      return read<int32_t>(P + SmallConstantOffset);
 
 
  155    LocationAccessor next()
 const {
 
  156      return LocationAccessor(
P + LocationAccessorSize);
 
  159    static const int KindOffset = 0;
 
  160    static const int SizeOffset = KindOffset + 
sizeof(
uint16_t);
 
  161    static const int DwarfRegNumOffset = SizeOffset + 
sizeof(
uint16_t);
 
  162    static const int SmallConstantOffset = DwarfRegNumOffset + 
sizeof(
uint32_t);
 
  163    static const int LocationAccessorSize = 
sizeof(
uint64_t) + 
sizeof(
uint32_t);
 
 
  169  class LiveOutAccessor {
 
  176      return read<uint16_t>(P + DwarfRegNumOffset);
 
 
  181      return read<uint8_t>(P + SizeOffset);
 
 
  187    LiveOutAccessor next()
 const {
 
  188      return LiveOutAccessor(
P + LiveOutAccessorSize);
 
  191    static const int DwarfRegNumOffset = 0;
 
  192    static const int SizeOffset =
 
  194    static const int LiveOutAccessorSize = 
sizeof(
uint32_t);
 
 
  200  class RecordAccessor {
 
  209      return read<uint64_t>(P + PatchpointIDOffset);
 
 
  215      return read<uint32_t>(P + InstructionOffsetOffset);
 
 
  220      return read<uint16_t>(P + NumLocationsOffset);
 
 
  225      unsigned LocationOffset =
 
  226        LocationListOffset + LocationIndex * LocationSize;
 
 
  247      return read<uint16_t>(P + getNumLiveOutsOffset());
 
 
  252      unsigned LiveOutOffset =
 
  253        getNumLiveOutsOffset() + 
sizeof(
uint16_t) + LiveOutIndex * LiveOutSize;
 
 
  275    unsigned getNumLiveOutsOffset()
 const {
 
  278      return LocOffset + 
sizeof(
uint16_t);
 
  282      unsigned RecordSize =
 
  284      return (RecordSize + 7) & ~0x7;
 
  287    RecordAccessor next()
 const {
 
  291    static const unsigned PatchpointIDOffset = 0;
 
  292    static const unsigned InstructionOffsetOffset =
 
  293      PatchpointIDOffset + 
sizeof(uint64_t);
 
  294    static const unsigned NumLocationsOffset =
 
  295      InstructionOffsetOffset + 
sizeof(uint32_t) + 
sizeof(uint16_t);
 
  296    static const unsigned LocationListOffset =
 
  297      NumLocationsOffset + 
sizeof(uint16_t);
 
  298    static const unsigned LocationSize = 
sizeof(uint64_t) + 
sizeof(uint32_t);
 
  299    static const unsigned LiveOutSize = 
sizeof(uint32_t);
 
 
  307      : StackMapSection(StackMapSection) {
 
  308    ConstantsListOffset = FunctionListOffset + 
getNumFunctions() * FunctionSize;
 
  310    assert(StackMapSection[0] == 3 &&
 
  311           "StackMapParser can only parse version 3 stackmaps");
 
  313    unsigned CurrentRecordOffset =
 
  317      StackMapRecordOffsets.push_back(CurrentRecordOffset);
 
  318      CurrentRecordOffset +=
 
  319        RecordAccessor(&StackMapSection[CurrentRecordOffset]).getSizeInBytes();
 
 
  326    if (StackMapSection.size() < 16)
 
  328          "the stack map section size (" + 
Twine(StackMapSection.size()) +
 
  329          ") is less than the minimum possible size of its header (16)");
 
  331    unsigned Version = StackMapSection[0];
 
  335          ") of the stack map section is unsupported, the " 
  336          "supported version is 3");
 
 
  349    return read<uint32_t>(&StackMapSection[NumFunctionsOffset]);
 
 
  354    return read<uint32_t>(&StackMapSection[NumConstantsOffset]);
 
 
  359    return read<uint32_t>(&StackMapSection[NumRecordsOffset]);
 
 
  365                            getFunctionOffset(FunctionIndex));
 
 
  410    std::size_t RecordOffset = StackMapRecordOffsets[RecordIndex];
 
 
  437  template <
typename T>
 
  442  static const unsigned HeaderOffset = 0;
 
  443  static const unsigned NumFunctionsOffset = HeaderOffset + 
sizeof(
uint32_t);
 
  444  static const unsigned NumConstantsOffset = NumFunctionsOffset + 
sizeof(
uint32_t);
 
  445  static const unsigned NumRecordsOffset = NumConstantsOffset + 
sizeof(
uint32_t);
 
  446  static const unsigned FunctionListOffset = NumRecordsOffset + 
sizeof(
uint32_t);
 
  448  static const unsigned FunctionSize = 3 * 
sizeof(
uint64_t);
 
  449  static const unsigned ConstantSize = 
sizeof(
uint64_t);
 
  451  std::size_t getFunctionOffset(
unsigned FunctionIndex)
 const {
 
  452    return FunctionListOffset + FunctionIndex * FunctionSize;
 
  455  std::size_t getConstantOffset(
unsigned ConstantIndex)
 const {
 
  459  ArrayRef<uint8_t> StackMapSection;
 
  460  unsigned ConstantsListOffset;
 
  461  std::vector<unsigned> StackMapRecordOffsets;
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
 
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
Lightweight error class with error context and mandatory checking.
 
static ErrorSuccess success()
Create a success value.
 
bool operator==(const AccessorIterator &Other) const
 
AccessorIterator(AccessorT A)
 
AccessorIterator & operator++()
 
bool operator!=(const AccessorIterator &Other) const
 
AccessorIterator operator++(int)
 
uint64_t getValue() const
Return the value of this constant.
 
friend class StackMapParser
 
Accessor for function records.
 
uint64_t getRecordCount() const
Get the number of callsite records.
 
uint64_t getFunctionAddress() const
Get the function address.
 
uint64_t getStackSize() const
Get the function's stack size.
 
friend class StackMapParser
 
Accessor for stackmap live-out fields.
 
uint16_t getDwarfRegNum() const
Get the Dwarf register number for this live-out.
 
friend class RecordAccessor
 
friend class StackMapParser
 
unsigned getSizeInBytes() const
Get the size in bytes of live [sub]register.
 
Accessor for location records.
 
unsigned getSizeInBytes() const
Get the Size for this location.
 
uint16_t getDwarfRegNum() const
Get the Dwarf register number for this location.
 
LocationKind getKind() const
Get the Kind for this location.
 
friend class RecordAccessor
 
friend class StackMapParser
 
int32_t getOffset() const
Get the offset for this location. (Kind must be Direct or Indirect).
 
uint32_t getConstantIndex() const
Get the constant-index for this location. (Kind must be ConstantIndex).
 
uint32_t getSmallConstant() const
Get the small-constant for this location. (Kind must be Constant).
 
Accessor for stackmap records.
 
iterator_range< liveout_iterator > liveouts() const
Iterator range for live-outs.
 
uint16_t getNumLocations() const
Get the number of locations contained in this record.
 
LocationAccessor getLocation(unsigned LocationIndex) const
Get the location with the given index.
 
uint32_t getInstructionOffset() const
Get the instruction offset (from the start of the containing function) for this record.
 
liveout_iterator liveouts_end() const
End iterator for live-outs.
 
iterator_range< location_iterator > locations() const
Iterator range for locations.
 
LiveOutAccessor getLiveOut(unsigned LiveOutIndex) const
Get the live-out with the given index.
 
AccessorIterator< LiveOutAccessor > liveout_iterator
 
friend class StackMapParser
 
AccessorIterator< LocationAccessor > location_iterator
 
location_iterator location_begin() const
Begin iterator for locations.
 
uint64_t getID() const
Get the patchpoint/stackmap ID for this record.
 
uint16_t getNumLiveOuts() const
Get the number of liveouts contained in this record.
 
liveout_iterator liveouts_begin() const
Begin iterator for live-outs.
 
location_iterator location_end() const
End iterator for locations.
 
constant_iterator constants_end() const
End iterator for constants.
 
record_iterator records_end() const
End iterator for records.
 
FunctionAccessor getFunction(unsigned FunctionIndex) const
Return an FunctionAccessor for the given function index.
 
AccessorIterator< FunctionAccessor > function_iterator
 
AccessorIterator< ConstantAccessor > constant_iterator
 
function_iterator functions_end() const
End iterator for functions.
 
iterator_range< record_iterator > records() const
Iterator range for records.
 
iterator_range< constant_iterator > constants() const
Iterator range for constants.
 
unsigned getVersion() const
Get the version number of this stackmap. (Always returns 3).
 
uint32_t getNumConstants() const
Get the number of large constants in the stack map.
 
function_iterator functions_begin() const
Begin iterator for functions.
 
record_iterator records_begin() const
Begin iterator for records.
 
uint32_t getNumRecords() const
Get the number of stackmap records in the stackmap.
 
constant_iterator constants_begin() const
Begin iterator for constants.
 
iterator_range< function_iterator > functions() const
Iterator range for functions.
 
AccessorIterator< RecordAccessor > record_iterator
 
ConstantAccessor getConstant(unsigned ConstantIndex) const
Return the large constant at the given index.
 
StackMapParser(ArrayRef< uint8_t > StackMapSection)
Construct a parser for a version-3 stackmap.
 
RecordAccessor getRecord(unsigned RecordIndex) const
Return a RecordAccessor for the given record index.
 
static Error validateHeader(ArrayRef< uint8_t > StackMapSection)
Validates the header of the specified stack map section.
 
uint32_t getNumFunctions() const
Get the number of functions in the stack map.
 
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
 
A range adaptor for a pair of iterators.
 
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
 
Error createError(const Twine &Err)
 
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
 
This is an optimization pass for GlobalISel generic memory operations.
 
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
 
FunctionAddr VTableAddr uintptr_t uintptr_t Version