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) {
195 return "fixed_vector";
197 return "scalable_vector";
199 return "typed_pointer";
216class ValuePackRange {
219 ValuePackHeader header;
222 uint32_t type_id()
const {
return header.
type_id; }
223 uint32_t
size()
const {
return header.
size; }
226 template <
typename T>
const T &as()
const {
227 return *
static_cast<const T *
>(
data);
229 template <
typename T>
const T *ptr()
const {
230 return static_cast<const T *
>(
data);
236 iterator(
const void *ptr, uint32_t num_elements, uint64_t max_offset)
237 : max_offset_(max_offset) {
239 if (ptr && !is_valid_position())
240 iter_.current =
nullptr;
249 if (!is_valid_position())
250 iter_.current =
nullptr;
254 bool operator!=(
const iterator &other)
const {
255 return iter_.current != other.iter_.current;
259 bool is_valid_position()
const {
262 if (iter_.index >= iter_.count)
264 if (max_offset_ > 0 && iter_.offset >= max_offset_)
269 ValuePackIterator iter_;
270 uint64_t max_offset_;
273 ValuePackRange(
const void *ptr, uint32_t num_elements, uint64_t max_size = 0)
274 : ptr_(ptr), num_elements_(num_elements), max_size_(max_size) {}
281 uint32_t num_elements_;
287inline const T *getValueAs(
const void *pack_ptr,
uint32_t num_elements,
289 return static_cast<const T *
>(
static void nextValuePack(ValuePackIterator *iter)
Move to the next value in the pack.
static const char * getLLVMTypeIDName(int32_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.
CompareFlags
CompareIO flag bitmask values.
@ COMPARE_FLAG_HAS_NO_NANS
@ COMPARE_FLAG_HAS_NO_INFS
@ COMPARE_FLAG_HAS_NO_SIGNED_ZEROS
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.
NumericFlags
Bitmask flags for different instrumentation opportunities.
@ NUMERIC_FLAG_NO_SIGNED_WRAP
@ NUMERIC_FLAG_NO_UNSIGNED_WRAP
@ NUMERIC_FLAG_HAS_NO_SIGNED_ZEROS
@ NUMERIC_FLAG_HAS_NO_INFS
@ NUMERIC_FLAG_HAS_NO_NANS
@ NUMERIC_FLAG_IS_DISJOINT
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.