gh-106360: remove redundant #ifdef (#106622)

This commit is contained in:
Irit Katriel 2023-07-11 15:41:50 +03:00 committed by GitHub
parent 95b7426f45
commit 388b5daa52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -960,7 +960,7 @@ struct opcode_macro_expansion {
extern const struct opcode_metadata _PyOpcode_opcode_metadata[512];
extern const struct opcode_macro_expansion _PyOpcode_macro_expansion[256];
extern const char * const _PyOpcode_uop_name[512];
#else
#else // if NEED_OPCODE_METADATA
const struct opcode_metadata _PyOpcode_opcode_metadata[512] = {
[NOP] = { true, INSTR_FMT_IX, 0 },
[RESUME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
@ -1293,7 +1293,6 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[256] = {
[BINARY_OP] = { .nuops = 1, .uops = { { BINARY_OP, 0, 0 } } },
[SWAP] = { .nuops = 1, .uops = { { SWAP, 0, 0 } } },
};
#ifdef NEED_OPCODE_METADATA
const char * const _PyOpcode_uop_name[512] = {
[300] = "EXIT_TRACE",
[301] = "SAVE_IP",
@ -1314,4 +1313,3 @@ const char * const _PyOpcode_uop_name[512] = {
[316] = "IS_NONE",
};
#endif // NEED_OPCODE_METADATA
#endif

View File

@ -1240,7 +1240,7 @@ class Analyzer:
self.out.emit("extern const struct opcode_metadata _PyOpcode_opcode_metadata[512];")
self.out.emit("extern const struct opcode_macro_expansion _PyOpcode_macro_expansion[256];")
self.out.emit("extern const char * const _PyOpcode_uop_name[512];")
self.out.emit("#else")
self.out.emit("#else // if NEED_OPCODE_METADATA")
self.out.emit("const struct opcode_metadata _PyOpcode_opcode_metadata[512] = {")
@ -1289,12 +1289,10 @@ class Analyzer:
case _:
typing.assert_never(thing)
self.out.emit("#ifdef NEED_OPCODE_METADATA")
with self.out.block("const char * const _PyOpcode_uop_name[512] =", ";"):
self.write_uop_items(lambda name, counter: f"[{counter}] = \"{name}\",")
self.out.emit("#endif // NEED_OPCODE_METADATA")
self.out.emit("#endif")
self.out.emit("#endif // NEED_OPCODE_METADATA")
with open(self.pymetadata_filename, "w") as f:
# Create formatter