14#ifndef INSTRUMENTOR_RUNTIME_H
15#define INSTRUMENTOR_RUNTIME_H
52 iter->
current = (
const char *)pack_ptr;
54 iter->
count = num_elements;
73 return data_start + padding;
106 if (!pack_ptr || index >= num_elements)
114 if (iter.
index == index) {
193 return "fixed_vector";
195 return "scalable_vector";
197 return "typed_pointer";
214class ValuePackRange {
217 ValuePackHeader header;
220 uint32_t type_id()
const {
return header.
type_id; }
221 uint32_t
size()
const {
return header.
size; }
224 template <
typename T>
const T &as()
const {
225 return *
static_cast<const T *
>(
data);
227 template <
typename T>
const T *ptr()
const {
228 return static_cast<const T *
>(
data);
234 iterator(
const void *ptr, uint32_t num_elements, uint64_t max_offset)
235 : max_offset_(max_offset) {
237 if (ptr && !is_valid_position())
238 iter_.current =
nullptr;
247 if (!is_valid_position())
248 iter_.current =
nullptr;
252 bool operator!=(
const iterator &other)
const {
253 return iter_.current != other.iter_.current;
257 bool is_valid_position()
const {
260 if (iter_.index >= iter_.count)
262 if (max_offset_ > 0 && iter_.offset >= max_offset_)
267 ValuePackIterator iter_;
268 uint64_t max_offset_;
271 ValuePackRange(
const void *ptr, uint32_t num_elements, uint64_t max_size = 0)
272 : ptr_(ptr), num_elements_(num_elements), max_size_(max_size) {}
279 uint32_t num_elements_;
285inline const T *getValueAs(
const void *pack_ptr,
uint32_t num_elements,
287 return static_cast<const T *
>(
static void nextValuePack(ValuePackIterator *iter)
Move to the next value in the pack.
static const char * getLLVMTypeIDName(uint32_t type_id)
Get the string name of an LLVM Type ID.
LLVMTypeID
LLVM Type IDs for interpreting value pack data.
@ X86_FP80TyID
80-bit floating point type (X87)
@ ScalableVectorTyID
Scalable SIMD vector type.
@ IntegerTyID
Arbitrary bit width integers.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ FP128TyID
128-bit floating point type (112-bit significand)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ ByteTyID
Arbitrary bit width bytes.
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ DoubleTyID
64-bit floating point type
@ FixedVectorTyID
Fixed width SIMD vector type.
@ HalfTyID
16-bit floating point type
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ FloatTyID
32-bit floating point type
@ VoidTyID
type with no size
@ TargetExtTyID
Target extension type.
static uint64_t getValuePackOffset(const ValuePackIterator *iter)
Get the current offset in bytes from the start of the pack.
static const void * getValuePackData(const ValuePackIterator *iter)
Get a pointer to the current value data.
static ValuePackHeader getValuePackHeader(const ValuePackIterator *iter)
Get the header for the current value.
static void initValuePackIterator(ValuePackIterator *iter, const void *pack_ptr, uint32_t num_elements)
Initialize a value pack iterator.
static const void * getValuePackEntry(const void *pack_ptr, uint32_t num_elements, uint32_t index, ValuePackHeader *header)
Extract a specific value from a value pack by index.
LLVM_ABI iterator begin() const
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
APInt operator*(APInt a, uint64_t RHS)
bool operator!=(uint64_t V1, const APInt &V2)
Iterator for reading values from a value pack.