GCC Middle and Back End API Reference
genemit.cc File Reference
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "errors.h"
#include "read-md.h"
#include "gensupport.h"
#include "internal-fn.def"
Include dependency graph for genemit.cc:

Data Structures

struct  clobber_pat
struct  clobber_ent
struct  generator

Macros

#define DEF_INTERNAL_OPTAB_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_FN(CODE, FLAGS, FNSPEC)
#define DEF_INTERNAL_SIGNED_OPTAB_FN(NAME, FLAGS, SELECTOR, SIGNED_OPTAB, UNSIGNED_OPTAB, TYPE)
#define DEF_INTERNAL_FLT_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_FLT_FLOATN_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_INT_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_INT_EXT_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_WIDENING_OPTAB_FN(NAME, FLAGS, SELECTOR, SOPTAB, UOPTAB, TYPE)
#define DEF_INTERNAL_COND_FN(NAME, FLAGS, OPTAB, TYPE)
#define DEF_INTERNAL_SIGNED_COND_FN(NAME, FLAGS, SELECTOR, SIGNED_OPTAB, UNSIGNED_OPTAB, TYPE)

Functions

static void output_peephole2_scratches (rtx, FILE *)
static void emit_c_code (const char *code, bool can_fail_p, const char *name, FILE *file)
static void maybe_queue_insn (const md_rtx_info &info)
static const char * start_gen_insn (FILE *file, const char *name, const pattern_stats &stats)
static void gen_insn (const md_rtx_info &info, FILE *file)
static void queue_expand (const md_rtx_info &info)
static void gen_expand (const md_rtx_info &info, FILE *file)
static void queue_split (const md_rtx_info &info)
static void gen_split (const md_rtx_info &info, FILE *file)
static void output_add_clobbers (FILE *file)
static void output_added_clobbers_hard_reg_p (FILE *file)
static void print_overload_arguments (overloaded_name *oname, FILE *file)
static void print_overload_test (overloaded_instance *instance, FILE *file)
static void handle_overloaded_code_for (overloaded_name *oname, FILE *file)
static void handle_overloaded_gen (overloaded_name *oname, FILE *file)
void print_header (FILE *file)
static bool handle_arg (const char *arg)
int main (int argc, const char **argv)

Variables

struct clobber_patclobber_list
static bool nofail_optabs [NUM_OPTABS]
static vec< md_rtx_infoqueue
unsigned FIRST_CODE = (unsigned) expand_opcode::FIRST_CODE
auto_vec< FILE *, 10 > output_files

Macro Definition Documentation

◆ DEF_INTERNAL_COND_FN

#define DEF_INTERNAL_COND_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
DEF_INTERNAL_OPTAB_FN (COND_##NAME, FLAGS, cond_##OPTAB, cond_##TYPE) \
DEF_INTERNAL_OPTAB_FN (COND_LEN_##NAME, FLAGS, cond_len_##OPTAB, \
cond_len_##TYPE)

◆ DEF_INTERNAL_FLT_FLOATN_FN

#define DEF_INTERNAL_FLT_FLOATN_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE)

◆ DEF_INTERNAL_FLT_FN

#define DEF_INTERNAL_FLT_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
DEF_INTERNAL_OPTAB_FN (NAME, FLAGS, OPTAB, TYPE)

◆ DEF_INTERNAL_FN

#define DEF_INTERNAL_FN ( CODE,
FLAGS,
FNSPEC )

◆ DEF_INTERNAL_INT_EXT_FN

#define DEF_INTERNAL_INT_EXT_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
DEF_INTERNAL_INT_FN (NAME, FLAGS, OPTAB, TYPE)

◆ DEF_INTERNAL_INT_FN

#define DEF_INTERNAL_INT_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
DEF_INTERNAL_OPTAB_FN (NAME, FLAGS, OPTAB, TYPE)

◆ DEF_INTERNAL_OPTAB_FN

#define DEF_INTERNAL_OPTAB_FN ( NAME,
FLAGS,
OPTAB,
TYPE )
Value:
nofail_optabs[OPTAB##_optab] = true;
static bool nofail_optabs[NUM_OPTABS]
Definition genemit.cc:55

◆ DEF_INTERNAL_SIGNED_COND_FN

#define DEF_INTERNAL_SIGNED_COND_FN ( NAME,
FLAGS,
SELECTOR,
SIGNED_OPTAB,
UNSIGNED_OPTAB,
TYPE )
Value:
DEF_INTERNAL_SIGNED_OPTAB_FN (COND_##NAME, FLAGS, SELECTOR, \
cond_##SIGNED_OPTAB, cond_##UNSIGNED_OPTAB, \
cond_##TYPE) \
DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_##NAME, FLAGS, SELECTOR, \
cond_len_##SIGNED_OPTAB, \
cond_len_##UNSIGNED_OPTAB, cond_len_##TYPE)

◆ DEF_INTERNAL_SIGNED_OPTAB_FN

#define DEF_INTERNAL_SIGNED_OPTAB_FN ( NAME,
FLAGS,
SELECTOR,
SIGNED_OPTAB,
UNSIGNED_OPTAB,
TYPE )
Value:
DEF_INTERNAL_FN (NAME, FLAGS | ECF_LEAF, NULL)

◆ DEF_INTERNAL_WIDENING_OPTAB_FN

#define DEF_INTERNAL_WIDENING_OPTAB_FN ( NAME,
FLAGS,
SELECTOR,
SOPTAB,
UOPTAB,
TYPE )
Value:
DEF_INTERNAL_SIGNED_OPTAB_FN (NAME, FLAGS, SELECTOR, SOPTAB, UOPTAB, TYPE) \
DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _LO, FLAGS, SELECTOR, SOPTAB##_lo, UOPTAB##_lo, TYPE) \
DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _HI, FLAGS, SELECTOR, SOPTAB##_hi, UOPTAB##_hi, TYPE) \
DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _EVEN, FLAGS, SELECTOR, SOPTAB##_even, UOPTAB##_even, TYPE) \
DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _ODD, FLAGS, SELECTOR, SOPTAB##_odd, UOPTAB##_odd, TYPE)

Function Documentation

◆ emit_c_code()

void emit_c_code ( const char * code,
bool can_fail_p,
const char * name,
FILE * file )
static
Emit the given C code to the output file. The code is allowed to fail if CAN_FAIL_P. NAME describes what we're generating, for use in error messages.

References rtx_reader_ptr.

Referenced by gen_expand(), and gen_split().

◆ gen_expand()

void gen_expand ( const md_rtx_info & info,
FILE * file )
static

◆ gen_insn()

void gen_insn ( const md_rtx_info & info,
FILE * file )
static
Generate the `gen_...' function for a DEFINE_INSN.

References add_implicit_parallel(), md_rtx_info::def, fatal_at(), generator::gen_exp(), get_pattern_stats(), md_rtx_info::loc, start_gen_insn(), table, XSTR, and XVEC.

Referenced by main().

◆ gen_split()

void gen_split ( const md_rtx_info & info,
FILE * file )
static

◆ handle_arg()

bool handle_arg ( const char * arg)
static

References fopen, and output_files.

◆ handle_overloaded_code_for()

void handle_overloaded_code_for ( overloaded_name * oname,
FILE * file )
static

◆ handle_overloaded_gen()

void handle_overloaded_gen ( overloaded_name * oname,
FILE * file )
static

◆ main()

int main ( int argc,
const char ** argv )
Internal functions. Copyright (C) 2011-2025 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 version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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 <http://www.gnu.org/licenses/>.
This file specifies a list of internal "functions". These functions differ from built-in functions in that they have no linkage and cannot be called directly by the user. They represent operations that are only synthesised by GCC itself. Internal functions are used instead of tree codes if the operation and its operands are more naturally represented as a GIMPLE_CALL than a GIMPLE_ASSIGN. Each entry in this file has one of the forms: DEF_INTERNAL_FN (NAME, FLAGS, FNSPEC) DEF_INTERNAL_OPTAB_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_SIGNED_OPTAB_FN (NAME, FLAGS, SELECTOR, SIGNED_OPTAB, UNSIGNED_OPTAB, TYPE) DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_FLT_FLOATN_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_INT_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_INT_EXT_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_COND_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_SIGNED_COND_FN (NAME, FLAGS, OPTAB, TYPE) DEF_INTERNAL_WIDENING_OPTAB_FN (NAME, FLAGS, SELECTOR, SOPTAB, UOPTAB, TYPE) where NAME is the name of the function, FLAGS is a set of ECF_* flags and FNSPEC is a string describing functions fnspec. DEF_INTERNAL_OPTAB_FN defines an internal function that maps to a direct optab. The function should only be called with a given set of types if the associated optab is available for the modes of those types. OPTAB says what optab to use (without the trailing "_optab") and TYPE categorizes the optab based on its inputs and outputs. The possible types of optab are: - mask_load: currently just maskload - load_lanes: currently just vec_load_lanes - mask_load_lanes: currently just vec_mask_load_lanes - mask_len_load_lanes: currently just vec_mask_len_load_lanes - gather_load: used for {mask_,mask_len_,}gather_load - strided_load: currently just mask_len_strided_load - len_load: currently just len_load - mask_len_load: currently just mask_len_load - mask_store: currently just maskstore - store_lanes: currently just vec_store_lanes - mask_store_lanes: currently just vec_mask_store_lanes - mask_len_store_lanes: currently just vec_mask_len_store_lanes - scatter_store: used for {mask_,mask_len_,}scatter_store - strided_store: currently just mask_len_strided_store - len_store: currently just len_store - mask_len_store: currently just mask_len_store - unary: a normal unary optab, such as vec_reverse_<mode> - binary: a normal binary optab, such as vec_interleave_lo_<mode> - ternary: a normal ternary optab, such as fma<mode>4 - unary_convert: a single-input conversion optab, such as lround<srcmode><dstmode>2. - cond_binary: a conditional binary optab, such as cond_add<mode> - cond_unary: a conditional unary optab, such as cond_neg<mode> - cond_ternary: a conditional ternary optab, such as cond_fma_rev<mode> - fold_left: for scalar = FN (scalar, vector), keyed off the vector mode - check_ptrs: used for check_{raw,war}_ptrs - cond_len_unary: a conditional unary optab, such as cond_len_neg<mode> - cond_len_binary: a conditional binary optab, such as cond_len_add<mode> - cond_len_ternary: a conditional ternary optab, such as cond_len_fma_rev<mode> DEF_INTERNAL_SIGNED_OPTAB_FN defines an internal function that maps to one of two optabs, depending on the signedness of an input. SIGNED_OPTAB and UNSIGNED_OPTAB are the optabs for signed and unsigned inputs respectively, both without the trailing "_optab". SELECTOR says which type in the tree_pair determines the signedness. DEF_INTERNAL_FLT_FN is like DEF_INTERNAL_OPTAB_FN, but in addition, the function implements the computational part of a built-in math function BUILT_IN_<NAME>{F,,L}. Unlike some built-in functions, these internal functions never set errno. DEF_INTERNAL_INT_FN is like DEF_INTERNAL_OPTAB_FN, but in addition says that the function extends the C-level BUILT_IN_<NAME>{,L,LL,IMAX} group of functions to any integral mode (including vector modes). DEF_INTERNAL_INT_EXT_FN is like DEF_INTERNAL_INT_FN, except that it has expand_##NAME defined in internal-fn.cc to override the DEF_INTERNAL_INT_FN expansion behavior. DEF_INTERNAL_WIDENING_OPTAB_FN is a wrapper that defines five internal functions with DEF_INTERNAL_SIGNED_OPTAB_FN: - one that describes a widening operation with the same number of elements in the output and input vectors, - two that describe a pair of high-low widening operations where the output vectors each have half the number of elements of the input vectors, corresponding to the result of the widening operation on the top half and bottom half, these have the suffixes _HI and _LO, - and two that describe a pair of even-odd widening operations where the output vectors each have half the number of elements of the input vectors, corresponding to the result of the widening operation on the even and odd elements, these have the suffixes _EVEN and _ODD. These five internal functions will require two optabs each, a SIGNED_OPTAB and an UNSIGNED_OTPAB. DEF_INTERNAL_COND_FN is a wrapper that defines 2 internal functions with DEF_INTERNAL_OPTAB_FN: - One is COND_* operations that are predicated by mask only. Such operations make sense for both vectors and scalars. - The other is COND_LEN_* operations that are predicated by mask and len both. Such operations only make sense for vectors. DEF_INTERNAL_SIGNED_COND_FN is like DEF_INTERNAL_COND_FN but defines intenal functions with DEF_INTERNAL_SIGNED_OPTAB_FN. Each entry must have a corresponding expander of the form: void expand_NAME (gimple_call stmt) where STMT is the statement that performs the call. These are generated automatically for optab functions and call out to a function or macro called expand_<TYPE>_optab_fn.
Extract the last active element from a vector.
Same, but return the first argument if no elements are active.
Unary math functions.
Floating-point to integer conversions. ??? Here we preserve the I/L/LL prefix convention from the corresponding built-in functions, rather than make the internal functions polymorphic in both the argument and the return types. Perhaps an alternative would be to pass a zero of the required return type as a second parameter.
FP rounding.
Binary math functions.
FP scales.
Ternary math functions.
Unary integer ops.
An unduplicable, uncombinable function. Generally used to preserve a CFG property in the face of jump threading, tail merging or other such optimizations. The first argument distinguishes between uses. See internal-fn.h for usage.
A function to represent an artifical initialization to an uninitialized automatic variable.
A function to associate the access size and access mode information with the corresponding reference to an object. It only reads from the 2nd argument.
DIM_SIZE and DIM_POS return the size of a particular compute dimension and the executing thread's position within that dimension. DIM_POS is pure (and not const) so that it isn't thought to clobber memory and can be gcse'd within a single parallel region, but not across FORK/JOIN boundaries. They take a single INTEGER_CST argument. This might be overly conservative.
OpenACC looping abstraction. See internal-fn.h for usage.
OpenACC reduction abstraction. See internal-fn.h for usage.
Openacc tile abstraction. Describes the spans of the element loop. GOACC_TILE (num-loops, loop-no, tile-arg, tile-mask, element-mask).
Set errno to EDOM, if GCC knows how to do that directly for the current target.
Atomic functions. These don't have ECF_NOTHROW because for -fnon-call-exceptions they can throw, otherwise we set gimple_call_nothrow_p on it.
To implement [[fallthrough]]. If the TREE_NOTHROW or GF_CALL_NOTHROW flag is set on the call (normally redundant with ECF_NOTHROW), it marks [[fallthrough]] at the end of C++ loop body.
To implement __builtin_launder.
Divmod function.
For coroutines.
A NOP function with arbitrary arguments and return value.
Temporary vehicle for __builtin_shufflevector.
<=> optimization.
[[assume (cond)]].
For if-conversion of inbranch SIMD clones.
_BitInt support.
Bitwise functions.

References choose_output(), md_rtx_info::def, FATAL_EXIT_CODE, file_location::filename, gen_expand(), gen_insn(), gen_split(), GET_CODE, handle_arg(), handle_overloaded_code_for(), handle_overloaded_gen(), init_rtx_reader_args_cb(), file_location::lineno, md_rtx_info::loc, maybe_queue_insn(), NULL, output_add_clobbers(), output_added_clobbers_hard_reg_p(), output_files, print_header(), progname, queue, queue_expand(), queue_split(), read_md_rtx(), rtx_reader_ptr, and SUCCESS_EXIT_CODE.

◆ maybe_queue_insn()

void maybe_queue_insn ( const md_rtx_info & info)
static

◆ output_add_clobbers()

void output_add_clobbers ( FILE * file)
static
Write a function, `add_clobbers', that is given a PARALLEL of sufficient size for the insn and an INSN_CODE, and inserts the required CLOBBERs at the end of the vector.

References clobber_list, clobber_ent::code_number, clobber_pat::first_clobber, GET_MODE, GET_MODE_NAME, GET_NUM_ELEM, i, clobber_pat::insns, clobber_ent::next, clobber_pat::next, clobber_pat::pattern, REG_P, REGNO, RTVEC_ELT, and XEXP.

Referenced by main().

◆ output_added_clobbers_hard_reg_p()

void output_added_clobbers_hard_reg_p ( FILE * file)
static
Write a function, `added_clobbers_hard_reg_p' that is given an insn_code number that will have clobbers added (as indicated by `recog') and returns 1 if those include a clobber of a hard reg or 0 if all of them just clobber SCRATCH.

References clobber_list, clobber_ent::code_number, clobber_pat::has_hard_reg, clobber_pat::insns, clobber_ent::next, and clobber_pat::next.

Referenced by main().

◆ output_peephole2_scratches()

void output_peephole2_scratches ( rtx split,
FILE * file )
static
Generate code to invoke find_free_register () as needed for the scratch registers used by the peephole2 pattern in SPLIT.

References GET_CODE, GET_MODE, GET_MODE_NAME, i, XINT, XSTR, XVECEXP, and XVECLEN.

Referenced by gen_split().

◆ print_header()

void print_header ( FILE * file)

◆ print_overload_arguments()

void print_overload_arguments ( overloaded_name * oname,
FILE * file )
static
Print "arg<N>" parameter declarations for each argument N of ONAME.

References overloaded_name::arg_types, and i.

Referenced by handle_overloaded_code_for(), and handle_overloaded_gen().

◆ print_overload_test()

void print_overload_test ( overloaded_instance * instance,
FILE * file )
static
Print code to test whether INSTANCE should be chosen, given that argument N of the overload is available as "arg<N>".

References overloaded_instance::arg_values, and i.

Referenced by handle_overloaded_code_for().

◆ queue_expand()

void queue_expand ( const md_rtx_info & info)
static
Process and queue the DEFINE_EXPAND in INFO.

References md_rtx_info::def, fatal_at(), md_rtx_info::loc, queue, XSTR, and XVEC.

Referenced by main().

◆ queue_split()

void queue_split ( const md_rtx_info & info)
static
Process and queue the DEFINE_SPLIT or DEFINE_PEEPHOLE2 in INFO.

References md_rtx_info::def, fatal_at(), GET_CODE, GET_RTX_NAME, md_rtx_info::loc, queue, and XVEC.

Referenced by main().

◆ start_gen_insn()

const char * start_gen_insn ( FILE * file,
const char * name,
const pattern_stats & stats )
static
Output the function name, argument declarations, and initial function body for a pattern called NAME, given that it has the properties in STATS. Return the C++ expression for the operands array.

References i.

Referenced by gen_expand(), and gen_insn().

Variable Documentation

◆ clobber_list

◆ FIRST_CODE

unsigned FIRST_CODE = (unsigned) expand_opcode::FIRST_CODE

Referenced by generator::add_code().

◆ nofail_optabs

bool nofail_optabs[NUM_OPTABS]
static
True for <X>_optab if that optab isn't allowed to fail.

Referenced by gen_expand().

◆ output_files

auto_vec<FILE *, 10> output_files
The list of output files.

Referenced by handle_arg(), handle_arg(), and main().

◆ queue