GCC Middle and Back End API Reference
gensupport.h File Reference
#include "hash-set.h"
#include "read-md.h"
#include "optabs.def"
Include dependency graph for gensupport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  md_rtx_info
struct  optab_def
struct  optab_pattern
struct  c_test
struct  pred_data
struct  pattern_stats
struct  generator_output

Macros

#define OPTAB_CL(name, pat, c, b, l)
#define OPTAB_CX(name, pat)
#define OPTAB_CD(name, pat)
#define OPTAB_NL(name, pat, c, b, s, l)
#define OPTAB_NC(name, pat, c)
#define OPTAB_NX(name, pat)
#define OPTAB_VL(name, pat, c, b, s, l)
#define OPTAB_VC(name, pat, c)
#define OPTAB_VX(name, pat)
#define OPTAB_DC(name, pat, c)
#define OPTAB_D(name, pat)
#define FOR_ALL_PREDICATES(p)

Typedefs

typedef enum optab_tag optab

Enumerations

enum  optab_tag { unknown_optab , NUM_OPTABS }

Functions

unsigned int get_register_filter_id (const char *)
rtx add_implicit_parallel (rtvec)
rtx_reader * init_rtx_reader_args_cb (int, const char **, bool(*)(const char *))
rtx_reader * init_rtx_reader_args (int, const char **)
int count_patterns ()
bool read_md_rtx (md_rtx_info *)
unsigned int get_num_insn_codes ()
const char * get_c_test (rtx)
int maybe_eval_c_test (const char *)
void add_c_test (const char *, int)
struct pred_data * lookup_predicate (const char *)
void add_predicate_code (struct pred_data *, enum rtx_code)
void add_predicate (struct pred_data *)
void get_pattern_stats (struct pattern_stats *ranges, rtvec vec)
void compute_test_codes (rtx, file_location, char *)
file_location get_file_location (rtx)
const char * get_emit_function (rtx)
bool find_optab (optab_pattern *, const char *)
unsigned int add_generator_output (vec< generator_output > &, const char *, bool)
void open_generator_outputs (vec< generator_output > &)
FILE * choose_output (const vec< generator_output > &)
bool close_generator_outputs (const vec< generator_output > &)

Variables

struct obstack * rtl_obstack
optab_def optabs []
unsigned int num_optabs
vec< const char * > register_filters
unsigned int num_dependent_filters
int insn_elision
struct pred_data * first_predicate
hash_set< rtx > compact_syntax

Macro Definition Documentation

◆ FOR_ALL_PREDICATES

#define FOR_ALL_PREDICATES ( p)
Value:
for (p = first_predicate; p; p = p->next)
struct pred_data * first_predicate
Definition gensupport.cc:3482
struct pred_data * next
Definition gensupport.h:178

Referenced by write_insn_preds_c(), and write_tm_preds_h().

◆ OPTAB_CD

#define OPTAB_CD ( name,
pat )
Value:
name,

◆ OPTAB_CL

#define OPTAB_CL ( name,
pat,
c,
b,
l )
Value:
name,

◆ OPTAB_CX

#define OPTAB_CX ( name,
pat )

◆ OPTAB_D

#define OPTAB_D ( name,
pat )
Value:
name,

◆ OPTAB_DC

#define OPTAB_DC ( name,
pat,
c )
Value:
name,

◆ OPTAB_NC

#define OPTAB_NC ( name,
pat,
c )
Value:
name,

◆ OPTAB_NL

#define OPTAB_NL ( name,
pat,
c,
b,
s,
l )
Value:
name,

◆ OPTAB_NX

#define OPTAB_NX ( name,
pat )

◆ OPTAB_VC

#define OPTAB_VC ( name,
pat,
c )
Value:
name,

◆ OPTAB_VL

#define OPTAB_VL ( name,
pat,
c,
b,
s,
l )
Value:
name,

◆ OPTAB_VX

#define OPTAB_VX ( name,
pat )

Typedef Documentation

◆ optab

typedef enum optab_tag optab
Enumerates all optabs.   

Enumeration Type Documentation

◆ optab_tag

enum optab_tag
Enumerates all optabs.   
Enumerator
unknown_optab 
NUM_OPTABS 
Definitions for operation tables, or "optabs".
   Copyright (C) 1987-2026 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/>.   
The entries in optabs.def are categorized:
  C: A "conversion" optab, which uses two modes; has libcall data.
  N: A "normal" optab, which uses one mode; has libcall data.
  D: A "direct" optab, which uses one mode; does not have libcall data.
  V: An "oVerflow" optab.  Like N, but does not record its code in
     code_to_optab.

  CX, NX, VX: An extra pattern entry for a conversion or normal optab.

These patterns may be present in the MD file with names that contain
the mode(s) used and the name of the operation.  This array contains
a list of optabs that need to be initialized.  Within each name,
$a and $b are used to match a short mode name (the part of the mode
name not including `mode' and converted to lower-case).

$I means that only full integer modes should be considered for the
next mode, and $F means that only float modes should be considered.
$P means that both full and partial integer modes should be considered.
$Q means that only fixed-point modes should be considered.

The pattern may be NULL if the optab exists only for the libcalls
that we plan to attach to it, and there are no named patterns in
the md files.
WARNING: do not have a pattern name have a `c` right before a possible scalar mode,
csi, cdi are valid modes (complex si/di) and the match is based on which pattern is done
first. For an example `andc$a3` and `and$a3` with `andcsi3` will match which one comes first
here.   
The extension libcalls are used for float extension.   
Conversions for fixed-point modes and other modes.   
Misc optabs that use two modes; model them as "conversions".   
Comparison libcalls for integers MUST come in pairs, signed/unsigned.   
EQ etc are floating point comparisons.   
These are all initialized individually, on a per-host basis.   
C99 implementations of fmax/fmin.   
Vector reduction to a scalar.   

Function Documentation

◆ add_c_test()

void add_c_test ( const char * expr,
int value )
extern
Add an entry to the table of conditions.  Used by genconditions and
by read-rtl.cc.   
Record the C test expression EXPR in the condition_table, with
value VAL.  Duplicates clobber previous entries.   

References add_c_test(), condition_table, c_test::expr, and c_test::value.

Referenced by add_c_test(), and main().

◆ add_generator_output()

unsigned int add_generator_output ( vec< generator_output > & outputs,
const char * name,
bool partition_p )
extern
Add output NAME to OUTPUTS.  A null NAME means standard output.
PARTITION_P is true if the output participates in size-based selection.
Return its index.   

References add_generator_output(), fatal(), gcc_assert, pred_data::name, and NULL.

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

◆ add_implicit_parallel()

rtx add_implicit_parallel ( rtvec vec)
extern
Return the rtx pattern specified by the list of rtxes in a
define_insn or define_split.   

References add_implicit_parallel(), GET_NUM_ELEM, RTVEC_ELT, rtx_alloc(), and XVEC.

Referenced by add_implicit_parallel(), gen_insn(), gen_rewrite_sequence(), main(), and process_one_cond_exec().

◆ add_predicate()

void add_predicate ( struct pred_data * pred)
extern

◆ add_predicate_code()

void add_predicate_code ( struct pred_data * pred,
enum rtx_code code )
extern

◆ choose_output()

FILE * choose_output ( const vec< generator_output > & outputs)
extern
Return the shortest partition file in OUTPUTS.   

References choose_output(), gcc_unreachable, and NULL.

Referenced by choose_output(), choose_output(), main(), main(), and print_subroutine_group().

◆ close_generator_outputs()

bool close_generator_outputs ( const vec< generator_output > & outputs)
extern
Close all files in OUTPUTS.  Return true if every close succeeds.   

References close_generator_outputs(), errno, and error().

Referenced by close_generator_outputs(), and main().

◆ compute_test_codes()

void compute_test_codes ( rtx exp,
file_location loc,
char * codes )
extern
Recursively calculate the set of rtx codes accepted by the
predicate expression EXP, writing the result to CODES.  LOC is
the .md file location of the directive containing EXP.   

References pred_data::codes, compute_test_codes(), did_you_mean_codes, error_at(), exp(), GET_CODE, GET_RTX_NAME, I, i, queue_elem::loc, lookup_predicate(), MATCH_OPERAND, message_at(), N, NUM_RTX_CODE, scan_comma_elt(), TRISTATE_AND, TRISTATE_NOT, TRISTATE_OR, XEXP, XSTR, and Y.

Referenced by add_constraint(), compute_test_codes(), and process_define_predicate().

◆ count_patterns()

int count_patterns ( )
extern
Count the number of patterns in all queues and return the count.   

References count_patterns(), queue_elem::data, define_attr_queue, define_insn_queue, define_pred_queue, get_c_test(), insn_elision, maybe_eval_c_test(), queue_elem::next, and other_queue.

Referenced by count_patterns().

◆ find_optab()

bool find_optab ( optab_pattern * p,
const char * name )
extern
Return true if NAME is the name of an optab, describing it in P if so.   

References find_optab(), optab_pattern::m1, optab_pattern::m2, match_pattern(), optab_pattern::name, pred_data::name, optab_def::op, optab_pattern::op, optabs, and optab_pattern::sort_num.

Referenced by find_optab(), gen_expand(), and gen_insn().

◆ get_c_test()

const char * get_c_test ( rtx x)
extern
Return the C test that says whether a definition rtx can be used,
or "" if it can be used unconditionally.   
Return the C test that says whether definition rtx DEF can be used,
or "" if it can be used unconditionally.   

References get_c_test(), GET_CODE, and XSTR.

Referenced by count_patterns(), gen_insn(), get_c_test(), main(), match_pattern_1(), read_md_rtx(), and validate_pattern().

◆ get_emit_function()

const char * get_emit_function ( rtx x)
extern
Return the emit_* function that should be used for pattern X, or NULL
if we can't pick a particular type at compile time and should instead
fall back to "emit".   

References classify_insn(), gcc_unreachable, get_emit_function(), and NULL.

Referenced by get_emit_function().

◆ get_file_location()

file_location get_file_location ( rtx x)
extern
Return the file location of DEFINE_* rtx X, which was previously
returned by read_md_rtx.   

References gcc_assert, get_file_location(), and rtx_locs.

Referenced by def_target_insn(), and get_file_location().

◆ get_num_insn_codes()

unsigned int get_num_insn_codes ( )
extern
Return the number of possible INSN_CODEs.  Only meaningful once the
whole file has been processed.   

References get_num_insn_codes(), and insn_sequence_num.

Referenced by get_num_insn_codes(), and main().

◆ get_pattern_stats()

void get_pattern_stats ( struct pattern_stats * stats,
rtvec pattern )
extern

◆ get_register_filter_id()

unsigned int get_register_filter_id ( const char * filter)
extern
Return the unique identifier for filter condition FILTER.  Identifiers
are assigned automatically when the define_register_constraint is
parsed.   

References gcc_assert, get_register_filter_id(), and register_filter_map.

Referenced by get_register_filter_id(), preprocess_constraints(), write_get_register_filter(), and write_get_register_filter_id().

◆ init_rtx_reader_args()

rtx_reader * init_rtx_reader_args ( int argc,
const char ** argv )
extern
Programs that don't have their own options can use this entry point
instead.   

References init_rtx_reader_args(), and init_rtx_reader_args_cb().

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

◆ init_rtx_reader_args_cb()

◆ lookup_predicate()

◆ maybe_eval_c_test()

int maybe_eval_c_test ( const char * expr)
extern
If the C test passed as the argument can be evaluated at compile
time, return its truth value; else return -1.  The test must have
appeared somewhere in the machine description when genconditions
was run.   
Given a string representing a C test expression, look it up in the
condition_table and report whether or not its value is known
at compile time.  Returns a tristate: 1 for known true, 0 for
known false, -1 for unknown.   

References condition_table, c_test::expr, maybe_eval_c_test(), and c_test::value.

Referenced by count_patterns(), def_target_insn(), gen_insn(), gen_insn(), gen_insn(), gen_proto(), match_pattern_1(), maybe_eval_c_test(), and read_md_rtx().

◆ open_generator_outputs()

void open_generator_outputs ( vec< generator_output > & outputs)
extern
Open each named file in OUTPUTS.   

References errno, fatal(), fopen, and open_generator_outputs().

Referenced by main(), and open_generator_outputs().

◆ read_md_rtx()

Variable Documentation

◆ compact_syntax

hash_set<rtx> compact_syntax
extern
List of entries which are part of the new syntax.   

Referenced by convert_syntax(), and gen_insn().

◆ first_predicate

struct pred_data* first_predicate
extern

◆ insn_elision

int insn_elision
extern
Set this to 0 to disable automatic elision of insn patterns which
can never be used in this configuration.  See genconditions.cc.
Must be set before calling init_md_reader.   

Referenced by count_patterns(), main(), and read_md_rtx().

◆ num_dependent_filters

unsigned int num_dependent_filters
extern

◆ num_optabs

unsigned int num_optabs
extern
The number of entries in optabs[].   

Referenced by main().

◆ optabs

optab_def optabs[]
extern
An array of all optabs.  Note that the same optab can appear more
than once, with a different pattern.   

Referenced by find_optab(), and main().

◆ register_filters

vec<const char *> register_filters
extern

◆ rtl_obstack