LLVM 23.0.0git
llvm::AMDGPU::HWEvents Class Reference

Bit mask of hardware events. More...

#include "Target/AMDGPU/AMDGPUHWEvents.h"

Classes

class  const_iterator
 Iterates over the set bits of an HWEvent. More...

Public Types

enum  : value_type { NONE = 0 , ALL = ((HWEVENT_LAST_EVENT << 1) - 1) }
using value_type = uint32_t

Public Member Functions

constexpr HWEvents ()=default
constexpr HWEvents (value_type V)
constexpr unsigned size () const
constexpr bool any () const
constexpr bool none () const
constexpr value_type value () const
constexpr operator bool () const
constexpr bool contains (HWEvents Other) const
const_iterator begin () const
const_iterator end () const
constexpr HWEvents operator| (HWEvents Other) const
constexpr HWEvents operator& (HWEvents Other) const
constexpr HWEvents operator^ (HWEvents Other) const
constexpr HWEvents operator- (HWEvents Other) const
constexpr HWEvents operator~ () const
constexpr bool operator== (HWEvents Other) const
constexpr bool operator!= (HWEvents Other) const
constexpr HWEventsoperator|= (HWEvents Other)
constexpr HWEventsoperator&= (HWEvents Other)
constexpr HWEventsoperator^= (HWEvents Other)
constexpr HWEvents operator-= (HWEvents Other)
constexpr HWEvents operator& (value_type Other) const
 Overload both bitwise AND operators w/ the value_type to avoid an implicit conversion to HWEvent in this common pattern used to clear an event bit: Events & ~HWEvent::EVENT_TO_CLEAR.
constexpr HWEventsoperator&= (value_type Other)
LLVM_DUMP_METHOD void dump () const

Detailed Description

Bit mask of hardware events.

This is useful to manipulate events as hardware events rarely come alone. This class implements all the usual operators one would need to manipulate a bit mask, and also supports printing to a raw_ostream and iterating over all the set bits of the event mask.

This class behaves like a constexpr set of flags. None of the methods should be able to mutate the data unless they are assignment operators. Examples:

///   A |= B;   // Add flags (union).
///   A -= B;   // Remove flags (substraction).
///   A &= B;   // Intersection.
///   A ^= B;   // Bitwise XOR.
///   (bool)A;  // Check whether any bits are set; A.any() also works.
///   !A;       // Check if no bits are set; A.none() also works.
///   A.size(); // Check how many bits are set.
/// 

This type also provides certain stronger guarantees than a simple integer:

  • Default constructor initializes the mask to zero.
  • Constructor ensures undefined bits cannot be set.

Definition at line 49 of file AMDGPUHWEvents.h.

Member Typedef Documentation

◆ value_type

using llvm::AMDGPU::HWEvents::value_type = uint32_t

Definition at line 51 of file AMDGPUHWEvents.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : value_type
Enumerator
NONE 
ALL 

Definition at line 53 of file AMDGPUHWEvents.h.

Constructor & Destructor Documentation

◆ HWEvents() [1/2]

◆ HWEvents() [2/2]

llvm::AMDGPU::HWEvents::HWEvents ( value_type V)
inlineconstexpr

Definition at line 93 of file AMDGPUHWEvents.h.

References ALL, and assert().

Member Function Documentation

◆ any()

bool llvm::AMDGPU::HWEvents::any ( ) const
inlineconstexpr

Definition at line 98 of file AMDGPUHWEvents.h.

Referenced by operator bool().

◆ begin()

const_iterator llvm::AMDGPU::HWEvents::begin ( ) const
inline

Definition at line 108 of file AMDGPUHWEvents.h.

◆ contains()

bool llvm::AMDGPU::HWEvents::contains ( HWEvents Other) const
inlineconstexpr

Definition at line 104 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ dump()

LLVM_DUMP_METHOD void llvm::AMDGPU::HWEvents::dump ( ) const

Definition at line 20 of file AMDGPUHWEvents.cpp.

References llvm::dbgs(), and LLVM_DUMP_METHOD.

◆ end()

const_iterator llvm::AMDGPU::HWEvents::end ( ) const
inline

Definition at line 109 of file AMDGPUHWEvents.h.

◆ none()

bool llvm::AMDGPU::HWEvents::none ( ) const
inlineconstexpr

Definition at line 99 of file AMDGPUHWEvents.h.

◆ operator bool()

llvm::AMDGPU::HWEvents::operator bool ( ) const
inlineexplicitconstexpr

Definition at line 102 of file AMDGPUHWEvents.h.

References any().

◆ operator!=()

bool llvm::AMDGPU::HWEvents::operator!= ( HWEvents Other) const
inlineconstexpr

Definition at line 128 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator&() [1/2]

HWEvents llvm::AMDGPU::HWEvents::operator& ( HWEvents Other) const
inlineconstexpr

Definition at line 114 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator&() [2/2]

HWEvents llvm::AMDGPU::HWEvents::operator& ( value_type Other) const
inlineconstexpr

Overload both bitwise AND operators w/ the value_type to avoid an implicit conversion to HWEvent in this common pattern used to clear an event bit: Events & ~HWEvent::EVENT_TO_CLEAR.

If we had the implicit conversion to HWEvent, we'd assert because ~HWEvent::EVENT_TO_CLEAR has bits set outside of HWEvent::ALL.

Definition at line 153 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator&=() [1/2]

HWEvents & llvm::AMDGPU::HWEvents::operator&= ( HWEvents Other)
inlineconstexpr

Definition at line 134 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator&=() [2/2]

HWEvents & llvm::AMDGPU::HWEvents::operator&= ( value_type Other)
inlineconstexpr

Definition at line 154 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator-()

HWEvents llvm::AMDGPU::HWEvents::operator- ( HWEvents Other) const
inlineconstexpr

Definition at line 121 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator-=()

HWEvents llvm::AMDGPU::HWEvents::operator-= ( HWEvents Other)
inlineconstexpr

Definition at line 143 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator==()

bool llvm::AMDGPU::HWEvents::operator== ( HWEvents Other) const
inlineconstexpr

Definition at line 127 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator^()

HWEvents llvm::AMDGPU::HWEvents::operator^ ( HWEvents Other) const
inlineconstexpr

Definition at line 117 of file AMDGPUHWEvents.h.

◆ operator^=()

HWEvents & llvm::AMDGPU::HWEvents::operator^= ( HWEvents Other)
inlineconstexpr

Definition at line 138 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator|()

HWEvents llvm::AMDGPU::HWEvents::operator| ( HWEvents Other) const
inlineconstexpr

Definition at line 111 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator|=()

HWEvents & llvm::AMDGPU::HWEvents::operator|= ( HWEvents Other)
inlineconstexpr

Definition at line 130 of file AMDGPUHWEvents.h.

References HWEvents(), and llvm::AMDGPU::Other.

◆ operator~()

HWEvents llvm::AMDGPU::HWEvents::operator~ ( ) const
inlineconstexpr

Definition at line 125 of file AMDGPUHWEvents.h.

References ALL, and HWEvents().

◆ size()

unsigned llvm::AMDGPU::HWEvents::size ( ) const
inlineconstexpr

Definition at line 97 of file AMDGPUHWEvents.h.

References llvm::popcount().

◆ value()

value_type llvm::AMDGPU::HWEvents::value ( ) const
inlineconstexpr

The documentation for this class was generated from the following files: