[llvm] [Offload] Define `_NUM_VARIANTS` macros for generated enumerations (PR #147314)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 08:03:36 PDT 2025
RossBrunton wrote:
Example output (in OffloadAPI.h.gen):
```c
///////////////////////////////////////////////////////////////////////////////
/// @brief Supported device info.
typedef enum ol_device_info_t {
/// [ol_device_type_t] type of the device
OL_DEVICE_INFO_TYPE = 0,
/// [ol_platform_handle_t] the platform associated with the device
OL_DEVICE_INFO_PLATFORM = 1,
/// [char[]] Device name
OL_DEVICE_INFO_NAME = 2,
/// [char[]] Device vendor
OL_DEVICE_INFO_VENDOR = 3,
/// [char[]] Driver version
OL_DEVICE_INFO_DRIVER_VERSION = 4,
/// [ol_dimensions_t] Maximum work group size in each dimension
OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 5,
/// @cond
OL_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
} ol_device_info_t;
/// @brief Number of variants for the OL_DEVICE_INFO enumeration
#define OL_DEVICE_INFO_NUM_VARIANTS 6
```
Just a macro to allow us to check whether an enum is in range or not. Wasn't sure if having it be a "real" enum value (i.e. defined inside the `typedef enum`) is preferred or not.
https://github.com/llvm/llvm-project/pull/147314
More information about the llvm-commits
mailing list