aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/mips
diff options
context:
space:
mode:
authorChris Demetriou <cgd@broadcom.com>2002-08-07 02:57:53 +0000
committerChris Demetriou <cgd@gcc.gnu.org>2002-08-06 19:57:53 -0700
commitaf34e51e35a9db97532a89dac909cc50c3b9ac6c (patch)
treec13b0c62cab6a17157a952037ef5199d0d414ea6 /gcc/config/mips
parentf538618effe28e22c24338e973a5916c36771651 (diff)
downloadgcc-af34e51e35a9db97532a89dac909cc50c3b9ac6c.zip
gcc-af34e51e35a9db97532a89dac909cc50c3b9ac6c.tar.gz
gcc-af34e51e35a9db97532a89dac909cc50c3b9ac6c.tar.bz2
mips.c (override_options): Set MASK_BRANCHLIKELY in target_flags based on ISA...
2002-08-06 Chris Demetriou <cgd@broadcom.com> * config/mips/mips.c (override_options): Set MASK_BRANCHLIKELY in target_flags based on ISA, if it was not set on the command line. Warn if MASK_BRANCHLIKLEY is set but the ISA does not support Branch Likely instructions. * config/mips/mips.h (MASK_BRANCHLIKLEY): New macro. (TARGET_BRANCHLIKELY): Likewise. (TARGET_SWITCHES): Add -mbranch-likely and -mno-branch-likely. (GENERATE_BRANCHLIKELY): Use TARGET_BRANCHLIKELY rather than ISA_HAS_BRANCHLIKELY. (ISA_HAS_BRANCHLIKELY): Do not include MIPS16 check. * doc/invoke.texi: Document new MIPS -mbranch-likely and -mno-branch-likely options. From-SVN: r56088
Diffstat (limited to 'gcc/config/mips')
-rw-r--r--gcc/config/mips/mips.c25
-rw-r--r--gcc/config/mips/mips.h13
2 files changed, 35 insertions, 3 deletions
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 31cd0d0..aa6be83 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -5177,6 +5177,31 @@ override_options ()
if (mips_abi != ABI_32 && mips_abi != ABI_O64)
flag_pcc_struct_return = 0;
+ if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0)
+ {
+ /* If neither -mbranch-likely nor -mno-branch-likely was given
+ on the command line, set MASK_BRANCHLIKELY based on the target
+ architecture.
+
+ By default, we enable use of Branch Likely instructions on
+ all architectures which support them except for MIPS32 and MIPS64
+ (i.e., the generic MIPS32 and MIPS64 ISAs, and processors which
+ implement them).
+
+ The MIPS32 and MIPS64 architecture specifications say "Software
+ is strongly encouraged to avoid use of Branch Likely
+ instructions, as they will be removed from a future revision
+ of the [MIPS32 and MIPS64] architecture." Therefore, we do not
+ issue those instructions unless instructed to do so by
+ -mbranch-likely. */
+ if (ISA_HAS_BRANCHLIKELY && !(ISA_MIPS32 || ISA_MIPS64))
+ target_flags |= MASK_BRANCHLIKELY;
+ else
+ target_flags &= ~MASK_BRANCHLIKELY;
+ }
+ if (TARGET_BRANCHLIKELY && !ISA_HAS_BRANCHLIKELY)
+ warning ("generation of Branch Likely instructions enabled, but not supported by architecture");
+
/* -fpic (-KPIC) is the default when TARGET_ABICALLS is defined. We need
to set flag_pic so that the LEGITIMATE_PIC_OPERAND_P macro will work. */
/* ??? -non_shared turns off pic code generation, but this is not
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 7db4f9e..eaf6852 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -232,6 +232,8 @@ extern void sbss_section PARAMS ((void));
consts in rodata */
#define MASK_NO_FUSED_MADD 0x01000000 /* Don't generate floating point
multiply-add operations. */
+#define MASK_BRANCHLIKELY 0x02000000 /* Generate Branch Likely
+ instructions. */
/* Debug switches, not documented */
#define MASK_DEBUG 0 /* unused */
@@ -322,6 +324,8 @@ extern void sbss_section PARAMS ((void));
#define TARGET_NO_CHECK_ZERO_DIV (target_flags & MASK_NO_CHECK_ZERO_DIV)
#define TARGET_CHECK_RANGE_DIV (target_flags & MASK_CHECK_RANGE_DIV)
+#define TARGET_BRANCHLIKELY (target_flags & MASK_BRANCHLIKELY)
+
/* This is true if we must enable the assembly language file switching
code. */
@@ -608,6 +612,10 @@ extern void sbss_section PARAMS ((void));
N_("Trap on integer divide overflow")}, \
{"no-check-range-division",-MASK_CHECK_RANGE_DIV, \
N_("Don't trap on integer divide overflow")}, \
+ { "branch-likely", MASK_BRANCHLIKELY, \
+ N_("Use Branch Likely instructions, overriding default for arch")}, \
+ { "no-branch-likely", -MASK_BRANCHLIKELY, \
+ N_("Don't use Branch Likely instructions, overriding default for arch")}, \
{"debug", MASK_DEBUG, \
NULL}, \
{"debuga", MASK_DEBUG_A, \
@@ -741,7 +749,7 @@ extern void sbss_section PARAMS ((void));
/* This is meant to be redefined in the host dependent files. */
#define SUBTARGET_TARGET_OPTIONS
-#define GENERATE_BRANCHLIKELY (!TARGET_MIPS16 && ISA_HAS_BRANCHLIKELY)
+#define GENERATE_BRANCHLIKELY (TARGET_BRANCHLIKELY && !TARGET_MIPS16)
/* Generate three-operand multiply instructions for SImode. */
#define GENERATE_MULT3_SI ((TARGET_MIPS3900 \
@@ -776,8 +784,7 @@ extern void sbss_section PARAMS ((void));
/* ISA has branch likely instructions (eg. mips2). */
/* Disable branchlikely for tx39 until compare rewrite. They haven't
been generated up to this point. */
-#define ISA_HAS_BRANCHLIKELY (!ISA_MIPS1 \
- && !TARGET_MIPS16)
+#define ISA_HAS_BRANCHLIKELY (!ISA_MIPS1)
/* ISA has the conditional move instructions introduced in mips4. */
#define ISA_HAS_CONDMOVE ((ISA_MIPS4 \