Skip to content

Commit 5cccb98

Browse files
Fix mypy
1 parent 2082537 commit 5cccb98

File tree

1 file changed

+0
-105
lines changed

1 file changed

+0
-105
lines changed

Tools/cases_generator/labels_generator.py

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -7,125 +7,20 @@
77

88
from analyzer import (
99
Analysis,
10-
Instruction,
11-
Uop,
12-
Part,
1310
analyze_files,
14-
Skip,
15-
Flush,
16-
analysis_error,
17-
StackItem,
1811
)
1912
from generators_common import (
2013
DEFAULT_INPUT,
2114
ROOT,
2215
write_header,
23-
type_and_null,
24-
Emitter,
2516
)
2617
from cwriter import CWriter
2718
from typing import TextIO
28-
from stack import Local, Stack, StackError, get_stack_effect, Storage
2919

3020

3121
DEFAULT_OUTPUT = ROOT / "Python/generated_labels.c.h"
3222

3323

34-
35-
def declare_variable(var: StackItem, out: CWriter) -> None:
36-
type, null = type_and_null(var)
37-
space = " " if type[-1].isalnum() else ""
38-
if var.condition:
39-
out.emit(f"{type}{space}{var.name} = {null};\n")
40-
else:
41-
out.emit(f"{type}{space}{var.name};\n")
42-
43-
44-
def declare_variables(inst: Instruction, out: CWriter) -> None:
45-
try:
46-
stack = get_stack_effect(inst)
47-
except StackError as ex:
48-
raise analysis_error(ex.args[0], inst.where) from None
49-
required = set(stack.defined)
50-
required.discard("unused")
51-
for part in inst.parts:
52-
if not isinstance(part, Uop):
53-
continue
54-
for var in part.stack.inputs:
55-
if var.name in required:
56-
required.remove(var.name)
57-
declare_variable(var, out)
58-
for var in part.stack.outputs:
59-
if var.name in required:
60-
required.remove(var.name)
61-
declare_variable(var, out)
62-
63-
64-
def write_uop(
65-
uop: Part,
66-
emitter: Emitter,
67-
offset: int,
68-
stack: Stack,
69-
inst: Instruction,
70-
braces: bool,
71-
) -> tuple[int, Stack]:
72-
# out.emit(stack.as_comment() + "\n")
73-
if isinstance(uop, Skip):
74-
entries = "entries" if uop.size > 1 else "entry"
75-
emitter.emit(f"/* Skip {uop.size} cache {entries} */\n")
76-
return (offset + uop.size), stack
77-
if isinstance(uop, Flush):
78-
emitter.emit(f"// flush\n")
79-
stack.flush(emitter.out)
80-
return offset, stack
81-
try:
82-
locals: dict[str, Local] = {}
83-
emitter.out.start_line()
84-
if braces:
85-
emitter.out.emit(f"// {uop.name}\n")
86-
emitter.emit("{\n")
87-
code_list, storage = Storage.for_uop(stack, uop)
88-
emitter._print_storage(storage)
89-
for code in code_list:
90-
emitter.emit(code)
91-
92-
for cache in uop.caches:
93-
if cache.name != "unused":
94-
if cache.size == 4:
95-
type = "PyObject *"
96-
reader = "read_obj"
97-
else:
98-
type = f"uint{cache.size*16}_t "
99-
reader = f"read_u{cache.size*16}"
100-
emitter.emit(
101-
f"{type}{cache.name} = {reader}(&this_instr[{offset}].cache);\n"
102-
)
103-
if inst.family is None:
104-
emitter.emit(f"(void){cache.name};\n")
105-
offset += cache.size
106-
107-
storage = emitter.emit_tokens(uop, storage, inst)
108-
if braces:
109-
emitter.out.start_line()
110-
emitter.emit("}\n")
111-
# emitter.emit(stack.as_comment() + "\n")
112-
return offset, storage.stack
113-
except StackError as ex:
114-
raise analysis_error(ex.args[0], uop.body[0])
115-
116-
117-
def uses_this(inst: Instruction) -> bool:
118-
if inst.properties.needs_this:
119-
return True
120-
for uop in inst.parts:
121-
if not isinstance(uop, Uop):
122-
continue
123-
for cache in uop.caches:
124-
if cache.name != "unused":
125-
return True
126-
return False
127-
128-
12924
def generate_labels(
13025
filenames: list[str], analysis: Analysis, outfile: TextIO
13126
) -> None:

0 commit comments

Comments
 (0)