MCPcopy Index your code
hub / github.com/python/cpython / generate_tier1

Function generate_tier1

Tools/cases_generator/tier1_generator.py:149–196  ·  view source on GitHub ↗
(
    filenames: list[str], analysis: Analysis, outfile: TextIO, lines: bool
)

Source from the content-addressed store, hash-verified

147"""
148
149def generate_tier1(
150 filenames: list[str], analysis: Analysis, outfile: TextIO, lines: bool
151) -> None:
152 write_header(__file__, filenames, outfile)
153 outfile.write("""
154#ifdef TIER_TWO
155 #error "This file is for Tier 1 only"
156#endif
157#define TIER_ONE 1
158""")
159 outfile.write(f"""
160#if !_Py_TAIL_CALL_INTERP
161#if !USE_COMPUTED_GOTOS
162 dispatch_opcode:
163 switch (dispatch_code)
164#endif
165 {{
166#endif /* _Py_TAIL_CALL_INTERP */
167 {INSTRUCTION_START_MARKER}
168"""
169 )
170 generate_tier1_cases(analysis, outfile, lines)
171 outfile.write(f"""
172 {INSTRUCTION_END_MARKER}
173#if !_Py_TAIL_CALL_INTERP
174#if USE_COMPUTED_GOTOS
175 _unknown_opcode:
176#else
177 EXTRA_CASES // From pycore_opcode_metadata.h, a 'case' for each unused opcode
178#endif
179 /* Tell C compilers not to hold the opcode variable in the loop.
180 next_instr points the current instruction without TARGET(). */
181 opcode = next_instr->op.code;
182 {UNKNOWN_OPCODE_HANDLER}
183
184 }}
185
186 /* This should never be reached. Every opcode should end with DISPATCH()
187 or goto error. */
188 Py_UNREACHABLE();
189#endif /* _Py_TAIL_CALL_INTERP */
190 {LABEL_START_MARKER}
191""")
192 out = CWriter(outfile, 2, lines)
193 emitter = Emitter(out, analysis.labels)
194 generate_tier1_labels(analysis, emitter)
195 outfile.write(f"{LABEL_END_MARKER}\n")
196 outfile.write(FOOTER)
197
198
199

Callers 2

tier1_generator.pyFile · 0.85

Calls 6

write_headerFunction · 0.90
CWriterClass · 0.90
EmitterClass · 0.90
generate_tier1_casesFunction · 0.85
generate_tier1_labelsFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…