~ubuntu-branches/ubuntu/vivid/qemu/vivid

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0068-target-arm-A64-add-support-for-conditional-compare-i.patch

  • Committer: Package Import Robot
  • Author(s): dann frazier
  • Date: 2014-02-11 15:41:53 UTC
  • Revision ID: package-import@ubuntu.com-20140211154153-2d001tf0ium08u81
Tags: 1.7.0+dfsg-3ubuntu2
* Backport changes to enable qemu-user-static support for aarch64
* debian/control: add ppc64el to Architectures
* debian/rules: only install qemu-system-aarch64 on arm64.
  Fixes a FTBFS  when built twice in a row on non-arm64 due to a stale
  debian/qemu-system-aarch64 directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From afb761a664ef46fac23a1631c6ffd236ea860aae Mon Sep 17 00:00:00 2001
 
2
From: Claudio Fontana <claudio.fontana@linaro.org>
 
3
Date: Sat, 4 Jan 2014 22:15:46 +0000
 
4
Subject: [PATCH 068/158] target-arm: A64: add support for conditional compare
 
5
 insns
 
6
 
 
7
this patch adds support for C3.5.4 - C3.5.5
 
8
Conditional compare (both immediate and register)
 
9
 
 
10
Signed-off-by: Claudio Fontana <claudio.fontana@linaro.org>
 
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
 
12
Reviewed-by: Richard Henderson <rth@twiddle.net>
 
13
---
 
14
 target-arm/translate-a64.c | 73 +++++++++++++++++++++++++++++++++++++---------
 
15
 1 file changed, 60 insertions(+), 13 deletions(-)
 
16
 
 
17
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
 
18
index 9f508b9..538d69e 100644
 
19
--- a/target-arm/translate-a64.c
 
20
+++ b/target-arm/translate-a64.c
 
21
@@ -2483,16 +2483,67 @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn)
 
22
     }
 
23
 }
 
24
 
 
25
-/* Conditional compare (immediate) */
 
26
-static void disas_cc_imm(DisasContext *s, uint32_t insn)
 
27
+/* C3.5.4 - C3.5.5 Conditional compare (immediate / register)
 
28
+ *  31 30 29 28 27 26 25 24 23 22 21  20    16 15  12  11  10  9   5  4 3   0
 
29
+ * +--+--+--+------------------------+--------+------+----+--+------+--+-----+
 
30
+ * |sf|op| S| 1  1  0  1  0  0  1  0 |imm5/rm | cond |i/r |o2|  Rn  |o3|nzcv |
 
31
+ * +--+--+--+------------------------+--------+------+----+--+------+--+-----+
 
32
+ *        [1]                             y                [0]       [0]
 
33
+ */
 
34
+static void disas_cc(DisasContext *s, uint32_t insn)
 
35
 {
 
36
-    unsupported_encoding(s, insn);
 
37
-}
 
38
+    unsigned int sf, op, y, cond, rn, nzcv, is_imm;
 
39
+    int label_continue = -1;
 
40
+    TCGv_i64 tcg_tmp, tcg_y, tcg_rn;
 
41
 
 
42
-/* Conditional compare (register) */
 
43
-static void disas_cc_reg(DisasContext *s, uint32_t insn)
 
44
-{
 
45
-    unsupported_encoding(s, insn);
 
46
+    if (!extract32(insn, 29, 1)) {
 
47
+        unallocated_encoding(s);
 
48
+        return;
 
49
+    }
 
50
+    if (insn & (1 << 10 | 1 << 4)) {
 
51
+        unallocated_encoding(s);
 
52
+        return;
 
53
+    }
 
54
+    sf = extract32(insn, 31, 1);
 
55
+    op = extract32(insn, 30, 1);
 
56
+    is_imm = extract32(insn, 11, 1);
 
57
+    y = extract32(insn, 16, 5); /* y = rm (reg) or imm5 (imm) */
 
58
+    cond = extract32(insn, 12, 4);
 
59
+    rn = extract32(insn, 5, 5);
 
60
+    nzcv = extract32(insn, 0, 4);
 
61
+
 
62
+    if (cond < 0x0e) { /* not always */
 
63
+        int label_match = gen_new_label();
 
64
+        label_continue = gen_new_label();
 
65
+        arm_gen_test_cc(cond, label_match);
 
66
+        /* nomatch: */
 
67
+        tcg_tmp = tcg_temp_new_i64();
 
68
+        tcg_gen_movi_i64(tcg_tmp, nzcv << 28);
 
69
+        gen_set_nzcv(tcg_tmp);
 
70
+        tcg_temp_free_i64(tcg_tmp);
 
71
+        tcg_gen_br(label_continue);
 
72
+        gen_set_label(label_match);
 
73
+    }
 
74
+    /* match, or condition is always */
 
75
+    if (is_imm) {
 
76
+        tcg_y = new_tmp_a64(s);
 
77
+        tcg_gen_movi_i64(tcg_y, y);
 
78
+    } else {
 
79
+        tcg_y = cpu_reg(s, y);
 
80
+    }
 
81
+    tcg_rn = cpu_reg(s, rn);
 
82
+
 
83
+    tcg_tmp = tcg_temp_new_i64();
 
84
+    if (op) {
 
85
+        gen_sub_CC(sf, tcg_tmp, tcg_rn, tcg_y);
 
86
+    } else {
 
87
+        gen_add_CC(sf, tcg_tmp, tcg_rn, tcg_y);
 
88
+    }
 
89
+    tcg_temp_free_i64(tcg_tmp);
 
90
+
 
91
+    if (cond < 0x0e) { /* continue */
 
92
+        gen_set_label(label_continue);
 
93
+    }
 
94
 }
 
95
 
 
96
 /* C3.5.6 Conditional select
 
97
@@ -2846,11 +2897,7 @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn)
 
98
             disas_adc_sbc(s, insn);
 
99
             break;
 
100
         case 0x2: /* Conditional compare */
 
101
-            if (insn & (1 << 11)) { /* (immediate) */
 
102
-                disas_cc_imm(s, insn);
 
103
-            } else {            /* (register) */
 
104
-                disas_cc_reg(s, insn);
 
105
-            }
 
106
+            disas_cc(s, insn); /* both imm and reg forms */
 
107
             break;
 
108
         case 0x4: /* Conditional select */
 
109
             disas_cond_select(s, insn);
 
110
-- 
 
111
1.9.rc1
 
112