[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:72c30ab3917cc6f6007e034cd7a9cb015a74448c
commit 72c30ab3917cc6f6007e034cd7a9cb015a74448c
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:a5141fcd065eb6ff5a3730ae7c53637ad5187acd
commit a5141fcd065eb6ff5a3730ae7c53637ad5187acd
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:618045fad030ab43c24c684aea97759fda1c9572
commit 618045fad030ab43c24c684aea97759fda1c9572
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:03a0b469c0e9140f33dd938d785b88eaa3899ecf
commit 03a0b469c0e9140f33dd938d785b88eaa3899ecf
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:e06d6381b9afb309b157dc50a41043a7e59a52a8
commit e06d6381b9afb309b157dc50a41043a7e59a52a8
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:6791d38ad0ddc995fa5fd88768ee81daf3774709
commit 6791d38ad0ddc995fa5fd88768ee81daf3774709
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:18a6b92e8b5ad16fb1de1331257b1740f9e0508c
commit 18a6b92e8b5ad16fb1de1331257b1740f9e0508c
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:08ab8be065a4dd504f2521c3e574fcb80631cf0e
commit 08ab8be065a4dd504f2521c3e574fcb80631cf0e
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:eac0419575528a9a79387d0563d722cd47f02b63
commit eac0419575528a9a79387d0563d722cd47f02b63
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:13c9dc3fe21b08336f03542afa048c58267ffa9d
commit 13c9dc3fe21b08336f03542afa048c58267ffa9d
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Introduce riscv_ext_info_t to hold extension metadata
https://gcc.gnu.org/g:1c2a37393d26b08c0d89d7b89bc31253197417d4
commit 1c2a37393d26b08c0d89d7b89bc31253197417d4
Author: Kito Cheng
Date: Wed May 7 20:59:15 2025 +0800
RISC-V: Introduce riscv_ext_info_t to hold extension metadata
Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags)
generated
from riscv-ext.def.
Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that
not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.
(cherry picked from commit 312c407aac772f3535ff952ebc5ebff1057a593c)
Diff:
---
gcc/common/config/riscv/riscv-common.cc | 191 +---
gcc/config/riscv/riscv-opts.h | 8 ++
2 files changed, 185 insertions(+), 14 deletions(-)
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index ff34a315caf6..5430da76d11c 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include
#include
+#include
#include
#define INCLUDE_STRING
@@ -41,11 +42,62 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_ENDIAN)
#endif
+/* Type for pointer to member of gcc_options and cl_target_option. */
+typedef int (gcc_options::*opt_var_ref_t);
+typedef int (cl_target_option::*cl_opt_var_ref_t);
+
+/* Types for recording extension to internal flag. */
+struct riscv_ext_flag_table_t
+{
+ riscv_ext_flag_table_t (const char *ext, opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (ext), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+ riscv_ext_flag_table_t (opt_var_ref_t var_ref,
+ cl_opt_var_ref_t cl_var_ref, int mask)
+ : ext (nullptr), var_ref (var_ref), cl_var_ref (cl_var_ref), mask (mask)
+ {}
+
+ const char *ext;
+ opt_var_ref_t var_ref;
+ cl_opt_var_ref_t cl_var_ref;
+ int mask;
+
+ void clean (gcc_options *opts) const { opts->*var_ref &= ~mask; }
+
+ void set (gcc_options *opts) const { opts->*var_ref |= mask; }
+
+ bool check (cl_target_option *opts) const
+ {
+return (opts->*cl_var_ref & mask);
+ }
+};
+
+/* Type for hold RISC-V extension version. */
+struct riscv_version_t
+{
+ riscv_version_t (int major_version, int minor_version,
+ enum riscv_isa_spec_class isa_spec_class
+ = ISA_SPEC_CLASS_NONE)
+: major_version (major_version), minor_version (minor_version),
+ isa_spec_class (isa_spec_class)
+ {}
+ int major_version;
+ int minor_version;
+ enum riscv_isa_spec_class isa_spec_class;
+};
+
typedef bool (*riscv_implied_predicator_t) (const riscv_subset_list *);
/* Type for implied ISA info. */
struct riscv_implied_info_t
{
+ constexpr riscv_implied_info_t (const char *implied_ext,
+ riscv_implied_predicator_t predicator
+ = nullptr)
+: ext (nullptr), implied_ext (implied_ext), predicator (predicator)
+ {}
+
constexpr riscv_implied_info_t (const char *ext, const char *implied_ext,
riscv_implied_predicator_t predicator
= nullptr)
@@ -53,7 +105,7 @@ struct riscv_implied_info_t
bool match (const riscv_subset_list *subset_list, const char *ext_name) const
{
-if (strcmp (ext_name, ext) != 0)
+if (ext_name && strcmp (ext_name, ext) != 0)
return false;
if (predicator && !predicator (subset_list))
@@ -73,6 +125,111 @@ struct riscv_implied_info_t
riscv_implied_predicator_t predicator;
};
+static void
+apply_extra_extension_flags (const char *ext,
+std::vector &flag_table);
+
+/* Class for hold the extension info. */
+class riscv_ext_info_t
+{
+public:
+ riscv_ext_info_t (const char *ext,
+ const std::vector &implied_exts,
+ const std::vector &supported_versions,
+ const std::vector &flag_table,
+ int bitmask_group_id, in
