mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-118423: Add INSTRUCTION_SIZE
macro to code generator (GH-125467)
This commit is contained in:
parent
b2eaa75b17
commit
aab58a93ef
9 changed files with 115 additions and 34 deletions
|
@ -1398,6 +1398,37 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
with self.assertRaises(SyntaxError):
|
||||
self.run_cases_test(input, output)
|
||||
|
||||
def test_instruction_size_macro(self):
|
||||
input = """
|
||||
inst(OP, (--)) {
|
||||
frame->return_offset = INSTRUCTION_SIZE;
|
||||
}
|
||||
"""
|
||||
|
||||
output = """
|
||||
TARGET(OP) {
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 1;
|
||||
INSTRUCTION_STATS(OP);
|
||||
frame->return_offset = 1 ;
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
self.run_cases_test(input, output)
|
||||
|
||||
# Two instructions of different sizes referencing the same
|
||||
# uop containing the `INSTRUCTION_SIZE` macro is not allowed.
|
||||
input = """
|
||||
inst(OP, (--)) {
|
||||
frame->return_offset = INSTRUCTION_SIZE;
|
||||
}
|
||||
macro(OP2) = unused/1 + OP;
|
||||
"""
|
||||
|
||||
output = "" # No output needed as this should raise an error.
|
||||
with self.assertRaisesRegex(SyntaxError, "All instructions containing a uop"):
|
||||
self.run_cases_test(input, output)
|
||||
|
||||
|
||||
class TestGeneratedAbstractCases(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue