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
 

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 print_code (RTX_CODE code, FILE *file)
 
static void gen_rtx_scratch (rtx x, enum rtx_code subroutine_type, FILE *file)
 
static void gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info, FILE *file)
 
static void gen_emit_seq (rtvec vec, char *used, md_rtx_info *info, FILE *file)
 
static void emit_c_code (const char *code, bool can_fail_p, const char *name, FILE *file)
 
static void gen_insn (md_rtx_info *info, FILE *file)
 
static void gen_expand (md_rtx_info *info, FILE *file)
 
static void gen_split (md_rtx_info *info, FILE *file)
 
static void output_add_clobbers (md_rtx_info *info, 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]
 
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:56

◆ 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()

static 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 md_reader::print_md_ptr_loc(), and rtx_reader_ptr.

Referenced by gen_expand(), and gen_split().

◆ gen_emit_seq()

static void gen_emit_seq ( rtvec vec,
char * used,
md_rtx_info * info,
FILE * file )
static
Output code to emit the instruction patterns in VEC, with each element
becoming a separate instruction.  USED is as for gen_exp.   

References gen_exp(), get_emit_function(), GET_NUM_ELEM, i, needs_barrier_p(), clobber_ent::next, and RTVEC_ELT.

Referenced by gen_expand(), and gen_split().

◆ gen_exp()

static void gen_exp ( rtx x,
enum rtx_code subroutine_type,
char * used,
md_rtx_info * info,
FILE * file )
static

◆ gen_expand()

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

◆ gen_insn()

◆ gen_rtx_scratch()

static void gen_rtx_scratch ( rtx x,
enum rtx_code subroutine_type,
FILE * file )
static

References GET_MODE, GET_MODE_NAME, and XINT.

Referenced by gen_exp().

◆ gen_split()

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

◆ handle_arg()

static bool handle_arg ( const char * arg)
static

References fopen, and output_files.

Referenced by main().

◆ handle_overloaded_code_for()

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

◆ handle_overloaded_gen()

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

◆ main()

int main ( int argc,
const char ** argv )
Internal functions.
   Copyright (C) 2011-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
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, md_reader::get_overloads(), handle_arg(), handle_overloaded_code_for(), handle_overloaded_gen(), init_rtx_reader_args_cb(), file_location::lineno, md_rtx_info::loc, overloaded_name::next, NULL, output_add_clobbers(), output_added_clobbers_hard_reg_p(), output_files, print_header(), progname, read_md_rtx(), rtx_reader_ptr, and SUCCESS_EXIT_CODE.

◆ output_add_clobbers()

static void output_add_clobbers ( md_rtx_info * info,
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_pat::code, clobber_ent::code_number, clobber_pat::first_clobber, gen_exp(), GET_NUM_ELEM, i, clobber_pat::insns, clobber_ent::next, clobber_pat::next, NULL, clobber_pat::pattern, and RTVEC_ELT.

Referenced by main().

◆ output_added_clobbers_hard_reg_p()

static 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()

static 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_code()

static void print_code ( RTX_CODE code,
FILE * file )
static

References GET_RTX_NAME.

Referenced by gen_exp().

◆ print_header()

void print_header ( FILE * file)

◆ print_overload_arguments()

static 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()

static 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().

Variable Documentation

◆ clobber_list

◆ 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(), and main().