Skip to contentSkip to conversation

Target-arm: Add the THUMB_DSP feature

PATCH In review Aurelio C. Remonda 2 participants 2 messages Jun 14, 2015 – Jun 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Target-arm: Add the THUMB_DSP feature

Created an ARM_FEATURE_THUMB_DSP to be added to any non-M thumb2-compatible CPU that uses DSP instructions. There are 85 DSP instructions (all of them thumb2). On disas_thumb2_insn the DSP feature is tested before the instruction is generated; if it's not enabled then its an illegal op.

---
* Changes in V2: Add the ARM_FEATURE_THUMB_DSP to non-M thumb2-compatible CPUs to this patch, and fixed some syntax errors. Also added extra switches so there's no need to do temp_free in some places.

 target-arm/cpu.c       |  4 +++
 target-arm/cpu.h       |  1 +
 target-arm/translate.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 94 insertions(+), 5 deletions(-)
target-arm/cpu.c +4 -0
index 4a888ab..ad381e2 100644
@@ -533,6 +533,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     if (arm_feature(env, ARM_FEATURE_CBAR_RO)) {
         set_feature(env, ARM_FEATURE_CBAR);
     }
+    if (arm_feature(env, ARM_FEATURE_THUMB2) &&
+        !arm_feature(env, ARM_FEATURE_M)) {
+        set_feature(env, ARM_FEATURE_THUMB_DSP);
+    }
 
     if (cpu->reset_hivecs) {
             cpu->reset_sctlr |= (1 << 13);
target-arm/cpu.h +1 -0
index 21b5b8e..7fedf3f 100644
@@ -890,6 +890,7 @@ enum arm_features {
     ARM_FEATURE_V8_SHA1, /* implements SHA1 part of v8 Crypto Extensions */
     ARM_FEATURE_V8_SHA256, /* implements SHA256 part of v8 Crypto Extensions */
     ARM_FEATURE_V8_PMULL, /* implements PMULL part of v8 Crypto Extensions */
+    ARM_FEATURE_THUMB_DSP,/* DSP insns supported in the Thumb encodings */
 };
 
 static inline int arm_feature(CPUARMState *env, int feature)
target-arm/translate.c +89 -5

167 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Aurelio C. Remonda

Created an ARM_FEATURE_THUMB_DSP to be added to any non-M thumb2-compatible CPU that uses DSP instructions. There are 85 DSP instructions (all of them thumb2). On disas_thumb2_insn the DSP feature is tested before the instruction is generated; if it's not enabled then its an illegal op.

Thanks. There was one bit where you seemed to have only done half of the hoist-decode-into-switch; I'm going to just make the minor fixup (below) as I put this patch into target-arm.next. I also made some minor format fixes (mostly mis-indented "break" statements). I hope that's OK.

@@ -9597,12 +9596,25 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw

                 case 0x08: /* rev */
                 case 0x09: /* rev16 */
                 case 0x0b: /* revsh */
-                break;
+                case 0x18: /* clz */
+                    break;
                 case 0x10: /* sel */
                     if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
                         goto illegal_op;
                     }
-                break;
+                    break;
+                case 0x20: /* crc32/crc32c */
+                case 0x21:
+                case 0x22:
+                case 0x28:
+                case 0x29:
+                case 0x2a:

+ if (!arm_dc_feature(s, ARM_FEATURE_CRC)) {
+ goto illegal_op;
+ }
+ break;
+ default:

+                    goto illegal_op;
                 }
                 tmp = load_reg(s, rn);
                 switch (op) {

-- PMM