"Maciej W. Rozycki" <macro@xxxxxxxxxxxxxx> writes: > On Sat, 1 Nov 2008, Kumba wrote: >> The branch-likely stuff is only going to work for MIPS-II or higher targets. >> In the odd (but possible) cases where MIPS-I might be used with -mfix-r10000, >> I assume we'll still have to emit 28 nops prior to a beq/beqz instruction. Is >> this already taken care of someplace? > > MIPS I does not support LL/SC, so that case is not to be concerned. > These instructions are emulated on such processors and as such can appear > in assembly snippets, but GCC is expected not to emit them itself (I hope > it hasn't changed; if it has, then we are in trouble -- I suppose a > compiler error is justified for such an odd case). Not quite true. Use of LL and SC is controlled by a separate option, -mllsc. As you'd expect, this option is on by default if the architecture provides LL and SC. It's therefore on by default for generic MIPS II and above, and for -march=<cpu> if <cpu> provides the instructions. However, the default for other architectures depends on the configuration. If the configured target is known to emulate the LL and SC instructions (as Linux targets are), the default is -mllsc. It is -mno-llsc otherwise. >> Hmm, okay. Might this work to enable -mbranch-likely if -mfix-r10000? (Kind >> of guessing by looking at other segments of code). >> >> if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0) >> { >> if (ISA_HAS_BRANCHLIKELY >> && (optimize_size >> || (!(target_flags_explicit & MASK_FIX_R10000) == 0) >> || (mips_tune_info->tune_flags & PTF_AVOID_BRANCHLIKELY) == 0)) >> target_flags |= MASK_BRANCHLIKELY; >> else >> target_flags &= ~MASK_BRANCHLIKELY; >> } >> >> >> >> My understanding so far for -mfix-r10000: >> - Gets enabled if -march=r10000 is passed (done) >> - Enable -mbranch-likely if not already enabled on >= MIPS-II (working on) >> - Emits beqzl in the asm templates if enabled and >= MIPS-II (unsure) >> - Emits 28 nops prior to beq/beqz if enabled and == MIPS-I (unsure) >> - Ditto for asm templates (unsure) >> - Documentation (not done) > > I think the best option is to leave -mbranch-likely intact and bail out > if -mfix-r10000 and -mno-branch-likely are passed at the same time. > Anything else is likely to cause confusion. Then -march=r10000 should > enable both -mfix-r10000 and -mbranch-likely. > > I believe (but have not checked) that all CPUs/ISAs that are within the > MIPS II - MIPS IV range enable -mbranch-likely by default, so there is no > problem here unless somebody requests -mno-branch-likely in which case > they get what they asked for (i.e. a compiler error). I believe all MIPS > architecture CPUs/ISAs disable -mbranch-likely by default, but such code > cannot run on the R10k anyway. > > I think it covers all cases. Comments? For avoidance of doubt, this is exactly option #1 in my messages. As you say, -march=r10000 already implies -mbranch-likely unless explicitly overridden. Richard