aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-17 23:26:13 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-27 00:18:45 +0100
commit532f662121d79ef50408cd4f67d0d379e55c2fa8 (patch)
treed9767294b5886a8cba93311ce6e459f0faad09bc /lib.c
parent16df5da6daa81ee91fda2fe7316fab7d966c1ec7 (diff)
downloadsparse-dev-532f662121d79ef50408cd4f67d0d379e55c2fa8.tar.gz
fp-abi: teach sparse about -mfloat-abi on ARM
Teach sparse about the -mfloat-abi option and set the related predefines for ARM accordingly. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 7c2fea99..519b3c3d 100644
--- a/lib.c
+++ b/lib.c
@@ -329,6 +329,7 @@ static int arch_msize_long = 0;
int arch_m64 = ARCH_M64_DEFAULT;
int arch_big_endian = ARCH_BIG_ENDIAN;
int arch_mach = MACH_NATIVE;
+int arch_fp_abi = FP_ABI_NATIVE;
int arch_cmodel = CMODEL_UNKNOWN;
@@ -679,6 +680,15 @@ static int handle_cmodel(const char *opt, const char *arg, const struct flag *fl
return handle_subopt_val(opt, arg, cmodels, flag->flag);
}
+static int handle_float_abi(const char *opt, const char *arg, const struct flag *flag, int options) {
+ static const struct val_map fp_abis[] = {
+ { "hard", FP_ABI_HARD },
+ { "soft", FP_ABI_SOFT },
+ { "softfp", FP_ABI_HYBRID },
+ { "?" },
+ };
+ return handle_subopt_val(opt, arg, fp_abis, flag->flag);
+}
static const struct flag mflags[] = {
{ "64", &arch_m64, NULL, OPT_VAL, ARCH_LP64 },
@@ -691,6 +701,7 @@ static const struct flag mflags[] = {
{ "big-endian", &arch_big_endian, NULL },
{ "little-endian", &arch_big_endian, NULL, OPT_INVERSE },
{ "cmodel", &arch_cmodel, handle_cmodel },
+ { "float-abi", &arch_fp_abi, handle_float_abi },
{ }
};
@@ -1519,6 +1530,18 @@ static void predefined_macros(void)
break;
case MACH_ARM:
predefine("__arm__", 1, "1");
+ switch (arch_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_HYBRID:
+ predefine("__ARM_PCS", 1, "1");
+ break;
+ }
+ predefine("__VFP_FP__", 1, "1");
break;
case MACH_M68K:
predefine("__m68k__", 1, "1");