This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[ARM][binutils] Rework CPU feature selection in the disassembler
- From: Matthew Wahab <matthew dot wahab at arm dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 21 May 2015 10:00:09 +0100
- Subject: [ARM][binutils] Rework CPU feature selection in the disassembler
- Authentication-results: sourceware.org; auth=none
The handling of feature-sets in arm-dis.c/select_arm_features currently uses a
pair of macro redefinitions to record the features to be recognized. These macro
redefinitions make the code difficult to understand. This patch reworks the code
to be more transparent.
Tested for arm-none-linux-gnueabihf with check-binutils and check-gas.
Ok for trunk?
Matthew
include/opcode/
2015-05-21 Matthew Wahab <matthew.wahab@arm.com>
* arm.h (ARM_FEATURE_ALL): New.
opcodes/
2015-05-21 Matthew Wahab <matthew.wahab@arm.com>
* arm-dis.c (select_arm_features): Rework to avoid used of
redefined macros.
diff --git a/include/opcode/arm.h b/include/opcode/arm.h
index 1bf6b3c..cbe9e7d 100644
--- a/include/opcode/arm.h
+++ b/include/opcode/arm.h
@@ -244,6 +244,7 @@
#define ARM_ARCH_NONE ARM_FEATURE_LOW (0, 0)
#define FPU_NONE ARM_FEATURE_LOW (0, 0)
#define ARM_ANY ARM_FEATURE (-1, -1, 0) /* Any basic core. */
+#define ARM_FEATURE_ALL ARM_FEATURE (-1, -1, -1)/* All CPU and FPU features. */
#define FPU_ANY_HARD ARM_FEATURE_COPROC (FPU_FPA | FPU_VFP_HARD | FPU_MAVERICK)
#define ARM_ARCH_THUMB2 ARM_FEATURE_CORE_LOW (ARM_EXT_V6T2 | ARM_EXT_V7 \
| ARM_EXT_V7A | ARM_EXT_V7R \
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 1585a4f..9c2665d 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -6026,43 +6026,40 @@ static void
select_arm_features (unsigned long mach,
arm_feature_set * features)
{
-#undef ARM_FEATURE_LOW
-#define ARM_FEATURE_LOW(ARCH1,CEXT) \
- features->core[0] = (ARCH1); \
- features->core[1] = 0; \
- features->coproc = (CEXT) | FPU_FPA; \
- return
-
-#undef ARM_FEATURE_CORE_LOW
-#define ARM_FEATURE_CORE_LOW(ARCH1) \
- features->core[0] = (ARCH1); \
- features->core[1] = 0; \
- features->coproc = FPU_FPA; \
- return
+#undef ARM_SET_FEATURES
+#define ARM_SET_FEATURES(FSET) \
+ { \
+ const arm_feature_set fset = FSET; \
+ arm_feature_set tmp = ARM_FEATURE (0, 0, FPU_FPA) ; \
+ ARM_MERGE_FEATURE_SETS (*features, tmp, fset); \
+ }
switch (mach)
{
- case bfd_mach_arm_2: ARM_ARCH_V2;
- case bfd_mach_arm_2a: ARM_ARCH_V2S;
- case bfd_mach_arm_3: ARM_ARCH_V3;
- case bfd_mach_arm_3M: ARM_ARCH_V3M;
- case bfd_mach_arm_4: ARM_ARCH_V4;
- case bfd_mach_arm_4T: ARM_ARCH_V4T;
- case bfd_mach_arm_5: ARM_ARCH_V5;
- case bfd_mach_arm_5T: ARM_ARCH_V5T;
- case bfd_mach_arm_5TE: ARM_ARCH_V5TE;
- case bfd_mach_arm_XScale: ARM_ARCH_XSCALE;
- case bfd_mach_arm_ep9312: ARM_FEATURE_LOW (ARM_AEXT_V4T, \
- ARM_CEXT_MAVERICK \
- | FPU_MAVERICK);
- case bfd_mach_arm_iWMMXt: ARM_ARCH_IWMMXT;
- case bfd_mach_arm_iWMMXt2: ARM_ARCH_IWMMXT2;
+ case bfd_mach_arm_2: ARM_SET_FEATURES (ARM_ARCH_V2); break;
+ case bfd_mach_arm_2a: ARM_SET_FEATURES (ARM_ARCH_V2S); break;
+ case bfd_mach_arm_3: ARM_SET_FEATURES (ARM_ARCH_V3); break;
+ case bfd_mach_arm_3M: ARM_SET_FEATURES (ARM_ARCH_V3M); break;
+ case bfd_mach_arm_4: ARM_SET_FEATURES (ARM_ARCH_V4); break;
+ case bfd_mach_arm_4T: ARM_SET_FEATURES (ARM_ARCH_V4T); break;
+ case bfd_mach_arm_5: ARM_SET_FEATURES (ARM_ARCH_V5); break;
+ case bfd_mach_arm_5T: ARM_SET_FEATURES (ARM_ARCH_V5T); break;
+ case bfd_mach_arm_5TE: ARM_SET_FEATURES (ARM_ARCH_V5TE); break;
+ case bfd_mach_arm_XScale: ARM_SET_FEATURES (ARM_ARCH_XSCALE); break;
+ case bfd_mach_arm_ep9312:
+ ARM_SET_FEATURES (ARM_FEATURE_LOW (ARM_AEXT_V4T,
+ ARM_CEXT_MAVERICK | FPU_MAVERICK));
+ break;
+ case bfd_mach_arm_iWMMXt: ARM_SET_FEATURES (ARM_ARCH_IWMMXT); break;
+ case bfd_mach_arm_iWMMXt2: ARM_SET_FEATURES (ARM_ARCH_IWMMXT2); break;
/* If the machine type is unknown allow all
architecture types and all extensions. */
- case bfd_mach_arm_unknown: ARM_FEATURE_LOW (-1UL, -1UL);
+ case bfd_mach_arm_unknown: ARM_SET_FEATURES (ARM_FEATURE_ALL); break;
default:
abort ();
}
+
+#undef ARM_SET_FEATURES
}