This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RFD: inline hooks
- From: Joern Rennecke <amylaar at spamcop dot net>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 01 Dec 2010 20:53:31 -0500
- Subject: RFD: inline hooks
For the rtl passes, architecture target macros are not much of an issue
with regards to executable code modularity: since the rtl passes are
deeply interwoven with the insn-*.c files, we might as well compile one
specialized copy of the rtl passes for each target architecture.
Another argument against leaving the macros are their often ill-defined
interface types and the call-by-name semantics that make all the identifiers
in scope at the call site a potential interface.
We could avoid the latter problems without sacrificing the speed that we
get from target-specific code by replacing the target macro with an
inline hook. E.g. consider HARD_REGNO_MODE_OK. We could have $tm_file
define TARGET_HARD_REGNO_MODE_OK as a static inline function, or #define it
as the name of a static inline function somewhere else in $tm_file.
The function's address will be in TARGET_INITIALIZER, and thus type
checking on the function definition will be done.
But a file that includes tm.h will be able to use the function
TARGET_HARD_REGNO_MODE_OK directly, which can then be inlined, thus
giving type safety without performance penalty.