mirror of https://github.com/python/cpython
GH-111485: Sort cases in the case generator output (GH-112315)
This commit is contained in:
parent
fef6fb8762
commit
1619f4350e
|
@ -405,19 +405,6 @@ class TestGeneratedCases(unittest.TestCase):
|
||||||
family(OP, INLINE_CACHE_ENTRIES_OP) = { OP3 };
|
family(OP, INLINE_CACHE_ENTRIES_OP) = { OP3 };
|
||||||
"""
|
"""
|
||||||
output = """
|
output = """
|
||||||
TARGET(OP1) {
|
|
||||||
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
|
|
||||||
next_instr += 2;
|
|
||||||
INSTRUCTION_STATS(OP1);
|
|
||||||
PyObject *right;
|
|
||||||
PyObject *left;
|
|
||||||
right = stack_pointer[-1];
|
|
||||||
left = stack_pointer[-2];
|
|
||||||
uint16_t counter = read_u16(&this_instr[1].cache);
|
|
||||||
op1(left, right);
|
|
||||||
DISPATCH();
|
|
||||||
}
|
|
||||||
|
|
||||||
TARGET(OP) {
|
TARGET(OP) {
|
||||||
frame->instr_ptr = next_instr;
|
frame->instr_ptr = next_instr;
|
||||||
next_instr += 6;
|
next_instr += 6;
|
||||||
|
@ -447,6 +434,19 @@ class TestGeneratedCases(unittest.TestCase):
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TARGET(OP1) {
|
||||||
|
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
|
||||||
|
next_instr += 2;
|
||||||
|
INSTRUCTION_STATS(OP1);
|
||||||
|
PyObject *right;
|
||||||
|
PyObject *left;
|
||||||
|
right = stack_pointer[-1];
|
||||||
|
left = stack_pointer[-2];
|
||||||
|
uint16_t counter = read_u16(&this_instr[1].cache);
|
||||||
|
op1(left, right);
|
||||||
|
DISPATCH();
|
||||||
|
}
|
||||||
|
|
||||||
TARGET(OP3) {
|
TARGET(OP3) {
|
||||||
frame->instr_ptr = next_instr;
|
frame->instr_ptr = next_instr;
|
||||||
next_instr += 6;
|
next_instr += 6;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -769,6 +769,7 @@ class Generator(Analyzer):
|
||||||
|
|
||||||
# Write and count instructions of all kinds
|
# Write and count instructions of all kinds
|
||||||
n_macros = 0
|
n_macros = 0
|
||||||
|
cases = []
|
||||||
for thing in self.everything:
|
for thing in self.everything:
|
||||||
match thing:
|
match thing:
|
||||||
case parsing.InstDef():
|
case parsing.InstDef():
|
||||||
|
@ -776,11 +777,14 @@ class Generator(Analyzer):
|
||||||
case parsing.Macro():
|
case parsing.Macro():
|
||||||
n_macros += 1
|
n_macros += 1
|
||||||
mac = self.macro_instrs[thing.name]
|
mac = self.macro_instrs[thing.name]
|
||||||
stacking.write_macro_instr(mac, self.out)
|
cases.append((mac.name, mac))
|
||||||
case parsing.Pseudo():
|
case parsing.Pseudo():
|
||||||
pass
|
pass
|
||||||
case _:
|
case _:
|
||||||
assert_never(thing)
|
assert_never(thing)
|
||||||
|
cases.sort()
|
||||||
|
for _, mac in cases:
|
||||||
|
stacking.write_macro_instr(mac, self.out)
|
||||||
|
|
||||||
self.out.write_raw("\n")
|
self.out.write_raw("\n")
|
||||||
self.out.write_raw("#undef TIER_ONE\n")
|
self.out.write_raw("#undef TIER_ONE\n")
|
||||||
|
|
Loading…
Reference in New Issue