Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Introduce isa-rev.h to define MIPS_ISA_REV

There are multiple instances in the kernel where we need to include or
exclude particular instructions based on the ISA revision of the target
processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
define. However, when targeting MIPS I - V, this define is absent. This
leads to each use of __mips_isa_rev having to check that it is defined
first. To simplify this, introduce the isa-rev.h header which always
exports MIPS_ISA_REV. The name is changed so as to avoid confusion with
the compiler builtin and to avoid accidentally using the builtin.
MIPS_ISA_REV is defined to the compilers builtin if provided, or 0,
which satisfies all current usages.

Suggested-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
Reviewed-by: Maciej W. Rozycki <macro@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/18676/
Signed-off-by: James Hogan <jhogan@kernel.org>

authored by

Matt Redfearn and committed by
James Hogan
16909052 997e93d4

+24
+24
arch/mips/include/asm/isa-rev.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2018 MIPS Tech, LLC 4 + * Author: Matt Redfearn <matt.redfearn@mips.com> 5 + */ 6 + 7 + #ifndef __MIPS_ASM_ISA_REV_H__ 8 + #define __MIPS_ASM_ISA_REV_H__ 9 + 10 + /* 11 + * The ISA revision level. This is 0 for MIPS I to V and N for 12 + * MIPS{32,64}rN. 13 + */ 14 + 15 + /* If the compiler has defined __mips_isa_rev, believe it. */ 16 + #ifdef __mips_isa_rev 17 + #define MIPS_ISA_REV __mips_isa_rev 18 + #else 19 + /* The compiler hasn't defined the isa rev so assume it's MIPS I - V (0) */ 20 + #define MIPS_ISA_REV 0 21 + #endif 22 + 23 + 24 + #endif /* __MIPS_ASM_ISA_REV_H__ */