Commit f9e4a411 by Sandra Loosemore Committed by Sandra Loosemore

Add mips16/nomips16 function attributes and -mflip-mips16 option for testing…

Add mips16/nomips16 function attributes and -mflip-mips16 option for testing mixed-mode compilation.

2007-09-05  Sandra Loosemore  <sandra@codesourcery.com>
	    David Ung  <davidu@mips.com>
            Nigel Stephens <nigel@mips.com>

	Add mips16/nomips16 function attributes and -mflip-mips16 option
	for testing mixed-mode compilation.

	gcc/

	* config/mips/mips.opt (mflip-mips16): New.

	* config/mips/mips.h (SYMBOL_FLAG_MIPS16_FUNC): Define.
	(SYMBOL_FLAG_MIPS16_FUNC_P): Define.

	* config/mips/mips.c (mips_base_target_flags): New.
	(mips_base_mips16): New.
	(mips_base_schedule_insns): New.
	(mips_base_reorder_blocks_and_partition): New.
	(mips_base_align_loops): New.
	(mips_base_align_jumps): New.
	(mips_base_align_functions): New.
	(mips16_flipper): New.
	(mips_attribute_table): Add "mips16" and "nomips16" entries.
	(TARGET_SET_CURRENT_FUNCTION): Define.
	(mips_mips16_type_p, mips_nomips16_type_p): New.
	(mips_comp_type_attributes): Check mips16/nomips16 attributes.
	(mips_function_ok_for_sibcall): Make it deal with functions with
	mips16 attributes.
	(mips_init_split_addresses): New, split out from override_options.
	(mips_init_relocs): New, split out from override_options.
	(was_mips16_p): New.
	(mips_set_mips16_mode): New, split out from override_options.
	(mips_set_current_function): New.
	(override_options):  Add sorry for unsupported mips16/pic
	combination.  Remove error for mips16/dsp combination.	Save
	base option settings.  
	(mips_file_start): Move mips16 mode setting output from here....
	(mips_output_function_prologue): ....to here.
	(mips_output_mi_thunk): Check for mips16 function.
	(build_mips16_function_stub): Don't set .mips16 here.
	(build_mips16_call_stub): Likewise.
	(mips_expand_builtin): Error in mips16 mode.
	(mips_use_mips16_mode_p): New.
	(mips_encode_section_info): Check for mips16 function, and set
	SYMBOL_REF_FLAGS accordingly.

	* doc/extend.texi (Function Attributes): Document new
	mips16/nomips16 attributes.
	* doc/invoke.texi (Option Summary): Add -mflip-mips16.
	(MIPS Options): Document -mflip-mips16.

	gcc/testsuite/
	* gcc.target/mips/mips16-attributes.c: New.

Co-Authored-By: David Ung <davidu@mips.com>
Co-Authored-By: Nigel Stephens <nigel@mips.com>

From-SVN: r128134
parent edede024
2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
David Ung <davidu@mips.com>
Nigel Stephens <nigel@mips.com>
Add mips16/nomips16 function attributes and -mflip-mips16 option
for testing mixed-mode compilation.
* config/mips/mips.opt (mflip-mips16): New.
* config/mips/mips.h (SYMBOL_FLAG_MIPS16_FUNC): Define.
(SYMBOL_FLAG_MIPS16_FUNC_P): Define.
* config/mips/mips.c (mips_base_target_flags): New.
(mips_base_mips16): New.
(mips_base_schedule_insns): New.
(mips_base_reorder_blocks_and_partition): New.
(mips_base_align_loops): New.
(mips_base_align_jumps): New.
(mips_base_align_functions): New.
(mips16_flipper): New.
(mips_attribute_table): Add "mips16" and "nomips16" entries.
(TARGET_SET_CURRENT_FUNCTION): Define.
(mips_mips16_type_p, mips_nomips16_type_p): New.
(mips_comp_type_attributes): Check mips16/nomips16 attributes.
(mips_function_ok_for_sibcall): Make it deal with functions with
mips16 attributes.
(mips_init_split_addresses): New, split out from override_options.
(mips_init_relocs): New, split out from override_options.
(was_mips16_p): New.
(mips_set_mips16_mode): New, split out from override_options.
(mips_set_current_function): New.
(override_options): Add sorry for unsupported mips16/pic
combination. Remove error for mips16/dsp combination. Save
base option settings.
(mips_file_start): Move mips16 mode setting output from here....
(mips_output_function_prologue): ....to here.
(mips_output_mi_thunk): Check for mips16 function.
(build_mips16_function_stub): Don't set .mips16 here.
(build_mips16_call_stub): Likewise.
(mips_expand_builtin): Error in mips16 mode.
(mips_use_mips16_mode_p): New.
(mips_encode_section_info): Check for mips16 function, and set
SYMBOL_REF_FLAGS accordingly.
* doc/extend.texi (Function Attributes): Document new
mips16/nomips16 attributes.
* doc/invoke.texi (Option Summary): Add -mflip-mips16.
(MIPS Options): Document -mflip-mips16.
2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
gcc/
* config/mips/mips.c (mips_legitimize_tls_address): Call sorry
if we encounter TLS address in MIPS16 mode.
(mips_legitimize_const_move): Check cannot_force_const_mem for
......
......@@ -2301,6 +2301,11 @@ typedef struct mips_args {
#define SYMBOL_REF_LONG_CALL_P(X) \
((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_LONG_CALL) != 0)
/* Flag to mark a function decl symbol a "mips16" function. */
#define SYMBOL_FLAG_MIPS16_FUNC (SYMBOL_FLAG_MACH_DEP << 1)
#define SYMBOL_REF_MIPS16_FUNC_P(RTX) \
((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_MIPS16_FUNC) != 0)
/* True if we're generating a form of MIPS16 code in which jump tables
are stored in the text section and encoded as 16-bit PC-relative
offsets. This is only possible when general text loads are allowed,
......
......@@ -42,6 +42,10 @@ mbranch-likely
Target Report Mask(BRANCHLIKELY)
Use Branch Likely instructions, overriding the architecture default
mflip-mips16
Target Report Var(TARGET_FLIP_MIPS16)
Switch on/off MIPS16 ASE on alternating functions for compiler testing
mcheck-zero-division
Target Report Mask(CHECK_ZERO_DIV)
Trap on integer divide by zero
......
......@@ -2202,6 +2202,24 @@ long as the old pointer is never referred to (including comparing it
to the new pointer) after the function returns a non-@code{NULL}
value.
@item mips16/nomips16
@cindex @code{mips16} attribute
@cindex @code{nomips16} attribute
On MIPS targets, you can use the @code{mips16} and @code{nomips16}
function attributes to locally select or turn off MIPS16 code generation.
A function with the @code{mips16} attribute is emitted as MIPS16 code,
while MIPS16 code generation is disabled for functions with the
@code{nomips16} attribute. These attributes override the
@option{-mips16} and @option{-mno-mips16} options on the command line
(@pxref{MIPS Options}).
When compiling files containing mixed MIPS16 and non-MIPS16 code, the
preprocessor symbol @code{__mips16} reflects the setting on the command line,
not that within individual functions. Mixed MIPS16 and non-MIPS16 code
may interact badly with some GCC extensions such as @code{__builtin_apply}
(@pxref{Constructing Calls}).
@item model (@var{model-name})
@cindex function addressability on the M32R/D
@cindex variable addressability on the IA-64
......
......@@ -620,7 +620,8 @@ Objective-C and Objective-C++ Dialects}.
@emph{MIPS Options}
@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol
-mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
-mips16 -mno-mips16 -mflip-mips16 @gol
-mabi=@var{abi} -mabicalls -mno-abicalls @gol
-mshared -mno-shared -mxgot -mno-xgot -mgp32 -mgp64 @gol
-mfp32 -mfp64 -mhard-float -msoft-float @gol
-msingle-float -mdouble-float -mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
......@@ -11626,6 +11627,16 @@ Equivalent to @samp{-march=mips64}.
Generate (do not generate) MIPS16 code. If GCC is targetting a
MIPS32 or MIPS64 architecture, it will make use of the MIPS16e ASE@.
MIPS16 code generation can also be controlled on a per-function basis
by means of @code{mips16} and @code{nomips16} attributes.
@xref{Function Attributes}, for more information.
@item -mflip-mips16
@opindex mflip-mips16
Generate MIPS16 code on alternating functions. This option is provided
for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
not intended for ordinary use in compiling user code.
@item -mabi=32
@itemx -mabi=o64
@itemx -mabi=n32
......
2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
David Ung <davidu@mips.com>
Nigel Stephens <nigel@mips.com>
* gcc.target/mips/mips16-attributes.c: New.
2007-09-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31564
/* Verify that mips16 and nomips16 attributes work, checking all combinations
of calling a nomips16/mips16/default function from a nomips16/mips16/default
function. */
/* { dg-do run { target mipsisa*-*-elf* } } */
#include <stdlib.h>
#define ATTR1 __attribute__ ((nomips16))
#define ATTR2 __attribute__ ((mips16))
#define ATTR3
double ATTR1
f1 (int i, float f, double d)
{
return i + f + d;
}
double ATTR2
f2 (int i, float f, double d)
{
return i + f + d;
}
double ATTR3
f3 (int i, float f, double d)
{
return i + f + d;
}
void ATTR1
g1 (int i, float f, double d)
{
double r = i + f + d;
if (f1 (i, f, d) != r)
abort ();
if (f2 (i+1, f+1, d+1) != r + 3)
abort ();
if (f3 (i+2, f+2, d+2) != r + 6)
abort ();
}
void ATTR2
g2 (int i, float f, double d)
{
double r = i + f + d;
if (f1 (i, f, d) != r)
abort ();
if (f2 (i+1, f+1, d+1) != r + 3)
abort ();
if (f3 (i+2, f+2, d+2) != r + 6)
abort ();
}
void ATTR3
g3 (int i, float f, double d)
{
double r = i + f + d;
if (f1 (i, f, d) != r)
abort ();
if (f2 (i+1, f+1, d+1) != r + 3)
abort ();
if (f3 (i+2, f+2, d+2) != r + 6)
abort ();
}
int ATTR3
main (void)
{
int i = 1;
float f = -2.0;
double d = 3.0;
g1 (i, f, d);
g2 (i, f, d);
g3 (i, f, d);
exit (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment