GCC Middle and Back End API Reference
multiple_target.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "stringpool.h"
#include "gimple.h"
#include "diagnostic-core.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-pass.h"
#include "target.h"
#include "attribs.h"
#include "pretty-print.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
#include "tree-inline.h"
#include "intl.h"
Include dependency graph for multiple_target.cc:


static tree replace_function_decl (tree *op, int *walk_subtrees, void *data)
static void create_dispatcher_calls (struct cgraph_node *node)
static int get_attr_str (tree arglist, char *attr_str)
static int separate_attrs (char *attr_str, char **attrs, int attrnum)
static bool is_valid_asm_symbol (char c)
static void create_new_asm_name (char *old_asm_name, char *new_asm_name)
static cgraph_nodecreate_target_clone (cgraph_node *node, bool definition, char *name, tree attributes)
static bool expand_target_clones (struct cgraph_node *node, bool definition)
static void redirect_to_specific_clone (cgraph_node *node)
static unsigned int ipa_target_clone (void)
simple_ipa_opt_passmake_pass_target_clone (gcc::context *ctxt)

Function Documentation

◆ create_dispatcher_calls()

◆ create_new_asm_name()

static void create_new_asm_name ( char * old_asm_name,
char * new_asm_name )
Replace all not valid assembler symbols with '_'.   

References ggc_alloc(), i, and is_valid_asm_symbol().

Referenced by expand_target_clones().

◆ create_target_clone()

◆ expand_target_clones()

◆ get_attr_str()

static int get_attr_str ( tree arglist,
char * attr_str )
Create string with attributes separated by comma.
Return number of attributes.   

References ggc_alloc(), TREE_CHAIN, TREE_STRING_POINTER, and TREE_VALUE.

Referenced by expand_target_clones().

◆ ipa_target_clone()

◆ is_valid_asm_symbol()

static bool is_valid_asm_symbol ( char c)
Return true if symbol is valid in assembler name.   

Referenced by create_new_asm_name().

◆ make_pass_target_clone()

simple_ipa_opt_pass * make_pass_target_clone ( gcc::context * ctxt)

References ggc_alloc().

◆ redirect_to_specific_clone()

static void redirect_to_specific_clone ( cgraph_node * node)
When NODE is a target clone, consider all callees and redirect
to a clone with equal target attributes.  That prevents multiple
multi-versioning dispatches and a call-chain can be optimized.   

References attribute_value_equal(), cgraph_node::callees, symtab_node::decl, DECL_ATTRIBUTES, cgraph_node::function_version(), ggc_alloc(), lookup_attribute(), NULL, NULL_TREE, and cgraph_edge::redirect_call_stmt_to_callee().

Referenced by ipa_target_clone().

◆ replace_function_decl()

static tree replace_function_decl ( tree * op,
int * walk_subtrees,
void * data )
Pass for parsing functions with multiple target attributes.

   Contributed by Evgeny Stupachenko <evstupac@gmail.com>

   Copyright (C) 2015-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
Walker callback that replaces all FUNCTION_DECL of a function that's
going to be versioned.   

References ggc_alloc(), walk_stmt_info::info, NULL, and TREE_CODE.

Referenced by create_dispatcher_calls().

◆ separate_attrs()

static int separate_attrs ( char * attr_str,
char ** attrs,
int attrnum )
Return number of attributes separated by comma and put them into ARGS.
If there is no DEFAULT attribute return -1.
If there is an empty string in attribute return -2.
If there are multiple DEFAULT attributes return -3.

References ggc_alloc(), i, and NULL.

Referenced by expand_target_clones().