1
From b8a2aeda588307fd562c2f88ff079bb0a523daca Mon Sep 17 00:00:00 2001
2
From: Peter Maydell <peter.maydell@linaro.org>
3
Date: Sun, 22 Dec 2013 22:32:30 +0000
4
Subject: [PATCH 061/158] target-arm: Pull "add one cpreg to hashtable" into
7
define_one_arm_cp_reg_with_opaque() has a set of nested loops which
8
insert a cpreg entry into the hashtable for each of the possible
9
opc/crn/crm values allowed by wildcard specifications. We're about
10
to add an extra loop to this nesting, so pull the core of the loop
11
(which adds a single entry to the hashtable) out into its own
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Richard Henderson <rth@twiddle.net>
17
target-arm/helper.c | 94 +++++++++++++++++++++++++++++------------------------
18
1 file changed, 52 insertions(+), 42 deletions(-)
20
diff --git a/target-arm/helper.c b/target-arm/helper.c
21
index 46679ed..923ce25 100644
22
--- a/target-arm/helper.c
23
+++ b/target-arm/helper.c
24
@@ -1946,6 +1946,57 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
28
+static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
29
+ void *opaque, int crm, int opc1, int opc2)
31
+ /* Private utility function for define_one_arm_cp_reg_with_opaque():
32
+ * add a single reginfo struct to the hash table.
34
+ uint32_t *key = g_new(uint32_t, 1);
35
+ ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
36
+ int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
37
+ *key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2);
39
+ r2->opaque = opaque;
41
+ /* Make sure reginfo passed to helpers for wildcarded regs
42
+ * has the correct crm/opc1/opc2 for this reg, not CP_ANY:
47
+ /* By convention, for wildcarded registers only the first
48
+ * entry is used for migration; the others are marked as
49
+ * NO_MIGRATE so we don't try to transfer the register
50
+ * multiple times. Special registers (ie NOP/WFI) are
53
+ if ((r->type & ARM_CP_SPECIAL) ||
54
+ ((r->crm == CP_ANY) && crm != 0) ||
55
+ ((r->opc1 == CP_ANY) && opc1 != 0) ||
56
+ ((r->opc2 == CP_ANY) && opc2 != 0)) {
57
+ r2->type |= ARM_CP_NO_MIGRATE;
60
+ /* Overriding of an existing definition must be explicitly
63
+ if (!(r->type & ARM_CP_OVERRIDE)) {
64
+ ARMCPRegInfo *oldreg;
65
+ oldreg = g_hash_table_lookup(cpu->cp_regs, key);
66
+ if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
67
+ fprintf(stderr, "Register redefined: cp=%d %d bit "
68
+ "crn=%d crm=%d opc1=%d opc2=%d, "
69
+ "was %s, now %s\n", r2->cp, 32 + 32 * is64,
70
+ r2->crn, r2->crm, r2->opc1, r2->opc2,
71
+ oldreg->name, r2->name);
72
+ g_assert_not_reached();
75
+ g_hash_table_insert(cpu->cp_regs, key, r2);
79
void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
80
const ARMCPRegInfo *r, void *opaque)
82
@@ -1986,48 +2037,7 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
83
for (crm = crmmin; crm <= crmmax; crm++) {
84
for (opc1 = opc1min; opc1 <= opc1max; opc1++) {
85
for (opc2 = opc2min; opc2 <= opc2max; opc2++) {
86
- uint32_t *key = g_new(uint32_t, 1);
87
- ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
88
- int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
89
- *key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2);
91
- r2->opaque = opaque;
93
- /* Make sure reginfo passed to helpers for wildcarded regs
94
- * has the correct crm/opc1/opc2 for this reg, not CP_ANY:
99
- /* By convention, for wildcarded registers only the first
100
- * entry is used for migration; the others are marked as
101
- * NO_MIGRATE so we don't try to transfer the register
102
- * multiple times. Special registers (ie NOP/WFI) are
103
- * never migratable.
105
- if ((r->type & ARM_CP_SPECIAL) ||
106
- ((r->crm == CP_ANY) && crm != 0) ||
107
- ((r->opc1 == CP_ANY) && opc1 != 0) ||
108
- ((r->opc2 == CP_ANY) && opc2 != 0)) {
109
- r2->type |= ARM_CP_NO_MIGRATE;
112
- /* Overriding of an existing definition must be explicitly
115
- if (!(r->type & ARM_CP_OVERRIDE)) {
116
- ARMCPRegInfo *oldreg;
117
- oldreg = g_hash_table_lookup(cpu->cp_regs, key);
118
- if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
119
- fprintf(stderr, "Register redefined: cp=%d %d bit "
120
- "crn=%d crm=%d opc1=%d opc2=%d, "
121
- "was %s, now %s\n", r2->cp, 32 + 32 * is64,
122
- r2->crn, r2->crm, r2->opc1, r2->opc2,
123
- oldreg->name, r2->name);
124
- g_assert_not_reached();
127
- g_hash_table_insert(cpu->cp_regs, key, r2);
128
+ add_cpreg_to_hashtable(cpu, r, opaque, crm, opc1, opc2);