diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-02-16 10:30:20 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-02-16 10:30:20 -0500 |
commit | cb3e0eac262e55774949b1717c64da383adbc621 (patch) | |
tree | a86ae96b5585e5f6d6c86bf152bc621ae76d632d /gcc/expmed.h | |
parent | a5de17d9120dde7e6598a05ea4d1556c2783c69b (diff) | |
download | gcc-cb3e0eac262e55774949b1717c64da383adbc621.zip gcc-cb3e0eac262e55774949b1717c64da383adbc621.tar.gz gcc-cb3e0eac262e55774949b1717c64da383adbc621.tar.bz2 |
don't declare header-defined functions both static and inline
Many functions defined in our headers are declared 'static inline' which
is a C idiom whose use predates our move to C++ as the implementation
language. But in C++ the inline keyword is more than just a compiler
hint, and is sufficient to give the function the intended semantics.
In fact declaring a function both static and inline is a pessimization
since static effectively disables the desired definition merging
behavior enabled by inline, and is also a source of (harmless) ODR
violations when a static inline function gets called from a non-static
inline one (such as tree_operand_check calling tree_operand_length).
This patch mechanically fixes the vast majority of occurrences of this
anti-pattern throughout the compiler's headers via the command line
sed -i 's/^static inline/inline/g' gcc/*.h gcc/*/*.h
There's also a manual change to remove the redundant declarations
of is_ivar and lookup_category in gcc/objc/objc-act.cc which would
otherwise conflict with their modified definitions in objc-act.h
(due to the difference in staticness).
Besides fixing some ODR violations, this speeds up stage1 cc1plus by
about 2% and reduces the size of its text segment by 1.5MB.
gcc/ChangeLog:
* addresses.h: Mechanically drop 'static' from 'static inline'
functions via s/^static inline/inline/g.
* asan.h: Likewise.
* attribs.h: Likewise.
* basic-block.h: Likewise.
* bitmap.h: Likewise.
* cfghooks.h: Likewise.
* cfgloop.h: Likewise.
* cgraph.h: Likewise.
* cselib.h: Likewise.
* data-streamer.h: Likewise.
* debug.h: Likewise.
* df.h: Likewise.
* diagnostic.h: Likewise.
* dominance.h: Likewise.
* dumpfile.h: Likewise.
* emit-rtl.h: Likewise.
* except.h: Likewise.
* expmed.h: Likewise.
* expr.h: Likewise.
* fixed-value.h: Likewise.
* gengtype.h: Likewise.
* gimple-expr.h: Likewise.
* gimple-iterator.h: Likewise.
* gimple-predict.h: Likewise.
* gimple-range-fold.h: Likewise.
* gimple-ssa.h: Likewise.
* gimple.h: Likewise.
* graphite.h: Likewise.
* hard-reg-set.h: Likewise.
* hash-map.h: Likewise.
* hash-set.h: Likewise.
* hash-table.h: Likewise.
* hwint.h: Likewise.
* input.h: Likewise.
* insn-addr.h: Likewise.
* internal-fn.h: Likewise.
* ipa-fnsummary.h: Likewise.
* ipa-icf-gimple.h: Likewise.
* ipa-inline.h: Likewise.
* ipa-modref.h: Likewise.
* ipa-prop.h: Likewise.
* ira-int.h: Likewise.
* ira.h: Likewise.
* lra-int.h: Likewise.
* lra.h: Likewise.
* lto-streamer.h: Likewise.
* memmodel.h: Likewise.
* omp-general.h: Likewise.
* optabs-query.h: Likewise.
* optabs.h: Likewise.
* plugin.h: Likewise.
* pretty-print.h: Likewise.
* range.h: Likewise.
* read-md.h: Likewise.
* recog.h: Likewise.
* regs.h: Likewise.
* rtl-iter.h: Likewise.
* rtl.h: Likewise.
* sbitmap.h: Likewise.
* sched-int.h: Likewise.
* sel-sched-ir.h: Likewise.
* sese.h: Likewise.
* sparseset.h: Likewise.
* ssa-iterators.h: Likewise.
* system.h: Likewise.
* target-globals.h: Likewise.
* target.h: Likewise.
* timevar.h: Likewise.
* tree-chrec.h: Likewise.
* tree-data-ref.h: Likewise.
* tree-iterator.h: Likewise.
* tree-outof-ssa.h: Likewise.
* tree-phinodes.h: Likewise.
* tree-scalar-evolution.h: Likewise.
* tree-sra.h: Likewise.
* tree-ssa-alias.h: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-manip.h: Likewise.
* tree-ssa-loop.h: Likewise.
* tree-ssa-operands.h: Likewise.
* tree-ssa-propagate.h: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa.h: Likewise.
* tree-ssanames.h: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.h: Likewise.
* tree-vectorizer.h: Likewise.
* tree.h: Likewise.
* wide-int.h: Likewise.
gcc/c-family/ChangeLog:
* c-common.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
gcc/c/ChangeLog:
* c-parser.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
gcc/cp/ChangeLog:
* cp-tree.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
gcc/fortran/ChangeLog:
* gfortran.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
gcc/jit/ChangeLog:
* jit-dejagnu.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
* jit-recording.h: Likewise.
gcc/objc/ChangeLog:
* objc-act.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
* objc-map.h: Likewise.
* objc-act.cc: Remove the redundant redeclarations of is_ivar
and lookup_category.
Diffstat (limited to 'gcc/expmed.h')
-rw-r--r-- | gcc/expmed.h | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/gcc/expmed.h b/gcc/expmed.h index 0419e2d..c1aee00 100644 --- a/gcc/expmed.h +++ b/gcc/expmed.h @@ -191,7 +191,7 @@ extern struct target_expmed *this_target_expmed; /* Return a pointer to the alg_hash_entry at IDX. */ -static inline struct alg_hash_entry * +inline struct alg_hash_entry * alg_hash_entry_ptr (int idx) { return &this_target_expmed->x_alg_hash[idx]; @@ -199,7 +199,7 @@ alg_hash_entry_ptr (int idx) /* Return true if the x_alg_hash field might have been used. */ -static inline bool +inline bool alg_hash_used_p (void) { return this_target_expmed->x_alg_hash_used_p; @@ -207,7 +207,7 @@ alg_hash_used_p (void) /* Set whether the x_alg_hash field might have been used. */ -static inline void +inline void set_alg_hash_used_p (bool usedp) { this_target_expmed->x_alg_hash_used_p = usedp; @@ -215,7 +215,7 @@ set_alg_hash_used_p (bool usedp) /* Compute an index into the cost arrays by mode class. */ -static inline int +inline int expmed_mode_index (machine_mode mode) { switch (GET_MODE_CLASS (mode)) @@ -244,7 +244,7 @@ expmed_mode_index (machine_mode mode) a particular operation performed in MODE is cheap when optimizing for SPEED. */ -static inline bool * +inline bool * expmed_op_cheap_ptr (struct expmed_op_cheap *eoc, bool speed, machine_mode mode) { @@ -255,7 +255,7 @@ expmed_op_cheap_ptr (struct expmed_op_cheap *eoc, bool speed, /* Return a pointer to a cost contained in COSTS when a particular operation is performed in MODE when optimizing for SPEED. */ -static inline int * +inline int * expmed_op_cost_ptr (struct expmed_op_costs *costs, bool speed, machine_mode mode) { @@ -265,7 +265,7 @@ expmed_op_cost_ptr (struct expmed_op_costs *costs, bool speed, /* Subroutine of {set_,}sdiv_pow2_cheap. Not to be used otherwise. */ -static inline bool * +inline bool * sdiv_pow2_cheap_ptr (bool speed, machine_mode mode) { return expmed_op_cheap_ptr (&this_target_expmed->x_sdiv_pow2_cheap, @@ -275,7 +275,7 @@ sdiv_pow2_cheap_ptr (bool speed, machine_mode mode) /* Set whether a signed division by a power of 2 is cheap in MODE when optimizing for SPEED. */ -static inline void +inline void set_sdiv_pow2_cheap (bool speed, machine_mode mode, bool cheap_p) { *sdiv_pow2_cheap_ptr (speed, mode) = cheap_p; @@ -284,7 +284,7 @@ set_sdiv_pow2_cheap (bool speed, machine_mode mode, bool cheap_p) /* Return whether a signed division by a power of 2 is cheap in MODE when optimizing for SPEED. */ -static inline bool +inline bool sdiv_pow2_cheap (bool speed, machine_mode mode) { return *sdiv_pow2_cheap_ptr (speed, mode); @@ -292,7 +292,7 @@ sdiv_pow2_cheap (bool speed, machine_mode mode) /* Subroutine of {set_,}smod_pow2_cheap. Not to be used otherwise. */ -static inline bool * +inline bool * smod_pow2_cheap_ptr (bool speed, machine_mode mode) { return expmed_op_cheap_ptr (&this_target_expmed->x_smod_pow2_cheap, @@ -302,7 +302,7 @@ smod_pow2_cheap_ptr (bool speed, machine_mode mode) /* Set whether a signed modulo by a power of 2 is CHEAP in MODE when optimizing for SPEED. */ -static inline void +inline void set_smod_pow2_cheap (bool speed, machine_mode mode, bool cheap) { *smod_pow2_cheap_ptr (speed, mode) = cheap; @@ -311,7 +311,7 @@ set_smod_pow2_cheap (bool speed, machine_mode mode, bool cheap) /* Return whether a signed modulo by a power of 2 is cheap in MODE when optimizing for SPEED. */ -static inline bool +inline bool smod_pow2_cheap (bool speed, machine_mode mode) { return *smod_pow2_cheap_ptr (speed, mode); @@ -319,7 +319,7 @@ smod_pow2_cheap (bool speed, machine_mode mode) /* Subroutine of {set_,}zero_cost. Not to be used otherwise. */ -static inline int * +inline int * zero_cost_ptr (bool speed) { return &this_target_expmed->x_zero_cost[speed]; @@ -327,7 +327,7 @@ zero_cost_ptr (bool speed) /* Set the COST of loading zero when optimizing for SPEED. */ -static inline void +inline void set_zero_cost (bool speed, int cost) { *zero_cost_ptr (speed) = cost; @@ -335,7 +335,7 @@ set_zero_cost (bool speed, int cost) /* Return the COST of loading zero when optimizing for SPEED. */ -static inline int +inline int zero_cost (bool speed) { return *zero_cost_ptr (speed); @@ -343,7 +343,7 @@ zero_cost (bool speed) /* Subroutine of {set_,}add_cost. Not to be used otherwise. */ -static inline int * +inline int * add_cost_ptr (bool speed, machine_mode mode) { return expmed_op_cost_ptr (&this_target_expmed->x_add_cost, speed, mode); @@ -351,7 +351,7 @@ add_cost_ptr (bool speed, machine_mode mode) /* Set the COST of computing an add in MODE when optimizing for SPEED. */ -static inline void +inline void set_add_cost (bool speed, machine_mode mode, int cost) { *add_cost_ptr (speed, mode) = cost; @@ -359,7 +359,7 @@ set_add_cost (bool speed, machine_mode mode, int cost) /* Return the cost of computing an add in MODE when optimizing for SPEED. */ -static inline int +inline int add_cost (bool speed, machine_mode mode) { return *add_cost_ptr (speed, mode); @@ -367,7 +367,7 @@ add_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}neg_cost. Not to be used otherwise. */ -static inline int * +inline int * neg_cost_ptr (bool speed, machine_mode mode) { return expmed_op_cost_ptr (&this_target_expmed->x_neg_cost, speed, mode); @@ -375,7 +375,7 @@ neg_cost_ptr (bool speed, machine_mode mode) /* Set the COST of computing a negation in MODE when optimizing for SPEED. */ -static inline void +inline void set_neg_cost (bool speed, machine_mode mode, int cost) { *neg_cost_ptr (speed, mode) = cost; @@ -384,7 +384,7 @@ set_neg_cost (bool speed, machine_mode mode, int cost) /* Return the cost of computing a negation in MODE when optimizing for SPEED. */ -static inline int +inline int neg_cost (bool speed, machine_mode mode) { return *neg_cost_ptr (speed, mode); @@ -392,7 +392,7 @@ neg_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}shift_cost. Not to be used otherwise. */ -static inline int * +inline int * shift_cost_ptr (bool speed, machine_mode mode, int bits) { return expmed_op_cost_ptr (&this_target_expmed->x_shift_cost[bits], @@ -401,7 +401,7 @@ shift_cost_ptr (bool speed, machine_mode mode, int bits) /* Set the COST of doing a shift in MODE by BITS when optimizing for SPEED. */ -static inline void +inline void set_shift_cost (bool speed, machine_mode mode, int bits, int cost) { *shift_cost_ptr (speed, mode, bits) = cost; @@ -410,7 +410,7 @@ set_shift_cost (bool speed, machine_mode mode, int bits, int cost) /* Return the cost of doing a shift in MODE by BITS when optimizing for SPEED. */ -static inline int +inline int shift_cost (bool speed, machine_mode mode, int bits) { return *shift_cost_ptr (speed, mode, bits); @@ -418,7 +418,7 @@ shift_cost (bool speed, machine_mode mode, int bits) /* Subroutine of {set_,}shiftadd_cost. Not to be used otherwise. */ -static inline int * +inline int * shiftadd_cost_ptr (bool speed, machine_mode mode, int bits) { return expmed_op_cost_ptr (&this_target_expmed->x_shiftadd_cost[bits], @@ -428,7 +428,7 @@ shiftadd_cost_ptr (bool speed, machine_mode mode, int bits) /* Set the COST of doing a shift in MODE by BITS followed by an add when optimizing for SPEED. */ -static inline void +inline void set_shiftadd_cost (bool speed, machine_mode mode, int bits, int cost) { *shiftadd_cost_ptr (speed, mode, bits) = cost; @@ -437,7 +437,7 @@ set_shiftadd_cost (bool speed, machine_mode mode, int bits, int cost) /* Return the cost of doing a shift in MODE by BITS followed by an add when optimizing for SPEED. */ -static inline int +inline int shiftadd_cost (bool speed, machine_mode mode, int bits) { return *shiftadd_cost_ptr (speed, mode, bits); @@ -445,7 +445,7 @@ shiftadd_cost (bool speed, machine_mode mode, int bits) /* Subroutine of {set_,}shiftsub0_cost. Not to be used otherwise. */ -static inline int * +inline int * shiftsub0_cost_ptr (bool speed, machine_mode mode, int bits) { return expmed_op_cost_ptr (&this_target_expmed->x_shiftsub0_cost[bits], @@ -455,7 +455,7 @@ shiftsub0_cost_ptr (bool speed, machine_mode mode, int bits) /* Set the COST of doing a shift in MODE by BITS and then subtracting a value when optimizing for SPEED. */ -static inline void +inline void set_shiftsub0_cost (bool speed, machine_mode mode, int bits, int cost) { *shiftsub0_cost_ptr (speed, mode, bits) = cost; @@ -464,7 +464,7 @@ set_shiftsub0_cost (bool speed, machine_mode mode, int bits, int cost) /* Return the cost of doing a shift in MODE by BITS and then subtracting a value when optimizing for SPEED. */ -static inline int +inline int shiftsub0_cost (bool speed, machine_mode mode, int bits) { return *shiftsub0_cost_ptr (speed, mode, bits); @@ -472,7 +472,7 @@ shiftsub0_cost (bool speed, machine_mode mode, int bits) /* Subroutine of {set_,}shiftsub1_cost. Not to be used otherwise. */ -static inline int * +inline int * shiftsub1_cost_ptr (bool speed, machine_mode mode, int bits) { return expmed_op_cost_ptr (&this_target_expmed->x_shiftsub1_cost[bits], @@ -482,7 +482,7 @@ shiftsub1_cost_ptr (bool speed, machine_mode mode, int bits) /* Set the COST of subtracting a shift in MODE by BITS from a value when optimizing for SPEED. */ -static inline void +inline void set_shiftsub1_cost (bool speed, machine_mode mode, int bits, int cost) { *shiftsub1_cost_ptr (speed, mode, bits) = cost; @@ -491,7 +491,7 @@ set_shiftsub1_cost (bool speed, machine_mode mode, int bits, int cost) /* Return the cost of subtracting a shift in MODE by BITS from a value when optimizing for SPEED. */ -static inline int +inline int shiftsub1_cost (bool speed, machine_mode mode, int bits) { return *shiftsub1_cost_ptr (speed, mode, bits); @@ -499,7 +499,7 @@ shiftsub1_cost (bool speed, machine_mode mode, int bits) /* Subroutine of {set_,}mul_cost. Not to be used otherwise. */ -static inline int * +inline int * mul_cost_ptr (bool speed, machine_mode mode) { return expmed_op_cost_ptr (&this_target_expmed->x_mul_cost, speed, mode); @@ -508,7 +508,7 @@ mul_cost_ptr (bool speed, machine_mode mode) /* Set the COST of doing a multiplication in MODE when optimizing for SPEED. */ -static inline void +inline void set_mul_cost (bool speed, machine_mode mode, int cost) { *mul_cost_ptr (speed, mode) = cost; @@ -517,7 +517,7 @@ set_mul_cost (bool speed, machine_mode mode, int cost) /* Return the cost of doing a multiplication in MODE when optimizing for SPEED. */ -static inline int +inline int mul_cost (bool speed, machine_mode mode) { return *mul_cost_ptr (speed, mode); @@ -525,7 +525,7 @@ mul_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}sdiv_cost. Not to be used otherwise. */ -static inline int * +inline int * sdiv_cost_ptr (bool speed, machine_mode mode) { return expmed_op_cost_ptr (&this_target_expmed->x_sdiv_cost, speed, mode); @@ -534,7 +534,7 @@ sdiv_cost_ptr (bool speed, machine_mode mode) /* Set the COST of doing a signed division in MODE when optimizing for SPEED. */ -static inline void +inline void set_sdiv_cost (bool speed, machine_mode mode, int cost) { *sdiv_cost_ptr (speed, mode) = cost; @@ -543,7 +543,7 @@ set_sdiv_cost (bool speed, machine_mode mode, int cost) /* Return the cost of doing a signed division in MODE when optimizing for SPEED. */ -static inline int +inline int sdiv_cost (bool speed, machine_mode mode) { return *sdiv_cost_ptr (speed, mode); @@ -551,7 +551,7 @@ sdiv_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}udiv_cost. Not to be used otherwise. */ -static inline int * +inline int * udiv_cost_ptr (bool speed, machine_mode mode) { return expmed_op_cost_ptr (&this_target_expmed->x_udiv_cost, speed, mode); @@ -560,7 +560,7 @@ udiv_cost_ptr (bool speed, machine_mode mode) /* Set the COST of doing an unsigned division in MODE when optimizing for SPEED. */ -static inline void +inline void set_udiv_cost (bool speed, machine_mode mode, int cost) { *udiv_cost_ptr (speed, mode) = cost; @@ -569,7 +569,7 @@ set_udiv_cost (bool speed, machine_mode mode, int cost) /* Return the cost of doing an unsigned division in MODE when optimizing for SPEED. */ -static inline int +inline int udiv_cost (bool speed, machine_mode mode) { return *udiv_cost_ptr (speed, mode); @@ -577,7 +577,7 @@ udiv_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}mul_widen_cost. Not to be used otherwise. */ -static inline int * +inline int * mul_widen_cost_ptr (bool speed, machine_mode mode) { gcc_assert (GET_MODE_CLASS (mode) == MODE_INT); @@ -588,7 +588,7 @@ mul_widen_cost_ptr (bool speed, machine_mode mode) /* Set the COST for computing a widening multiplication in MODE when optimizing for SPEED. */ -static inline void +inline void set_mul_widen_cost (bool speed, machine_mode mode, int cost) { *mul_widen_cost_ptr (speed, mode) = cost; @@ -597,7 +597,7 @@ set_mul_widen_cost (bool speed, machine_mode mode, int cost) /* Return the cost for computing a widening multiplication in MODE when optimizing for SPEED. */ -static inline int +inline int mul_widen_cost (bool speed, machine_mode mode) { return *mul_widen_cost_ptr (speed, mode); @@ -605,7 +605,7 @@ mul_widen_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}mul_highpart_cost. Not to be used otherwise. */ -static inline int * +inline int * mul_highpart_cost_ptr (bool speed, machine_mode mode) { gcc_assert (GET_MODE_CLASS (mode) == MODE_INT); @@ -618,7 +618,7 @@ mul_highpart_cost_ptr (bool speed, machine_mode mode) /* Set the COST for computing the high part of a multiplication in MODE when optimizing for SPEED. */ -static inline void +inline void set_mul_highpart_cost (bool speed, machine_mode mode, int cost) { *mul_highpart_cost_ptr (speed, mode) = cost; @@ -627,7 +627,7 @@ set_mul_highpart_cost (bool speed, machine_mode mode, int cost) /* Return the cost for computing the high part of a multiplication in MODE when optimizing for SPEED. */ -static inline int +inline int mul_highpart_cost (bool speed, machine_mode mode) { return *mul_highpart_cost_ptr (speed, mode); @@ -635,7 +635,7 @@ mul_highpart_cost (bool speed, machine_mode mode) /* Subroutine of {set_,}convert_cost. Not to be used otherwise. */ -static inline int * +inline int * convert_cost_ptr (machine_mode to_mode, machine_mode from_mode, bool speed) { @@ -651,7 +651,7 @@ convert_cost_ptr (machine_mode to_mode, machine_mode from_mode, /* Set the COST for converting from FROM_MODE to TO_MODE when optimizing for SPEED. */ -static inline void +inline void set_convert_cost (machine_mode to_mode, machine_mode from_mode, bool speed, int cost) { @@ -661,7 +661,7 @@ set_convert_cost (machine_mode to_mode, machine_mode from_mode, /* Return the cost for converting from FROM_MODE to TO_MODE when optimizing for SPEED. */ -static inline int +inline int convert_cost (machine_mode to_mode, machine_mode from_mode, bool speed) { |