diff options
Diffstat (limited to 'gcc/tree.cc')
-rw-r--r-- | gcc/tree.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/tree.cc b/gcc/tree.cc index 9bc6228..0f02924 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -15420,6 +15420,65 @@ get_target_clone_attr_len (tree arglist) return str_len_sum; } +/* Returns an auto_vec of string_slices containing the version strings from + ARGLIST. DEFAULT_COUNT is incremented for each default version found. */ + +auto_vec<string_slice> +get_clone_attr_versions (const tree arglist, int *default_count) +{ + gcc_assert (TREE_CODE (arglist) == TREE_LIST); + auto_vec<string_slice> versions; + + static const char separator_str[] = {TARGET_CLONES_ATTR_SEPARATOR, 0}; + string_slice separators = string_slice (separator_str); + + for (tree arg = arglist; arg; arg = TREE_CHAIN (arg)) + { + string_slice str = string_slice (TREE_STRING_POINTER (TREE_VALUE (arg))); + while (str.is_valid ()) + { + string_slice attr = string_slice::tokenize (&str, separators); + attr = attr.strip (); + + if (attr == "default" && default_count) + (*default_count)++; + versions.safe_push (attr); + } + } + return versions; +} + +/* Returns an auto_vec of string_slices containing the version strings from + the target_clone attribute from DECL. DEFAULT_COUNT is incremented for each + default version found. */ +auto_vec<string_slice> +get_clone_versions (const tree decl, int *default_count) +{ + tree attr = lookup_attribute ("target_clones", DECL_ATTRIBUTES (decl)); + if (!attr) + return auto_vec<string_slice> (); + tree arglist = TREE_VALUE (attr); + return get_clone_attr_versions (arglist, default_count); +} + +/* If DECL has a target_version attribute, returns a string_slice containing the + attribute value. Otherwise, returns string_slice::invalid. + Only works for target_version due to target attributes allowing multiple + string arguments to specify one target. */ +string_slice +get_target_version (const tree decl) +{ + gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE); + + tree attr = lookup_attribute ("target_version", DECL_ATTRIBUTES (decl)); + + if (!attr) + return string_slice::invalid (); + + return string_slice (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))) + .strip (); +} + void tree_cc_finalize (void) { |