[Patch,AVR] Light-weight DImode implementation.

Georg-Johann Lay avr@gjlay.de
Mon Nov 21 19:51:00 GMT 2011


This adds support for DImode insns that don't operate byte-wise like NEG,
COMPARE, PLUS, MINUS, ASHIFT, LSHIFTRT, ASHIFTRT, ROTATE.

The crucial point is that there is no movdi, with the following reasoning as
cited from new avr-dimode.md:

;; The purpose of this file is to provide a light-weight DImode
;; implementation for AVR.  The trouble with DImode is that tree -> RTL
;; lowering leads to really unpleasant code for operations that don't
;; work byte-wise like NEG, PLUS, MINUS, etc.  Defining optabs entries for
;; them won't help because the optab machinery assumes these operations
;; are cheap and does not check if a libgcc implementation is available.
;;
;; The DImode insns are all straight forward -- except movdi.  The approach
;; of this implementation is to provide DImode insns without the burden of
;; introducing movdi.
;;
;; The caveat is that if there are insns for some mode, there must also be a
;; respective move insn that describes reloads.  Therefore, this
;; implementation uses an accumulator-based model with two hard-coded,
;; accumulator-like registers
;;
;;    A[] = reg:DI 18
;;    B[] = reg:DI 10
;;
;; so that no DImode insn contains pseudos or needs reloading.

Comments are welcome whether this is reasonable or bullshit ;-)

The implementation is just some 300 lines and works smooth with the test suite
and libgcc and avr-libc generated with -m64, of course.

All insns/expanders in the new avr-dimode.md are triggered by -m64 which is off
per default.

The new option is because I excepted problems with the patch, but it runs
smooth since the first line so that the option can be dropped if the
explanation above holds.

The changes to the rest of the backend are just hand-full of lines :-)

As said above, test suite passes fine both woth -m64 off and with -m64 turn on
and with libgcc/libc built with that switch.

Ok?

Johann

gcc/
	* config/avr/avr.opt (-m64): New option.
	* config/avr/avr-dimode.md: New file.
	* config/avr/avr.md: Include it.
	(adjust_len): Add plus64, compare64.
	(HIDI): Remove code iterator.
	(code_stdname): New code attribute.
	(rotx, rotsmode): Remove DI.
	(rotl<mode>3, *rotw<mode>, *rotb<mode>): Use HISI instead of HIDI
	as code iterator.
	* config/avr/avr-protos.h (avr_out_plus64, avr_out_compare64): New.
	* config/avr/avr.c (avr_out_compare): Handle DImode.
	(avr_out_compare64, avr_out_plus64): New functions.
	(avr_out_plus_1): Use simplify_unary_operation to negate xval.
	(adjust_insn_length): Handle ADJUST_LEN_COMPARE64, ADJUST_LEN_PLUS64.
	(avr_compare_pattern): Skip DImode comparisons.

libgcc/
	* config/avr/t-avr (LIB1ASMFUNCS): Add _adddi3, _adddi3_s8,
	_subdi3, _cmpdi2, _cmpdi2_s8, _rotldi3.
	* config/avr/lib1funcs.S (__adddi3, __adddi3_s8, __subdi3,
	__cmpdi2, __cmpdi2_s8, __rotldi3): New functions.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dimode.diff
Type: text/x-patch
Size: 22738 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20111121/bbe28623/attachment.bin>


More information about the Gcc-patches mailing list