[llvm] [Offload] Define `_NUM_VARIANTS` macros for generated enumerations (PR #147314)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 04:25:16 PDT 2025


================
@@ -151,6 +151,12 @@ static void ProcessEnum(const EnumRec &Enum, raw_ostream &OS) {
                 Enum.getEnumValNamePrefix());
 
   OS << formatv("} {0};\n", Enum.getName());
+
+  // Add field for the number of variants
+  OS << formatv(TAB_1
----------------
jhuber6 wrote:

Well it depends what we're using it for. If the enumerator is meant to be an exhaustive list from 0 to whatever then `ENUM_LAST` is the way to go (Because it auto-updates). If it's spread apart like `FOO = 500, BAR = 600` then not.

https://github.com/llvm/llvm-project/pull/147314


More information about the llvm-commits mailing list