Skip to content

Commit 542ddd4

Browse files
authored
Autogen instructions & opcodes (#7797)
1 parent c9d2a92 commit 542ddd4

12 files changed

Lines changed: 4041 additions & 1235 deletions

File tree

‎crates/codegen/src/compile.rs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5971,7 +5971,7 @@ impl Compiler {
59715971
if self.ctx.func != FunctionContext::AsyncFunction {
59725972
return Err(self.error(CodegenErrorType::InvalidAsyncFor));
59735973
}
5974-
emit!(self, Instruction::GetAIter);
5974+
emit!(self, Instruction::GetAiter);
59755975

59765976
self.switch_to_block(for_block);
59775977

@@ -5980,7 +5980,7 @@ impl Compiler {
59805980

59815981
// SETUP_FINALLY to guard the __anext__ call
59825982
emit!(self, PseudoInstruction::SetupFinally { delta: else_block });
5983-
emit!(self, Instruction::GetANext);
5983+
emit!(self, Instruction::GetAnext);
59845984
self.emit_load_const(ConstantData::None);
59855985
end_async_for_target = self.compile_yield_from_sequence(true)?;
59865986
// POP_BLOCK for SETUP_FINALLY - only GetANext/yield_from are protected
@@ -9445,7 +9445,7 @@ impl Compiler {
94459445

94469446
// Get iterator / turn item into an iterator
94479447
if generator.is_async {
9448-
emit!(self, Instruction::GetAIter);
9448+
emit!(self, Instruction::GetAiter);
94499449
} else {
94509450
emit!(self, Instruction::GetIter);
94519451
}
@@ -9455,7 +9455,7 @@ impl Compiler {
94559455
let mut end_async_for_target = BlockIdx::NULL;
94569456
if generator.is_async {
94579457
emit!(self, PseudoInstruction::SetupFinally { delta: after_block });
9458-
emit!(self, Instruction::GetANext);
9458+
emit!(self, Instruction::GetAnext);
94599459
self.push_fblock(
94609460
FBlockType::AsyncComprehensionGenerator,
94619461
loop_block,
@@ -9565,7 +9565,7 @@ impl Compiler {
95659565
// Get iterator / turn item into an iterator
95669566
// Use is_async from the first generator, not has_an_async_gen which covers ALL generators
95679567
if outermost.is_async {
9568-
emit!(self, Instruction::GetAIter);
9568+
emit!(self, Instruction::GetAiter);
95699569
} else {
95709570
emit!(self, Instruction::GetIter);
95719571
};
@@ -9646,7 +9646,7 @@ impl Compiler {
96469646
}
96479647
}
96489648
if has_async && generators[0].is_async {
9649-
emit!(self, Instruction::GetAIter);
9649+
emit!(self, Instruction::GetAiter);
96509650
} else {
96519651
emit!(self, Instruction::GetIter);
96529652
}
@@ -9822,7 +9822,7 @@ impl Compiler {
98229822
if i > 0 {
98239823
self.compile_for_iterable_expression(&generator.iter, generator.is_async)?;
98249824
if generator.is_async {
9825-
emit!(self, Instruction::GetAIter);
9825+
emit!(self, Instruction::GetAiter);
98269826
} else {
98279827
emit!(self, Instruction::GetIter);
98289828
}
@@ -9833,7 +9833,7 @@ impl Compiler {
98339833
let mut end_async_for_target = BlockIdx::NULL;
98349834
if generator.is_async {
98359835
emit!(self, PseudoInstruction::SetupFinally { delta: after_block });
9836-
emit!(self, Instruction::GetANext);
9836+
emit!(self, Instruction::GetAnext);
98379837
self.push_fblock(
98389838
FBlockType::AsyncComprehensionGenerator,
98399839
loop_block,
@@ -18406,7 +18406,7 @@ async def f(items):
1840618406
"async dict comprehension should be inlined"
1840718407
);
1840818408
assert!(
18409-
ops.iter().any(|op| matches!(op, Instruction::GetAIter)),
18409+
ops.iter().any(|op| matches!(op, Instruction::GetAiter)),
1841018410
"inlined async dict comprehension should keep GET_AITER in outer code, got ops={ops:?}"
1841118411
);
1841218412
assert!(
@@ -23486,7 +23486,7 @@ async def name_4():
2348623486
let Some(get_aiter_pos) = name_4
2348723487
.instructions
2348823488
.iter()
23489-
.position(|unit| matches!(unit.op, Instruction::GetAIter))
23489+
.position(|unit| matches!(unit.op, Instruction::GetAiter))
2349023490
else {
2349123491
panic!("missing GET_AITER in name_4");
2349223492
};

‎crates/codegen/src/ir.rs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ use rustpython_compiler_core::{
1212
bytecode::{
1313
AnyInstruction, AnyOpcode, Arg, CO_FAST_CELL, CO_FAST_FREE, CO_FAST_HIDDEN, CO_FAST_LOCAL,
1414
CodeFlags, CodeObject, CodeUnit, CodeUnits, ConstantData, ExceptionTableEntry,
15-
InstrDisplayContext, Instruction, InstructionMetadata, IntrinsicFunction1, Label, OpArg,
16-
Opcode, PseudoInstruction, PseudoOpcode, PyCodeLocationInfoKind, encode_exception_table,
17-
oparg,
15+
InstrDisplayContext, Instruction, IntrinsicFunction1, Label, OpArg, Opcode,
16+
PseudoInstruction, PseudoOpcode, PyCodeLocationInfoKind, encode_exception_table, oparg,
1817
},
1918
varint::{write_signed_varint, write_varint},
2019
};
@@ -3227,7 +3226,7 @@ impl CodeInfo {
32273226
}
32283227
AnyInstruction::Real(
32293228
Instruction::FormatSimple
3230-
| Instruction::GetANext
3229+
| Instruction::GetAnext
32313230
| Instruction::GetLen
32323231
| Instruction::GetYieldFromIter
32333232
| Instruction::ImportFrom { .. }
@@ -6896,7 +6895,7 @@ impl CodeInfo {
68966895
block
68976896
.instructions
68986897
.iter()
6899-
.any(|info| matches!(info.instr.real(), Some(Instruction::GetANext)))
6898+
.any(|info| matches!(info.instr.real(), Some(Instruction::GetAnext)))
69006899
}
69016900

69026901
fn block_has_return(block: &Block) -> bool {
@@ -11624,7 +11623,7 @@ fn block_contains_suspension_point(block: &Block) -> bool {
1162411623
instr,
1162511624
Instruction::YieldValue { .. }
1162611625
| Instruction::GetAwaitable { .. }
11627-
| Instruction::GetANext
11626+
| Instruction::GetAnext
1162811627
| Instruction::EndAsyncFor
1162911628
)
1163011629
})

0 commit comments

Comments
 (0)