@@ -1,3 +1,13 @@
+2021-02-20 YunQiang Su <yunqiang.su@cipunited.com>
+
+ * config/mips/mips.c (mips_option_override):
+ * config/mips/mips.h (TARGET_RTP_PIC): not trigger error for
+ compact-branches=always for pre-R6.
+ (TARGET_CB_NEVER): Likewise.
+ (TARGET_CB_ALWAYS): Likewise.
+ (struct mips_cpu_info): define macros for compact branch policy.
+ * doc/invoke.texi: Document "always" with pre-R6.
+
2021-02-19 Martin Sebor <msebor@redhat.com>
PR c/97172
@@ -20107,13 +20107,7 @@ mips_option_override (void)
target_flags |= MASK_ODD_SPREG;
}
- if (!ISA_HAS_COMPACT_BRANCHES && mips_cb == MIPS_CB_ALWAYS)
- {
- error ("unsupported combination: %qs%s %s",
- mips_arch_info->name, TARGET_MICROMIPS ? " -mmicromips" : "",
- "-mcompact-branches=always");
- }
- else if (!ISA_HAS_DELAY_SLOTS && mips_cb == MIPS_CB_NEVER)
+ if (!ISA_HAS_DELAY_SLOTS && mips_cb == MIPS_CB_NEVER)
{
error ("unsupported combination: %qs%s %s",
mips_arch_info->name, TARGET_MICROMIPS ? " -mmicromips" : "",
@@ -103,11 +103,9 @@ struct mips_cpu_info {
#define TARGET_RTP_PIC (TARGET_VXWORKS_RTP && flag_pic)
/* Compact branches must not be used if the user either selects the
- 'never' policy or the 'optimal' policy on a core that lacks
+ 'never' policy or the 'optimal' / 'always' policy on a core that lacks
compact branch instructions. */
-#define TARGET_CB_NEVER (mips_cb == MIPS_CB_NEVER \
- || (mips_cb == MIPS_CB_OPTIMAL \
- && !ISA_HAS_COMPACT_BRANCHES))
+#define TARGET_CB_NEVER (mips_cb == MIPS_CB_NEVER || !ISA_HAS_COMPACT_BRANCHES)
/* Compact branches may be used if the user either selects the
'always' policy or the 'optimal' policy on a core that supports
@@ -117,10 +115,11 @@ struct mips_cpu_info {
&& ISA_HAS_COMPACT_BRANCHES))
/* Compact branches must always be generated if the user selects
- the 'always' policy or the 'optimal' policy om a core that
- lacks delay slot branch instructions. */
-#define TARGET_CB_ALWAYS (mips_cb == MIPS_CB_ALWAYS \
- || (mips_cb == MIPS_CB_OPTIMAL \
+ the 'always' policy on a core support compact branches,
+ or the 'optimal' policy on a core that lacks delay slot branch instructions. */
+#define TARGET_CB_ALWAYS ((mips_cb == MIPS_CB_ALWAYS \
+ && ISA_HAS_COMPACT_BRANCHES) \
+ || (mips_cb == MIPS_CB_OPTIMAL \
&& !ISA_HAS_DELAY_SLOTS))
/* Special handling for JRC that exists in microMIPSR3 as well as R6
@@ -655,6 +654,13 @@ struct mips_cpu_info {
builtin_define ("__mips_no_lxc1_sxc1"); \
if (!ISA_HAS_UNFUSED_MADD4 && !ISA_HAS_FUSED_MADD4) \
builtin_define ("__mips_no_madd4"); \
+ \
+ if (TARGET_CB_NEVER) \
+ builtin_define ("__mips_compact_branches_never"); \
+ else if (TARGET_CB_ALWAYS) \
+ builtin_define ("__mips_compact_branches_always"); \
+ else \
+ builtin_define ("__mips_compact_branches_optimal"); \
} \
while (0)
@@ -25237,6 +25237,7 @@ instruction is not available, a delay slot form of the branch will be
used instead.
This option is supported from MIPS Release 6 onwards.
+If it is used for pre-R6 target, it will be just ignored.
The @option{-mcompact-branches=optimal} option will cause a delay slot
branch to be used if one is available in the current ISA and the delay
@@ -1,3 +1,11 @@
+2021-02-20 YunQiang Su <yunqiang.su@cipunited.com>
+
+ * gcc.target/mips/compact-branches-1.c: add isa_rev>=6.
+ * gcc.target/mips/mips.exp: don't add -mipsXXr6 option for
+ -mcompact-branches=always. It is usable for pre-R6 now.
+ * gcc.target/mips/compact-branches-8.c: New test.
+ * gcc.target/mips/compact-branches-9.c: New test.
+
2021-02-19 Nathan Sidwell <nathan@acm.org>
PR c++/98741
@@ -1,4 +1,4 @@
-/* { dg-options "-mcompact-branches=always -mno-micromips" } */
+/* { dg-options "-mcompact-branches=always -mno-micromips isa_rev>=6" } */
int glob;
void
new file mode 100644
@@ -0,0 +1,10 @@
+/* { dg-options "-mno-abicalls -mcompact-branches=always isa_rev<=5" } */
+void bar (int);
+
+void
+foo ()
+{
+ bar (1);
+}
+
+/* { dg-final { scan-assembler "\t(j|jal)\t" } } */
new file mode 100644
@@ -0,0 +1,10 @@
+/* { dg-options "-mno-abicalls -fno-PIC -mcompact-branches=always isa_rev>=6" } */
+void bar (int);
+
+void
+foo ()
+{
+ bar (1);
+}
+
+/* { dg-final { scan-assembler "\t(bc|balc)\t" } } */
@@ -1163,10 +1163,8 @@ proc mips-dg-options { args } {
# We need a revision 6 or better ISA for:
#
# - When the LSA instruction is required
- # - When only using compact branches
if { $isa_rev < 6
- && ([mips_have_test_option_p options "HAS_LSA"]
- || [mips_have_test_option_p options "-mcompact-branches=always"]) } {
+ && ([mips_have_test_option_p options "HAS_LSA"]) } {
if { $gp_size == 32 } {
mips_make_test_option options "-mips32r6"
} else {