MIPS: Simplify GCC_OFF_SMALL_ASM definition
authorPaul Burton <paul.burton@mips.com>
Wed, 7 Nov 2018 23:05:46 +0000 (23:05 +0000)
committerPaul Burton <paul.burton@mips.com>
Thu, 8 Nov 2018 00:26:42 +0000 (16:26 -0800)
commitd08b8ccc476215ceee6e3370f0c1732d5f83f5ef
treea1c5a58d7f8c42f654fb9404706c639531acd673
parent57810ecb581aec8008ad579013c0755c7acaf490
MIPS: Simplify GCC_OFF_SMALL_ASM definition

The GCC_OFF_SMALL_ASM macro defines the constraint to use for
instructions needing "small offsets", typically the LL or SC
instructions. Historically these had 16 bit offsets, but microMIPS &
MIPS32/MIPS64r6 onwards reduced the width of the offset field.

GCC 4.9 & higher supports a ZC constraint which matches the offset
requirements of the LL & SC instructions. Where supported we can use
the ZC constraint regardless of ISA, and it will handle the requirements
of the ISA correctly. As such we require 3 cases:

  - GCC 4.9 & higher can use ZC.

  - GCC older than 4.9 must use the older R constraint, which does not
    take into account microMIPS or MIPSr6.

  - microMIPS builds therefore require GCC 4.9 or higher. MIPSr6 support
    was only introduced in newer compilers anyway so it can be ignored
    here.

The current code complicates this a little by specifically having MIPSr6
bypass the GCC version check, and using the R constraint for pre-MIPSr6
builds even if the compiler supports ZC which would be equivalent.

Simplify this such that the code straightforwardly implements the 3
cases outlined above.

For non-GCC compilers we presume that ZC is safe to use. In practice the
only non-GCC compiler of interest is clang and it has supported the ZC
constraint since version 3.7.0. It seems safe enough to presume that
nobody will expect to built a working kernel using a clang version older
than that, and if they do then they'll have bigger problems. As such we
don't check the clang version number & just presume ZC is usable when
the compiler is not GCC.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/20999/
Cc: linux-mips@linux-mips.org
arch/mips/include/asm/compiler.h