[Patch,avr] Ad PR 54222: Add roundfx, countlsfx to stdfix.h
Fri Feb 8 06:06:00 GMT 2013
2013/2/7 Georg-Johann Lay <firstname.lastname@example.org>:
> This patch adds more fixed-point features from embedded-C:
> - roundfx rounding functions
> - countlsfx bit counting functions
> - add implementations of builtins so that an implementation / symbol is
> available when the address of such a function is taken
> The stdfix.h header is cleaned up and just contains defines that map the
> available embedded-C functions to their builtin like
> #define roundr __builtin_avr_roundr
> Reasoning is
> 1) Is is possible to take the address of roundr
> 2) Some builtins might print diagnostics. If the functions in
> stdfix.h were implemented as inline functions, the diagnose
> will point to the implementation in stdfix.h but not to the
> used code that uses the builtin with odd values.
> I found no way to get the location of the argument; EXPR_LOCATION won't work,
> and emitting a warning during built-in folding will show at locations more or
> less randomly distributed (depending on pass) around the correct location...
> The type-generic functions are implemented by overloading them.
> A new, avr-specific C source is added to libgcc that is used to compile objects
> to be added to libgcc.a. The objects are compiled by iterating over the
> source, which is not possible with LIB2ADD. That is: With LIB2ADD, there would
> be a bunch of new C modules, one for each function. The new iteration scheme
> is similar to iterating over libgcc sources like lib1funcs.S, fp-bit.c,
> fixed-bit.c, etc.
> The new test cases pass but they need the following patch to work correctly:
> This is pending review.
> Ok for trunk?
> PR target/54222
> * config/avr/avr.md (unspec) <UNSPEC_ROUND>: Add.
> * config/avr/avr-fixed.md (ALL4QA, ALL124QA): New mode iterators.
> (round<mode>3, round<mode>3_const): New expanders for fixed-mode.
> (*round<mode>3.libgcc): New insns for fixed-modes.
> * config/avr/builtins.def (ABSxx): Use a non-NULL LIBNAME.
> (ROUNDxx, COUNTLSxx, BITSxx, xxBITS): New DEF_BUILTINs.
> (ROUNDFX, COUNTLSFX, ABSFX): New DEF_BUILTINs.
> * config/avr/stdfix.h (absFX, bitsFX, FXbits): Remove inline
> implementations. Define to __builtin_avr_absFX,
> __builtin_avr_bitsFX, __builtin_avr_FXbits, respectively.
> (roundFX, countlsFX): Define to __builtin_avr_roundFX,
> __builtin_avr_countlsFX, respectively.
> * config/avr/avr-c.c (target.h): Include it.
> (enum avr_builtin_id): New enum.
> (avr_resolve_overloaded_builtin): New static function.
> (avr_register_target_pragmas): Use it to set
> * config/avr/avr.c (avr_init_builtins): Supply myriads of local
> tree nodes used by DEF_BUILTIN.
> (avr_expand_builtin) <AVR_BUILTIN_ROUNDxx>: Sanity-check them.
> (avr_fold_builtin) <AVR_BUILTIN_BITSxx>: Fold to VIEW_COVERT_EXPR.
> <AVR_BUILTIN_xxBITS>: Same.
> PR target/54222
> * config/avr/lib2funcs.c: New C sources for modules for libgcc.a.
> * config/avr/lib2-object.mk: New iterator to build objects from it.
> * config/avr/t-avr: Iterate lib2-object.mk to build objects from
> (LIB2FUNCS_EXCLUDE): Add _clrsbdi2.
> (LIB1ASMFUNCS): Add: _ssabs_1, _mask1, _ret, _roundqq3, _rounduqq3,
> _round_s2, _round_u2, _round_2_const, _addmask_2, _round_s4,
> _round_u4, _round_4_const, _addmask_4, _round_x8, _rounddq3
> _roundudq3, _roundda3 _rounduda3, _roundta3 _rounduta3.
> * config/avr/lib1funcs-fixed.S: Implement them.
> PR target/54222
> * gcc.target/avr/torture/builtins-4-roundfx.c: New test.
> * gcc.target/avr/torture/builtins-5-countlsfx.c: New test.
More information about the Gcc-patches