public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Reintroduce -mflat option on SPARC
@ 2011-02-23 13:51 Laurent Rougé
  2011-02-26  0:18 ` Eric Botcazou
  2011-04-12 17:44 ` Eric Botcazou
  0 siblings, 2 replies; 9+ messages in thread
From: Laurent Rougé @ 2011-02-23 13:51 UTC (permalink / raw)
  To: gcc-patches, Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 2162 bytes --]

Hello,

This patch reintroduce the -mflat option on SPARC. The -mfalt option was 
deprecated in february 2004 with GCC 3.4.6. Now, with the support of 
LEON processor on GCC, this option has found a new interest.

The patch has been tested, validated and made with Eric collaboration.

Please apply this patch on mainline and backport it to 4.6 branch.

The patch change :
* doc/invoke.texi (SPARC options): Add -mflat option.
* config/sparc/sparc.c: Likewise.
(load_pic_register): Remove static and prototype.
(sparc_expand_prologue): Rename into sparc_nonflat_expland_prologue.
(sparc_expand_epilogue): Rename into sparc_nonflat_expand_epilogue.
(sparc_can_use_return_insn_p): Add TARGET_FLAT handling.
(sparc_function_ok_for_sibcall): Likewise.
(sparc_frame_pointer_required): Likewise.
(struct sparc_frame_info, current_frame_info, zero_frame_info): Add.
(RETURN_ADDR_REGNUM, HARD_FRAME_POINTER_MASK,
RETURN_ADDR_MASK): Define.
(sparc_expand_prologue): New.
(sparc_expland_epilogue): Likewise.
(sparc_flat_must_save_register_p): Likewise.
(sparc_flat_compute_frame_size): Likewise.
(sparc_flat_save_or_restore): Likewise.
(sparc_flat_expand_prologue): Likewise.
(sparc_flat_expand_epilogue): Likewise.
(flat_output_return): Likewise.
(sparc_flat_eligible_for_return_delay): Likewise.
* config/sparc/sparc.h:
(CPP_CPU_SPEC): Add mflat option.
(SPARC_INCOMING_INT_ARG_FIRST): Add TARGET_FLAT handling.
(CONDITIONAL_REGISTER_USAGE): Likewise.
(INITIAL_ELIMINATION_OFFSET): Likewise.
(INCOMING_REGNO): Likewise.
(OUTGOING_REGNO): Likewise.
(LOCAL_REGNO): Likewise.
(EPILOGUE_USES): Likewise.
(ELIGIBLE_FOR_EPILOGUE_DELAY): Define.
* config/sparc/sparc.md:
("flat" attribute): Add.
(return_internal): Add TARGET_FLAT and "flat" attribute handling.
(do_builtin_setjmp_setup): Likewise.
(exception_receiver): Add.
(builtin_setjmp_receiver): Likewise.
* config/sparc/sparc.opt: Define mflat option.
* config/sparc/sparc-protos.h: Add sparc_flat_* prototypes.
(load_pic_register prototype): Add.
* config/sparc/t-elf:
(MULTILIB_OPTIONS): Add mflat option.
(MULTILIB_DIRNAMES): Add flat folder.
* gcc.dg/20020503-1.c: Add -mflat dg-options.

Regards,
Laurent Rougé.


[-- Attachment #2: gcc-4.5.1-flat.diff.gz --]
[-- Type: application/gzip, Size: 10365 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-02-23 13:51 Reintroduce -mflat option on SPARC Laurent Rougé
@ 2011-02-26  0:18 ` Eric Botcazou
  2011-04-12 17:44 ` Eric Botcazou
  1 sibling, 0 replies; 9+ messages in thread
From: Eric Botcazou @ 2011-02-26  0:18 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

> This patch reintroduce the -mflat option on SPARC. The -mfalt option was
> deprecated in february 2004 with GCC 3.4.6. Now, with the support of
> LEON processor on GCC, this option has found a new interest.

Thanks for crafting and submitting this.

> Please apply this patch on mainline and backport it to 4.6 branch.

Yes, I think this is the best course of action.  We're running out of time as 
far as 4.6.0 is concerned, given that the SPARC is a "primary" architecture, 
so let's wait until after mainline reopens and backport the patch for 4.6.1.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-02-23 13:51 Reintroduce -mflat option on SPARC Laurent Rougé
  2011-02-26  0:18 ` Eric Botcazou
@ 2011-04-12 17:44 ` Eric Botcazou
  2011-04-14 18:55   ` Laurent Rougé
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2011-04-12 17:44 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

> This patch reintroduce the -mflat option on SPARC. The -mfalt option was
> deprecated in february 2004 with GCC 3.4.6. Now, with the support of
> LEON processor on GCC, this option has found a new interest.

Just a couple of remarks:
 - the epilogue isn't fully RTL-ized,
 - delay slot filling for epilogue doesn't work: DELAY_SLOTS_FOR_EPILOGUE isn't 
defined anymore so defining ELIGIBLE_FOR_EPILOGUE_DELAY is useless.

I'm going to fix these minor issues, as well as try to refactor the code a bit.

One question: I presume there is no point in supporting -mflat in 64-bit mode 
for the time being?

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-04-12 17:44 ` Eric Botcazou
@ 2011-04-14 18:55   ` Laurent Rougé
  2011-05-17 13:06     ` Eric Botcazou
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Rougé @ 2011-04-14 18:55 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches


>> This patch reintroduce the -mflat option on SPARC. The -mfalt option was
>> deprecated in february 2004 with GCC 3.4.6. Now, with the support of
>> LEON processor on GCC, this option has found a new interest.
> Just a couple of remarks:
>  - the epilogue isn't fully RTL-ized,
>  - delay slot filling for epilogue doesn't work: DELAY_SLOTS_FOR_EPILOGUE isn't 
> defined anymore so defining ELIGIBLE_FOR_EPILOGUE_DELAY is useless.
>
> I'm going to fix these minor issues, as well as try to refactor the code a bit.

Please, it will be interesting to see corrections.

> One question: I presume there is no point in supporting -mflat in 64-bit mode 
> for the time being?

Right, -mflat option should only be for 32-bit SPARC target.

Regards,
Laurent.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-04-14 18:55   ` Laurent Rougé
@ 2011-05-17 13:06     ` Eric Botcazou
  2011-05-18 14:36       ` Eric Botcazou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2011-05-17 13:06 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

> Right, -mflat option should only be for 32-bit SPARC target.

OK, let's keep it that way for now.

Another question: why does the model hijack %i7 to use it as frame pointer, 
instead of just using %fp?  AFAICS both are kept as fixed registers by the 
code so the model seems to be wasting 1 register (2 without frame pointer).

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-05-17 13:06     ` Eric Botcazou
@ 2011-05-18 14:36       ` Eric Botcazou
  2011-05-26 20:29         ` Laurent Rougé
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2011-05-18 14:36 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

> Another question: why does the model hijack %i7 to use it as frame pointer,
> instead of just using %fp?  AFAICS both are kept as fixed registers by the
> code so the model seems to be wasting 1 register (2 without frame pointer).

Related question: why saving the Local and In registers in the frame instead of 
at their standard location, right above the stack pointer?  It would seem to 
me that the layout of the frame can be identical to the standard one.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-05-18 14:36       ` Eric Botcazou
@ 2011-05-26 20:29         ` Laurent Rougé
  2011-05-26 21:54           ` Eric Botcazou
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Rougé @ 2011-05-26 20:29 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

Dear Eric,

In fact, I haven't tried to make big changes in how mflat option was
implemented. From my point of view, the goal was to facilitate mflat
option reintroduction first, and then improve it after. I hope you
understand. I know there's some place to improve, maybe you have start
to do it ?

So why mflat is like that we should ask the questions to 'wilson' who
did it in 92 (see revision 1275) !

Regards,
Laurent.

Le 18/05/2011 12:31, Eric Botcazou a écrit :
>> Another question: why does the model hijack %i7 to use it as frame pointer,
>> instead of just using %fp?  AFAICS both are kept as fixed registers by the
>> code so the model seems to be wasting 1 register (2 without frame pointer).
> Related question: why saving the Local and In registers in the frame instead of 
> at their standard location, right above the stack pointer?  It would seem to 
> me that the layout of the frame can be identical to the standard one.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-05-26 20:29         ` Laurent Rougé
@ 2011-05-26 21:54           ` Eric Botcazou
  2011-06-10 11:11             ` Eric Botcazou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2011-05-26 21:54 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 3959 bytes --]

> In fact, I haven't tried to make big changes in how mflat option was
> implemented. From my point of view, the goal was to facilitate mflat
> option reintroduction first, and then improve it after. I hope you
> understand. I know there's some place to improve, maybe you have start
> to do it ?

Yes, I have changed a few things, patch attached.  The basic stuff works, but 
not yet the fancy features (non-local gotos, setjmp/longjmp and exceptions).  
I'm also working on the GDB side.

> So why mflat is like that we should ask the questions to 'wilson' who
> did it in 92 (see revision 1275) !

Indeed, thanks for doing the archaeology. :-)


	* doc/invoke.texi (SPARC options): Add -mflat.
	* config/sparc/sparc.opt: Likewise.
	* config/sparc/sparc-protos.h (sparc_flat_expand_prologue): Declare.
	(sparc_flat_expand_epilogue): Likewise.
	(load_got_register): Likewise.
	* config/sparc/sparc.h (CPP_CPU_SPEC): Define _FLAT in flat mode.
	(SPARC_INCOMING_INT_ARG_FIRST): Add TARGET_FLAT handling.
	(INCOMING_REGNO): Likewise.
	(OUTGOING_REGNO): Likewise.
	(LOCAL_REGNO): Likewise.
	(FIXED_REGISTERS): Set 0 for %fp.
	(CALL_USED_REGISTERS): Likewise.
	(RETURN_ADDR_REGNUM): Define.
	(RETURN_ADDR_RTX): Use it.
	(EH_RETURN_HANDLER_RTX): Use it.
	(INCOMING_RETURN_ADDR_REGNUM): Define.
	(INCOMING_RETURN_ADDR_RTX): Use it.
	(DWARF_FRAME_RETURN_COLUMN): Likewise.
	(EH_RETURN_REGNUM): Define.
	(EH_RETURN_STACKADJ_RTX): Use it.
	(EPILOGUE_USES): Use them and add TARGET_FLAT handling.
	* config/sparc/sparc.c (struct machine_function): Add frame_size,
	apparent_frame_size, frame_base_reg, frame_base_offset, n_regs
	and save_local_in_regs_p fields.
	(sparc_frame_size, sparc_apparent_frame_size, sparc_frame_base_reg,
	sparc_frame_base_offset, sparc_n_regs, sparc_save_local_in_regs_p):
	New macros.
	(sparc_option_override): Error out if -fcall-saved-REG is specified
	for Out registers.
	(eligible_for_restore_insn): Fix formatting.
	(eligible_for_return_delay): Likewise.  Add TARGET_FLAT handling.
	(load_got_register): Make global.
	(save_global_or_fp_reg_p): New predicate.
	(incoming_return_addr_reg_clobbered_p): Likewise.
	(save_local_or_in_reg_p): Likewise.
	(sparc_compute_frame_size): Use them.  Add TARGET_FLAT handling.
	(SORR_SAVE, SORR_RESTORE): Delete.
	(sorr_pred_t): New typedef.
	(sorr_act_t): New enum.
	(save_or_restore_regs): Rename to...
	(emit_save_or_restore): ...this.  Changed type of LOW/HIGH parameters
	remove ACTION parameter, add LEAF_FUNCTION_P, SAVE_P, ACTION_TRUE and
	ACTION_FALSE parameters.  Implement more general mechanism.  Add CFI
	information for double-word saves in 32-bit mode.
	(emit_adjust_base_to_offset): New function extracted from...
	(emit_save_or_restore_regs): ...this.  Rename the rest to...
	(emit_save_or_restore_regs_global_fp_regs): ...this.
	(emit_save_or_restore_regs_local_in_regs): New function.
	(gen_create_flat_frame_[123]): New functions.
	(sparc_expand_prologue): Use SIZE local variable.  Adjust.
	(sparc_flat_expand_prologue): New function.
	(sparc_asm_function_prologue): Add TARGET_FLAT handling.
	(sparc_expand_epilogue): Use SIZE local variable.  Adjust.
	(sparc_flat_expand_epilogue): New function.
	(sparc_can_use_return_insn_p):  Add TARGET_FLAT handling.
	(output_return): Likewise.
	(sparc_function_ok_for_sibcall): Likewise.
	(sparc_frame_pointer_required): Likewise.
	(sparc_can_eliminate): Call sparc_frame_pointer_required directly.
	(sparc_conditional_register_usage): If TARGET_FLAT, disable leaf
	function optimization.
	* config/sparc/sparc.md (flat): New attribute.
	(prologue): Add TARGET_FLAT handling.
	(epilogue): Likewise.
	(sibcall_epilogue): Likewise.
	(save_register_window): Disable if TARGET_FLAT.
	(create_flat_frame_[123]): New patterns.
	(return_internal): Add TARGET_FLAT handling.
	(flush_register_windows): Likewise.
	(goto_handler_and_restore): Likewise.
	(exception_receiver): New pattern.
	(builtin_setjmp_receiver): Likewise.


-- 
Eric Botcazou

[-- Attachment #2: gcc-4.7-mflat-2.diff.gz --]
[-- Type: application/x-gzip, Size: 12293 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reintroduce -mflat option on SPARC
  2011-05-26 21:54           ` Eric Botcazou
@ 2011-06-10 11:11             ` Eric Botcazou
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Botcazou @ 2011-06-10 11:11 UTC (permalink / raw)
  To: Laurent Rougé; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 5546 bytes --]

> Yes, I have changed a few things, patch attached.  The basic stuff works,
> but not yet the fancy features (non-local gotos, setjmp/longjmp and
> exceptions). I'm also working on the GDB side.

I've now installed the attached version.  It adds support for the above fancy 
features plus sibling calls, frame pointer elimination and 64-bit code in flat 
mode.  I'll submit the associated GDB patch sometime next week.

It also contains a few changes for the regular mode:
 - %fp isn't a fixed register anymore,
 - EXIT_IGNORE_STACK is defined to 1 unconditionally,
 - __builtin_eh_return is more correctly implemented,
 - sparc_legitimate_address_p was wrongly rejecting offsettable addresses when 
the offset was too close to 4095.

Bootstrapped/regtested on SPARC/Solaris and SPARC64/Solaris.  The C testsuite 
is 100% clean in flat mode; for the others, you need at least -mflat multlibs.


2011-06-10  Eric Botcazou  <ebotcazou@adacore.com>
	    Laurent Rougé  <laurent.rouge@menta.fr>

	* doc/invoke.texi (SPARC options): Add -mflat.
	* config/sparc/sparc.opt: Likewise.
	* config/sparc/sparc-protos.h (sparc_expand_epilogue): Add parameter.
	(sparc_flat_expand_prologue): Declare.
	(sparc_flat_expand_epilogue): Likewise.
	* config/sparc/sparc.h (CPP_CPU_SPEC): Do not handle -msoft-float.
	(CPP_ENDIAN_SPEC): Replace with...
	(CPP_OTHER_SPEC): ...this.  Also handle -mflat and -msoft-float.
	(CPP_SPEC): Adjust to above change.
	(EXTRA_SPECS): Likewise.
	(SPARC_INCOMING_INT_ARG_FIRST): Add TARGET_FLAT handling.
	(INCOMING_REGNO): Likewise.
	(OUTGOING_REGNO): Likewise.
	(LOCAL_REGNO): Likewise.
	(SETUP_FRAME_ADDRESSES): Likewise.
	(FIXED_REGISTERS): Set 0 for %fp.
	(CALL_USED_REGISTERS): Likewise.
	(INITIAL_ELIMINATION_OFFSET): Pass current_function_is_leaf.
	(EXIT_IGNORE_STACK): Define to 1 unconditionally.
	(RETURN_ADDR_REGNUM): Define.
	(RETURN_ADDR_RTX): Use it.
	(INCOMING_RETURN_ADDR_REGNUM): Define.
	(INCOMING_RETURN_ADDR_RTX): Use it.
	(DWARF_FRAME_RETURN_COLUMN): Likewise.
	(EH_RETURN_REGNUM): Define.
	(EH_RETURN_STACKADJ_RTX): Use it.
	(EH_RETURN_HANDLER_RTX): Delete.
	(EPILOGUE_USES): Use them and add TARGET_FLAT handling.
	* config/sparc/sparc.c (apparent_fsize, actual_fsize, num_gfregs):
	Delete.
	(struct machine_function): Add frame_size, apparent_frame_size,
	frame_base_reg, frame_base_offset, n_global_fp_regs and
	save_local_in_regs_p fields.
	(sparc_frame_size, sparc_apparent_frame_size, sparc_frame_base_reg,
	sparc_frame_base_offset, sparc_n_global_fp_regs,
	sparc_save_local_in_regs_p): New macros.
	(sparc_option_override): Error out if -fcall-saved-REG is specified
	for Out registers.
	(eligible_for_restore_insn): Fix formatting.
	(eligible_for_return_delay): Likewise.  Add TARGET_FLAT handling.
	(eligible_for_sibcall_delay): Likewise.
	(RTX_OK_FOR_OFFSET_P, RTX_OK_FOR_OLO10_P): Add MODE parameter.
	(sparc_legitimate_address_p): Adjust to above change.
	(save_global_or_fp_reg_p): New predicate.
	(return_addr_reg_needed_p): Likewise.
	(save_local_or_in_reg_p): Likewise.
	(sparc_compute_frame_size): Use them.  Add TARGET_FLAT handling.
	(SORR_SAVE, SORR_RESTORE): Delete.
	(sorr_pred_t): New typedef.
	(sorr_act_t): New enum.
	(save_or_restore_regs): Rename to...
	(emit_save_or_restore_regs): ...this.  Change type of LOW and HIGH
	parameters, remove ACTION parameter, add LEAF_FUNCTION_P, SAVE_P,
	ACTION_TRUE and ACTION_FALSE parameters.  Implement more general
	mechanism.  Add CFI information for double-word saves in 32-bit mode.
	(emit_adjust_base_to_offset): New function extracted from...
	(emit_save_or_restore_regs): ...this.  Rename the rest to...
	(emit_save_or_restore_regs_global_fp_regs): ...this.
	(emit_save_or_restore_regs_local_in_regs): New function.
	(gen_create_flat_frame_[123]): New functions.
	(sparc_expand_prologue): Use SIZE local variable.  Adjust.
	(sparc_flat_expand_prologue): New function.
	(sparc_asm_function_prologue): Add TARGET_FLAT handling.
	(sparc_expand_epilogue): Use SIZE local variable.  Adjust.
	(sparc_flat_expand_epilogue): New function.
	(sparc_can_use_return_insn_p): Add TARGET_FLAT handling.
	(output_return): Likewise.
	(output_sibcall): Likewise.
	(sparc_output_mi_thunk): Likewise.
	(sparc_frame_pointer_required): Likewise.
	(sparc_conditional_register_usage): If TARGET_FLAT, disable the leaf
	function optimization.
	* config/sparc/sparc.md (flat): New attribute.
	(prologue): Add TARGET_FLAT handling.
	(save_register_window): Disable if TARGET_FLAT.
	(create_flat_frame_[123]): New patterns.
	(epilogue): Add TARGET_FLAT handling.
	(sibcall_epilogue): Likewise.
	(eh_return): New expander.
	(eh_return_internal): New insn and splitter.
	(return_internal): Add TARGET_FLAT handling.
	(untyped_return): Remove bogus test and use RETURN_ADDR_REGNUM.
	(save_stack_nonlocal): Use RETURN_ADDR_REGNUM.
	(nonlocal_goto): Add TARGET_FLAT handling.
	* config/sparc/t-elf: Add -mflat multilib.
	* config/sparc/t-leon: Likewise.


2011-06-10  Eric Botcazou  <ebotcazou@adacore.com>
            Laurent Rougé  <laurent.rouge@menta.fr>

	* gcc.dg/20020503-1.c: Add back -mflat option on the SPARC.
	* gcc.target/sparc/sparc-ret.c: Skip if -mflat is passed.


2011-06-10  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/linux-unwind.h (STACK_BIAS): Define.
	(sparc64_fallback_frame_state): Use it.
	(sparc64_frob_update_context): Further adjust context.
	* config/sparc/sol2-unwind.h (sparc64_frob_update_context): Likewise.
	* config/sparc/sol2-ci.S: Add TARGET_FLAT handling.
	* config/sparc/sol2-cn.S: Likewise.


-- 
Eric Botcazou

[-- Attachment #2: gcc-4.7-mflat-3.diff.gz --]
[-- Type: application/x-gzip, Size: 16313 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-06-10 10:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-23 13:51 Reintroduce -mflat option on SPARC Laurent Rougé
2011-02-26  0:18 ` Eric Botcazou
2011-04-12 17:44 ` Eric Botcazou
2011-04-14 18:55   ` Laurent Rougé
2011-05-17 13:06     ` Eric Botcazou
2011-05-18 14:36       ` Eric Botcazou
2011-05-26 20:29         ` Laurent Rougé
2011-05-26 21:54           ` Eric Botcazou
2011-06-10 11:11             ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).