RFR: 8367103: RISC-V: store cpu features in a bitmap [v5]

Ludovic Henry luhenry at openjdk.org
Wed Sep 24 12:20:37 UTC 2025


On Wed, 24 Sep 2025 10:53:34 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Yes, it'll be good if we can just remove the explicit numbering of the enum, but seems there is no good way to pass in the enum value to the constructor of `NAME##RVExtFeatureValue` in `DEF_RV_EXT_FEATURE`. We could do it with an static member of RVExtFeatureValue, increment it in RVExtFeatureValue constructor, but seems it's not straight and clear.
>> So my preference is to keep the explicit enum value in `RV_EXT_FEATURE_FLAGS`.
>> How do you think about it?
>
> We also need this feature index when construct a `NAME##RVExtFeatureValue` instance in vm_version_riscv.cpp

Can't we define the constructor as (including the comment at https://github.com/openjdk/jdk/pull/27152/files#r2375581724):

  #define DECLARE_RV_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING, FLAGF)                   \
  struct NAME##RVExtFeatureValue : public RVExtFeatureValue {                                                  \
    NAME##RVExtFeatureValue() : \
      RVExtFeatureValue(#PRETTY, LINUX_BIT, CPU_#NAME, FSTRING) {}                                  \
    FLAGF;                                                                                                     \
  };                                                                                                           \
  static NAME##RVExtFeatureValue NAME;    

(note the use of `CPU_#NAME` in place of `CPU_FEATURE_INDEX`)

That way you use the enum's implicit value, and you don't need to have an explicit `CPU_FEATURE_INDEX`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27152#discussion_r2375592908


More information about the hotspot-dev mailing list