[PATCH 1/3] teach sparse about -mfloat-abi on ARM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Teach sparse about the -mfloat-abi option and set the
related predefines for ARM accordingly.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c     | 26 ++++++++++++++++++++++++++
 machine.h | 14 ++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/lib.c b/lib.c
index 83e6a1e1b..ee6353939 100644
--- a/lib.c
+++ b/lib.c
@@ -306,6 +306,8 @@ int dbg_entry = 0;
 int dbg_ir = 0;
 int dbg_postorder = 0;
 
+static unsigned long fp_abi = FP_ABI_NATIVE;
+
 unsigned long fdump_ir;
 int fmem_report = 0;
 unsigned long long fmemcpy_max_count = 100000;
@@ -918,6 +920,17 @@ static int handle_fdump_ir(const char *arg, const char *opt, const struct flag *
 	return handle_suboption_mask(arg, opt, dump_ir_options, &fdump_ir);
 }
 
+static int handle_float_abi(const char *arg, const char *opt, const struct flag *flag, int options) {
+	static const struct mask_map fp_abis[] = {
+		{ "hard",		FP_ABI_HARD },
+		{ "sofp",		FP_ABI_SOFT },
+		{ "softfp",		FP_ABI_MIXED },
+		{ },
+	};
+
+	return handle_suboption_mask(arg, opt, fp_abis, &fp_abi);
+}
+
 static int handle_fmemcpy_max_count(const char *arg, const char *opt, const struct flag *flag, int options)
 {
 	opt_ullong(arg, opt, &fmemcpy_max_count, OPTNUM_ZERO_IS_INF|OPTNUM_UNLIMITED);
@@ -933,6 +946,7 @@ static int handle_fmax_warnings(const char *arg, const char *opt, const struct f
 static struct flag fflags[] = {
 	{ "diagnostic-prefix",	NULL,	handle_fdiagnostic_prefix },
 	{ "dump-ir",		NULL,	handle_fdump_ir },
+	{ "float-abi=",		NULL,	handle_float_abi },
 	{ "linearize",		NULL,	handle_fpasses,	PASS_LINEARIZE },
 	{ "max-warnings=",	NULL,	handle_fmax_warnings },
 	{ "mem-report",		&fmem_report },
@@ -1320,6 +1334,18 @@ static void predefined_macros(void)
 		break;
 	case MACH_ARM:
 		predefine("__arm__", 1, "1");
+		switch (fp_abi) {
+		case FP_ABI_HARD:
+			predefine("__ARM_PCS_VFP", 1, "1");
+			break;
+		case FP_ABI_SOFT:
+			predefine("__SOFTFP", 1, "1");
+			/* fall-through */
+		case FP_ABI_MIXED:
+			predefine("__ARM_PCS", 1, "1");
+			break;
+		}
+		predefine("__VFP_FP__", 1, "1");
 		break;
 	case MACH_M68K:
 		predefine("__m68k__", 1, "1");
diff --git a/machine.h b/machine.h
index b46383ac1..ca68b2bdb 100644
--- a/machine.h
+++ b/machine.h
@@ -80,4 +80,18 @@ enum machine {
 #define UNSIGNED_CHAR	0
 #endif
 
+enum fp_abi {
+	FP_ABI_HARD,
+	FP_ABI_SOFT,
+	FP_ABI_MIXED,
+};
+
+#if   defined(__ARM_PCS_VFP)
+#define FP_ABI_NATIVE		FP_ABI_HARD
+#elif defined(__SOFTFP__)
+#define FP_ABI_NATIVE		FP_ABI_SOFT
+#else
+#define FP_ABI_NATIVE		FP_ABI_MIXED
+#endif
+
 #endif
-- 
2.20.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux