aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/compiler.h
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@mips.com>2018-11-07 18:05:46 -0500
committerPaul Burton <paul.burton@mips.com>2018-11-07 19:26:42 -0500
commitd08b8ccc476215ceee6e3370f0c1732d5f83f5ef (patch)
treea1c5a58d7f8c42f654fb9404706c639531acd673 /arch/mips/include/asm/compiler.h
parent57810ecb581aec8008ad579013c0755c7acaf490 (diff)
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
Diffstat (limited to 'arch/mips/include/asm/compiler.h')
-rw-r--r--arch/mips/include/asm/compiler.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/mips/include/asm/compiler.h b/arch/mips/include/asm/compiler.h
index 9196fca4335d..f77e99f1722e 100644
--- a/arch/mips/include/asm/compiler.h
+++ b/arch/mips/include/asm/compiler.h
@@ -43,18 +43,14 @@
43#undef barrier_before_unreachable 43#undef barrier_before_unreachable
44#define barrier_before_unreachable() asm volatile(".insn") 44#define barrier_before_unreachable() asm volatile(".insn")
45 45
46#ifdef CONFIG_CPU_MIPSR6 46#if !defined(CONFIG_CC_IS_GCC) || \
47/* All MIPS R6 toolchains support the ZC constrain */ 47 (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
48#define GCC_OFF_SMALL_ASM() "ZC" 48# define GCC_OFF_SMALL_ASM() "ZC"
49#else 49#elif defined(CONFIG_CPU_MICROMIPS)
50#ifndef CONFIG_CPU_MICROMIPS 50# error "microMIPS compilation unsupported with GCC older than 4.9"
51#define GCC_OFF_SMALL_ASM() "R"
52#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
53#define GCC_OFF_SMALL_ASM() "ZC"
54#else 51#else
55#error "microMIPS compilation unsupported with GCC older than 4.9" 52# define GCC_OFF_SMALL_ASM() "R"
56#endif /* CONFIG_CPU_MICROMIPS */ 53#endif
57#endif /* CONFIG_CPU_MIPSR6 */
58 54
59#ifdef CONFIG_CPU_MIPSR6 55#ifdef CONFIG_CPU_MIPSR6
60#define MIPS_ISA_LEVEL "mips64r6" 56#define MIPS_ISA_LEVEL "mips64r6"