xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/doc/portability.texi (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1*8feb0f0bSmrg@c Copyright (C) 1988-2020 Free Software Foundation, Inc.
21debfc3dSmrg@c This is part of the GCC manual.
31debfc3dSmrg@c For copying conditions, see the file gcc.texi.
41debfc3dSmrg
51debfc3dSmrg@node Portability
61debfc3dSmrg@chapter GCC and Portability
71debfc3dSmrg@cindex portability
81debfc3dSmrg@cindex GCC and portability
91debfc3dSmrg
101debfc3dSmrgGCC itself aims to be portable to any machine where @code{int} is at least
111debfc3dSmrga 32-bit type.  It aims to target machines with a flat (non-segmented) byte
121debfc3dSmrgaddressed data address space (the code address space can be separate).
131debfc3dSmrgTarget ABIs may have 8, 16, 32 or 64-bit @code{int} type.  @code{char}
141debfc3dSmrgcan be wider than 8 bits.
151debfc3dSmrg
161debfc3dSmrgGCC gets most of the information about the target machine from a machine
171debfc3dSmrgdescription which gives an algebraic formula for each of the machine's
181debfc3dSmrginstructions.  This is a very clean way to describe the target.  But when
191debfc3dSmrgthe compiler needs information that is difficult to express in this
201debfc3dSmrgfashion, ad-hoc parameters have been defined for machine descriptions.
211debfc3dSmrgThe purpose of portability is to reduce the total work needed on the
221debfc3dSmrgcompiler; it was not of interest for its own sake.
231debfc3dSmrg
241debfc3dSmrg@cindex endianness
251debfc3dSmrg@cindex autoincrement addressing, availability
261debfc3dSmrg@findex abort
271debfc3dSmrgGCC does not contain machine dependent code, but it does contain code
281debfc3dSmrgthat depends on machine parameters such as endianness (whether the most
291debfc3dSmrgsignificant byte has the highest or lowest address of the bytes in a word)
301debfc3dSmrgand the availability of autoincrement addressing.  In the RTL-generation
311debfc3dSmrgpass, it is often necessary to have multiple strategies for generating code
321debfc3dSmrgfor a particular kind of syntax tree, strategies that are usable for different
331debfc3dSmrgcombinations of parameters.  Often, not all possible cases have been
341debfc3dSmrgaddressed, but only the common ones or only the ones that have been
351debfc3dSmrgencountered.  As a result, a new target may require additional
361debfc3dSmrgstrategies.  You will know
371debfc3dSmrgif this happens because the compiler will call @code{abort}.  Fortunately,
381debfc3dSmrgthe new strategies can be added in a machine-independent fashion, and will
391debfc3dSmrgaffect only the target machines that need them.
40