Skip to content

Commit 207a2ba

Browse files
committed
nanomips: fix warnings with GCC 14
GCC 14 shows -Wshadow=local warnings if an enum conflicts with a local variable (including a parameter). To avoid this, move the problematic enum and all of its dependencies after the hundreds of functions that have a parameter named "instruction". Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d1ce2cc commit 207a2ba

File tree

1 file changed

+97
-97
lines changed

1 file changed

+97
-97
lines changed

disas/nanomips.c

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -36,58 +36,13 @@ typedef uint32_t uint32;
3636
typedef uint16_t uint16;
3737
typedef uint64_t img_address;
3838

39-
typedef enum {
40-
instruction,
41-
call_instruction,
42-
branch_instruction,
43-
return_instruction,
44-
reserved_block,
45-
pool,
46-
} TABLE_ENTRY_TYPE;
47-
48-
typedef enum {
49-
MIPS64_ = 0x00000001,
50-
XNP_ = 0x00000002,
51-
XMMS_ = 0x00000004,
52-
EVA_ = 0x00000008,
53-
DSP_ = 0x00000010,
54-
MT_ = 0x00000020,
55-
EJTAG_ = 0x00000040,
56-
TLBINV_ = 0x00000080,
57-
CP0_ = 0x00000100,
58-
CP1_ = 0x00000200,
59-
CP2_ = 0x00000400,
60-
UDI_ = 0x00000800,
61-
MCU_ = 0x00001000,
62-
VZ_ = 0x00002000,
63-
TLB_ = 0x00004000,
64-
MVH_ = 0x00008000,
65-
ALL_ATTRIBUTES = 0xffffffffull,
66-
} TABLE_ATTRIBUTE_TYPE;
67-
6839
typedef struct Dis_info {
6940
img_address m_pc;
7041
fprintf_function fprintf_func;
7142
FILE *stream;
7243
sigjmp_buf buf;
7344
} Dis_info;
7445

75-
typedef bool (*conditional_function)(uint64 instruction);
76-
typedef char * (*disassembly_function)(uint64 instruction,
77-
Dis_info *info);
78-
79-
typedef struct Pool {
80-
TABLE_ENTRY_TYPE type;
81-
const struct Pool *next_table;
82-
int next_table_size;
83-
int instructions_size;
84-
uint64 mask;
85-
uint64 value;
86-
disassembly_function disassembly;
87-
conditional_function condition;
88-
uint64 attributes;
89-
} Pool;
90-
9146
#define IMGASSERTONCE(test)
9247

9348

@@ -544,58 +499,6 @@ static uint64 extract_op_code_value(const uint16 *data, int size)
544499
}
545500

546501

547-
/*
548-
* Recurse through tables until the instruction is found then return
549-
* the string and size
550-
*
551-
* inputs:
552-
* pointer to a word stream,
553-
* disassember table and size
554-
* returns:
555-
* instruction size - negative is error
556-
* disassembly string - on error will constain error string
557-
*/
558-
static int Disassemble(const uint16 *data, char **dis,
559-
TABLE_ENTRY_TYPE *type, const Pool *table,
560-
int table_size, Dis_info *info)
561-
{
562-
for (int i = 0; i < table_size; i++) {
563-
uint64 op_code = extract_op_code_value(data,
564-
table[i].instructions_size);
565-
if ((op_code & table[i].mask) == table[i].value) {
566-
/* possible match */
567-
conditional_function cond = table[i].condition;
568-
if ((cond == NULL) || cond(op_code)) {
569-
if (table[i].type == pool) {
570-
return Disassemble(data, dis, type,
571-
table[i].next_table,
572-
table[i].next_table_size,
573-
info);
574-
} else if ((table[i].type == instruction) ||
575-
(table[i].type == call_instruction) ||
576-
(table[i].type == branch_instruction) ||
577-
(table[i].type == return_instruction)) {
578-
disassembly_function dis_fn = table[i].disassembly;
579-
if (dis_fn == 0) {
580-
*dis = g_strdup(
581-
"disassembler failure - bad table entry");
582-
return -6;
583-
}
584-
*type = table[i].type;
585-
*dis = dis_fn(op_code, info);
586-
return table[i].instructions_size;
587-
} else {
588-
*dis = g_strdup("reserved instruction");
589-
return -2;
590-
}
591-
}
592-
}
593-
}
594-
*dis = g_strdup("failed to disassemble");
595-
return -1; /* failed to disassemble */
596-
}
597-
598-
599502
static uint64 extract_code_18_to_0(uint64 instruction)
600503
{
601504
uint64 value = 0;
@@ -16213,6 +16116,51 @@ static char *YIELD(uint64 instruction, Dis_info *info)
1621316116
*
1621416117
*/
1621516118

16119+
typedef enum {
16120+
instruction,
16121+
call_instruction,
16122+
branch_instruction,
16123+
return_instruction,
16124+
reserved_block,
16125+
pool,
16126+
} TABLE_ENTRY_TYPE;
16127+
16128+
typedef enum {
16129+
MIPS64_ = 0x00000001,
16130+
XNP_ = 0x00000002,
16131+
XMMS_ = 0x00000004,
16132+
EVA_ = 0x00000008,
16133+
DSP_ = 0x00000010,
16134+
MT_ = 0x00000020,
16135+
EJTAG_ = 0x00000040,
16136+
TLBINV_ = 0x00000080,
16137+
CP0_ = 0x00000100,
16138+
CP1_ = 0x00000200,
16139+
CP2_ = 0x00000400,
16140+
UDI_ = 0x00000800,
16141+
MCU_ = 0x00001000,
16142+
VZ_ = 0x00002000,
16143+
TLB_ = 0x00004000,
16144+
MVH_ = 0x00008000,
16145+
ALL_ATTRIBUTES = 0xffffffffull,
16146+
} TABLE_ATTRIBUTE_TYPE;
16147+
16148+
typedef bool (*conditional_function)(uint64 instruction);
16149+
typedef char * (*disassembly_function)(uint64 instruction,
16150+
Dis_info *info);
16151+
16152+
typedef struct Pool {
16153+
TABLE_ENTRY_TYPE type;
16154+
const struct Pool *next_table;
16155+
int next_table_size;
16156+
int instructions_size;
16157+
uint64 mask;
16158+
uint64 value;
16159+
disassembly_function disassembly;
16160+
conditional_function condition;
16161+
uint64 attributes;
16162+
} Pool;
16163+
1621616164
static const Pool P_SYSCALL[2] = {
1621716165
{ instruction , 0 , 0 , 32,
1621816166
0xfffc0000, 0x00080000, &SYSCALL_32_ , 0,
@@ -21907,6 +21855,58 @@ static const Pool MAJOR[2] = {
2190721855
0x0 }, /* P16 */
2190821856
};
2190921857

21858+
/*
21859+
* Recurse through tables until the instruction is found then return
21860+
* the string and size
21861+
*
21862+
* inputs:
21863+
* pointer to a word stream,
21864+
* disassember table and size
21865+
* returns:
21866+
* instruction size - negative is error
21867+
* disassembly string - on error will constain error string
21868+
*/
21869+
static int Disassemble(const uint16 *data, char **dis,
21870+
TABLE_ENTRY_TYPE *type, const Pool *table,
21871+
int table_size, Dis_info *info)
21872+
{
21873+
for (int i = 0; i < table_size; i++) {
21874+
uint64 op_code = extract_op_code_value(data,
21875+
table[i].instructions_size);
21876+
if ((op_code & table[i].mask) == table[i].value) {
21877+
/* possible match */
21878+
conditional_function cond = table[i].condition;
21879+
if ((cond == NULL) || cond(op_code)) {
21880+
if (table[i].type == pool) {
21881+
return Disassemble(data, dis, type,
21882+
table[i].next_table,
21883+
table[i].next_table_size,
21884+
info);
21885+
} else if ((table[i].type == instruction) ||
21886+
(table[i].type == call_instruction) ||
21887+
(table[i].type == branch_instruction) ||
21888+
(table[i].type == return_instruction)) {
21889+
disassembly_function dis_fn = table[i].disassembly;
21890+
if (dis_fn == 0) {
21891+
*dis = g_strdup(
21892+
"disassembler failure - bad table entry");
21893+
return -6;
21894+
}
21895+
*type = table[i].type;
21896+
*dis = dis_fn(op_code, info);
21897+
return table[i].instructions_size;
21898+
} else {
21899+
*dis = g_strdup("reserved instruction");
21900+
return -2;
21901+
}
21902+
}
21903+
}
21904+
}
21905+
*dis = g_strdup("failed to disassemble");
21906+
return -1; /* failed to disassemble */
21907+
}
21908+
21909+
2191021910
static bool nanomips_dis(const uint16_t *data, char **buf, Dis_info *info)
2191121911
{
2191221912
TABLE_ENTRY_TYPE type;

0 commit comments

Comments
 (0)