Commit Graph

334 Commits

Author SHA1 Message Date
Georg-Johann Lay
f1f59bc724 re PR target/50910 ([avr] inefficient division by 2)
PR target/50910
	* config/avr/avr.opt (-mbranch-cost=): New option.
	* config/avr/avr.h (BRANCH_COST): Define to avr_branch_cost.
	* config/avr/avr.c (avr_rtx_costs_1): Adjust [U]DIV/[U]MOD costs.
	* config/avr/avr.md (*addqi3.lt0, *addhi3.lt0, *addsi3.lt0): New insns.
	(*addhi3_zero_extend1): Remov % in constraint of operand 1.
	(*addhi3.sign_extend1, *subhi3.sign_extend2): New insns.

From-SVN: r180739
2011-11-01 14:10:13 +00:00
Georg-Johann Lay
d702f362b5 re PR target/50887 ([avr] Support ACCUMULATE_OUTGOING_ARGS)
PR target/50887
	* config/avr/avr.opt (-maccumulate-args): New option.
	* config/avr/avr.h (STARTING_FRAME_OFFSET): Redefine to
	avr_starting_frame_offset.
	(ACCUMULATE_OUTGOING_ARGS): Define to avr_accumulate_outgoing_args.
	* config/avr/avr.md (UNSPECV_WRITE_SP_IRQ_ON): Remove.
	(UNSPECV_WRITE_SP_IRQ_OFF): Remove.
	(UNSPECV_WRITE_SP): New constant.
	(*addhi3_sp_R): Rewrite to...
	(*addhi3_sp): ...this new insn.
	(movhi_sp_r_irq_off, movhi_sp_r_irq_on): Combine to...
	(movhi_sp_r): ...this new insn.
	* config/avr/avr-protos.h (avr_accumulate_outgoing_args): New.
	(avr_starting_frame_offset): New.
	* config/avr/avr.c (avr_accumulate_outgoing_args): New function.
	(avr_starting_frame_offset): New function.
	(avr_outgoing_args_size): New static function.
	(avr_initial_elimination_offset): Use it.
	(avr_simple_epilogue): Use it.
	(avr_asm_function_end_prologue): Use it.
	(expand_epilogue): Use it.
	(expand_prologue): Use it.  Break out code to...
	(avr_prologue_setup_frame): ...this new static function.
	(avr_can_eliminate): Allow eliminating to frame pointer if there
	is one.
	(avr_frame_pointer_required_p): Use frame pointer if target has a
	nonlocal label.
	* config/avr/constraints.md (R): Remove.
	(Csp): New constraint.
	* config/avr/predicates.md (avr_sp_immediate_operand): Use it.

From-SVN: r180654
2011-10-29 14:35:59 +00:00
Georg-Johann Lay
d2111e2f14 avr.c: Break long lines.
* config/avr/avr.c: Break long lines.
	Define target hooks on the fly if applicable.
	(TARGET_ASM_FUNCTION_RODATA_SECTION): Remove first definition
	overridden later.
	(targetm): Move definition to end of file.
	(avr_can_eliminate): Make static on the fly.
	(avr_frame_pointer_required_p): Ditto.
	(avr_hard_regno_scratch_ok): Ditto.
	(avr_builtin_setjmp_frame_value): Make static on the fly.
	Indent according to coding rules.
	(avr_case_values_threshold): Ditto.
	(avr_attribute_table): Move down.

From-SVN: r180371
2011-10-24 09:39:09 +00:00
Georg-Johann Lay
c1a330ef7f avr.h (LEGITIMIZE_RELOAD_ADDRESS): Pass address of X instead of X to avr_legitimize_reload_address.
* config/avr/avr.h (LEGITIMIZE_RELOAD_ADDRESS): Pass address of X
	instead of X to avr_legitimize_reload_address.
	* config/avr/avr-protos.h (avr_legitimize_reload_address): Change
	first argument's type from rtx to rtx*.
	* config/avr/avr.c (avr_legitimize_reload_address): Ditto.
	Pass PX to push_reload instead of &X.  Change log messages for
	better distinction.

From-SVN: r180308
2011-10-21 15:46:32 +00:00
Georg-Johann Lay
2f47b8d3be re PR target/50447 ([avr] Better support of AND, OR, XOR and PLUS with constant integers for 16- and 32-bit values)
PR target/50447
	* config/avr/avr.md (cc): New alternative out_plus_noclobber.
	(adjust_len): Ditto.
	(addhi3): Don't pipe through short; use gen_int_mode instead.
	Prior to reload, expand to gen_addhi3_clobber.
	(*addhi3): Use avr_out_plus_noclobber if applicable, use
	out_plus_noclobber in cc and adjust_len attribute.
	(addhi3_clobber): 2 new RTL peepholes.
	(addhi3_clobber): New insn.
	* config/avr/avr-protos.h: (avr_out_plus_noclobber): New prototype.
	* config/avr/avr.c (avr_out_plus_noclobber): New function.
	(notice_update_cc): Handle CC_OUT_PLUS_NOCLOBBER.
	(avr_out_plus_1): Tweak if only MSB is +/-1 and other bytes are 0.
	Set cc0 to set_zn for adiw on 16-bit values.
	(adjust_insn_length): Handle ADJUST_LEN_OUT_PLUS_NOCLOBBER.
	(expand_epilogue): No need to add 0 to frame_pointer_rtx.

From-SVN: r180193
2011-10-19 14:59:00 +00:00
Georg-Johann Lay
7c3297ce40 avr.h (ASSEMBLER_DIALECT): Remove.
* config/avr/avr.h (ASSEMBLER_DIALECT): Remove.
	* config/avr/avr.md (mcu_have_movw, mcu_mega): Remove attributes.
	(adjust_len): Add alternative "call".
	(isa, enabled): New insn attributes.
	(length): Use match_test with AVR_HAVE_JMP_CALL instead of
	mcu_mega attribute.
	(*sbrx_branch<mode>): Ditto.
	(*sbrx_and_branch<mode>): Ditto.
	(*sbix_branch): Ditto.
	(*sbix_branch_bit7): Ditto.
	(*sbix_branch_tmp): Ditto.
	(*sbix_branch_tmp_bit7): Ditto.
	(jump): Ditto.
	(negsi2): Use attribute "isa" instead of assembler dialect.
	(extendhisi2): Ditto.
	(call_insn, call_value_insn): Set adjust_len attribute.
	(indirect_jump): Indent to coding rules.
	(call_prologue_saves): Use isa attribute instead of mcu_mega.
	(epilogue_restores): Ditto.  Fix setting of SP as described in the
	RTX pattern.
	(*indirect_jump): Fusion of *jcindirect_jump, *njcindirect_jump
	and *indirect_jump_avr6.
	(*tablejump): Fusion of *tablejump_rjmp and *tablejump_lib.
	(*jcindirect_jump, *njcindirect_jump, *indirect_jump_avr6): Remove.
	(*tablejump_rjmp, *tablejump_lib): Remove.
	* config/avr/avr.c (adjust_insn_length): Handle ADJUST_LEN_CALL.

From-SVN: r180104
2011-10-17 17:53:07 +00:00
Georg-Johann Lay
a08147527b Fix thinko from r179765
Fix thinko from r179765
	* config/avr/avr.c (avr_option_override): Don't override
	flag_omit_frame_pointer if not actually needed.

From-SVN: r179994
2011-10-14 16:42:24 +00:00
Georg-Johann Lay
e8ac5ac96a re PR target/46278 (avr-gcc 4.5.1 doing suboptimal reloads using X)
PR target/46278
	* doc/invoke.texi (AVR Options): Document -mstrict-X.
	* config/avr/avr.opt (-mstrict-X): New option.
	(avr_strict_X): New variable reflecting -mstrict-X.
	* config/avr/avr.c (avr_reg_ok_for_addr_p): Add parameter
	outer_code and pass it down to avr_regno_mode_code_ok_for_base_p.
	(avr_legitimate_address_p): Pass outer_code to
	avr_reg_ok_for_addr_p and use that function in case PLUS.
	(avr_mode_code_base_reg_class): Depend on avr_strict_X.
	(avr_regno_mode_code_ok_for_base_p): Ditto, and depend on outer_code.
	(avr_option_override): Disable -fcaller-saves if -mstrict-X is on.

From-SVN: r179993
2011-10-14 15:42:33 +00:00
Georg-Johann Lay
9bc9ee6799 re PR target/49939 ([avr] Skip 2-word instructions if applicable)
PR target/49939
	* config/avr/avr.md (*movqi): Rename to movqi_insn.
	(*call_insn): Rename to call_insn.
	(*call_value_insn): Rename to call_value_insn.
	* config/avr/avr.c (avr_2word_insn_p): New static function.
	(jump_over_one_insn_p): Use it.

From-SVN: r179843
2011-10-12 09:59:30 +00:00
Georg-Johann Lay
8efab2c5ea avr-protos.h (avr_mode_code_base_reg_class): New prototype.
* config/avr/avr-protos.h (avr_mode_code_base_reg_class): New prototype.
	(avr_regno_mode_code_ok_for_base_p): New prototype.
	* config/avr/avr.h (BASE_REG_CLASS): Remove.
	(REGNO_OK_FOR_BASE_P): Remove.
	(REG_OK_FOR_BASE_NOSTRICT_P): Remove.
	(REG_OK_FOR_BASE_STRICT_P): Remove.
	(MODE_CODE_BASE_REG_CLASS): New define.
	(REGNO_MODE_CODE_OK_FOR_BASE_P): New define.
	* config/avr/avr.c (avr_mode_code_base_reg_class): New function.
	(avr_regno_mode_code_ok_for_base_p): New function.
	(avr_reg_ok_for_addr_p): New static function.
	(avr_legitimate_address_p): Use it.  Beautify.

From-SVN: r179817
2011-10-11 18:34:16 +00:00
Georg-Johann Lay
05058b6e31 re PR target/50447 ([avr] Better support of AND, OR, XOR and PLUS with constant integers for 16- and 32-bit values)
PR target/50447
	* config/avr/avr.md (cc): Add out_plus attribute alternative.
	(addsi3): Use it.  Adapt avr_out_plus to new prototype.  Use
	avr_out_plus for all CONST_INT addends.
	* config/avr/avr-protos.h (avr_out_plus): Change prototype.
	* config/avr/avr.c (notice_update_cc): Call avr_out_plus on
	CC_OUT_PLUS.
	(avr_out_plus_1): Change prototype and report effect on cc0.
	(avr_out_plus): Ditto.
	(adjust_insn_length): Adapt call to avr_out_plus to new prototype.

From-SVN: r179816
2011-10-11 18:28:49 +00:00
Georg-Johann Lay
16bbc87591 avr.c (avr_option_override): Set flag_omit_frame_pointer to 0 if frame pointer is needed for unwinding.
* config/avr/avr.c (avr_option_override): Set
	flag_omit_frame_pointer to 0 if frame pointer is needed for
	unwinding.

From-SVN: r179765
2011-10-10 17:25:48 +00:00
Georg-Johann Lay
180ee6d101 avr-protos.h (avr_out_addto_sp): New prototype.
* config/avr/avr-protos.h (avr_out_addto_sp): New prototype.
	* config/avr/avr.c (avr_out_addto_sp): New function.
	(adjust_insn_length): Handle ADJUST_LEN_ADDTO_SP.
	* config/avr/avr.md (adjust_len): Add "addto_sp".
	(*movhi_sp): Remove insn.
	(*addhi3_sp_R_pc2, *addhi3_sp_R_pc3): Merge to *addhi3_sp_R.

From-SVN: r179544
2011-10-05 11:16:10 +00:00
Georg-Johann Lay
36a50ab6e0 re PR target/50566 ([avr]: Add support for better logging similar to -mdeb)
PR target/50566
	* config/avr/avr-protos.h (avr_legitimize_reload_address): New
	prototype.
	* config/avr/avr.h (LEGITIMIZE_RELOAD_ADDRESS): Copy worker code
	from here...
	* config/avr/avr.c (avr_legitimize_reload_address) ...to this new
	function.  Log if avr_log.legitimize_reload_address.

From-SVN: r179494
2011-10-04 08:23:03 +00:00
Georg-Johann Lay
fe780c134a re PR target/50566 ([avr]: Add support for better logging similar to -mdeb)
PR target/50566
	* config/avr/avr-protos.h (avr_log_t): New field address_cost.
	* config/avr/avr.c (avr_address_cost): Use it.
	* config/avr/avr-log.c (avr_log_set_avr_log): Initialize it.
	(avr_log_vadump): Unknown %-codes finish printing.

From-SVN: r179391
2011-09-30 15:15:23 +00:00
Georg-Johann Lay
ab758510b2 re PR target/50566 ([avr]: Add support for better logging similar to -mdeb)
PR target/50566
	* config/avr/avr-log.c (avr_log_vadump): Use %b to print bool.
	* config/avr/avr.c (avr_rtx_costs_1): New static function, renamed
	from avr_rtx_costs.
	(avr_legitimate_address_p): Use avr_edump to print log information
	filtered by avr_log.
	(extra_constraint_Q): Ditto.
	(avr_legitimize_address): Ditto.
	(avr_rtx_costs): Ditto.  Rewrite as wrapper for avr_rtx_costs_1.
	(final_prescan_insn): Use avr_log.rtx_costs as filter.

From-SVN: r179359
2011-09-29 16:24:57 +00:00
Georg-Johann Lay
6c7dfafee6 re PR target/50566 ([avr]: Add support for better logging similar to -mdeb)
PR target/50566
	* config.gcc (extra_objs): Add avr-log.o for $target in:
	avr-*-rtems*, avr-*-*.
	* config/avr/t-avr (avr-log.o): New rule to compile...
	* config/avr/avr-log.c: ...this new file.
	* config/avr/avr.opt (mlog=): New option.
	* config/avr/avr-protos.h (avr_edump, avr_fdump): New macros.
	(avr_log_set_caller_e, avr_log_set_caller_f): New prototypes.
	(avr_log_set_avr_log): New prototype.
	(avr_log_t): New typedef.
	(avr_log): New declaration.
	* config/avr/avr.c (avr_option_override): Call avr_log_set_avr_log.

From-SVN: r179344
2011-09-29 11:51:59 +00:00
Georg-Johann Lay
1cd12949e1 avr.md (ashrqi3): Split alternative "n" into its remaining parts C03...
* config/avr/avr.md (ashrqi3): Split alternative "n"
	into its remaining parts C03, C04, C05, C06, C07 and describe
	impact in CC by attribute "cc" appropriately.
	* config/avr/avr.c (notice_update_cc): Clean-up: Don't patch CC0
	by digging RTX.

From-SVN: r179241
2011-09-27 08:08:16 +00:00
Georg-Johann Lay
31fd727b4d avr.md (peephole casesi+2): Use -1 instead of 65536.
* config/avr/avr.md (peephole casesi+2): Use -1 instead of 65536.
	* config/avr/avr.c (avr_out_compare): Print shorter sequence for
	EQ/NE comparisons against +/-1 in the case of unused-after,
	non-ld-regs target.

From-SVN: r179206
2011-09-26 16:55:55 +00:00
Georg-Johann Lay
8a6a05ce93 re PR target/50465 ([avr] Use insn attribute to depict if and how instruction lengths have to be adjusted)
PR target/50465
	* config/avr/avr-protos.h (output_reload_insisf): Don't pass insn.
	* config/avr/avr.md (*reload_insi, *reload_insf): Change call to
	output_reload_insisf.
	(adjust_len): Set default to "no".
	Remove alternative "yes".  Add alternatives: "mov8", "mov16",
	"mov32", "ashlqi", "ashrqi", "lshrqi", "ashlhi", "ashrhi",
	"lshrhi", "ashlsi, "ashrsi", "lshrsi".
	(*movqi, *movhi, *movsi, *ashlqi3, ashlhi3, ashlsi3,
	*ashlhi3_const, *ashlsi3_const, ashrqi3, ashrhi3, ashrsi3,
	*ashrhi3_const, *ashrsi3_const, *lshrqi3, lshrhi3, *lshrhi3_const,
	*lshrsi3_const): Set attribute "adjust_len".
	* config/avr/avr.c (output_reload_insisf): Remove parameter "insn".
	(output_movsisf): Don't pass insn to output_reload_insisf.
	(adjust_insn_length): Handle new alternatives to adjust_len.
	Remove handling of ADJUST_LEN_YES.  Clean-up code.

From-SVN: r179191
2011-09-26 11:53:40 +00:00
Georg-Johann Lay
20633efc34 avr-protos.h (output_reload_inhi): Change prototype.
* config/avr/avr-protos.h (output_reload_inhi): Change prototype.
	* config/avr/avr.md (adjust_len): Add "reload_in16" alternative.
	(*reload_inhi): Use it.  Adapt call to output_reload_inhi to new
	prototype.
	(*movhi): Split constraint alternative "r,rL" into "r,r" and "r,L".
	* config/avr/avr.c: Rename output_reload_insisf_1 to
	output_reload_in_const.
	(avr_popcount_each_byte): Handle SFmode, too.
	(output_reload_in_const): Change so it can handle HI loads, too.
	Use avr_popcount_each_byte to work out if scratch register must be
	created on the fly.
	(output_reload_inhi): Rewrite using output_reload_in_const and...
	(output_movhi): ...use it to print constants' loads.
	(adjust_insn_length): New case ADJUST_LEN_RELOAD_IN16. Cleanup code.

From-SVN: r179181
2011-09-26 08:14:25 +00:00
Georg-Johann Lay
4103605f99 * config/avr/avr.c: Fix some typos in comments.
From-SVN: r179127
2011-09-23 17:44:57 +00:00
Georg-Johann Lay
a7c0acd019 re PR target/50447 ([avr] Better support of AND, OR, XOR and PLUS with constant integers for 16- and 32-bit values)
* config/avr/avr.md (adjust_len): Add alternatives "tsthi",
	"tstsi", "compare".
	(*cmpqi_sign_extend): Use s8_operand.
	(*cmphi, *cmpsi): Rewrite using avr_out_compare.
	* config/avr/avr-protos.h (compare_diff_p, compare_eq_p): Remove
	prototypes.
	(out_tsthi, out_tstsi): Remove prototypes.
	(avr_out_tsthi, avr_out_tstsi): New prototypes.
	* config/avr/avr.c (out_tsthi, out_tstsi): Remove functions.
	(avr_asm_len): Negative length now sets *plen to -length.
	(compare_sign_p): Return bool instead of int.
	(compare_diff_p, compare_eq_p): Ditto and make static.
	(avr_out_tsthi): New function.
	(avr_out_tstsi): New function.
	(avr_out_compare): New function.
	(adjust_insn_length): Handle ADJUST_LEN_TSTHI, ADJUST_LEN_TSTSI,
	ADJUST_LEN_COMPARE.
	PR target/50447

From-SVN: r179124
2011-09-23 17:06:44 +00:00
Georg-Johann Lay
590245153a re PR target/50447 ([avr] Better support of AND, OR, XOR and PLUS with constant integers for 16- and 32-bit values)
PR target/50447
	* config/avr/avr.md: (adjust_len): Add alternative "out_plus".
	(addsi3): Rewrite using QI scratch register.  Adjust text
	peepholes using plus:SI.
	(*addsi3_zero_extend.hi): New insn.
	(*subsi3_zero_extend.hi): New insn.
	(*subhi3_zero_extend1): Set attribute "cc" to "set_czn".
	(*subsi3_zero_extend): Ditto.
	(subsi3): Change predicate #2 to register_operand.
	* config/avr/avr-protos.h (avr_out_plus): New prototype.
	(avr_out_plus_1): New static function.
	(avr_out_plus): New function.
	(adjust_insn_length): Handle ADJUST_LEN_OUT_PLUS.

From-SVN: r179123
2011-09-23 17:02:10 +00:00
Georg-Johann Lay
6ebe2d6cf6 re PR target/50447 ([avr] Better support of AND, OR, XOR and PLUS with constant integers for 16- and 32-bit values)
PR target/50447
	PR target/50465
	* config/avr/avr-protos.h (avr_out_bitop): New prototype.
	(avr_popcount_each_byte): New prototype.
	* config/avr/avr.c (avr_popcount): New static function.
	(avr_popcount_each_byte): New function.
	(avr_out_bitop): New function.
	(adjust_insn_length): ADJUST_LEN_OUT_BITOP dispatches to
	avr_out_bitop.  Cleanup code.
	* config/avr/constraints.md (Ca2, Co2, Cx2): New constraints.
	(Ca4, Co4, Cx4): New constraints.
	* config/avr/avr.md (adjust_len): Add "out_bitop" insn attribute
	alternative.
	(andhi3, iorhi3, xorhi3): Rewrite insns using avr_out_bitop.
	(andsi3, iorsi3, xorsi3): Ditto.
	(*iorhi3_clobber, *iorsi3_clobber): Remove insns.

From-SVN: r179081
2011-09-22 09:55:13 +00:00
Georg-Johann Lay
e3e285857d re PR target/45099 ([avr] Warning could be issued for use of register variables that will fail.)
PR target/45099
	* config/avr/avr.c (avr_function_arg_advance): Change error to
	warning if a fixed register is needed as function argument.

From-SVN: r179040
2011-09-21 09:40:13 +00:00
Georg-Johann Lay
88cb6dd256 * config/avr/avr.c (avr_function_arg_advance): Undo r179037.
From-SVN: r179038
2011-09-21 08:27:49 +00:00
Georg-Johann Lay
8dab2ba518 re PR target/50449 ([avr] Loading some 32-bit constants not optimal)
PR target/50449
	PR target/50465
	* config/avr/avr.md (adjust_len): New insn attribute.
	(*reload_insi, *reload_insf): Use it.
	(*movsi, *movsf): Use new interface of output_movsisf.
	* config/avr/avr-protos.h (output_movsisf): Change prototype.
	* config/avr/avr.c (output_movsisf): Ditto.
	(adjust_insn_length): Use insn attribute "adjust_len" to adjust
	lengths of insns *reload_insi, *reload_insf.
	(output_reload_insisf_1): New static function.
	(output_reload_insisf): Use it.

From-SVN: r179037
2011-09-21 08:21:57 +00:00
Georg-Johann Lay
1b65da7dfd re PR target/50358 (AVR: Implement [u]maddqihi4 [u]msubqihi4 patterns on the enhanced core)
PR target/50358
	* config/avr/avr.md (*ashiftqihi2.signx.1): New insn.
	(*maddqi4, *maddqi4.const): New insns.
	(*msubqi4, *msubqi4.const): New insns.
	* config/avr/avr.c (avr_rtx_costs): Record costs of above in cases
	PLUS:QI and MINUS:QI.  Increase costs of multiply-add/-sub for
	HImode by 1 in the case of multiplying with a CONST_INT.
	Record cost of *ashiftqihi2.signx.1 in case ASHIFT:QI.

From-SVN: r178912
2011-09-16 18:27:10 +00:00
Georg-Johann Lay
3e0cef6ddd re PR target/50358 (AVR: Implement [u]maddqihi4 [u]msubqihi4 patterns on the enhanced core)
PR target/50358
	* config/avr/predicates.md (const_1_to_6_operand): New predicate.
	* config/avr/avr.md: (extend_s): New code attribute.
	(mul_r_d): New code attribute.
	(*maddqihi4, *umaddqihi4): New insns.
	(*msubqihi4, *umsubqihi4): New insns.
	(*usmaddqihi4, *sumaddqihi4): New insns.
	(*usmsubqihi4, *susubdqihi4): New insns.
	(*umaddqihi4.uconst, *maddqihi4.sconst): New insn-and-splits.
	(*umsubqihi4.uconst, *msubqihi4.sconst): New insn-and-splits.
	(*umsubqihi4.uconst.ashift): New insn-and-split.
	(*msubqihi4.sconst.ashift): New insn-and-split.
	(*sumaddqihi4.uconst): New insn-and-split.
	(*sumsubqihi4.uconst): New insn-and-split.
	* config/avr/avr.c (avr_rtx_costs): Report costs of above in case
	PLUS:HI and MINUS:HI.

From-SVN: r178806
2011-09-13 09:23:36 +00:00
Georg-Johann Lay
886a64f901 re PR target/43746 (-fmerge-constants and -fmerge-all-constants don't work at AVR target)
gcc/
	PR target/43746
	* config/avr/avr.c (AVR_SECTION_PROGMEM): New Define.
	(progmem_section): New Variable.
	(avr_asm_init_sections): Initialize it.
	(TARGET_ASM_SELECT_SECTION): Define to...
	(avr_asm_select_section): ... this new Function.
	(avr_replace_prefix): New Function.
	(avr_asm_function_rodata_section): Use it.
	(avr_insert_attributes): Don't add section attribute for PROGMEM.
	(avr_section_type_flags): Use avr_progmem_p instead of section
	name to detect if object is in PROGMEM.
	(avr_asm_named_section): Set section name prefix for objects in
	PROGMEM.

testsuite/
	PR target/43746
	* testsuite/gcc.target/avr/torture/avr-torture.exp
	(AVR_TORTURE_OPTIONS): Add test cases "-O2 -fdata-sections" and
	"-O2 -fmerge-all-constants".

From-SVN: r178779
2011-09-12 10:06:46 +00:00
Georg-Johann Lay
1e3a7e8662 re PR target/50289 ([avr]: call-prologues saving/restoring global register variables)
PR target/50289
	* config/avr/avr.c (sequent_regs_live): Don't recognize sequences
	that contain global register variable.

From-SVN: r178528
2011-09-05 12:20:03 +00:00
Georg-Johann Lay
c149e48765 avr.h (progmem_section): Remove Declaration.
* config/avr/avr.h (progmem_section): Remove Declaration.
	* config/avr/avr.c (progmem_section): Make static and rename to
	progmem_swtable_section.
	(avr_output_addr_vec_elt): No need to switch sections.
	(avr_asm_init_sections): Use output_section_asm_op as section
	callback for progmem_swtable_section.
	(avr_output_progmem_section_asm_op): Remove Function.
	(TARGET_ASM_FUNCTION_RODATA_SECTION): New Define.
	(avr_asm_function_rodata_section): New static Function.
	* config/avr/elf.h (ASM_OUTPUT_BEFORE_CASE_LABEL): Output
	alignment 2**1 for jump tables.

From-SVN: r178525
2011-09-05 08:30:17 +00:00
Georg-Johann Lay
3e4c754bbf * config/avr/avr.c (byte_immediate_operand): Remove Function.
From-SVN: r178067
2011-08-25 14:36:01 +00:00
Georg-Johann Lay
61af7eb4d1 avr.c (reg_class_tab): Make local to avr_regno_reg_class.
* config/avr/avr.c (reg_class_tab): Make local to
	avr_regno_reg_class.  Return smallest register class available.

From-SVN: r178063
2011-08-25 13:50:30 +00:00
Georg-Johann Lay
f2814222f9 avr.c (STR_PREFIX_P): New Define.
* config/avr/avr.c (STR_PREFIX_P): New Define.
	(avr_asm_declare_function_name): Use it.
	(avr_asm_named_section): Use it.
	(avr_section_type_flags): Use it.

From-SVN: r178062
2011-08-25 13:46:35 +00:00
Richard Sandiford
68f932c443 tm.texi.in (TARGET_RTX_COSTS): Add an opno paramter.
gcc/
	* doc/tm.texi.in (TARGET_RTX_COSTS): Add an opno paramter.
	* doc/tm.texi: Regenerate.
	* target.def (rtx_costs): Add an opno parameter.
	* hooks.h (hook_bool_rtx_int_int_intp_bool_false): Replace with...
	(hook_bool_rtx_int_int_int_intp_bool_false): ...this.
	* hooks.c (hook_bool_rtx_int_int_intp_bool_false): Replace with...
	(hook_bool_rtx_int_int_int_intp_bool_false): ...this.
	* cse.c (COST_IN): Add an opno parameter.
	(notreg_cost): Likewise.  Update call to rtx_cost.
	(COST, fold_rtx): Update accordingly.
	* dojump.c (prefer_and_bit_test): Update call to rtx_cost.
	* expmed.c (emit_store_flag): Likewise.
	* optabs.c (avoid_expensive_constant): Add an opno parameter.
	Update call to rtx_cost.
	(expand_binop_directly, expand_binop): Likewise.
	(expand_twoval_binop, prepare_cmp_insn): Likewise.
	* rtl.h (rtx_cost, get_full_rtx_cost): Add opno parameters.
	(set_src_cost, get_full_set_src_cost): Update accordingly.
	* rtlanal.c (rtx_cost): Add an opno parameter.  Update call
	to target hook.
	(get_full_rtx_cost): Add an opno paramter.  Update calls to rtx_cost.
	(default_adress_cost): Update calls to rtx_cost.

	* config/arm/arm.c (arm_rtx_costs_1, arm_size_rtx_costs)
	(arm_slowmul_rtx_costs): Adjust calls to rtx_cost.
	(arm_rtx_costs): Add an opno parameter.
	* config/alpha/alpha.c (alpha_rtx_costs): Add an opno parameter and
	adjust any recursive rtx-cost calls.
	* config/avr/avr.c (avr_operand_rtx_cost, avr_rtx_costs): Likewise.
	* config/bfin/bfin.c (bfin_rtx_costs): Likewise.
	* config/c6x/c6x.c (c6x_rtx_costs): Likewise.
	* config/cris/cris.c (cris_rtx_costs): Likewise.
	* config/frv/frv.c (frv_rtx_costs): Likewise.
	* config/h8300/h8300.c (h8300_rtx_costs): Likewise.
	* config/i386/i386.c (ix86_rtx_costs): Likewise.
	* config/ia64/ia64.c (ia64_rtx_costs): Likewise.
	* config/iq2000/iq2000.c (iq2000_rtx_costs): Likewise.
	* config/lm32/lm32.c (lm32_rtx_costs): Likewise.
	* config/m32c/m32c.c (m32c_rtx_costs): Likewise.
	* config/m32r/m32r.c (m32r_rtx_costs): Likewise.
	* config/m68k/m68k.c (m68k_rtx_costs): Likewise.
	* config/mcore/mcore.c (mcore_rtx_costs): Likewise.
	* config/mep/mep.c (mep_rtx_cost): Likewise.
	* config/microblaze/microblaze.c (microblaze_rtx_costs): Likewise.
	* config/mips/mips.c (mips_binary_cost): Update call to rtx_cost.
	(mips_zero_extend_cost): Add an opno parameter.
	* config/mmix/mmix.c (mmix_rtx_costs): Likewise.
	* config/mn10300/mn10300.c (mn10300_address_cost): Update call
	to rtx_cost.
	(mn10300_rtx_costs): Add an opno parameter and adjust any recursive
	rtx-cost calls.
	* config/pa/pa.c (hppa_rtx_costs): Likewise.
	* config/pdp11/pdp11.c (pdp11_rtx_costs): Likewise.
	* config/picochip/picochip.c (picochip_rtx_costs): Likewise.
	* config/rs6000/rs6000.c (rs6000_rtx_costs): Likewise.
	(rs6000_debug_rtx_costs): Likewise.
	* config/s390/s390.c (s390_rtx_costs): Likewise.
	* config/score/score-protos.h (score_rtx_costs): Likewise.
	* config/score/score.c (score_rtx_costs): Likewise.
	* config/sh/sh.c (andcosts): Update call to rtx_cost.
	(sh_rtx_costs): Add an opno parameter.
	* config/sparc/sparc.c (sparc_rtx_costs): Likewise.
	* config/spu/spu.c (spu_rtx_costs): Likewise.
	* config/stormy16/stormy16.c (xstormy16_rtx_costs): Likewise.
	* config/v850/v850.c (v850_rtx_costs): Likewise.
	* config/vax/vax.c (vax_rtx_costs): Likewise.
	* config/xtensa/xtensa.c (xtensa_rtx_costs): Likewise.

From-SVN: r177852
2011-08-18 12:37:53 +00:00
Richard Sandiford
5e8f01f434 rtl.h (set_src_cost, [...]): New functions.
gcc/
	* rtl.h (set_src_cost, get_full_set_src_cost): New functions.
	* auto-inc-dec.c (attempt_change): Use set_src_cost instead of
	rtx_cost.
	* calls.c (precompute_register_parameters): Likewise.
	* combine.c (expand_compound_operation, make_extraction): Likewise.
	(force_to_mode, distribute_and_simplify_rtx): Likewise.
	* dse.c (find_shift_sequence): Likewise.
	* expmed.c (init_expmed, expand_mult, expand_smod_pow2): Likewise.
	* expr.c (compress_float_constant): Likewise.
	* fwprop.c (should_replace_address, try_fwprop_subst): Likewise.
	* gcse.c (want_to_gcse_p): Likewise.
	* ifcvt.c (noce_try_sign_mask): Likewise.
	* loop-doloop.c (doloop_optimize): Likewise.
	* loop-invariant.c (create_new_invariant): Likewise.
	* optabs.c (avoid_expensive_constant): Likewise.
	* postreload.c (reload_cse_simplify_set, reload_cse_simplify_operands)
	(try_replace_in_use, reload_cse_move2add): Likewise.
	* reload1.c (calculate_elim_costs_all_insns): Likewise.
	(note_reg_elim_costly): Likewise.
	* rtlanal.c (insn_rtx_cost): Likewise.
	* simplify-rtx.c (simplify_binary_operation_1): Likewise.
	* stmt.c (lshift_cheap_p): Likewise.
	* tree-ssa-loop-ivopts.c (seq_cost, computation_cost): Likewise.
	* config/avr/avr.c (final_prescan_insn): Likewise.
	* config/bfin/bfin.c (bfin_rtx_costs): Likewise.
	* config/mips/mips.c (mips_binary_cost, mips_rtx_costs): Likewise.

From-SVN: r177851
2011-08-18 12:37:27 +00:00
Georg-Johann Lay
f371377833 re PR target/49903 ([avr] Redundant comparisons in binary-search switch/case expansion)
* PR target/49903
	* config/avr/avr.md (UNSPEC_IDENTITY): New c_enum.
	(branch_unspec): New insn.
	(branch): Beauty farm.
	* config/avr/avr.c (compare_condition): Use JUMP_P.  Test SET_SRC
	to be IF_THEN_ELSE.
	(avr_compare_pattern, avr_reorg_remove_redundant_compare):
	New static functions.
	(avr_reorg): Use them.  Use next_real_insn instead of NEXT_INSN.
	Use CONST_INT_P.  Beauty.

From-SVN: r177744
2011-08-14 09:10:13 +00:00
Georg-Johann Lay
7ece388150 re PR target/49687 ([avr] Missed optimization for widening MUL)
PR target/49687
	* config/avr/avr.md (smulqi3_highpart): New insn.
	(umulqi3_highpart): New insn.
	(*subqi3.ashiftrt7): New insn.
	(smulhi3_highpart): New expander.
	(umulhi3_highpart): Nex expander.
	(*smulhi3_highpart_call): New insn.
	(*umulhi3_highpart_call): New insn.
	(extend_u): New code attribute.
	(extend_prefix): Rename code attribute to extend_su.
	* config/avr/avr.c (avr_rtx_costs): Report costs of highpart of
	widening QI/HI multiply.

From-SVN: r177648
2011-08-11 07:50:37 +00:00
Georg-Johann Lay
296799ba06 re PR target/49687 ([avr] Missed optimization for widening MUL)
PR target/49687
	* config/avr/t-avr (LIB1ASMFUNCS): Remove _xmulhisi3_exit.
	Add _muluhisi3, _mulshisi3, _usmulhisi3.
	* config/avr/libgcc.S (__mulsi3): Rewrite.
	(__mulhisi3): Rewrite.
	(__umulhisi3): Rewrite.
	(__usmulhisi3): New.
	(__muluhisi3): New.
	(__mulshisi3): New.
	(__mulohisi3): New.
	(__mulqi3, __mulqihi3, __umulqihi3, __mulhi3): Use DEFUN/ENDF to
	declare.
	* config/avr/predicates.md (pseudo_register_operand): Rewrite.
	(pseudo_register_or_const_int_operand): New.
	(combine_pseudo_register_operand): New.
	(u16_operand): New.
	(s16_operand): New.
	(o16_operand): New.
	* config/avr/avr.c (avr_rtx_costs): Handle costs for mult:SI.
	* config/avr/avr.md (QIHI, QIHI2): New mode iterators.
	(any_extend, any_extend2): New code iterators.
	(extend_prefix): New code attribute.
	(mulsi3): Rewrite. Turn insn to expander.
	(mulhisi3): Ditto.
	(umulhisi3): Ditto.
	(usmulhisi3): New expander.
	(*mulsi3): New insn-and-split.
	(mulu<mode>si3): New insn-and-split.
	(muls<mode>si3): New insn-and-split.
	(mulohisi3): New insn-and-split.
	(*uumulqihisi3, *uumulhiqisi3, *uumulhihisi3, *uumulqiqisi3,
	*usmulqihisi3, *usmulhiqisi3, *usmulhihisi3, *usmulqiqisi3,
	*sumulqihisi3, *sumulhiqisi3, *sumulhihisi3, *sumulqiqisi3,
	*ssmulqihisi3, *ssmulhiqisi3, *ssmulhihisi3, *ssmulqiqisi3): New
	insn-and-split.
	(*mulsi3_call): Rewrite.
	(*mulhisi3_call): Rewrite.
	(*umulhisi3_call): Rewrite.
	(*usmulhisi3_call): New insn.
	(*muluhisi3_call): New insn.
	(*mulshisi3_call): New insn.
	(*mulohisi3_call): New insn.
	(extendqihi2): Use combine_pseudo_register_operand as predicate
	for operand 1.
	(extendqisi2): Ditto.
	(zero_extendqihi2): Ditto.
	(zero_extendqisi2): Ditto.
	(zero_extendhisi2): Ditto.
	(extendhisi2): Ditto. Don't early-clobber operand 0.

From-SVN: r176862
2011-07-28 08:03:07 +00:00
Georg-Johann Lay
f4da258f52 re PR target/39386 ([avr] different computation results for O1 and O0 executables)
PR target/39386
	* config/avr/avr.c (out_shift_with_cnt): Use tmp_reg as
	shift counter for x << x and x >> x shifts.

From-SVN: r176756
2011-07-25 15:41:55 +00:00
Georg-Johann Lay
e951472536 avr.c (final_prescan_insn): Fix printing of rtx_costs.
* config/avr/avr.c (final_prescan_insn): Fix printing of rtx_costs.

From-SVN: r176575
2011-07-21 15:46:28 +00:00
Georg-Johann Lay
21f3ae2f34 * config/avr/avr.c (avr_rtx_costs): Set cost of CONST, LABEL_REF to 0.
From-SVN: r176554
2011-07-21 07:52:14 +00:00
Georg-Johann Lay
8c352fa8ed re PR target/36467 ([avr] Missed optimization with pointer arithmetic and mul*)
PR target/36467
	PR target/49687
	* config/avr/avr.md (mulhi3): Use register_or_s9_operand for
	operand2 and expand appropriately if there is a CONST_INT in
	operand2.
	(usmulqihi3): New insn.
	(*sumulqihi3): New insn.
	(*osmulqihi3): New insn.
	(*oumulqihi3): New insn.
	(*muluqihi3.uconst): New insn_and_split.
	(*muluqihi3.sconst): New insn_and_split.
	(*mulsqihi3.sconst): New insn_and_split.
	(*mulsqihi3.uconst): New insn_and_split.
	(*mulsqihi3.oconst): New insn_and_split.
	(*ashifthi3.signx.const): New insn_and_split.
	(*ashifthi3.signx.const7): New insn_and_split.
	(*ashifthi3.zerox.const): New insn_and_split.
	(mulsqihi3): New insn.
	(muluqihi3): New insn.
	(muloqihi3): New insn.
	* config/avr/predicates.md (const_2_to_7_operand): New.
	(const_2_to_6_operand): New.
	(u8_operand): New.
	(s8_operand): New.
	(o8_operand): New.
	(s9_operand): New.
	(register_or_s9_operand): New.

From-SVN: r176527
2011-07-20 17:23:28 +00:00
Georg-Johann Lay
73451ae785 * config/avr/avr.c (avr_rtx_costs): Set cost of SYMBOL_REF to 0.
From-SVN: r176516
2011-07-20 15:10:13 +00:00
Anatoly Sokolov
a8c44c522d target.def (class_max_nregs): New hook.
* target.def (class_max_nregs): New hook.
	* doc/tm.texi.in (TARGET_CLASS_MAX_NREGS): Document.
	* doc/tm.texi: Regenerate.
	* targhooks.c (default_class_max_nregs): New function.
	* targhooks.h (default_class_max_nregs): Declare.
	* ira.h (target_ira): Change type x_ira_reg_class_max_nregs and
	x_ira_reg_class_min_nregs arrays to unsigned char.
	* ira.c (setup_reg_class_nregs): Use TARGET_CLASS_MAX_NREGS target
	hook instead of CLASS_MAX_NREGS macro.
	* reginfo.c (restore_register_info): Ditto.
	* ira-conflicts.c (process_regs_for_copy): Use
	ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro.
	Change type rclass and aclass vars to reg_class_t.
	* ira-costs.c (record_reg_classes): Use ira_reg_class_max_nregs
	array instead of CLASS_MAX_NREGS macro. Change type rclass var to
	reg_class_t.
	* reload.c (combine_reloads, find_reloads, find_reloads_address_1):
	Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro.

	* config/i386/i386.h (CLASS_MAX_NREGS): Remove.
	* config/i386/i386.c (ix86_class_max_nregs): New function.
	(ix86_register_move_cost): Use TARGET_CLASS_MAX_NREGS target hook
	instead of CLASS_MAX_NREGS macro.
	(TARGET_CLASS_MAX_NREGS): Define.
	* config/avr/avr.h (CLASS_MAX_NREGS): Remove.
	* config/avr/avr-protos.h (class_max_nregs): Remove declaration.
	* config/avr/avr.c (class_max_nregs): Remove function.
	* config/alpha/alpha.h (CLASS_MAX_NREGS): Remove.
	* config/spu/spu.h (CLASS_MAX_NREGS): Remove.
	* config/mep/mep.h (CLASS_MAX_NREGS): Remove.
	* config/m32r/m32r.h (CLASS_MAX_NREGS): Remove.
	* config/microblaze/microblaze.h (CLASS_MAX_NREGS): Remove.
	* config/xtensa/xtensa.h (CLASS_MAX_NREGS): Remove.
	* config/stormy16/stormy16.h (CLASS_MAX_NREGS): Remove.
	* config/lm32/lm32.h (CLASS_MAX_NREGS): Remove.
	* config/moxie/moxie.h (CLASS_MAX_NREGS): Remove.
	* config/iq2000/iq2000.h (CLASS_MAX_NREGS): Remove.
	* config/mn10300/mn10300.h (CLASS_MAX_NREGS): Remove.
	* config/score/score.h (CLASS_MAX_NREGS): Remove.
	* config/vax/vax.h (CLASS_MAX_NREGS): Remove.
	* config/h8300/h8300.h (CLASS_MAX_NREGS): Remove.
	* config/v850/v850.h (CLASS_MAX_NREGS): Remove.

From-SVN: r176490
2011-07-20 02:34:31 +04:00
Georg-Johann Lay
d772f97cb6 re PR target/49487 ([avr] ICE in bytewise rotate)
PR target/49487
	* config/avr/avr.md (rotl<mode>3): Generate SCRATCH instead
	of REG.
	(*rotw<mode>): Use const_int_operand for operand2.
	Use match_scatch for operand3.
	(*rotb<mode>): Ditto
	* config/avr/avr.c (avr_rotate_bytes): Treat SCRATCH.

From-SVN: r176276
2011-07-14 15:10:12 +00:00
Georg-Johann Lay
eb1dcdffa7 re PR target/43746 (-fmerge-constants and -fmerge-all-constants don't work at AVR target)
gcc/
	PR target/43746
	* config/avr/elf.h (TARGET_ASM_SELECT_SECTION): Remove,
	i.e. use default_elf_select_section.
	(TARGET_HAVE_SWITCHABLE_BSS_SECTIONS): Remove.
	(READONLY_DATA_SECTION_ASM_OP): Remove.
	(TARGET_ASM_NAMED_SECTION): Move from here...
	* config/avr/avr.c: ...to here.
	(avr_asm_init_sections): Set unnamed callback of
	readonly_data_section.
	(avr_asm_named_section): Make static.
	
testsuite/
	PR target/43746
	* gcc.dg/array-quals-1.c: Don't xfail on AVR.

From-SVN: r176262
2011-07-14 07:49:14 +00:00
Georg-Johann Lay
7e4ec472ee re PR target/39633 ([avr] loop bug: missing 8-bit comparison (*cmpqi))
gcc/
	PR target/39633
	* config/avr/avr.c (notice_update_cc): For ashiftrt:QI, only
	offsets 1..5 set cc0 in a usable way.

testsuite/
	PR target/39633
	* gcc.target/avr/torture/pr39633.c: New test case.

From-SVN: r176141
2011-07-11 10:13:30 +00:00