Richard Sandiford d63c889d5c genemit: Use a byte encoding to generate insns
genemit has traditionally used open-coded gen_rtx_FOO sequences
to build up the instruction pattern.  This is now the source of
quite a bit of bloat in the binary, and also a source of slow
compile times.

Two obvious ways of trying to deal with this are:

(1) Try to identify rtxes that have a similar form and use shared
    routines to generate rtxes of that form.

(2) Use a static table to encode the rtx and call a common routine
    to expand it.

I did briefly look at (1).  However, it's more complex than (2),
and I think suffers from being the worst of both worlds, for reasons
that I'll explain below.  This patch therefore does (2).

In theory, one of the advantages of open-coding the calls to
gen_rtx_FOO is that the rtx can be populated using stores of known
constants (for the rtx code, mode, unspec number, etc).  However,
the time spent constructing an rtx is likely to be dominated by
the call to rtx_alloc, rather than by the stores to the fields.

Option (1) above loses this advantage of storing constants.
The shared routines would parameterise an rtx according to things
like the modes on the rtx and its suboperands, so the code would
need to fetch the parameters.  In a sense, the rtx structure would
be open-coded but the parameters would be table-encoded (albeit
in a simple way).

The expansion code also shouldn't be particularly hot.  Anything that
treats expand/discard cycles as very cheap would be misconceived,
since each discarded expansion generates garbage memory that needs
to be cleaned up later.

Option (2) turns out to be pretty simple -- certainly simpler
than (1) -- and seems to give a reasonable saving.  Some numbers,
all for --enable-checking=yes,rtl,extra:

[A] size of the @progbits sections in insn-emit-*.o, new / old
[B] size of the load segments in cc1, new / old
[C] time to compile a typical insn-emit*.cc, new / old

Target                 [A]      [B]      [C]
--------------------------------------------
native aarch64      0.5627   0.9585   0.5677
native x86_64       0.5925   0.9467   0.6377
aarch64-x-riscv64   0.5555   0.9066   0.2762

To get an idea of the effect on the final compiler, I tried compiling
fold-const.ii with -O0 (no -g), since that should give any slowdown
less room to hide.  I couldn't measure any difference in compile time
before or after the patch for any of the three variants above.

gcc/
	* gensupport.h (needs_barrier_p): Delete.
	* gensupport.cc (needs_barrier_p): Likewise.
	* rtl.h (always_void_p): Return true for PC, RETURN and SIMPLE_RETURN.
	(expand_opcode): New enum class.
	(expand_rtx, complete_seq): Declare.
	* emit-rtl.cc (rtx_expander): New class.
	(expand_rtx, complete_seq): New functions.
	* gengenrtl.cc (special_rtx, excluded_rtx): Add a cross-reference
	comment.
	* genemit.cc (FIRST_CODE): New constant.
	(print_code): Delete.
	(generator::file, generator::used, generator::sequence_type): Delete.
	(generator::bytes): New member variable.
	(generator::generator): Update accordingly.
	(generator::gen_rtx_scratch): Delete.
	(generator::add_uint, generator::add_opcode, generator::add_code)
	(generator::add_match_operator, generator::add_exp)
	(generator::add_vec, generator::gen_table): New member functions.
	(generator::gen_exp): Rewrite to use a bytecode expansion.
	(generator::gen_emit_seq): Likewise.
	(start_gen_insn): Return the C++ expression for the operands array.
	(gen_insn, gen_expand, gen_split): Update callers accordingly.
	(emit_c_code): Remove use of _val.
2025-05-21 10:01:32 +01:00
2025-01-02 11:59:57 +01:00
2025-04-16 00:18:18 +00:00
2025-05-10 00:17:59 +00:00
2025-04-02 00:18:25 +00:00
2025-05-15 00:19:47 +00:00
2025-01-02 11:59:57 +01:00
2025-05-10 00:17:59 +00:00
2025-04-11 00:17:32 +00:00
2025-01-02 11:59:57 +01:00
2025-05-17 00:17:29 +00:00
2025-01-02 11:59:57 +01:00
2024-10-26 00:19:39 +00:00
2025-05-21 00:17:57 +00:00
2025-05-21 00:17:57 +00:00
2025-05-14 00:18:21 +00:00
2025-04-25 00:18:00 +00:00
2025-05-20 00:18:27 +00:00
2025-04-01 00:19:09 +00:00
2025-05-14 00:18:21 +00:00
2025-05-10 00:17:59 +00:00
2025-01-02 11:59:57 +01:00
2025-05-10 00:17:59 +00:00
2025-04-10 00:18:06 +00:00
2025-05-03 00:18:18 +00:00
2025-01-02 11:59:57 +01:00
2025-05-10 00:17:59 +00:00
2025-03-07 00:17:19 +00:00
2025-04-26 00:19:18 +00:00
2025-05-17 00:17:29 +00:00
2024-11-19 12:27:33 +01:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 1.5 GiB
Languages
C++ 30.7%
C 30%
Ada 14.5%
D 6.1%
Go 5.7%
Other 12.5%